BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

useragent.class.php 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. #declare(strict_types=1);
  3. class UserAgent
  4. {
  5. private static $Browsers = array(
  6. // Less popular
  7. 'Shiira' => 'Shiira',
  8. 'Songbird' => 'Songbird',
  9. 'SeaMonkey' => 'SeaMonkey',
  10. 'OmniWeb' => 'OmniWeb',
  11. 'Camino' => 'Camino',
  12. 'Chimera' => 'Chimera',
  13. 'Epiphany' => 'Epiphany',
  14. 'Konqueror' => 'Konqueror',
  15. 'Iceweasel' => 'Iceweasel',
  16. 'Lynx' => 'Lynx',
  17. 'Links' => 'Links',
  18. 'libcurl' => 'cURL',
  19. 'midori' => 'Midori',
  20. 'Blackberry' => 'BlackBerry Browser',
  21. // Big names
  22. 'Firefox' => 'Firefox',
  23. 'OPR' => 'Opera Blink', # Opera 15+ (the version running Blink)
  24. 'Opera' => 'Opera',
  25. 'Chrome' => 'Chrome',
  26. 'Safari' => 'Safari',
  27. // Put Chrome Frame above IE
  28. 'chromeframe' => 'Chrome Frame',
  29. 'x-clock' => 'Chrome Frame',
  30. 'MSIE' => 'Internet Explorer',
  31. 'Trident' => 'Internet Explorer',
  32. // Firefox versions
  33. 'Shiretoko' => 'Firefox (Experimental)',
  34. 'Minefield' => 'Firefox (Experimental)',
  35. 'GranParadiso' => 'Firefox (Experimental)',
  36. 'Namoroka' => 'Firefox (Experimental)',
  37. 'AppleWebKit' => 'WebKit',
  38. 'Mozilla' => 'Mozilla'
  39. // Weird shit
  40. /*
  41. 'WWW-Mechanize' => 'Perl',
  42. 'Wget' => 'Wget',
  43. 'BTWebClient' => 'µTorrent',
  44. 'Transmission' => 'Transmission',
  45. 'Java' => 'Java',
  46. 'RSS' => 'RSS Downloader'
  47. */
  48. );
  49. private static $OperatingSystems = array(
  50. // Mobile
  51. 'SymbianOS' => 'Symbian',
  52. 'blackberry' => 'BlackBerry',
  53. 'iphone' => 'iPhone',
  54. 'ipod' => 'iPhone',
  55. 'android' => 'Android',
  56. 'palm' => 'Palm',
  57. 'mot-razr' => 'Motorola Razr',
  58. //'tablet PC' => 'Windows RT',
  59. //'ARM; Trident' => 'Windows RT',
  60. // Windows
  61. 'Windows NT 10.0' => 'Windows 10',
  62. 'Windows NT 6.4' => 'Windows 10',
  63. 'Windows NT 6.3' => 'Windows 8.1',
  64. 'Windows 8.1' => 'Windows 8.1',
  65. 'Windows NT 6.2' => 'Windows 8',
  66. 'Windows 8' => 'Windows 8',
  67. 'Windows NT 6.1' => 'Windows 7',
  68. 'Windows 7' => 'Windows 7',
  69. 'Windows NT 6.0' => 'Windows Vista',
  70. 'Windows Vista' => 'Windows Vista',
  71. 'windows nt 5.2' => 'Windows 2003',
  72. 'windows 2003' => 'Windows 2003',
  73. 'windows nt 5.0' => 'Windows 2000',
  74. 'windows 2000' => 'Windows 2000',
  75. 'windows nt 5.1' => 'Windows XP',
  76. 'windows xp' => 'Windows XP',
  77. 'Win 9x 4.90' => 'Windows ME',
  78. 'Windows Me' => 'Windows ME',
  79. 'windows nt' => 'Windows NT',
  80. 'winnt' => 'Windows NT',
  81. 'windows 98' => 'Windows 98',
  82. 'windows ce' => 'Windows CE',
  83. 'win98' => 'Windows 98',
  84. 'windows 95' => 'Windows 95',
  85. 'windows 95' => 'Windows 95',
  86. 'win95' => 'Windows 95',
  87. 'win16' => 'Windows 3.1',
  88. //'windows' => 'Windows',
  89. 'cros' => 'Chrome OS',
  90. // OS X
  91. 'os x' => 'Mac OS X',
  92. 'macintosh' => 'Mac OS X',
  93. 'darwin' => 'Mac OS X',
  94. // Less popular
  95. 'ubuntu' => 'Ubuntu',
  96. 'debian' => 'Debian',
  97. 'fedora' => 'Fedora',
  98. 'freebsd' => 'FreeBSD',
  99. 'openbsd' => 'OpenBSD',
  100. 'bsd' => 'BSD',
  101. 'x11' => 'Linux',
  102. 'gnu' => 'Linux',
  103. 'linux' => 'Linux',
  104. 'unix' => 'Unix',
  105. 'Sun OS' => 'Sun',
  106. 'Sun' => 'Sun',
  107. // Weird shit
  108. /*
  109. 'WWW-Mechanize' => 'Perl',
  110. 'Wget' => 'Wget',
  111. 'BTWebClient' => 'µTorrent',
  112. 'Transmission' => 'Transmission',
  113. 'Java' => 'Java',
  114. 'RSS' => 'RSS Downloader',
  115. */
  116. // Catch-all
  117. 'win' => 'Windows',
  118. 'mac' => 'Mac OS X'
  119. );
  120. public static function operating_system(&$UserAgentString)
  121. {
  122. if (empty($UserAgentString)) {
  123. return 'Hidden';
  124. }
  125. foreach (self::$OperatingSystems as $String => $OperatingSystem) {
  126. if (stripos($UserAgentString, $String) !== false) {
  127. return $OperatingSystem;
  128. }
  129. }
  130. return 'Unknown';
  131. }
  132. public static function mobile(&$UserAgentString)
  133. {
  134. if (strpos($UserAgentString, 'iPad') !== false) {
  135. return false;
  136. }
  137. // "Mobi" catches "Mobile" too
  138. if (strpos($UserAgentString, 'Device') || strpos($UserAgentString, 'Mobi') || strpos($UserAgentString, 'Mini') || strpos($UserAgentString, 'webOS')) {
  139. return true;
  140. }
  141. return false;
  142. }
  143. public static function browser(&$UserAgentString)
  144. {
  145. if (empty($UserAgentString)) {
  146. return 'Hidden';
  147. }
  148. $Return = 'Unknown';
  149. foreach (self::$Browsers as $String => $Browser) {
  150. if (strpos($UserAgentString, $String) !== false) {
  151. $Return = $Browser;
  152. break;
  153. }
  154. }
  155. if (self::mobile($UserAgentString)) {
  156. $Return .= ' Mobile';
  157. }
  158. return $Return;
  159. }
  160. }