phpSniff
[ class tree: phpSniff ] [ index: phpSniff ] [ all elements ]

Class: phpSniff

Source Location: /modules/Sniffer/pnincludes/phpSniff.class.php

Class Overview


PHP Sniffer Class


Author(s):

Variables

Methods



Class Details

[line 37]
PHP Sniffer Class

Used to determine the browser and other associated properies using nothing other than the HTTP_USER_AGENT value supplied by a user's web browser.




Tags:

author:  Roger Raymond <epsilon7@users.sourceforge.net>
access:  public


[ Top ]


Class Variables

$_allow_masquerading =  NULL

[line 85]

default : null Allow for browser to Masquerade as another. (ie: Opera identifies as MSIE 5.0)



Tags:

access:  public

Type:   string


[ Top ]

$_browsers = array(
        'microsoft internet explorer' => 'IE',
        'msie'                        => 'IE',
        'netscape6'                   => 'NS',
        'netscape'                    => 'NS',
        'galeon'                      => 'GA',
        'phoenix'                     => 'PX',
        'mozilla firebird'            => 'FB',
        'firebird'                    => 'FB',
        'firefox'                     => 'FX',
        'chimera'                     => 'CH',
        'camino'                      => 'CA',
        'epiphany'                    => 'EP',
        'safari'                      => 'SF',
        'k-meleon'                    => 'KM',
        'mozilla'                     => 'MZ',
        'opera'                       => 'OP',
        'konqueror'                   => 'KQ',
        'icab'                        => 'IC',
        'lynx'                        => 'LX',
        'links'                       => 'LI',
        'ncsa mosaic'                 => 'MO',
        'amaya'                       => 'AM',
        'omniweb'                     => 'OW',
        'hotjava'                      => 'HJ',
        'browsex'                     => 'BX',
        'amigavoyager'                => 'AV',
        'amiga-aweb'                  => 'AW',
        'ibrowse'                     => 'IB'
        )

[line 104]

2D Array of browsers we wish to search for in key => value pairs.

  key   = browser to search for [as in HTTP_USER_AGENT]
  value = value to return as 'browser' property




Tags:

access:  public

Type:   array


[ Top ]

$_browser_features = array(
        /**
         *    the following are true by default
         *    (see phpSniff.core.php $_feature_set array)
         *    browsers listed here will be set to false
         **/
        'html'        =>    '',
        'images'    =>    'LI,LX',
        'frames'     =>    'LX',
        'tables'    =>    '',
        'java'        =>    'OP3,LI,LX,NS1,MO,IE1,IE2',
        'plugins'    =>    'IE1,IE2,LI,LX',
        /**
         *    the following are false by default
         *    (see phpSniff.core.php $_feature_set array)
         *    browsers listed here will be set to true
         **/
        'css2'        =>    'NS5+,IE5+,MZ,PX,FB,FX,CH,CA,SF,GA,KQ3+,OP7+,KM,EP',
        'css1'        =>    'NS4+,IE4+,MZ,PX,FB,FX,CH,CA,SF,GA,KQ,OP7+,KM,EP',
        'iframes'    =>    'LI,IE3+,NS5+,MZ,PX,FB,FX,CH,CA,SF,GA,KQ,OP7+,KM,EP',
        'xml'        =>    'IE5+,NS5+,MZ,PX,FB,FX,CH,CA,SF,GA,KQ,OP7+,KM,EP',
        'dom'        =>    'IE5+,NS5+,MZ,PX,FB,FX,CH,CA,SF,GA,KQ,OP7+,KM,EP',
        'hdml'        =>    '',
        'wml'        =>    ''
        )

[line 169]

$_browser_features desc : 2D Array of browser features supported by which browser : in key => value pairs.

: key = feature : value = search parameter for browsers that support the : feature listed in the key (comma delimited) : note: the search parameters rely on the values : set in the $_browsers array




Tags:

access:  public

Type:   string


[ Top ]

$_browser_quirks = array(
        'must_cache_forms'            =>    'NS,MZ,FB,PX,FX',
        'avoid_popup_windows'        =>    'IE3,LI,LX',
        'cache_ssl_downloads'        =>    'IE',
        'break_disposition_header'    =>    'IE5.5',
        'empty_file_input_value'    =>    'KQ',
        'scrollbar_in_way'            =>    'IE6'
        )

[line 208]

$_browser_quirks desc : 2D Array of browser quirks present in which browser : in key => value pairs.

: key = quirk : value = search parameter for browsers that feature the : quirk listed in the key (comma delimited) : note: the search parameters rely on the values : set in the $_browsers array




Tags:

access:  public

Type:   string


[ Top ]

$_check_cookies =  NULL

[line 67]

$_check_cookies

default : null desc : Allow for the script to redirect the browser in order : to check for cookies. In order for this to work, this : class must be instantiated before any headers are sent.




Tags:

access:  public

Type:   string


[ Top ]

$_default_language =  'en-us'

[line 76]

$_default_language

default : en-us desc : language to report as if no languages are found




Tags:

access:  public

Type:   string


[ Top ]

$_javascript_versions = array(
        '1.5'   =>  'NS5+,MZ,PX,FB,FX,GA,CH,CA,SF,KQ3+,KM,EP', // browsers that support JavaScript 1.5
        '1.4'   =>  '',
        '1.3'   =>  'NS4.05+,OP5+,IE5+',
        '1.2'   =>  'NS4+,IE4+',
        '1.1'   =>  'NS3+,OP,KQ',
        '1.0'   =>  'NS2+,IE3+',
        '0'     =>    'LI,LX,HJ'
        )

[line 147]

$_javascript_versions desc : 2D Array of javascript version supported by which browser : in key => value pairs.

: key = javascript version : value = search parameter for browsers that support the : javascript version listed in the key (comma delimited) : note: the search parameters rely on the values : set in the $_browsers array




Tags:

access:  public

Type:   array


[ Top ]

$_temp_file_path =  '/tmp/'

[line 55]

$_temp_file_path default : /tmp/ desc : directory writable by the server to store cookie check files.

: trailing slash is needed. only used if you use the check cookie routine




Tags:

access:  public

Type:   string


[ Top ]



Class Methods


constructor phpSniff [line 304]

object phpSniff phpSniff( [string $UA = ''], [mixed $settings = true])

Performs some basic initialization and returns and object



Tags:

return:  object


Parameters:

string   $UA   User Agent to parse
mixed   $settings   array of settings [check_cookies, default_language, allow_masqeurading]

[ Top ]

method allow_masquerading [line 374]

void allow_masquerading( bool $yn)

allow browser masquerading



Parameters:

bool   $yn   true or false

[ Top ]

method browser_is [line 435]

bool browser_is( string $s)

browser_is



Tags:

return:  true on success ex: $client->browser_is('OP5Up');


Parameters:

string   $s   search phrase for browser

[ Top ]

method check_cookies [line 365]

void check_cookies( bool $yn)

turn the cookie check routine on or off



Parameters:

bool   $yn   true or false

[ Top ]

method default_language [line 383]

void default_language( string $language)

set the default browser language



Parameters:

string   $language   valid language (ex: en-us)

[ Top ]

method get_property [line 407]

mixed get_property( string $p)

get_property is an alias for property



Tags:

return:  array/string entire array or value of property


Parameters:

string   $p   property to return . optional (null returns entire array)

[ Top ]

method has_feature [line 472]

bool has_feature( string $s)

checks to see if the browser supports any of the following features:

  • html
  • images
  • frames
  • tables
  • plugins
  • iframes
  • css2
  • css1
  • xml
  • dom
  • wml
  • hdml
  1. ex$client->has_feature('html');




Tags:

return:  true on success


Parameters:

string   $s   feature we're checking on

[ Top ]

method has_quirk [line 490]

bool has_quirk( string $s)

checks to see if the browser has any of the following quirks:

  • must_cache_forms
  • avoid_popup_windows
  • cache_ssl_downloads
  • break_disposition_header
  • empty_file_input_value
  • scrollbar_in_way
  1. ex$client->has_quirk('avoid_popup_windows');




Tags:

return:  true on success


Parameters:

string   $s   quirk we're looking for

[ Top ]

method init [line 338]

void init( )



[ Top ]

method is [line 417]

bool is( string $s)

is



Tags:

return:  true on success ex: $client->is('b:OP5Up');


Parameters:

string   $s   search phrase format = l:lang;b:browser

[ Top ]

method language_is [line 446]

bool language_is( string $s)

language_is



Tags:

return:  true on success ex: $client->language_is('en-US');


Parameters:

string   $s   search phrase for language

[ Top ]

method property [line 393]

mixed property( [string $p = null])

property



Tags:

return:  array/string entire array or value of property


Parameters:

string   $p   property to return . optional (null returns entire array)

[ Top ]


Documentation generated on Fri, 18 Jul 2008 21:48:23 +0200 by phpDocumentor 1.4.1