Home > php教程 > php手册 > body text

很犀利!PHP获取游客访问细节类

WBOY
Release: 2016-06-06 19:37:49
Original
1521 people have browsed it

当游客访问贵网站时,这个类可以把游客的相关信息储存在数据库。 它还可以检索从它的IP地址和其它请求头的到当前页面访问者若干细节。 目前,它记录用户计算机操作系统,浏览器,IP地址,国家,城市,地理坐标,互联网服务供应商或使用ip-api.comWeb服务。 所

当游客访问贵网站时,这个类可以把游客的相关信息储存在数据库。

它还可以检索从它的IP地址和其它请求头的到当前页面访问者若干细节。

目前,它记录用户计算机操作系统,浏览器,IP地址,国家,城市,地理坐标,互联网服务供应商或使用ip-api.com Web服务。

所存储的数据可以关联到一个给定的域名地址。

详细下载地址:http://www.codepearl.com/files/239.html PHP 很犀利!PHP获取游客访问细节类
<?php
http://www.codepearl.com
include('Visitors.php');
$info=new Visitors();
$info->setSubdomain("www.codepearl.com");
$info->getVisitorInfo($_SERVER['HTTP_USER_AGENT']);
$info->insertInfo();
?>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="Dragan Zlatkovski">
</head>

<body>

</body>
</html>
Copy after login
CREATE TABLE IF NOT EXISTS `visitors` (
`id` int(11) NOT NULL,
  `domain` varchar(150) NOT NULL,
  `ip` varchar(15) NOT NULL,
  `serverDate` varchar(10) NOT NULL,
  `serverTime` varchar(10) NOT NULL,
  `timeZone` varchar(100) NOT NULL,
  `userOS` varchar(100) NOT NULL,
  `userBrowser` varchar(100) NOT NULL,
  `userAgent` varchar(300) NOT NULL,
  `country` varchar(100) NOT NULL,
  `countryCode` varchar(10) NOT NULL,
  `city` varchar(100) NOT NULL,
  `state` varchar(10) NOT NULL,
  `lat` varchar(40) NOT NULL,
  `lon` varchar(40) NOT NULL,
  `isp` varchar(200) NOT NULL,
  `org` varchar(200) NOT NULL,
  `asp` varchar(200) NOT NULL
) ENGINE=MyISAM AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;
Copy after login
function getVisitorInfo($httpUserAgent)
    {
        $this->setUserIp();
        $this->setServerDate();
        $this->setServerTime();
        $this->setUserOs($httpUserAgent);
        $this->setUserBrowser($httpUserAgent);
        $this->setUserAgent($httpUserAgent);
        $query = @unserialize(file_get_contents('http://ip-api.com/php/'.$this->getUserIp()));  //获取IP接口自己可以设定
        $this->setUserCountry($query['country']);
        $this->setUserCountryCode($query['countryCode']);
        $this->setUserCity($query['city']);
        $this->setUserStateOfRegion($query['regionName']);
        $this->setLatitude($query['lat']);
        $this->setLongitude($query['lon']);
        $this->setISP($query['isp']);
        $this->setORG($query['org']);
        $this->setAS($query['as']);
        $this->setTimeZone($query['timezone']);

    }
Copy after login
很犀利!PHP获取游客访问细节类
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template