Блог в котором есть много интересной информации…
Нашел в интерне базу IP адресов с городами, ссылки: http://habrahabr.ru/post/120872/, http://netload.biz/2011/12/31/geoip5/ . База неточная, но лучше чем ничего. Поставить её несложно, однако, при установке самой базы и обновления были некоторые нюансы, может быть кому-то будет интересно почитать…
cidr_optim.txt cities.txt db.php GeoIPCountryWhois.csv GeoLiteCity-Blocks.csv GeoLiteCity-Location.csv lib.php readme.txt update_maxmind.php update_ru.php
$ php5 update_ru.php Added countries blocks: 118884 Added cities blocks: 43355 $ php5 ./update_maxmind.php Added countries blocks: 97897 update net_city_ip set `verified`=1 where city_id=244
update_maxmind.php почему-то не проходит, как видно из кода, падает в этом месте:
// Отмечаем блоки проверенных городов $sql = "select * from net_city"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { $city_id = $row['id']; $usql = "update net_city_ip set `verified`=1 where city_id=$city_id"; mysql_query($usql) or die($usql); }
оказывается, всё очень просто – нужно убрать кавычки в одном запросе, то есть заменить строчку 81:
// Обновляем города $fp = fopen ("./GeoLiteCity-Blocks.csv", "r"); if ($fp) { // Удаляем все старые записи mysql_query("truncate net_city_ip"); // Добавляем временное поле mysql_query("alter table net_city_ip add column `verified` bit(1) null default '0'");
на
mysql_query("alter table net_city_ip add column `verified` bit(1) null default 0");
теперь вроде всё нормально:
$ php5 update_maxmind.php Added countries blocks: 97897 Added cities blocks: 1520015