English 中文(简体)
1. 找到一个用户的当前地点
原标题:Get a user s current location

我如何根据IP地址确定用户的目前地点(我猜测这一方式如何运作)。

问题回答
<?php
$user_ip = getenv( REMOTE_ADDR );
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$user_ip"));
$country = $geo["geoplugin_countryName"];
$city = $geo["geoplugin_city"];
?>
<?php
    $query = @unserialize (file_get_contents( http://ip-api.com/php/ ));
    if ($query && $query[ status ] ==  success ) {
        echo  Hey user from   . $query[ country ] .  ,   . $query[ city ] .  ! ;
    }
    foreach ($query as $data) {
        echo $data . "<br>";
    }
?>

利用这一来源对这项法典进行查询。 页: 1

由于PHP依靠服务器,可以提供实时地点。 只能提供固定地点。 最好避免将 Java印成一个地点,而不是使用PHP。

但是,需要将贾瓦文数据张贴到PHP上,以便能够方便地向服务器上的一个方案提供。

旧的 免费电离层光电灯现在被涂上,将于2018-07-01停止。

新的预报系统从ipstack>。 你们必须打造账户。 然后,你可以使用APURL中的存取钥匙。

$url = "http://api.ipstack.com/122.167.180.20?access_key=ACCESS_KEY&format=1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
$response = json_decode($response);
$city  = $response->city; // You can get all the details like longitude, latitude from the  $response .

详情请上<https://github.com/apilayer/freegeoip” rel=“nofollow noreferer”>freegeoip 。 (Git/2007/5)。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签