PHP Classes

PHP Browser OS Detection and Age Guessing: Estimate the age of the browser and OS it runs on

Recommend this page to a friend!
  Info   View files Documentation   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 308 All time: 7,327 This week: 68Up
Version License PHP version Categories
software-age-gauge 1.0.36Custom (specified...5HTTP, PHP 5, Parsers
Description 

Author

This class can estimate the age of the browser and OS it runs on.

It can check the name of the current browser accessing a site and parses it to determines the browser type, version number and operating system type.

The class can look up a list of known browsers and operating systems make educated guess of the browser age based on the version number.

Innovation Award
PHP Programming Innovation award winner
April 2018
Winner
Some sites require that the users use a more recent browser that is not older than a certain age and works on certain operation systems that are well supported.

This package can guess check the identification of a user browser sent via HTTP requests and detect what is the age of the version of the browser that is being used, as well the operation system that it is running.

Manuel Lemos
Picture of Peter Kahl
  Performance   Level  
Name: Peter Kahl <contact>
Classes: 37 packages by
Country: United Kingdom
Age: ???
All time rank: 41721 in United Kingdom
Week rank: 91 Up3 in United Kingdom Up
Innovation award
Innovation award
Nominee: 23x

Winner: 2x

Documentation

Version To Age (Software Age Gauge)

Downloads License If this project has business value for you then don't hesitate to support me with a small donation.

Estimates age of browser and OS software. The script stores an associative array of software names and version and timestamp pairs. It periodically connects to external servers to fetch the latest information on Firefox and Chrome browsers.

image

Limitations

This script knows only that which is stored in its data array.

Browsers: * chrome * crios * edge * explorer * firefox * fios * lunascape * maxthon * safari * mobile safari * netsurf * opera * samsungbrowser * seamonkey

Operating Systems: * android * ios * macos * windows

Usage

use peterkahl\Version2age\Version2age;

$v2a = new Version2age;

# Location of CA certificate file
# You may download and install on your server this Mozilla CA bundle
# from this page: <https://curl.haxx.se/docs/caextract.html>
$v2a->CAbundle = '/srv/certs/ca-bundle.pem';

# Location of your cache directory
$v2a->CacheDir = '/srv/cache';

# Perhaps you have user agent string like this
# $user_agent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) CriOS/65.0.3325.152 Mobile/15E5216a Safari/604.1';
# I have used this parser at <https://github.com/peterkahl/user-agent-parser>
# to parse the above string down to
$os_name = 'iOS'; # case insensitive
$os_vers = '11.3';

$age = $v2a->GetAge($os_name, $os_vers);
$age = $age/31536000; # years

if (is_string($age) && $age == 'UNKNOWN') {
  echo 'I\'m sorry. I don\'t know this software.'
}
elseif ($age >= 1) {
  echo 'Your software is 1 year old or older.';
}

Crontab Job to keep up-to-date

Run the script below every 6 hours. This forces connection to external servers in order to fetch the most up-to-date data on Firefox and Chrome browsers.

use peterkahl\Version2age\Version2age;

# Location of CA certificate file
# You may download and install on your server this Mozilla CA bundle
# from this page: <https://curl.haxx.se/docs/caextract.html>
$v2a->CAbundle = '/srv/certs/ca-bundle.pem';

# Location of your cache directory
$v2a->CacheDir = '/srv/cache';

$v2a->Initialise(true);


  Files folder image Files  
File Role Description
Files folder imagesrc (2 files)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Image file screen-shot.png Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Accessible without login Plain text file data.json Data Auxiliary data
  Plain text file Version2age.php Class Class source

Downloadsoftware-age-gauge-2020-06-02.zip 486KB
Downloadsoftware-age-gauge-2020-06-02.tar.gz 487KB
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
curl Master Download .zip .tar.gz Make HTTP connection Required
 Version Control Unique User Downloads Download Rankings  
 100%
Total:308
This week:0
All time:7,327
This week:68Up