sudo apt-get install libgeoip-dev
pecl install geoip-1.1.0
extension=geoip.so geoip.custom_directory="/usr/share/GeoIP"
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz gunzip GeoLiteCity.dat.gz sudo mkdir -v /usr/share/GeoIP sudo mv -v GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
php -a
<?php
print_r(geoip_record_by_name('106.37.165.80')); //回车后按Ctrl+D运行
Array
(
[continent_code] => AS
[country_code] => CN
[country_code3] => CHN
[country_name] => China //国家
[region] => 22
[city] => Beijing //城市
[postal_code] =>
[latitude] => 39.928901672363 //纬度
[longitude] => 116.38829803467 //经度
[dma_code] => 0
[area_code] => 0
)
traceroute www.oschina.net
61.145.122.155
sudo apt-get install geoip-bin geoip-database geoiplookup 61.145.122.155 -f /usr/share/GeoIP/GeoIP.dat GeoIP Country Edition: CN, China
geoiplookup 61.145.122.155 -f /usr/share/GeoIP/GeoIPCity.dat GeoIP City Edition, Rev 1: CN, 30, Guangdong, Guangzhou, N/A, 23.116699, 113.250000, 0, 0
geoip_record_by_name($_SERVER['REMOTE_ADDR'])
geoip_record_by_name()
<?php //以当前用户经纬度为中心,查询5000米内的其他用户 $y = 5000 / 110852; //纬度的范围 $x = 5000 / (111320*cos($lat)); //经度的范围 $sql = ' select * from user where lat >= ($lat-$y) and lat <= ($lat+$y) and lon >= ($lon-$x) and lon <= ($lon+$x); ';
($lat-$y) <= lat <= ($lat+$y) ($lon-$x) <= lon <= ($lon+$x)
<?php
function distance($lat1, $lon1, $lat2, $lon2) {
$R = 6371393; //地球平均半径,单位米
$dlat = deg2rad($lat2-$lat1);
$dlon = deg2rad($lon2-$lon1);
$a = pow(sin($dlat/2), 2) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * pow(sin($dlon/2), 2);
$c = 2 * atan2(sqrt($a), sqrt(1-$a));
$d = $R * $c;
return round($d);
}
echo distance(0, 0, -1, 0); // 111202米
<?php
$arr = array(
'win' => array(
'dis' => 1024,
'age' => 31
),
'osx' => array(
'dis' => 512,
'age' => 15
),
'lin' => array(
'dis' => 512,
'age' => 25
)
);
foreach($arr as $k => $v) {
$sort['dis'][$k] = $v['dis'];
$sort['age'][$k] = $v['age'];
}
//先按距离升序排序,如果距离相同,则按年龄降序排序
array_multisort($sort['dis'], SORT_ASC, $sort['age'], SORT_DESC, $arr);
echo json_encode($arr);
//{"lin":{"dis":512,"age":25},"osx":{"dis":512,"age":15},"win":{"dis":1024,"age":31}}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有