Jump to content
php.lv forumi

Checking Ip


Joe de Frenky

Recommended Posts

Ir predefineets variablis:

 

<code><font color="#000000">
<font color="#0000CC"><?
$ip </font><font color="#006600">= </font><font color="#0000CC">$_SERVER</font><font color="#006600">[</font><font color="#CC0000">"REMOTE_ADDR"</font><font color="#006600">];
</font><font color="#0000CC">?></font>
</font>
</code>

Link to comment
Share on other sites

Iz PHP manuāļa komentāriem:

 

<code><font color="#000000">
<font color="#0000CC"><?
</font><font color="#006600">if (</font><font color="#0000CC">[url=http://lv.php.net/getenv]getenv[/url]</font><font color="#006600">(</font><font color="#CC0000">'HTTP_X_FORWARDED_FOR'</font><font color="#006600">)) { 
   </font><font color="#0000CC">$ip   </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/getenv]getenv[/url]</font><font color="#006600">(</font><font color="#CC0000">'HTTP_X_FORWARD_FOR'</font><font color="#006600">); 
   </font><font color="#0000CC">$host </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/gethostbyaddr]gethostbyaddr[/url]</font><font color="#006600">(</font><font color="#0000CC">$ip</font><font color="#006600">); 
  } else { 
   </font><font color="#0000CC">$ip   </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/getenv]getenv[/url]</font><font color="#006600">(</font><font color="#CC0000">'REMOTE_ADDR'</font><font color="#006600">); 
   </font><font color="#0000CC">$host </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/gethostbyaddr]gethostbyaddr[/url]</font><font color="#006600">(</font><font color="#0000CC">$ip</font><font color="#006600">); 
  }
</font><font color="#0000CC">?></font>
</font>
</code>

Link to comment
Share on other sites

Ko nozīmē:

HTTP_X_FORWARDED_FOR!

Gadījumos, kad cilvēki lien uz āru (pie tava saita) caur proxy serveri, lielākoties publiskie proxy šajā mainīgajā ievieto līdēja patieso IP adresi.

Link to comment
Share on other sites

×
×
  • Create New...