Php code. You can also obtain the real ip address using the proxy server. The code is pasted from ThinkPHP and does not obtain the visitor's real ippublicfunctionGetip () {if (! Empty ($ _ SERVER [HTTP_CLIENT_IP]) {$ ip $ _ SERVER [HTTP_CLIENT_IP];} if (! Empty ($ _ SERVER [HTTP_X_FORWARDED_FOR]) {
Php code. You can also obtain the real ip address using the proxy server. The code is pasted from ThinkPHP without // obtain the real ip address of the visitor public function Getip () {if (! Empty ($ _ SERVER ["HTTP_CLIENT_IP"]) {$ ip = $ _ SERVER ["HTTP_CLIENT_IP"];} if (! Empty ($ _ SERVER ['HTTP _ X_FORWARDED_FOR ']) {//
Php code. The real ip Address can also be obtained using the proxy server. The code is pasted from ThinkPHP. <无>
// Obtain the visitor's real ip address public function Getip () {if (! Empty ($ _ SERVER ["HTTP_CLIENT_IP"]) {$ ip = $ _ SERVER ["HTTP_CLIENT_IP"];} if (! Empty ($ _ SERVER ['HTTP _ X_FORWARDED_FOR ']) {// get proxy ip $ ips = explode (',', $ _ SERVER ['HTTP _ X_FORWARDED_FOR ']);} if ($ ip) {$ ips = array_unshift ($ ips, $ ip );} $ count = count ($ ips); for ($ I = 0; $ I <$ count; $ I ++) {if (! Preg_match ("/^ (10 | 172 \. 16 | 192 \. (168 )\. /I ", $ ips [$ I]) {// exclude LAN ip $ ip = $ ips [$ I]; break ;}$ tip = $ ip? $ Ip: $ _ SERVER ['remote _ ADDR ']; if ($ tip = "127.0.0.1 ") {// obtain the local real IP return $ this-> get_onlineip () ;}else {return $ tip ;}// obtain the local real IP public function get_onlineip () {$ mip = file_get_contents ("http://www.ip138.com/ip2city.asp"); if ($ mip) {preg_match ("/\[. * \]/", $ mip, $ sip); $ p = array ("/\ [/","/\]/"); return preg_replace ($ p, "", $ sip [0]);} else {return "An error occurred while obtaining the local IP address! ";}}