php-useragent, A User-agent analyze project which written by PHP.

分享于 

4分钟阅读

GitHub

  繁體
一个简单的User-Agent库,可以从一条User-Agent字符串获取该用户的相关信息。库内附带可检测出的浏览器、操作系统和设备16x16和24x24的icon。
  • 源代码名称:php-useragent
  • 源代码网址:http://www.github.com/zsxsoft/php-useragent
  • php-useragent源代码文档
  • php-useragent源代码下载
  • Git URL:
    git://www.github.com/zsxsoft/php-useragent.git
    Git Clone代码到本地:
    git clone http://www.github.com/zsxsoft/php-useragent
    Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/zsxsoft/php-useragent
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
    
    PHP-UserAgent

    Build StatusLatest Stable VersionCodacy BadgePackagist

    A User-agent analyze project.

    Try it

    http://www.zsxsoft.com/php-useragent/test-my-useragent.php

    JavaScript Edition

    https://github.com/zsxsoft/useragent.js/

    Contributors

    zsx(http://www.zsxsoft.com)

    The project is based on kyleabaker's "wp-useragent".

    Supported Browsers/Platforms

    Click here to see full list.

    Tested Browsers: Amazon Silk / Android Webkit / Avant Browser / Comodo Dragon / curl / Firefox / Google Chrome / Internet Explorer / Microsoft Edge / Links / Lynx / Maxthon / MxNitro / Opera / QQBrowser / Safari SRWare Iron / Teleca Q7 / UC Browser / Vivaldi / W3M / wget / Yandex.Browser and so on..

    OS: Android / Arch Linux / CentOS / Chrome OS / Debain / Fedora / FreeBSD / OSX / Red Hat / openSUSE / SymbianOS / Unix / Palm webOS / Windows 3.1 - 10 / Ubuntu / Linux and so on..

    Devices: Xiaomi / BlackBerry / Nexus / HTC / Huawei / Kindle / Lenovo / LG / Motorola / Nokia / OnePlus / PlayStation / Samsung / Sony Xperia / ZTE / Ubuntu / Windows Phone / Apple Family and so on.

    Example & API

    
    
    
    <?php
    
    
    /**
    
    
     * Test Useragent
    
    
     * @package php-useragent
    
    
     * @author zsx <zsx@zsxsoft.com>
    
    
     * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
    
    
     */
    
    
    ini_set('display_errors', 'On');
    
    
    error_reporting(E_ALL);
    
    
    include './useragent.class.php';
    
    
    $useragent = UserAgentFactory::analyze($_SERVER['HTTP_USER_AGENT']);
    
    
    ?>
    
    
    <!DOCTYPE html>
    
    
    <html lang="en">
    
    
    <head>
    
    
            <meta charset="UTF-8">
    
    
            <title>UserAgent</title>
    
    
    </head>
    
    
    <body>
    
    
        <h1>Test UserAgent</h1>
    
    
        <p>UserAgent: <?php echo $useragent->useragent; ?></p>
    
    
        <p>Platform Type: <?php echo $useragent->platform['type'] ?>
    
    
        <p>Device: <img src="<?php echo $useragent->device['image'] ?>"/><?php echo $useragent->device['title'] ?>(Brand: <?php echo $useragent->device['brand'] ?>, Model: <?php echo $useragent->device['model'] ?>) </p>
    
    
        <p>OS: <img src="<?php echo $useragent->os['image'] ?>"/><?php echo $useragent->os['title'] ?> (Name = <?php echo $useragent->os['name'] ?>, Version = <?php echo $useragent->os['version'] ?>)</p>
    
    
        <p>Browser: <img src="<?php echo $useragent->browser['image'] ?>"/><?php echo $useragent->browser['title'] ?> (Name = <?php echo $useragent->browser['name'] ?>, Version = <?php echo $useragent->browser['version'] ?>)</p>
    
    
    
    </body>
    
    
    </html>
    
    
    

    ##TODO

    • Move out RegExps like useragent.js from the PHP file

    ##License


    相关文章