Jump to content
php.lv forumi

Ip Adreses


Ugga

Recommended Posts

<_<  vai kaads var uzrakstiit kaa var nochekot kaadas ir apmekleetaaju ip adreses??? :unsure:

<code><font color="#000000">

<font color="#0000CC"><?
$ip </font><font color="#006600">= (</font><font color="#0000CC">getenv </font><font color="#006600">(</font><font color="#CC0000">"HTTP_X_FORWARDED_FOR"</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="#CC0000">' ('</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_FORWARDED_FOR"</font><font color="#006600">).</font><font color="#CC0000">')'</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">));
echo </font><font color="#0000CC">$ip</font><font color="#006600">;
</font><font color="#0000CC">?>
</font>
</font>
</code>

Link to comment
Share on other sites

getenv strādā ne vienmēr, labprātāk lietoju caur superglobāli $_SERVER:

REMOTE_ADDR,HTTP_CLIENT,HTTP_X_FORWARDED_FOR ($_SERVER['REMOTE_ADDR'] utml.) Un labāk čeko visus kopā, tāpēc ka tādam, kam ir HTTP_CLIENT varētu būt arī forwarded for, dažiem ir visas trīs, dažiem var sakrist remote, kad nevar dabūt client ar cita client, kuram nevar dabūt remote.

Tā lūk.

Link to comment
Share on other sites

×
×
  • Create New...