File modules/util/Browser.class.php

Last commit: Sat Feb 22 23:58:02 2020 +0100	Jan Dankert	Refactoring: Namespacing for module 'util'.
1 <?php 2 3 namespace util; 4 /** 5 * Very simple approach to identify a browsers name and platform. 6 */ 7 class Browser 8 { 9 10 public $name; 11 public $platform; 12 13 14 /** 15 * Takes the user agent from the HTTP request and analyzes name and platform. 16 */ 17 public function __construct() 18 { 19 $agent = @$_SERVER['HTTP_USER_AGENT']; 20 21 22 if (stripos($agent, 'Opera') || stripos($agent, 'OPR/')) 23 $this->name = 'Opera'; 24 elseif (stripos($agent, 'Edge')) 25 $this->name = 'Microsoft Edge'; 26 elseif (stripos($agent, 'vivaldi')) 27 $this->name = 'Vivaldi'; 28 elseif (stripos($agent, 'netscape')) 29 $this->name = 'Netscape'; 30 elseif (stripos($agent, 'Chrome')) 31 $this->name = 'Google Chrome'; 32 elseif (stripos($agent, 'Safari')) 33 $this->name = 'Safari'; 34 elseif (stripos($agent, 'Firefox')) 35 $this->name = 'Mozilla Firefox'; 36 elseif (stripos($agent, 'MSIE') || stripos($agent, 'Trident/7')) 37 $this->name = 'Internet Explorer'; 38 else 39 $this->name = 'Unknown Browser'; 40 41 if (stripos($agent, 'Linux') || stripos($agent, 'linux')) 42 $this->platform = 'Linux'; 43 elseif (stripos($agent, 'Windows') || stripos($agent, 'win32')) 44 $this->platform = 'Windows'; 45 elseif (stripos($agent, 'android')) 46 $this->platform = 'Android'; 47 elseif (stripos($agent, 'mac os') || stripos($agent, 'cpu os') || stripos($agent, 'iPhone') || stripos($agent, 'OS X')) 48 $this->platform = 'Android'; 49 elseif (stripos($agent, 'cros')) 50 $this->platform = 'Chrome OS'; 51 elseif (stripos($agent, 'SymbOS')) 52 $this->platform = 'Symbian OS'; 53 elseif (stripos($agent, 'windows phone')) 54 $this->platform = 'Microsoft Windows Phone '; 55 elseif (stripos($agent, 'nokia')) 56 $this->platform = 'Nokia'; 57 elseif (stripos($agent, 'blackberry')) 58 $this->platform = 'Blackberry'; 59 elseif (stripos($agent, 'openbsd')) 60 $this->platform = 'OpenBSD'; 61 elseif (stripos($agent, 'freebsd')) 62 $this->platform = 'FreeBSD'; 63 else 64 $this->name = 'Unknown OS'; 65 66 } 67 }
Download modules/util/Browser.class.php
History Sat, 22 Feb 2020 23:58:02 +0100 Jan Dankert Refactoring: Namespacing for module 'util'. Thu, 23 Jan 2020 00:50:55 +0100 Jan Dankert Refactoring: Switching to PHPs newer SimpleXML-extension (pre-work for using XML namespaces) Fri, 23 Aug 2019 00:56:00 +0200 Jan Dankert Refactoring: Authentication-Token nicht aus Benutzerdaten ermitteln (unsicher), sondern SHA1-Hash in neuer Tabelle speichern. Jedes Gerät erhält seinen eigenen Token, damit diese später einzeln löschbar sind.