Coder Social home page Coder Social logo

ipservice-1's Introduction

IpService

1.1 功能介绍

查询ip所属的国家、国家代码、省份、城市、所属运营商。

查询返回的结果,比如:
array (size=6)
'ip' => '61.135.169.74'
'country' => '**'
'country_code' => 'CN'
'province' => '北京'
'city' => '北京'
'provider' => '移动'

查询IP: 61.135.169.74 耗时 7.47 毫秒

2.1 使用方式

样例见项目的:index.php文件。

3.1 文件作用介绍

3.1.1 index.php // 使用样例
3.1.2 IpService.php // IP 查询服务的类
3.1.3 functions.php // IP 查询的几个相关操作的函数
3.1.4 Runtime.php // 脚本执行时间统计的类
3.1.5 separate_ipdata_to_file.php // 切分ip数据大文件(ip.data)的脚本
3.1.6 ip.data // ip数据的大文件(180k行数据)
3.1.7 ip_dir/ // 已经被切分成每个文件1000行的小文件

4.1 实现方式

前置处理:将大文件切分成多个含有1000行数据的小文件,并且以该文件中覆盖到最大的ip 的long型值作为文件名。

具体做法:一个ip过来,先转成long型整数,然后获取所有ip小文件的文件名,降序存在一个数组里面。接着,拿这个ip去跟这些文件名对比,以定位该ip所在的区间在哪个文件。当定位到所属的ip文件之后,再用该ip去一行一行比较,获取该ip的信息。(具体可以看PHP脚本文件:IpService.php)

备注: ip数据来自网上。这些ip也没有更新,所以久了也会过期。

ipservice-1's People

Contributors

hikoqiu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.