diff options
author | Christian Pointner <equinox@spreadspace.org> | 2012-10-22 01:45:14 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2012-10-22 01:45:14 +0200 |
commit | e4b6f1889e057ea210bc0578e3e8c0792ef5b277 (patch) | |
tree | f39c3fc22007c0ff0fed41384b304efd779f7d52 /contrib/www/2012/browser.php | |
parent | fixed install script for hls (diff) |
added sample www scripts
Diffstat (limited to 'contrib/www/2012/browser.php')
-rw-r--r-- | contrib/www/2012/browser.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/contrib/www/2012/browser.php b/contrib/www/2012/browser.php new file mode 100644 index 0000000..5df08dc --- /dev/null +++ b/contrib/www/2012/browser.php @@ -0,0 +1,45 @@ +<?php +$browser = array( + 'platform' => 'unknown', + 'name' => 'unknown', + 'version' => '0.0.0', + 'majorver' => 0, + 'minorver' => 0, + 'build' => 0, + 'useragent' => '' +); + +$browsers = array( + 'firefox', 'msie', 'opera', 'chrome', 'safari', 'mozilla', 'seamonkey', 'konqueror', 'netscape', + 'gecko', 'navigator', 'mosaic', 'lynx', 'amaya', 'omniweb', 'avant', 'camino', 'flock', 'aol' +); + +if (isset($_SERVER['HTTP_USER_AGENT'])) { + $browser['useragent'] = $_SERVER['HTTP_USER_AGENT']; + $user_agent = strtolower($browser['useragent']); + foreach($browsers as $_browser) { + if (preg_match("/($_browser)[\/ ]?([0-9.]*)/", $user_agent, $match)) { + $browser['name'] = $match[1]; + $browser['version'] = $match[2]; + @list($browser['majorver'], $browser['minorver'], $browser['build']) = explode('.', $browser['version']); + break; + } + } + if (preg_match('/linux/i', $user_agent)) { + $browser['platform'] = 'linux'; + } + elseif (preg_match('/macintosh|mac os x/i', $user_agent)) { + $browser['platform'] = 'mac'; + } + elseif (preg_match('/windows|win32/i', $user_agent)) { + $browser['platform'] = 'windows'; + } + +} + +if ( isset($_GET['debug']) ) { + echo "<pre>"; + print_r($browser); + echo "</pre>"; +} +?> |