我想让所有 ip(s) 属于一个域,例如 google.com,我最近看了这个,https://github.com/ip2location/ip2location-cakephp。所以,我要做的是这样的:
<?php
// clientIp() will iterate from 1.1.1.1 to 255.255.255.255
App::uses('IP2LocationCore', 'IP2Location.Model');
$IP2Location = new IP2LocationCore();
$record = $IP2Location->get($this->request->clientIp());
if(strcmp($record->domainName, 'google.com')) {
// log the ip to a text file
}
?>
我的问题是:这个解决方案可行吗?无论如何比这更好?