首页 文章 精选 留言 我的

精选列表

搜索[地理位置权限],共10013篇文章
优秀的个人博客,低调大师

PHP使用Redis的GEO(地理位置)命令

相关笔记:CentOS6.9源码编译安装redis和php-redis扩展我喜欢爬山,学习GEO的时候我也以山的坐标做演示,我的坐标是:116.517159,39.922267我整理了一些山的坐标 $mountainCoordinates = array( array('115.793844', '40.584459', 'Hai_tuo'),//海陀山坐标 array('115.056232', '39.948933', 'Small_wutai'),//小五台山坐标 array('114.173822', '27.474563', 'Wu_gong'),//武功山坐标 array('111.341648', '25.518178', 'Leek_ridge'),//韭菜岭坐标 array('103.901761', '31.60487', 'Jiu_ding'),//九顶山坐标 array('107.398009', '34.057777', 'Ao_Shan'),//鳌山坐标 ); 1.向mountainCoordinates的key里增加坐标 try { $redis = new Redis(); $redis->connect('192.168.75.132', 6379); foreach ($mountainCoordinates as $coordinates){ $param = array('geoadd', 'mountainCoordinates'); $param = array_merge($param, $coordinates); $ret = call_user_func_array(array($redis, 'rawCommand'), $param); print_r($ret); } } catch (Exception $e){ echo $e->getMessage(); } 执行结果 int(1) int(1) int(1) int(1) int(1) int(1) 2.获取坐标 try { $redis = new Redis(); $redis->connect('192.168.75.132', 6379); $param = array('geopos', 'mountainCoordinates', 'Hai_tuo', 'Wu_gong', 'Jiu_ding'); $ret = call_user_func_array(array($redis, 'rawCommand'), $param); print_r($ret); } catch (Exception $e){ echo $e->getMessage(); } 执行结果 Array ( [0] => Array ( [0] => 115.79384654760360718 [1] => 40.58445845049069334 ) [1] => Array ( [0] => 114.1738244891166687 [1] => 27.47456377424472151 ) [2] => Array ( [0] => 103.90176326036453247 [1] => 31.60486909089710394 ) ) 3.计算两个坐标间距离 try { $redis = new Redis(); $redis->connect('192.168.75.132', 6379); $param = array('geodist', 'mountainCoordinates', 'Hai_tuo', 'Small_wutai', 'km'); $ret = call_user_func_array(array($redis, 'rawCommand'), $param); var_dump($ret); } catch (Exception $e){ echo $e->getMessage(); } 执行结果:海陀山和小五台山之间距离是94.4219km string(7) "94.4219" 4.以我的坐标为原点,按半径100km取坐标(找出离我100公里以内的山) try { $redis = new Redis(); $redis->connect('192.168.75.132', 6379); $param = array('georadius', 'mountainCoordinates', '116.517159', '39.922267', '100', 'km', 'WITHDIST', 'WITHCOORD'); $ret = call_user_func_array(array($redis, 'rawCommand'), $param); print_r($ret); } catch (Exception $e){ echo $e->getMessage(); } 执行结果:只有海陀山,离我95.8884km Array ( [0] => Array ( [0] => Hai_tuo [1] => 95.8884 [2] => Array ( [0] => 115.79384654760360718 [1] => 40.58445845049069334 ) ) ) 5.以我的坐标为原点,按半径1500km取坐标(找出离我1500公里以内的山) try { $redis = new Redis(); $redis->connect('192.168.75.132', 6379); $param = array('georadius', 'mountainCoordinates', '116.517159', '39.922267', '1500', 'km', 'WITHDIST', 'WITHCOORD'); $ret = call_user_func_array(array($redis, 'rawCommand'), $param); print_r($ret); } catch (Exception $e){ echo $e->getMessage(); } 执行结果:找出了5座山 Array ( [0] => Array ( [0] => Jiu_ding [1] => 1464.4350 [2] => Array ( [0] => 103.90176326036453247 [1] => 31.60486909089710394 ) ) [1] => Array ( [0] => Ao_Shan [1] => 1039.1217 [2] => Array ( [0] => 107.3980066180229187 [1] => 34.05777705537607147 ) ) [2] => Array ( [0] => Wu_gong [1] => 1401.2353 [2] => Array ( [0] => 114.1738244891166687 [1] => 27.47456377424472151 ) ) [3] => Array ( [0] => Small_wutai [1] => 124.6283 [2] => Array ( [0] => 115.05623370409011841 [1] => 39.94893288365195616 ) ) [4] => Array ( [0] => Hai_tuo [1] => 95.8884 [2] => Array ( [0] => 115.79384654760360718 [1] => 40.58445845049069334 ) ) ) 6.以小五台山的坐标为原点,按半径1000km取坐标(找出离小五台山1000公里以内的山) try { $redis = new Redis(); $redis->connect('192.168.75.132', 6379); $param = array('georadiusbymember', 'mountainCoordinates', 'Small_wutai', '1000', 'km', 'WITHDIST', 'WITHCOORD'); $ret = call_user_func_array(array($redis, 'rawCommand'), $param); print_r($ret); } catch (Exception $e){ echo $e->getMessage(); } 执行结果:排除小五台自己,找到了鳌山和海陀山 Array ( [0] => Array ( [0] => Small_wutai [1] => 0.0000 [2] => Array ( [0] => 115.05623370409011841 [1] => 39.94893288365195616 ) ) [1] => Array ( [0] => Hai_tuo [1] => 94.4219 [2] => Array ( [0] => 115.79384654760360718 [1] => 40.58445845049069334 ) ) [2] => Array ( [0] => Ao_Shan [1] => 943.7873 [2] => Array ( [0] => 107.3980066180229187 [1] => 34.05777705537607147 ) ) ) 原文地址:https://www.jmsite.cn/blog-578.html

优秀的个人博客,低调大师

Python获取IP地址对应的地理位置信息!

开发工具 Python版本:3.6.4相关模块:IPy模块;argparse模块;requests模块;以及一些Python自带的模块。 环境搭建 安装Python并添加到环境变量,pip安装需要的相关模块即可。 先睹为快 py文件运行方式(cmd窗口):python ipLocQuery.py -ip ipaddrpython ipLocQuery.py -f ipaddrfileexe文件运行方式(cmd窗口):ipLocQuery.exe -ip ipaddripLocQuery.exe -f ipaddrfile效果如下: 在学习中有迷茫不知如何学习的朋友小编推荐一个学Python的学习q u n 227 -435- 450可以来了解一起进步一起学习!免费分享视频资料 原理简介 利用了三个可以查询ip地址对应归属地的网站做的这个小工具,分别是: ① ip.taobao.com 速度快,查国内的ip地址对应归属地比较精确。 ② ip-api.com 速度很慢,准确性一般,国内外ip地址对应归属地均可查询,同时提供了经纬度信息。 ③ api.ipstack.com(推荐) 速度快,准确性高,国内外ip地址对应归属地均可查询,同时提供了经纬度信息。 代码实现起来比较简单,主要流程为: (1)IP地址有效性验证 图方便,就直接调用IPy模块来验证的,有bug。具体代码如下: (2)请求API接口获取ip地址对应归属地 根据ip地址分别请求每个网站提供的API接口来获取ip地址对应归属地。由于返回结果是英文或者拼音,因此需要调用有道翻译的API接口对返回结果进行翻译,最后再把翻译结果打印出来。 具体代码实现如下(以ipstack为例):

优秀的个人博客,低调大师

PHP获取用户ip、地理位置、浏览器和系统信息

public function service() { $list['ip'] = $_SERVER["REMOTE_ADDR"]; $list['service'] = $this->get_os(); $list['broswer'] = $this->get_broswer(); $list['where'] = $this->position($list['ip']); dump($list);die; } /** * 获取客户端操作系统信息包括win10 * @param null * @author Jea杨 * @return string */ function get_os(){ $agent = $_SERVER['HTTP_USER_AGENT']; $os = false; if (preg_match('/win/i', $agent) && strpos($agent, '95')) { $os = 'Windows 95'; } else if (preg_match('/win 9x/i', $agent) && strpos($agent, '4.90')) { $os = 'Windows ME'; } else if (preg_match('/win/i', $agent) && preg_match('/98/i', $agent)) { $os = 'Windows 98'; } else if (preg_match('/win/i', $agent) && preg_match('/nt 6.0/i', $agent)) { $os = 'Windows Vista'; } else if (preg_match('/win/i', $agent) && preg_match('/nt 6.1/i', $agent)) { $os = 'Windows 7'; } else if (preg_match('/win/i', $agent) && preg_match('/nt 6.2/i', $agent)) { $os = 'Windows 8'; }else if(preg_match('/win/i', $agent) && preg_match('/nt 10.0/i', $agent)) { $os = 'Windows 10';#添加win10判断 }else if (preg_match('/win/i', $agent) && preg_match('/nt 5.1/i', $agent)) { $os = 'Windows XP'; } else if (preg_match('/win/i', $agent) && preg_match('/nt 5/i', $agent)) { $os = 'Windows 2000'; } else if (preg_match('/win/i', $agent) && preg_match('/nt/i', $agent)) { $os = 'Windows NT'; } else if (preg_match('/win/i', $agent) && preg_match('/32/i', $agent)) { $os = 'Windows 32'; } else if (preg_match('/linux/i', $agent)) { $os = 'Linux'; } else if (preg_match('/unix/i', $agent)) { $os = 'Unix'; } else if (preg_match('/sun/i', $agent) && preg_match('/os/i', $agent)) { $os = 'SunOS'; } else if (preg_match('/ibm/i', $agent) && preg_match('/os/i', $agent)) { $os = 'IBM OS/2'; } else if (preg_match('/Mac/i', $agent) && preg_match('/PC/i', $agent)) { $os = 'Macintosh'; } else if (preg_match('/PowerPC/i', $agent)) { $os = 'PowerPC'; } else if (preg_match('/AIX/i', $agent)) { $os = 'AIX'; } else if (preg_match('/HPUX/i', $agent)) { $os = 'HPUX'; } else if (preg_match('/NetBSD/i', $agent)) { $os = 'NetBSD'; } else if (preg_match('/BSD/i', $agent)) { $os = 'BSD'; } else if (preg_match('/OSF1/i', $agent)) { $os = 'OSF1'; } else if (preg_match('/IRIX/i', $agent)) { $os = 'IRIX'; } else if (preg_match('/FreeBSD/i', $agent)) { $os = 'FreeBSD'; } else if (preg_match('/teleport/i', $agent)) { $os = 'teleport'; } else if (preg_match('/flashget/i', $agent)) { $os = 'flashget'; } else if (preg_match('/webzip/i', $agent)) { $os = 'webzip'; } else if (preg_match('/offline/i', $agent)) { $os = 'offline'; } else { $os = '未知操作系统'; } return $os; } /** * 获取客户端浏览器信息 添加win10 edge浏览器判断 * @param null * @author Jea杨 * @return string */ function get_broswer(){ $sys = $_SERVER['HTTP_USER_AGENT']; //获取用户代理字符串 if (stripos($sys, "Firefox/") > 0) { preg_match("/Firefox\/([^;)]+)+/i", $sys, $b); $exp[0] = "Firefox"; $exp[1] = $b[1]; //获取火狐浏览器的版本号 } elseif (stripos($sys, "Maxthon") > 0) { preg_match("/Maxthon\/([\d\.]+)/", $sys, $aoyou); $exp[0] = "傲游"; $exp[1] = $aoyou[1]; } elseif (stripos($sys, "MSIE") > 0) { preg_match("/MSIE\s+([^;)]+)+/i", $sys, $ie); $exp[0] = "IE"; $exp[1] = $ie[1]; //获取IE的版本号 } elseif (stripos($sys, "OPR") > 0) { preg_match("/OPR\/([\d\.]+)/", $sys, $opera); $exp[0] = "Opera"; $exp[1] = $opera[1]; } elseif(stripos($sys, "Edge") > 0) { //win10 Edge浏览器 添加了chrome内核标记 在判断Chrome之前匹配 preg_match("/Edge\/([\d\.]+)/", $sys, $Edge); $exp[0] = "Edge"; $exp[1] = $Edge[1]; } elseif (stripos($sys, "Chrome") > 0) { preg_match("/Chrome\/([\d\.]+)/", $sys, $google); $exp[0] = "Chrome"; $exp[1] = $google[1]; //获取google chrome的版本号 } elseif(stripos($sys,'rv:')>0 && stripos($sys,'Gecko')>0){ preg_match("/rv:([\d\.]+)/", $sys, $IE); $exp[0] = "IE"; $exp[1] = $IE[1]; }else { $exp[0] = "未知浏览器"; $exp[1] = ""; } return $exp[0].'('.$exp[1].')'; } function get_position($ip){ if(empty($ip)){ return '缺少用户ip'; } $url = 'http://ip.taobao.com/service/getIpInfo.php?ip='.$ip; $ipContent = file_get_contents($url); $ipContent = json_decode($ipContent,true); $list = $ipContent['data']['country'].$ipContent['data']['region'].$ipContent['data']['city'].$ipContent['data']['isp']; return $list; }

优秀的个人博客,低调大师

hive权限控制

<property> <name>hive.server2.authentication</name> <value>CUSTOM</value> </property> <property> <name>hive.server2.custom.authentication.class</name> <value>com.hiveserver.auth.CustomHiveServerAuth</value> </property> <property> <name>hive.server2.custom.authentication.file</name> <value>/home/soft/hive/conf/hiveserver2.users.conf</value> </property> <property> <name>hive.metastore.local</name> <value>false</value> </property> <property> <name>hive.metastore.uris</name> <value>thrift://spark01:9083</value> <description>Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.</description> </property> <property> <name>hive.security.authenticator.manager</name> <value>org.apache.hadoop.hive.ql.security.SessionStateUserAuthenticator</value> <description> hive client authenticator manager class name. The user defined authenticator should implement interface org.apache.hadoop.hive.ql.security.HiveAuthenticationProvider. </description> </property> <property> <name>hive.security.authorization.enabled</name> <value>true</value> <description>enable or disable the Hive client authorization</description> </property> <property> <name>hive.security.authorization.manager</name> <value>org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory</value> <description> The Hive client authorization manager class name. The user defined authorization class should implement interface org.apache.hadoop.hive.ql.security.authorization.HiveAuthorizationProvider. </description> </property> <property> <name>hive.users.in.admin.role</name> <value>root</value> <description> Comma separated list of users who are in admin role for bootstrapping. More users can be added in ADMIN role later. </description> </property> <property> <name>hive.server2.enable.doAs</name> <value>false</value> <description> Setting this property to true will have HiveServer2 execute Hive operations as the user making the calls to it. </description> </property> <property> <name>hive.server2.thrift.bind.host</name> <value>spark01</value> <description>Bind host on which to run the HiveServer2 Thrift service.</description> </property> <property> <name>hive.server2.thrift.port</name> <value>10000</value> <description>Port number of HiveServer2 Thrift interface when hive.server2.transport.mode is 'binary'.</description> </property> <property> <name>hive.server2.thrift.http.port</name> <value>10001</value> <description>Port number of HiveServer2 Thrift interface when hive.server2.transport.mode is 'http'.</description> </property> hive --service metastore &hive --service hiveserver2 & !connect jdbc:hive2://172.16.0.71:10000 create database tycybgongshang;describe database tycbygongshang;create database tycybzhuanli;set role admin;

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册