/**
  * Categorize Incoming Request  
  * 
  * @access public
  * @return category of request, typically of the order M00X. 
  */
 public function determineCategory($userAgent = null, $defaultGrade = Grades::UNSUPPORTED)
 {
     $logger = $GLOBALS['logger'];
     $app = $GLOBALS['app'];
     $parsedUA = UA::parse($userAgent);
     if (!empty($app) && !$app->getConfiguration()->isLocal()) {
         try {
             $logger->info('Attempting device lookup in database');
             $browser = $this->_lookupDB($parsedUA);
             return $this->_computeCategory($browser);
         } catch (\Exception $ex) {
             $logger->info("No device database found, defaulting to local file based detection");
             $browser = $this->_lookupLocal($parsedUA, $defaultGrade);
             return $this->_computeCategory($browser);
         }
     } else {
         //$logger->info("Local environment, defaulting to local file based detection");
         $browser = $this->_lookupLocal($parsedUA, $defaultGrade);
         return $this->_computeCategory($browser);
     }
 }
Exemple #2
0
  / / / | | '_ \|  _/ _ \  \__ \ '_ ` _ \ / _ \
 / / /  | | | | | || (_) | (   / | | | | |  __/
/_/_/   |_|_| |_|_| \___/   |_||_| |_| |_|\___|
      </pre>
			script written by heiswayi nrird
			</div>
			
			
			<div id="output">

<table class="info"><tbody>

<?php 
// required functions
require "UAParser.php";
$ua = UA::parse();
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
    $iplocal = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $iplocal = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
    $iplocal = $_SERVER['REMOTE_ADDR'];
}
$file = file_get_contents('http://ip6.me/');
$pos = strpos($file, '+3') + 3;
$ip = substr($file, $pos, strlen($file));
$pos = strpos($ip, '</');
$ip = substr($ip, 0, $pos);
// display data
echo '<tr><td class="label">web_browser:</td><td>' . $ua->browserFull . '</td></tr>';
echo '<tr><td class="label">operating_system:</td><td>' . $ua->osFull . '</td></tr>';
Exemple #3
0
 * Copyright (c) 2011-2012 Dave Olsen, http://dmolsen.com
 * Licensed under the MIT license
 */
// include the ua-parser-php library to rip apart user agent strings
require __DIR__ . "/../lib/ua-parser-php/UAParser.php";
if ($uaListJSON = @file_get_contents(__DIR__ . "/../user-agents/core/ua.list.json")) {
    $uaList = (array) json_decode($uaListJSON);
    asort($uaList);
    foreach ($uaList as $key => $value) {
        $file = __DIR__ . "/../user-agents/core/ua." . $key . ".json";
        if (!isset($ua->device)) {
            $uaItemJSON = @file_get_contents($file);
            $uaJSON = json_decode($uaItemJSON);
            unset($uaJSON->deviceOSGeneral);
            unset($uaJSON->deviceOSSpecific);
            unset($uaJSON->majorVersion);
            unset($uaJSON->minorVersion);
            unset($uaJSON->isTablet);
            unset($uaJSON->isMobile);
            unset($uaJSON->isComputer);
            unset($uaJSON->isSpider);
            unset($uaJSON->iOSUIWebview);
            $userAgent = UA::parse($uaJSON->ua);
            $updatedInfo = (object) array_merge((array) $uaJSON, (array) $userAgent);
            $updatedInfo = json_encode($updatedInfo);
            $fp = fopen($file, "w");
            fwrite($fp, $updatedInfo);
            fclose($fp);
        }
    }
}
Exemple #4
0
 /**
  * Adds the user agent hash and user agent to a list for retrieval in the demo (or for any reason i guess)
  * @param  {Object}        the core template object
  *
  * @return {Object}        the core template object "filled out" from ua-parser-php
  */
 private static function createUAProperties($obj)
 {
     // include the ua-parser-php library to rip apart user agent strings
     require_once __DIR__ . "/lib/ua-parser-php/UAParser.php";
     // classify the user agent string so we can learn more what device this really is. more for readability than anything
     $userAgent = UA::parse();
     // save properties from ua-parser-php
     foreach ($userAgent as $key => $value) {
         $obj->{$key} = $value;
     }
     return $obj;
 }