<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_65989"> <div class="blockcode"> <div id="code_XWp"><ol> <li><?php<li> <li>function getLocationInfoByIp(){<li> $client = @$_SERVER['HTTP_CLIENT_IP'];<li> $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];<li> $remote = @$_SERVER[' REMOTE_ADDR'];<li> $result = array('country'=>'', 'city'=>'');</li> <li> if(filter_var($client, FILTER_VALIDATE_IP)){</li> <li> $ip = $client;</li> <li> } elseif(filter_var($forward, FILTER_VALIDATE_IP)){</li> <li> $ip = $forward;</li> <li> }else{</li> <li> $ip = $remote;</li> <li> }</li> <li> $ip_data = @json_decode</li> <li>(file_get_contents("http://www.geoplugin. net/json.gp?ip=".$ip));</li> <li> if($ip_data && $ip_data->geoplugin_countryName != null){</li> <li> $result['country'] = $ip_data->geoplugin_countryCode;</li> <li> $ result['city'] = $ip_data->geoplugin_city;</li> <li> }</li> <li> return $result;</li> <li>}</li> <li>?></li> </ol></div> <em onclick="copycode($('code_XWp'));">复制代</em> </div> <br> </td></tr></table> <div class="ptg mbm mtn"> PHP</div> <div id="comment_65989" class="cm"> </div> <div id="post_rate_div_65989"></div> <br><br>