我有一个系统,记录每个成员的IP地址,浏览器和操作系统。
我想以某种方式实现this。
有没有什么方法可以让我将用户的IP发布到他们的网站,拉取诸如ISP和国家之类的值,并将它们存储在我本地的MySQL数据库中,以便在对某些滥用用户运行查询时快速访问?
发布于 2013-06-26 05:30:56
IP to location并不总是准确的,而且很容易克服,但this might help you
发布于 2013-06-26 05:33:59
PHP对Maxmind的GeoIP服务有本机支持。详情请参见this PECL extension。
发布于 2013-06-26 05:41:10
查看此网站:http://ipinfodb.com/ip_location_api.php
它们提供API将ip地址传递给这些服务,以XML/JSON格式返回地理位置,然后可以在PHP脚本上解析。
如何使用它的示例如下所示:
<?php
include('ip2locationlite.class.php');
//Load the class
$ipLite = new ip2location_lite;
$ipLite->setKey('<your_api_key>');
//Get errors and locations
$locations = $ipLite->getCity($_SERVER['REMOTE_ADDR']);
$errors = $ipLite->getError();
//Getting the result
echo "<p>\n";
echo "<strong>First result</strong><br />\n";
if (!empty($locations) && is_array($locations)) {
foreach ($locations as $field => $val) {
echo $field . ' : ' . $val . "<br />\n";
}
}
echo "</p>\n";
//Show errors
echo "<p>\n";
echo "<strong>Dump of all errors</strong><br />\n";
if (!empty($errors) && is_array($errors)) {
foreach ($errors as $error) {
echo var_dump($error) . "<br /><br />\n";
}
} else {
echo "No errors" . "<br />\n";
}
echo "</p>\n";
?>也许这会让你朝着正确的方向前进?
https://stackoverflow.com/questions/17307825
复制相似问题