PHP Classes
elePHPant
Icontem

File: test/_data/syntheseFunction.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Frédéric Thizy  >  Request Info User Agent  >  test/_data/syntheseFunction.php  >  Download  
File: test/_data/syntheseFunction.php
Role: Example script
Content type: text/plain
Description: exemple for make stat with the xml file
Class: Request Info User Agent
Detect the type of browser accessing the site
Author: By
Last change: update required file path
Date: 6 years ago
Size: 1,846 bytes
 

Contents

Class file image Download
<?php
require_once dirname(__FILE__) . '/../UserAgent.php';

function
systemsStats() {
   
FredT_Request_Info_UserAgent::setDetectMode(FredT_Request_Info_UserAgent::MODE_FULL_DETECT);
   
$_infoUA = new FredT_Request_Info_UserAgent();
   
$_oSXE = @simplexml_load_file(dirname(__FILE__) . '/UA.xml');
   
$aTest=array();
    foreach (
$_oSXE as $val) {
       
$_infoUA->setUserAgent((string) $val->navigateur);
       
$type=$_infoUA->getSystemType();
        if ( ! isset(
$aTest[$type])) {
           
$aTest[$type]=array();
        }
       
$name=$_infoUA->getSystem();
        if ( ! isset(
$aTest[$type][$name])) {
           
$aTest[$type][$name]=array();
        }
       
$version=$_infoUA->getSystemVersion();
        if ( ! isset(
$aTest[$type][$name][$version])) {
           
$aTest[$type][$name][$version]=0;
        }
       
$aTest[$type][$name][$version]+=$val->nb;
    }
   
//var_dump($aTest);
   
return $aTest;
}

function
systemsWinLin() {
   
FredT_Request_Info_UserAgent::setDetectMode(FredT_Request_Info_UserAgent::MODE_FULL_DETECT);
   
$_infoUA = new FredT_Request_Info_UserAgent();
   
$_oSXE = @simplexml_load_file(dirname(__FILE__) . '/UA.xml');
   
$aTest=array();
    foreach (
$_oSXE as $val) {
       
$_infoUA->setUserAgent((string) $val->navigateur);
       
$system=$_infoUA->getSystem();
        if (
$system=='Windows' || $system=='Linux') {
            if ( ! isset(
$aTest[$system])) {
               
$aTest[$system]=array();
            }
           
$version=$_infoUA->getSystemVersion();
            if ( ! isset(
$aTest[$system][$version])) {
               
$aTest[$system][$version]= array();
            }
           
$aTest[$system][$version][]=$_infoUA->getUserAgent();
        }
    }
    return
$aTest;
}

//var_dump(systemsWinLin());
//var_dump(systemsStats());