Location: PHPKode > scripts > Client info > client-info/client_info.class.php
<?php

class client_info {

  function parse_user_agent($user_agent)
  {
    $client_data = array(
    'system' => "",
    'system_icon' => "unknown",
    'browser' => "",
    'browser_icon' => "unknown"
    );
    $tmp_array = array();

    // 
    // Check browsers
    // 
  
    // Camino
    if(preg_match('/mozilla.*rv:[0-9\.]+.*gecko\/[0-9]+.*camino\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Camino";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'camino';
      }

    // Netscape
    if(preg_match('/mozilla.*netscape[0-9]?\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Netscape";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'netscape';
      }

    // Epiphany
    if(preg_match('/mozilla.*gecko\/[0-9]+.*epiphany\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Epiphany";
      $client_data['browser_version']=($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'epiphany';
      }

    // Galeon
    if(preg_match('/mozilla.*gecko\/[0-9]+.*galeon\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Galeon";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'galeon';
      }

    // Flock
    if(preg_match('/mozilla.*gecko\/[0-9]+.*flock\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Flock";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'flock';
      }

    // Minimo
    if(preg_match('/mozilla.*gecko\/[0-9]+.*minimo\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Minimo";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'mozilla';
      }

    // K-Meleon
    if(preg_match('/mozilla.*gecko\/[0-9]+.*k\-meleon\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "K-Meleon";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'k-meleon';
      }

    // K-Ninja
    if(preg_match('/mozilla.*gecko\/[0-9]+.*k-ninja\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "K-Ninja";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'k-ninja';
      }

    // Kazehakase
    if(preg_match('/mozilla.*gecko\/[0-9]+.*kazehakase\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Kazehakase";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'kazehakase';
      }

    // SeaMonkey
    if(preg_match('/mozilla.*rv:[0-9\.]+.*gecko\/[0-9]+.*seamonkey\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "SeaMonkey";
      $client_data['browser_version'] =($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'seamonkey';
      }

    // IceApe
    if(preg_match('/mozilla.*rv:[0-9\.]+.*gecko\/[0-9]+.*iceape\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "IceApe";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'iceape';
      }

    // Firefox
    if(preg_match('/mozilla.*rv:[0-9\.]+.*gecko\/[0-9]+.*firefox\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Firefox";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'firefox';
      }

    // IceWeasel
    if(preg_match('/mozilla.*rv:[0-9\.]+.*gecko\/[0-9]+.*iceweasel\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "IceWeasel";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'iceweasel';
      }

    // Bon Echo
    if(preg_match('/mozilla.*rv:[0-9\.]+.*gecko\/[0-9]+.*BonEcho\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Bon Echo";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'deerpark';
      }

    // Gran Paradiso
    if(preg_match('/mozilla.*rv:[0-9\.]+.*gecko\/[0-9]+.*GranParadiso\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Gran Paradiso";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'deerpark';
      }

    // Minefield
    if(preg_match('/mozilla.*rv:[0-9\.]+.*gecko\/[0-9]+.*Minefield\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Minefield";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'minefield';
      }

    // Thunderbird
    if(preg_match('/mozilla.*rv:[0-9\.]+.*gecko\/[0-9]+.*thunderbird\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Thunderbird";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'thunderbird';
      }

    // IceDove
    if(preg_match('/mozilla.*rv:[0-9\.]+.*gecko\/[0-9]+.*icedove\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "IceDove";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'icedove';
      }

    // Firebird
    if(preg_match('/mozilla.*rv:[0-9\.]+.*gecko\/[0-9]+.*firebird\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Firebird";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'phoenix';
      }

    // Phoenix
    if(preg_match('/mozilla.*rv:[0-9\.]+.*gecko\/[0-9]+.*phoenix\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Phoenix";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'phoenix';
      }

    // Mozilla Suite
    if(preg_match('/mozilla.*rv:([0-9\.]+).*gecko\/[0-9]+.*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Mozilla";
      $client_data['browser_icon'] = 'mozilla';

    if((int)substr($tmp_array[1],2,1) <= 7)
      {
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      }
    else
      {
      $client_data['browser_version'] = " compatible";
      }
    }

    // Konqueror
    if(preg_match('/mozilla.*konqueror\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Konqueror";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'konqueror';
      if(preg_match('/khtml\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array))
        {
        $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
        }
      }

    // Opera
    if((preg_match('/mozilla.*opera ([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) || preg_match('/^opera\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array)) && !$client_data['browser'])
      {
      $client_data['browser'] = "Opera";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'opera';
      if(preg_match('/opera mini/si', $user_agent))
        {
        preg_match('/opera mini\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array);
        $client_data['browser_version'] .= " (Opera Mini" . ($tmp_array[1] ? " ".$tmp_array[1] : "") . ")";
        }
    }

    // OmniWeb
    if(preg_match('/mozilla.*applewebkit\/[0-9]+.*omniweb\/v[0-9\.]+/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "OmniWeb";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'omniweb';
      }

    // SunriseBrowser
    if(preg_match('/mozilla.*applewebkit\/[0-9]+.*sunrisebrowser\/([0-9a-z\+\-\.]+)/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "SunriseBrowser";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'sunrise';
      }

    // DeskBrowse
    if(preg_match('/mozilla.*applewebkit\/[0-9]+.*deskbrowse\/([0-9a-z\+\-\.]+)/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "DeskBrowse";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'deskbrowse';
      }

    // Shiira
    if(preg_match('/mozilla.*applewebkit.*shiira\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Shiira";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'shiira';
      }

    // Safari
    if(preg_match('/mozilla.*applewebkit.*safari\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Safari";
      $client_data['browser_icon'] = 'safari';

      // Translate Safari build into version number
      if($tmp_array[1] == "522.12" || $tmp_array[1] == "522.13.1")
        {
        $client_data['browser_version'] = " 3.0";
        }
      elseif($tmp_array[1] == "522.11.3")
        {
        $client_data['browser_version'] = " 3.0 beta";
        }
      elseif(substr($tmp_array[1], 0, 3) == "419")
        {
        $client_data['browser_version'] = " 2.0.4";
        }
      elseif(substr($tmp_array[1], 0, 3) == "417")
        {
        $client_data['browser_version'] = " 2.0.3";
        }
      elseif(substr($tmp_array[1], 0, 3) == "416")
        {
        $client_data['browser_version'] = " 2.0.2";
        }
      elseif($tmp_array[1] == "412.5")
        {
        $client_data['browser_version'] = " 2.0.1";
        }
      elseif(substr($tmp_array[1], 0, 3) == "412")
        {
        $client_data['browser_version'] = " 2.0";
        }
      elseif($tmp_array[1] == "312.6" || $tmp_array[1] == "312.5")
        {
        $client_data['browser_version'] = " 1.3.2";
        }
      elseif(substr($tmp_array[1], 0, 5) == "312.3")
        {
        $client_data['browser_version'] = " 1.3.1";
        }
      elseif(substr($tmp_array[1], 0, 3) == "312")
        {
        $client_data['browser_version'] = " 1.3";
        }
      elseif($tmp_array[1] == "125.12" || $tmp_array[1] == "125.11")
        {
        $client_data['browser_version'] = " 1.2.4";
        }
      elseif($tmp_array[1] == "125.9")
        {
        $client_data['browser_version'] = " 1.2.3";
        }
      elseif($tmp_array[1] == "125.8" || $tmp_array[1] == "125.7")
        {
        $client_data['browser_version'] = " 1.2.2";
        }
      elseif($tmp_array[1] == "125.1")
        {
        $client_data['browser_version'] = " 1.2.1";
        }
      elseif(substr($tmp_array[1], 0, 3) == "125")
        {
        $client_data['browser_version'] = " 1.2";
        }
      elseif($tmp_array[1] == "101.1")
        {
        $client_data['browser_version'] = " 1.1.1";
        }
      elseif(substr($tmp_array[1], 0, 3) == "100")
        {
        $client_data['browser_version'] = " 1.1";
        }
      elseif(substr($tmp_array[1], 0, 4) == "85.8")
        {
        $client_data['browser_version'] = " 1.0.3";
        }
      elseif($tmp_array[1] == "85.7")
        {
        $client_data['browser_version'] = " 1.0.2";
        }
      elseif(substr($tmp_array[1], 0, 2) == "85")
        {
        $client_data['browser_version'] = " 1.0";
        }
      elseif(substr($tmp_array[1], 0, 2) == "74")
        {
        $client_data['browser_version'] = " 1.0b2";
        }
      elseif(substr($tmp_array[1], 0, 2) == "73")
        {
        $client_data['browser_version'] = " 0.9";
        }
      elseif(substr($tmp_array[1], 0, 2) == "60")
        {
        $client_data['browser_version'] = " 0.8.2";
        }
      elseif(substr($tmp_array[1], 0, 2) == "51")
        {
        $client_data['browser_version'] = " 0.8.1";
        }
      elseif(substr($tmp_array[1], 0, 2) == "48")
        {
        $client_data['browser_version'] = " 0.8";
        }
      }
  
    // Dillo
    if(preg_match('/dillo\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Dillo";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'dillo';
      }

    // iCab
    if(preg_match('/icab\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "iCab";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'icab';
      }

    // Lynx
    if(preg_match('/^lynx\/([0-9a-z\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Lynx";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'lynx';
      }

    // Links
    if(preg_match('/^links \(([0-9a-z\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Links";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'links';
      }

    // Elinks
    if(preg_match('/^elinks \(([0-9a-z\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "ELinks";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'links';
      }
    if(preg_match('/^elinks\/([0-9a-z\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "ELinks";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'links';
      }
    if(preg_match('/^elinks$/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "ELinks";
      $client_data['browser_icon'] = 'links';
      }

    // Wget
    if(preg_match('/^Wget\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Wget";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'wget';
      }

    // Amiga Aweb
    if(preg_match('/Amiga\-Aweb\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Amiga Aweb";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'aweb';
      }

    // Amiga Voyager
    if(preg_match('/AmigaVoyager\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Amiga Voyager";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'voyager';
      }

    // QNX Voyager
    if(preg_match('/QNX Voyager ([0-9a-z.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "QNX Voyager";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'qnx';
      }

    // IBrowse
    if(preg_match('/IBrowse\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "IBrowse";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'ibrowse';
      }

    // Openwave
    if(preg_match('/UP\.Browser\/([0-9a-zA-Z\.]+).*/s', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Openwave";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'openwave';
      }
    if(preg_match('/UP\/([0-9a-zA-Z\.]+).*/s', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Openwave";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'openwave';
      }

    // NetFront
    if(preg_match('/NetFront\/([0-9a-z\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "NetFront";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'netfront';
      }

    // PlayStation Portable
    if(preg_match('/psp.*playstation.*portable[^0-9]*([0-9a-z\.]+)\)/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "PSP";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'playstation';
      }

    // Various robots...

    // Googlebot
    if(preg_match('/Googlebot\/([0-9a-z\+\-\.]+).*/s', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Googlebot";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'robot';
      }

    // Googlebot Image
    if(preg_match('/Googlebot\-Image\/([0-9a-z\+\-\.]+).*/s', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Googlebot Image ";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'robot';
      }

    // Gigabot
    if(preg_match('/Gigabot\/([0-9a-z\+\-\.]+).*/s', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Gigabot";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'robot';
      }

    // W3C Validator
    if(preg_match('/^W3C_Validator\/([0-9a-z\+\-\.]+)$/s', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "W3C Validator";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'robot';
      }

    // W3C CSS Validator
    if(preg_match('/W3C_CSS_Validator_[a-z]+\/([0-9a-z\+\-\.]+)$/s', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "W3C CSS Validator";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'robot';
      }

    // MSN Bot
    if(preg_match('/msnbot(-media|)\/([0-9a-z\+\-\.]+).*/s', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "MSNBot";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'robot';
      }

    // Psbot
    if(preg_match('/psbot\/([0-9a-z\+\-\.]+).*/s', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Psbot";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'robot';
      }

    // IRL crawler
    if(preg_match('/IRLbot\/([0-9a-z\+\-\.]+).*/s', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "IRL crawler";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'robot';
      }

    // Seekbot
    if(preg_match('/Seekbot\/([0-9a-z\+\-\.]+).*/s', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Seekport Robot";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'robot';
      }

    // Microsoft Research Bot
    if(preg_match('/^MSRBOT /s', $user_agent) && !$client_data['browser'])
      {
      $client_data['browser'] = "MSRBot";
      $client_data['browser_icon'] = 'robot';
      }

    // cfetch/voyager
    if(preg_match('/^(cfetch|voyager)\/([0-9a-z\+\-\.]+)$/s', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "voyager";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'robot';
      }

    // BecomeBot
    if(preg_match('/BecomeBot\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "BecomeBot";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'robot';
      }

    // Alexa
    if(preg_match('/^ia_archiver$/s', $user_agent) && !$client_data['browser'])
      {
      $client_data['browser'] = "Alexa";
      $client_data['browser_icon'] = 'robot';
      }

    // Inktomi Slurp
    if(preg_match('/Slurp.*inktomi/s', $user_agent) && !$client_data['browser'])
      {
      $client_data['browser'] = "Inktomi Slurp";
      $client_data['browser_icon'] = 'robot';
      }

    // Yahoo Slurp
    if(preg_match('/Yahoo!.*Slurp/s', $user_agent) && !$client_data['browser'])
      {
      $client_data['browser'] = "Yahoo! Slurp";
      $client_data['browser_icon'] = 'robot';
      }

    // Ask.com
    if(preg_match('/Ask Jeeves\/Teoma/s', $user_agent) && !$client_data['browser'])
      {
      $client_data['browser'] = "Ask.com";
      $client_data['browser_icon'] = 'robot';
      }

    // end of robots

    // MSIE
    if(preg_match('/microsoft.*internet.*explorer/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Microsoft Internet Explorer 1.0";
      $client_data['browser_icon'] = 'msie';
      }
    if(preg_match('/mozilla.*MSIE ([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Microsoft Internet Explorer";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'msie';
      }

    // Netscape Navigator
    if(preg_match('/Mozilla\/([0-4][0-9\.]+).*/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Netscape Navigator";
      $client_data['browser_version'] = ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['browser_icon'] = 'netscape_old';
      }

    // Catchall for other Mozilla compatible browsers
    if(preg_match('/mozilla/si', $user_agent, $tmp_array) && !$client_data['browser'])
      {
      $client_data['browser'] = "Mozilla compatible";
      $client_data['browser_icon'] = 'mozilla';
      }

    // 
    // Check system
    // 

    // Linux
    if(preg_match('/linux/si', $user_agent) && !$client_data['system'])
      {
      $client_data['system'] = "Linux";
      $client_data['system_icon'] = "linux";
      if(preg_match('/mdk/si', $user_agent))
        {
        $client_data['system'] .= " (Mandrake)";
        $client_data['system_icon'] = "mandrake";
        }
      elseif(preg_match('/kanotix/si', $user_agent))
        {
        $client_data['system'] .= " (Kanotix)";
        $client_data['system_icon'] = "kanotix";
        }
      elseif(preg_match('/lycoris/si', $user_agent))
        {
        $client_data['system'] .= " (Lycoris)";
        $client_data['system_icon'] = "lycoris";
        }
      elseif(preg_match('/knoppix/si', $user_agent))
        {
        $client_data['system'] .= " (Knoppix)";
        $client_data['system_icon'] = "knoppix";
        }
      elseif(preg_match('/centos/si', $user_agent))
        {
        $client_data['system'] .= " (CentOS)";
        $client_data['system_icon'] = "centos";
        }
      elseif(preg_match('/gentoo/si', $user_agent))
        {
        $client_data['system'] .= " (Gentoo)";
        $client_data['system_icon'] = "gentoo";
        }
      elseif(preg_match('/fedora/si', $user_agent))
        {
        $client_data['system'] .= " (Fedora)";
        $client_data['system_icon'] = "fedora";
        }
      elseif(preg_match('/ubuntu.feist/si', $user_agent))
        {
        $client_data['system'] .= " (Ubuntu 7.04 Feisty Fawn)";
        $client_data['system_icon'] = "ubuntu";
        }
      elseif(preg_match('/ubuntu.edgy/si', $user_agent))
        {
        $client_data['system'] .= " (Ubuntu 6.10 Edgy Eft)";
        $client_data['system_icon'] = "ubuntu";
        }
      elseif(preg_match('/ubuntu.dapper/si', $user_agent))
        {
        $client_data['system'] .= " (Ubuntu 6.06 LTS Dapper Drake)";
        $client_data['system_icon'] = "ubuntu";
        }
      elseif(preg_match('/ubuntu.breezy/si', $user_agent))
        {
        $client_data['system'] .= " (Ubuntu 5.10 Breezy Badger)";
        $client_data['system_icon'] = "ubuntu";
        }
      elseif(preg_match('/kubuntu/si', $user_agent))
        {
        $client_data['system'] .= " (Kubuntu)";
        $client_data['system_icon'] = "kubuntu";
        }
      elseif(preg_match('/xubuntu/si', $user_agent))
        {
        $client_data['system'] .= " (Xubuntu)";
        $client_data['system_icon'] = "xubuntu";
        }
      elseif(preg_match('/ubuntu/si', $user_agent))
        {
        $client_data['system'] .= " (Ubuntu)";
        $client_data['system_icon'] = "ubuntu";
        }
      elseif(preg_match('/slackware/si', $user_agent))
        {
        $client_data['system'] .= " (Slackware)";
        $client_data['system_icon'] = "slackware";
        }
      elseif(preg_match('/suse/si', $user_agent))
        {
        $client_data['system'] .= " (Suse)";
        $client_data['system_icon'] = "suse";
        }
      elseif(preg_match('/redhat/si', $user_agent))
        {
        $client_data['system'] .= " (Redhat)";
        $client_data['system_icon'] = "redhat";
        }
      elseif(preg_match('/debian/si', $user_agent))
        {
        $client_data['system'] .= " (Debian)";
        $client_data['system_icon'] = "debian";
        }
      elseif(preg_match('/PLD\/([0-9.]*) \(([a-z]{2})\)/si', $user_agent, $tmp_array))
        {
        $client_data['system'] .= " (PLD".($tmp_array[1] ? " ".$tmp_array[1] : "").($tmp_array[2] ? " ".$tmp_array[2] : "").")";
        $client_data['system_icon'] = "pld";
        }
      }

    // BSD
    if(preg_match('/bsd/si', $user_agent) && !$client_data['system'])
      {
      $client_data['system'] = "BSD";
      $client_data['system_icon'] = "bsd";
      if(preg_match('/freebsd/si', $user_agent))
        {
        $client_data['system'] = "FreeBSD";
        }
      elseif(preg_match('/openbsd/si', $user_agent))
        {
        $client_data['system'] = "OpenBSD";
        }
      elseif(preg_match('/netbsd/si', $user_agent))
        {
        $client_data['system'] = "NetBSD";
        }
      }

    // Mac OS (X)
    if((preg_match('/mac_/si', $user_agent) || preg_match('/macos/si', $user_agent) || preg_match('/powerpc/si', $user_agent) || preg_match('/mac os/si', $user_agent) || preg_match('/68k/si', $user_agent) || preg_match('/macintosh/si', $user_agent)) && !$client_data['system'])
    {
      $client_data['system'] = "Mac OS";
      $client_data['system_icon'] = "macos";
      if(preg_match('/mac os x/si', $user_agent))
        {
        $client_data['system'] .= " X";

        // if browser == safari try to detect Mac OS X version
        if(preg_match('/applewebkit\/([0-9\.]+).*/si', $user_agent, $tmp_array))
          {
          if($tmp_array[1] == "419.2.1")
            {
            $client_data['system'] .= " 10.4.10";
            }
          elseif($tmp_array[1] == "419")
            {
            $client_data['system'] .= " 10.4.9";
            }
          elseif($tmp_array[1] == "418.9.1")
            {
            $client_data['system'] .= " 10.4.8";
            }
          elseif($tmp_array[1] == "418.9")
            {
            $client_data['system'] .= " 10.4.8";
            }
          elseif($tmp_array[1] == "418.8")
            {
            $client_data['system'] .= " 10.4.7";
            }
          elseif(substr($tmp_array[1], 0, 3) == "418")
            {
            $client_data['system'] .= " 10.4.6";
            }
          elseif($tmp_array[1] == "417.9")
            {
            $client_data['system'] .= " 10.4.4/10.4.5";
            }
          elseif(substr($tmp_array[1], 0, 3) == "416")
            {
            $client_data['system'] .= " 10.4.3";
            }
          elseif(substr($tmp_array[1], 0, 4) == "412.")
            {
            $client_data['system'] .= " 10.4.2";
            }
          elseif(substr($tmp_array[1], 0, 3) == "412")
            {
            $client_data['system'] .= " 10.4/10.4.1";
            }
          elseif(substr($tmp_array[1], 0, 3) == "312")
            {
            $client_data['system'] .= " 10.3.9";
            }
          elseif($tmp_array[1] == "125.5.7")
            {
            $client_data['system'] .= " 10.3.8";
            }
          elseif($tmp_array[1] == "125.5.5" && $tmp_array[2] == "125.11")
            {
            $client_data['system'] .= " 10.3.6";
            }
          elseif(($tmp_array[1] == "125.5.6" || $tmp_array[1] == "125.5.5") && substr($tmp_array[1], 0, 5) == "125.1")
            {
            $client_data['system'] .= " 10.3.6/10.3.7/10.3.8";
            }
          elseif($tmp_array[1] == "125.5" || $tmp_array[1] == "125.4")
            {
            $client_data['system'] .= " 10.3.5";
            }
          elseif($tmp_array[1] == "125.2")
            {
            $client_data['system'] .= " 10.3.4";
            }
          elseif($tmp_array[1] == "100"  && $tmp_array[2] == "100.1")
            {
            $client_data['system'] .= " 10.3.2";
            }
          elseif(substr($tmp_array[1], 0, 3) == "100")
            {
            $client_data['system'] .= " 10.3";
            }
          elseif(substr($tmp_array[1], 0, 2) == "85")
            {
            $client_data['system'] .= " 10.2.8";
            }
          }
        }
      }

    // ReactOS
    if(preg_match('/ReactOS ([0-9a-zA-Z\+\-\. ]+).*/s', $user_agent, $tmp_array))
      {
      $client_data['system'] = "ReactOS" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['system_icon'] = "reactos";
      }

    // SunOs
    if(preg_match('/sunos/si', $user_agent) && !$client_data['system'])
      {
      $client_data['system'] = "Solaris";
      $client_data['system_icon'] = "solaris";
      }

    // Amiga
    if(preg_match('/amiga/si', $user_agent) && !$client_data['system'])
      {
      $client_data['system'] = "Amiga";
      $client_data['system_icon'] = "amiga";
      }

    // Irix
    if(preg_match('/irix/si', $user_agent) && !$client_data['system'])
      {
      $client_data['system'] = "IRIX";
      $client_data['system_icon'] = "irix";
      }

    // OpenVMS
    if(preg_match('/open.*vms/si', $user_agent) && !$client_data['system'])
      {
      $client_data['system'] = "OpenVMS";
      $client_data['system_icon'] = "openvms";
      }

    // BeOs
    if(preg_match('/beos/si', $user_agent) && !$client_data['system'])
      {
      $client_data['system'] = "BeOS";
      $client_data['system_icon'] = "beos";
      }

    // QNX
    if(preg_match('/QNX/si', $user_agent) && preg_match('/Photon/si', $user_agent) && !$client_data['system'])
      {
      $client_data['system'] = "QNX";
      $client_data['system_icon'] = "qnx";
      }

    // OS/2 Warp
    if(preg_match('/OS\/2.*Warp ([0-9.]+).*/si', $user_agent, $tmp_array) && !$client_data['system'])
      {
      $client_data['system'] = "OS/2 Warp" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['system_icon'] = "os2";
      }

    // Java on mobile
    if(preg_match('/j2me/si', $user_agent) && !$client_data['system'])
      {
      $client_data['system'] = "Java Platform Micro Edition";
      $client_data['system_icon'] = "java";
      }

    // Symbian Os
    if(preg_match('/symbian/si', $user_agent) && !$client_data['system'])
      {
      $client_data['system'] = "Symbian OS";
      $client_data['system_icon'] = "symbian";
      // try to get version
      if(preg_match('/SymbianOS\/([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array))
        {
        $client_data['system'] .= ($tmp_array[1] ? " ".$tmp_array[1] : "");
        }
      }

    // Palm Os
    if(preg_match('/palmos/si', $user_agent) && !$client_data['system'])
      {
      $client_data['system'] = "Palm OS";
      $client_data['system_icon'] = "palmos";
      // try to get version
      if(preg_match('/PalmOS ([0-9a-z\+\-\.]+).*/si', $user_agent, $tmp_array))
        {
        $client_data['system'] .= ($tmp_array[1] ? " ".$tmp_array[1] : "");
        }
      }

    // PlayStation Portable
    if(preg_match('/psp.*playstation.*portable/si', $user_agent) && !$client_data['system'])
      {
      $client_data['system'] = "PlayStation Portable";
      $client_data['system_icon'] = 'playstation';
      }

    // Nintentdo Wii
    if(preg_match('/Nintendo Wii/si', $user_agent) && !$client_data['system'])
      {
      $client_data['system'] = "Nintendo Wii";
      $client_data['system_icon'] = 'wii';
      }

    // Try to detect some mobile devices...

    // Nokia
    if(preg_match('/Nokia[ ]{0,1}([0-9a-zA-Z\+\-\.]+){0,1}.*/s', $user_agent, $tmp_array))
      {
      if(!$client_data['system'])
        {
        $client_data['system'] = "Nokia" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        $client_data['system_icon'] = "mobile";
        }
      else
        {
        $client_data['system'] .= " / Nokia" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        }
      }

    // Motorola
    if(preg_match('/mot\-([0-9a-zA-Z\+\-\.]+){0,1}\//si', $user_agent, $tmp_array))
      {
      if(!$client_data['system'])
        {
        $client_data['system'] = "Motorola" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        $client_data['system_icon'] = "mobile";
        }
      else
        {
        $client_data['system'] .= " / Motorola" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        }
      }

    // Siemens
    if(preg_match('/sie\-([0-9a-zA-Z\+\-\.]+){0,1}\//si', $user_agent, $tmp_array))
      {
      if(!$client_data['system'])
        {
        $client_data['system'] = "Siemens" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        $client_data['system_icon'] = "mobile";
        }
      else
        {
        $client_data['system'] .= " / Siemens" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        }
      }

    // Samsung
    if(preg_match('/samsung\-([0-9a-zA-Z\+\-\.]+){0,1}\//si', $user_agent, $tmp_array))
      {
      if(!$client_data['system'])
        {
        $client_data['system'] = "Samsung" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        $client_data['system_icon'] = "mobile";
        }
      else
        {
        $client_data['system'] .= " / Samsung" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        }
      }
    
    // SonyEricsson & Ericsson
    if(preg_match('/SonyEricsson[ ]{0,1}([0-9a-zA-Z\+\-\.]+){0,1}.*/s', $user_agent, $tmp_array))
      {
      if(!$client_data['system'])
        {
        $client_data['system'] = "Sony Ericsson" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        $client_data['system_icon'] = "mobile";
        }
      else
        {
        $client_data['system'] .= " / Sony Ericsson" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        }
      }
    elseif(preg_match('/Ericsson[ ]{0,1}([0-9a-zA-Z\+\-\.]+){0,1}.*/s', $user_agent, $tmp_array))
      {
      if(!$client_data['system'])
        {
        $client_data['system'] = "Ericsson" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        $client_data['system_icon'] = "mobile";
        }
      else
        {
        $client_data['system'] .= " / Ericsson" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        }
      }

    // Alcatel
    if(preg_match('/Alcatel\-([0-9a-zA-Z\+\-\.]+){0,1}.*/s', $user_agent, $tmp_array))
      {
      if(!$client_data['system'])
        {
        $client_data['system'] = "Alcatel" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        $client_data['system_icon'] = "mobile";
        }
      else
        {
        $client_data['system'] .= " / Alcatel" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        }
      }

    // Panasonic
    if(preg_match('/Panasonic\-{0,1}([0-9a-zA-Z\+\-\.]+){0,1}.*/s', $user_agent, $tmp_array))
      {
      if(!$client_data['system'])
        {
        $client_data['system'] = "Panasonic" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        $client_data['system_icon'] = "mobile";
        }
      else
        {
        $client_data['system'] .= " / Panasonic" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        }
      }

    // Philips
    if(preg_match('/Philips\-([0-9a-z\+\-\@\.]+){0,1}.*/si', $user_agent, $tmp_array))
      {
      if(!$client_data['system'])
        {
        $client_data['system'] = "Philips" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        $client_data['system_icon'] = "mobile";
        }
      else
        {
        $client_data['system'] .= " / Philips" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        }
      }

    // Acer
    if(preg_match('/Acer\-([0-9a-z\+\-\.]+){0,1}.*/si', $user_agent, $tmp_array))
      {
      if(!$client_data['system'])
        {
        $client_data['system'] = "Acer" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        $client_data['system_icon'] = "mobile";
        }
      else
        {
        $client_data['system'] .= " / Acer" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        }
      }

    // BlackBerry
    if(preg_match('/BlackBerry([0-9a-zA-Z\+\-\.]+){0,1}\//s', $user_agent, $tmp_array))
      {
      if(!$client_data['system'])
        {
        $client_data['system'] = "BlackBerry" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        $client_data['system_icon'] = "mobile";
        }
      else
        {
        $client_data['system'] .= " / BlackBerry" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        }
      }

    // Windows 3.x, 95, 98 and other numerical
    if(preg_match('/windows ([0-9\.]+).*/si', $user_agent, $tmp_array) && !$client_data['system'])
      {
      $client_data['system'] = "Windows" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
      $client_data['system_icon'] = "win_old";
      }

    if(preg_match('/[ \(]win([0-9\.]+).*/si', $user_agent, $tmp_array) && !$client_data['system'])
      {
      if($tmp_array[1] == "16")
        {
        $client_data['system'] = "Windows 3.x";
        $client_data['system_icon'] = "win_old";
        }
      elseif($tmp_array[1] == "32")
        {
        $client_data['system'] = "Windows";
        $client_data['system_icon'] = "win_old";
        }
      else
        {
        $client_data['system'] = "Windows" . ($tmp_array[1] ? " " . $tmp_array[1] : "");
        $client_data['system_icon'] = "win_old";
        }
      }

    // Windows ME
    if(preg_match('/windows me/si', $user_agent, $tmp_array) || preg_match('/win 9x 4\.90/si', $user_agent, $tmp_array) && !$client_data['system'])
      {
      $client_data['system'] = "Windows Millenium";
      $client_data['system_icon'] = "win_old";
      }

    // Windows CE
    if(preg_match('/windows ce/si', $user_agent, $tmp_array) && !$client_data['system'])
      {
      $client_data['system'] = "Windows CE";
      $client_data['system_icon'] = "win_old";
      }

    // Windows XP
    if(preg_match('/windows xp/si', $user_agent, $tmp_array) && !$client_data['system'])
      {
      $client_data['system'] = "Windows XP";
      $client_data['system_icon'] = "win_new";
      }

    // Windows NT, no version, to be sure it will catch
    if(preg_match('/windows nt/si', $user_agent, $tmp_array) || preg_match('/winnt/si', $user_agent, $tmp_array) && !$client_data['system'])
      {
      $client_data['system'] = "Windows NT";
      $client_data['system_icon'] = "win_old";
      }

    // Windows NT with version
    if(preg_match('/windows nt ([0-9\.]+).*/si', $user_agent, $tmp_array) || preg_match('/winnt([0-9\.]+).*/si', $user_agent, $tmp_array) && !$client_data['system'])
      {
      if($tmp_array[1] == "6.0")
        {
        $client_data['system'] = "Windows Vista";
        $client_data['system_icon'] = "win_new";
        }
      elseif($tmp_array[1] == "5.2")
        {
        $client_data['system'] = "Windows Server 2003";
        $client_data['system_icon'] = "win_new";
        }
      elseif($tmp_array[1] == "5.1")
        {
        $client_data['system'] = "Windows XP";
        $client_data['system_icon'] = "win_new";
        }
      elseif($tmp_array[1] == "5.0" || $tmp_array[1] == "5.01")
        {
        $client_data['system'] = "Windows 2000";
        $client_data['system_icon'] = "win_old";
        }
      else
        {
        $client_data['system'] = "Windows NT" . ($tmp_array[1] ? " ".$tmp_array[1] : "");
        $client_data['system_icon'] = "win_old";
        }
      }

    // Catchall for all other windozez
    if(preg_match('/windows/si', $user_agent, $tmp_array) && !$client_data['system'])
      {
      $client_data['system'] = "Windows";
      $client_data['system_icon'] = "win_old";
      }

    return $client_data;
}
}
?>
Return current item: Client info