Constants

VERSION

VERSION

Current version of the class.

UPDATE_FOPEN

UPDATE_FOPEN

Different ways to access remote and local files.

UPDATE_FOPEN: Uses the fopen url wrapper (use file_get_contents). UPDATE_FSOCKOPEN: Uses the socket functions (fsockopen). UPDATE_CURL: Uses the cURL extension. UPDATE_LOCAL: Updates from a local file (file_get_contents).

UPDATE_FSOCKOPEN

UPDATE_FSOCKOPEN

UPDATE_CURL

UPDATE_CURL

UPDATE_LOCAL

UPDATE_LOCAL

REGEX_DELIMITER

REGEX_DELIMITER

Options for regex patterns.

REGEX_DELIMITER: Delimiter of all the regex patterns in the whole class. REGEX_MODIFIERS: Regex modifiers.

REGEX_MODIFIERS

REGEX_MODIFIERS

VALUES_TO_QUOTE

VALUES_TO_QUOTE

The values to quote in the ini file

ORDER_FUNC_ARGS

ORDER_FUNC_ARGS

Definitions of the function used by the uasort() function to order the userAgents array.

ORDER_FUNC_ARGS: Arguments that the function will take. ORDER_FUNC_LOGIC: Internal logic of the function.

ORDER_FUNC_LOGIC

ORDER_FUNC_LOGIC

REQUEST_HEADERS

REQUEST_HEADERS

The headers to be sent for checking the version and requesting the file.

Properties

$remoteIniUrl

$remoteIniUrl : 

Options for auto update capabilities

$remoteVerUrl: The location to use to check out if a new version of the

               browscap.ini file is available.

$remoteIniUrl: The location from which download the ini file.

               The placeholder for the file should be represented by a %s.

$timeout: The timeout for the requests. $updateInterval: The update interval in seconds. $errorInterval: The next update interval in seconds in case of an error. $doAutoUpdate: Flag to disable the automatic interval based update. $updateMethod: The method to use to update the file, has to be a value of

               an UPDATE_* constant, null or false.

Type

$remoteVerUrl

$remoteVerUrl : 

Type

$timeout

$timeout : 

Type

$updateInterval

$updateInterval : 

Type

$errorInterval

$errorInterval : 

Type

$doAutoUpdate

$doAutoUpdate : 

Type

$updateMethod

$updateMethod : 

Type

$localFile

$localFile : string

The path of the local version of the browscap.ini file from which to update (to be set only if used).

Type

string

$userAgent

$userAgent : string

The useragent to include in the requests made by the class during the update process.

Type

string

$lowercase

$lowercase : boolean

Flag to enable only lowercase indexes in the result.

The cache has to be rebuilt in order to apply this option.

Type

boolean

$cacheFilename

$cacheFilename : string

Where to store the cached PHP arrays.

Type

string

$iniFilename

$iniFilename : string

Where to store the downloaded ini file.

Type

string

$cacheDir

$cacheDir : string

Path to the cache directory

Type

string

$_cacheLoaded

$_cacheLoaded : boolean

Flag to be set to true after loading the cache

Type

boolean

$_userAgents

$_userAgents : array

Where to store the value of the included PHP cache file

Type

array

$_browsers

$_browsers : 

Type

$_patterns

$_patterns : 

Type

$_properties

$_properties : 

Type

Methods

__construct()

__construct(string  $cache_dir, boolean  $setTimeZone = true) : \Fuman_Util_Browscap

Constructor class, checks for the existence of (and loads) the cache and if needed updated the definitions

Parameters

string $cache_dir
boolean $setTimeZone

Throws

\Exception

Returns

\Fuman_Util_Browscap

getBrowser()

getBrowser(string|null  $user_agent = null, boolean  $return_array = false) : \stdClass

Gets the information about the browser by User Agent

Parameters

string|null $user_agent

the user agent string

boolean $return_array

whether return an array or an object

Throws

\Exception

Returns

\stdClass —

the object containing the browsers details. Array if

                $return_array is set to true.

updateCache()

updateCache(boolean  $forceDownload = true) : boolean

Parses the ini file and updates the cache files

Parameters

boolean $forceDownload

Returns

boolean —

whether the file was correctly written to the disk

catchError()

catchError(object|null  $a = null, object|null  $b = null, object|null  $c = null, object|null  $d = null) : void

Catches any errors while parsing ini

Parameters

object|null $a
object|null $b
object|null $c
object|null $d

_loadCache()

_loadCache(string  $cache_file) : void

Loads the cache into object's properties

Parameters

string $cache_file

_buildCache()

_buildCache() : string

Parses the array to cache and creates the PHP string to write to disk

Returns

string —

the PHP string to save into the cache file

_updateIniFile()

_updateIniFile(string  $url, string  $localIniPath) : boolean

Updates the local copy of the ini file (by version checking) and adapts his syntax to the PHP ini parser

Parameters

string $url

the url of the remote server

string $localIniPath

the path of the ini file to update

Throws

\Exception

Returns

boolean —

if the ini file was updated

_getRemoteMTime()

_getRemoteMTime() : integer

Gets the remote ini file update timestamp

Throws

\Exception

Returns

integer —

the remote modification timestamp

_getLocalMTime()

_getLocalMTime() : integer

Gets the local ini file update timestamp

Throws

\Exception

Returns

integer —

the local modification timestamp

_getUpdateMethod()

_getUpdateMethod() : string

Checks for the various possibilities offered by the current configuration of PHP to retrieve external HTTP data

Returns

string —

the name of function to use to retrieve the file

_getRemoteData()

_getRemoteData(string  $url) : string

Retrieve the data identified by the URL

Parameters

string $url

the url of the data

Throws

\Exception

Returns

string —

the retrieved data

_getUserAgent()

_getUserAgent() : string

Format the useragent string to be used in the remote requests made by the class during the update process.

Returns

string —

the formatted user agent

_touch()

_touch(string  $path, integer|null  $time = null) 

Touches file

Parameters

string $path
integer|null $time