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

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