PHP取得客戶端作業系統,瀏覽器,語言,IP,IP歸屬地等

WBOY
發布: 2016-07-25 08:50:18
原創
1355 人瀏覽過
{ return false;
PHP取得客戶端作業系統,瀏覽器,語言,IP,IP歸屬地等
希望能樓下的繼續補充啊 完善這個東東

2013.8.12更新了下更完善了
  1. class Client
  2. {
  3. function CID_windows_detect_os($ua) {
  4. $os_name = $os_f pda_code = $pda_ver = null;
  5. if (preg_match('/Windows 95/i', $ua) || preg_match('/Win95/', $ua)) {
  6. $os_name = " Windows";
  7. $os_code = "windows";
  8. $os_ver = "95";
  9. } elseif (preg_match('/Windows NT 5.0/i', $ua) || preg_match('/ Windows 2000/i', $ua)) {
  10. $os_name = "Windows";
  11. $os_code = "windows";
  12. $os_ver = "2000";
  13. } elseif (preg_match(' / Win 9x 4.90/i', $ua) || preg_match('/Windows ME/i', $ua)) {
  14. $os_name = "Windows";
  15. $os_code = "windows";
  16. $os_ver = "ME";
  17. } elseif (preg_match('/Windows.98/i', $ua) || preg_match('/Win98/i', $ua)) {
  18. $os_name = " Windows";
  19. $os_code = "windows";
  20. $os_ver = "98";
  21. } elseif (preg_match('/Windows NT 6.0/i', $ua)) {
  22. $ os_name = "Windows";
  23. $os_code = "windows_vista";
  24. $os_ver = "Vista";
  25. } elseif (preg_match('/Windows NT 6.1/i', $ua)) {
  26. $os_name = "Windows";
  27. $os_code = "windows_win7";
  28. $os_ver = "7";
  29. } elseif (preg_match('/Windows NT 6.2/i', $ua)) {
  30. $os_name = "Windows";
  31. $os_code = "windows_win8";
  32. $os_ver = "8";
  33. } elseif (preg_match('/Windows NT 5.1/i', $ua) ) {
  34. $os_name = "Windows";
  35. $os_code = "windows";
  36. $os_ver = "XP";
  37. } elseif (preg_match('/Windows NT 5.2/i', $ ua )) {
  38. $os_name = "Windows";
  39. $os_code = "windows";
  40. if (preg_match('/Win64/i', $ua)) {
  41. $os_ver = " XP 64 位元";
  42. } else {
  43. $os_ver = "Server 2003";
  44. }
  45. }
  46. elseif (preg_match('/Mac_PowerPC/i', $ua)) {
  47. $os_name = "Mac OS";
  48. $os_code = "macos";
  49. }elseif (preg_match('/Windows Phone/i', $ua)) {
  50. $matches =explode(' ; ',$ua);
  51. $os_name = $matches[2];
  52. $os_code = "windows_phone7";
  53. } elseif (preg_match('/Windows NT 4.0/i', $ua) | | preg_match('/WinNT4.0/i', $ua)) {
  54. $os_name = "Windows";
  55. $os_code = "windows";
  56. $os_ver = "NT 4.0";
  57. } elseif (preg_match('/Windows NT/i', $ua) || preg_match('/WinNT/i', $ua)) {
  58. $os_name = "Windows";
  59. $os_code = "windows ";
  60. $os_ver = "NT";
  61. } elseif (preg_match('/Windows CE/i', $ua)) {
  62. list($os_name, $os_code, $os_ver, $pda_name, $pda_code, $pda_ver) = self::CID_pda_detect_os($ua);
  63. $os_name = "Windows";
  64. $os_code = "windows";
  65. $os_ver = "CE";
  66. if
  67. if (preg_match('/PPC/i', $ua)) {
  68. $os_name = "Microsoft PocketPC";
  69. $os_code = "windows";
  70. $os_ver = '';
  71. }
  72. if (preg_match('/smartphone/i', $ua)) {
  73. $os_name = "微軟智慧型手機";
  74. $os_code = "windows";
  75. $os_ver = '';
  76. }
  77. } else{
  78. $os_name = '未知Os';
  79. $os_code = '其他';
  80. }
  81. return array($os_name, $os_code, $os_code os_ver , $pda_name, $pda_code, $pda_ver);
  82. }
  83. function CID_unix_detect_os($ua) {
  84. $os_name = $os_ver = $os_code =osfm. ' /Linux/i', $ua)) {
  85. $os_name = "Linux";
  86. $os_code = "linux";
  87. if (preg_match('#Debian#i', $ua)) {
  88. $os_code = "debian";
  89. $os_name = "Debian GNU/Linux";
  90. } elseif (preg_match('#Mandrake#i', $ua)) {
  91. $os_code = " mandrake";
  92. $os_name = "Mandrake Linux";
  93. } elseif (preg_match('#Kindle Fire#i',$ua)) {//for Kindle Fire
  94. $matches =explode(' ; ',$ua);
  95. $os_code = "kindle";
  96. $matches2 =explode(')',$matches[4]);
  97. $os_name = $matches[2].$matches2[ 0];
  98. } elseif (preg_match('#Android#i',$ua)) {//Android
  99. $matches =explode(';',$ua);
  100. $os_code = "android ";
  101. $matches2 = Explode(')',$matches[4]);
  102. $os_name = $matches[2].$matches2[0];
  103. } elseif (preg_match('#SuSE ) ) #i', $ua)) {
  104. $os_code = "suse";
  105. $os_name = "SuSE Linux";
  106. } elseif (preg_match('#Novell#i', $ua) ) {
  107. $os_code = "novell";
  108. $os_name = "Novell Linux";
  109. } elseif (preg_match('#Ubuntu#i', $ua)) {
  110. $os_code = " ubuntu " ;
  111. $os_name = "Ubuntu Linux";
  112. } elseif (preg_match('#Red ?Hat#i', $ua)) {
  113. $os_code = "redhat";
  114. $ os_name =「紅帽Linux」;
  115. }elseif (preg_match('#Gentoo#i', $ua)) {
  116. $os_code = "gentoo";
  117. $os_name = "Gentoo Linux";
  118. } elseif (preg_match('#Fedora#i ) ) ', $ua)) {
  119. $os_code = "fedora";
  120. $os_name = "Fedora Linux";
  121. } elseif (preg_match('#MEPIS#i', $ua)) {
  122. $os_name = "MEPIS Linux";
  123. } elseif (preg_match('#Knoppix#i', $ua)) {
  124. $os_name = "Knoppix Linux";
  125. } elseif (preg_match( ' # Slackware#i', $ua)) {
  126. $os_code = "slackware";
  127. $os_name = "Slackware Linux";
  128. } elseif (preg_match('#Xandros#i', $ua ) ) {
  129. $os_name = "Xandros Linux";
  130. } elseif (preg_match('#Kanotix#i', $ua)) {
  131. $os_name = "Kanotix Linux";
  132. }
  133. } elseif (preg_match('/FreeBSD/i', $ua)) {
  134. $os_name = "FreeBSD";
  135. $os_code = "freebsd";
  136. } elseif (preg_match('/NetSD / i) ', $ua)) {
  137. $os_name = "NetBSD";
  138. $os_code = "netbsd";
  139. } elseif (preg_match('/OpenBSD/i', $ua)) {
  140. $os_name = "OpenBSD";
  141. $os_code = "openbsd";
  142. } elseif (preg_match('/IRIX/i', $ua)) {
  143. $os_name = "SGI IRIX" ;
  144. $os_code = "sgi";
  145. } elseif (preg_match('/SunOS/i', $ua)) {
  146. $os_name = "Solaris";
  147. $os_code = "sun" ;
  148. } elseif (preg_match('#iPod.*.CPU.([a-zA-Z0-9.( _)] )#i', $ua, $matches)) {
  149. $os_name = " iPod" ;
  150. $os_code = "iphone";
  151. $os_ver = $matches[1];
  152. } elseif (preg_match('#iPhone.*.CPU.([a-zA-Z0- 9 .() _)] )#i', $ua, $matches)) {
  153. $os_name = "iPhone";
  154. $os_code = "iphone";
  155. $os_ver = $matches[1 ] ;
  156. } elseif (preg_match('#iPad.*.CPU.([a-zA-Z0-9.( _)] )#i', $ua, $matches)) {
  157. $os_name = "iPad" ;
  158. $os_code = "ipad";
  159. $os_ver = $matches[1];
  160. } elseif (preg_match('/Mac OS X.([0-9. _] )/i', $ua, $matches)) {
  161. $os_name = "Mac OS";
  162. $os_code = "macos";
  163. if(count(explode(7,$matches[ 1]))>1) $matches[1] = '獅子'.$matches[1];
  164. elseif(count(explode(8,$matches[1]))>1) $matches[1 ] = '山獅'.$matches[1];
  165. $os_ver = "X ".$matches[1];
  166. } elseif (preg_match('/Macintosh/i', $ua)) {
  167. $os_name = "Mac OS";
  168. $os_code = "macos";
  169. } elseif (preg_match('/Unix/i', $ua)) {
  170. $os_name = "UNIX";
  171. $os_code = "unix";
  172. } elseif (preg_match('/CrOS/i', $ua)){
  173. $os_name="Google Chrome 網路";
  174. $os_code=" chromeos ";
  175. } elseif (preg_match('/Fedor.([0-9._] )/i', $ua, $matches)){
  176. $os_name="Fedora";
  177. $ os_code ="fedora";
  178. $os_ver = $matches[1];
  179. } else{
  180. $os_name = '未知網路';
  181. $os_code = '其他';
  182. }
  183. }
  184. return array($os_name, $os_code, $os_ver);
  185. }
  186. function CID_pda_detect_os($ua) {
  187. $os_name = $os_code = $osnamever = $dapua) {
  188. $os_name = $os_code = $osnamever = $dap pda_code = $pda_ver = null;
  189. if (preg_match('#PalmOS#i', $ua)) {
  190. $os_name = "Palm OS";
  191. $os_code = "palm";
  192. } elseif (preg_match('#Windows CE#i', $ua)) {
  193. $os_name = "Windows CE";
  194. $os_code = "windows";
  195. } elseif (preg_match(' #QtEmbedded #QtEmbedded ) #i', $ua)) {
  196. $os_name = "Qtopia";
  197. $os_code = "linux";
  198. } elseif (preg_match('#Zaurus#i', $ua) ) {
  199. $os_name = "Linux";
  200. $os_code = "linux";
  201. } elseif (preg_match('#Symbian#i', $ua)) {
  202. $os_name = "Symbian作業系統」;
  203. $os_code = "symbian";
  204. } elseif (preg_match('#PalmOS/sony/model#i', $ua)) {
  205. $pda_name = "Sony Clie";
  206. $pda_code = "sony";
  207. } elseif (preg_match('#Zaurus ([a-zA-Z0-9.] )#i', $ua, $matches)) {
  208. $pda_name = "夏普Zaurus " $matches[1];
  209. $pda_code = "zaurus";
  210. $pda_ver = $matches[1];
  211. } elseif (preg_match('#Series ([0-9] )#i' , $ua, $matches)) {
  212. $pda_name = "系列";
  213. $pda_code = "Nokia";
  214. $pda_ver = $matches[1];
  215. } elseif (preg_match(' # Nokia([0-9] )#i', $ua, $matches)) {
  216. $pda_name = " Nokia";
  217. $pda_code = " Nokia";
  218. $pda_ver = $matches[ 1 ];
  219. } elseif (preg_match('#SIE-([a-zA-Z0-9] )#i', $ua, $matches)) {
  220. $pda_name = "西門子";
  221. $pda_code = "siemens";
  222. $pda_ver = $matches[1];
  223. } elseif (preg_match('#dopod([a-zA-Z0-9] )#i', $ua, $匹配)) {
  224. $pda_name = "Dopod";
  225. $pda_code = "dopod";
  226. $pda_ver = $matches[1];
  227. } elseif (preg_match('#o2 xda ([ a
  228. } elseif (preg_match('#o2 xda ([ a
  229. } a -zA-Z0-9 ] );#i', $ua, $matches)) { $pda_name = "O2 XDA"; $pda_code = "o2"; $pda_ver = $匹配[1]; }elseif (preg_match('#SEC-([a-zA-Z0-9] )#i', $ua, $matches)) {
  230. $pda_name = "三星";
  231. $pda_code = "三星" ;
  232. $pda_ver = $matches[1];
  233. } elseif (preg_match('#SonyEricsson ?([a-zA-Z0-9] )#i', $ua, $matches)) {
  234. $pda_name = "SonyEricsson";
  235. $pda_code = "sonyericsson";
  236. $pda_ver = $matches[1];
  237. } elseif (preg_match('#Kindle/([a-zA-Z0- 9. ×(.)] )#i',$ua, $matches)) {//for Kindle
  238. $pda_name = "kindle";
  239. $pda_code = "kindle";
  240. $pda_ver = $matches[1];
  241. } else {
  242. $pda_name = '未知網路';
  243. $pda_code = '其他';
  244. }
  245. return array($os_name, $ os_code, $os_ver, $pda_name, $pda_code, $pda_ver);
  246. }
  247. function CID_detect_browser($ua) {
  248. $browser_name = $brow_ver_code = $brow_ver_ $os_ver = $pda_name = $pda_code = $pda_ver = null;
  249. $ua = preg_replace("/FunWebProducts/i", "", $ua);
  250. if (preg_match('#MovableType[ /]) () [a-zA-Z0-9.] )#i', $ua, $matches)) {
  251. $browser_name = 'MovableType';
  252. $browser_code = 'mt';
  253. $browser_ver = $ matches[1];
  254. } elseif (preg_match('#WordPress[ /]([a-zA-Z0-9.]*)#i', $ua, $matches)) {
  255. $ browser_name = 'WordPress';
  256. $browser_code = 'wp';
  257. $browser_ver = $matches[1];
  258. } elseif (preg_match('#typepad[ /]([a-zA-Z0- 9. ]*)#i', $ua, $matches)) {
  259. $browser_name = 'TypePad';
  260. $browser_code = 'typepad';
  261. $browser_ver = $matches[1];
  262. } elseif (preg_match('#drupal#i', $ua)) {
  263. $browser_name = 'Drupal';
  264. $browser_code = 'drupal';
  265. $browser_ver = count($matmat) >ches; 0 ? $matches[1] : "";
  266. } elseif (preg_match('#symbianos/([a-zA-Z0-9.] )#i', $ua, $matches)) {
  267. $os_name = "SymbianOS";
  268. $os_ver = $matches[1];
  269. $os_code = 'symbian';
  270. } elseif (preg_match('#avantbrowser.com#i', $ua)) {
  271. $browser_name = 'Avant Browser';
  272. $browser_code = 'avantbrowser';
  273. } elseif (preg_match('#(Camino|Chimera)[ /]([a-zA-Z0-9.] ) #i', $ua, $matches)) {
  274. $browser_name = '卡米諾';
  275. $browser_code = '卡米諾';
  276. $browser_ver = $matches[2];
  277. $os_name = "Mac OS";
  278. $os_code = "macos";
  279. $os_ver = "X";
  280. } elseif (preg_match('#anonymouse#i', $ua, $matches) ) {
  281. $browser_name = 'Anonymouse';
  282. $browser_code = 'anonymouse';
  283. } elseif (preg_match('#PHP#', $ua, $matches)) {
  284. $browser_name = $b. 'PHP';
  285. $browser_code = 'php';
  286. } elseif (preg_match('#danger hiptop#i', $ua, $matches)) {
  287. $browser_name = 'Danger HipTop'; $browser_ = '危險';
  288. } elseif (preg_match('#w3m/([a-zA-Z0-9.] )#i', $ua, $matches)) {
  289. $browser_name = 'W3M' ;
  290. $browser_code = 'w3m';
  291. $browser_ver = $matches[1];
  292. } elseif (preg_match('#Shiira[/]([a-zA-Z0-9.] )# i', $ua, $matches)) {
  293. $browser_name = 'Shiira';
  294. $browser_code = 'shiira';
  295. $browser_ver = $matches[1];
  296. $os_name = " Mac OS";
  297. $os_code = "macos";
  298. $os_ver = "X";
  299. } elseif (preg_match('#Dillo[ /]([a-zA-Z0-9.] ) #i', $ua, $matches)) {
  300. $browser_name = 'Dillo';
  301. $browser_code = 'dillo';
  302. $browser_ver = $matches[1];
  303. } elseif ( preg_match('#Epiphany/([a-zA-Z0-9.] )#i', $ua, $matches)) {
  304. $browser_name = 'Epiphany';
  305. $browser_code = 'epiphany';
  306. $browser_ver = $matches[1];
  307. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  308. } elseif (preg_match('#UP.Browser/ ) ) ([a-zA-Z0-9.] )#i', $ua, $matches)) {
  309. $browser_name = 'Openwave UP.Browser';
  310. $browser_code = 'openwave';
  311. $browser_ver = $matches[1];
  312. } elseif (preg_match('#DoCoMo/([a-zA-Z0-9.] )#i', $ua, $matches)) {
  313. $ browser_name = 'DoCoMo';
  314. $browser_code = 'docomo';
  315. $browser_ver = $matches[1];
  316. if ($browser_ver == '1.0') {
  317. preg_match('# DoCoMo) / ([a-zA-Z0-9.] )/([a-zA-Z0-9.] )#i', $ua, $matches);
  318. $browser_ver = $matches[2] ;
  319. } elseif ($browser_ver == '2.0') {
  320. preg_match('#DoCoMo/([a-zA-Z0-9.] ) ([a-zA-Z0-9.] )# i' , $ua, $matches);
  321. $browser_ver = $matches[2];
  322. }
  323. } elseif (preg_match('#(SeaMonkey)/([a-zA-Z0-9. ] ) # i', $ua, $matches)) {
  324. $browser_name = 'Mozilla SeaMonkey';
  325. $browser_code = 'seamonkey';
  326. $browser_ver = $matches[2];
  327. if ( preg_match ('/Windows/i', $ua)) {
  328. 列表($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua);
  329. } else {
  330. 列表($ os_name , $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  331. }
  332. } elseif (preg_match('#Kazehakase/([a-zA-Z0-9.] )#i ', $ ua, $matches)) {
  333. $browser_name = 'Kazehakase';
  334. $browser_code = 'kazehakase';
  335. $browser_ver = $matches[1];
  336. if (> $browser_ver = $matches[1];
  337. if (pregmatch' /Windows) / i', $ua)) {
  338. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua);
  339. }else {
  340. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  341. }
  342. } elseif (preg_match('#Flock/([a-zA-Z0-zzA-Z0-zzA-Z0-zzA-Z0-z 9.] )#i', $ua, $matches)) {
  343. $browser_name = 'Flock';
  344. $browser_code = 'flock';
  345. $browser_ver = $matches[1];
  346. if (preg_match('/Windows/i', $ua)) {
  347. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua);
  348. } else {
  349. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  350. }
  351. } elseif (preg_match('#(Firefox|Phoenix|Firebird|BonEcho|GranParadiIchoo|GranParadiIas)| /4([a-zA-Z0-9.] )#i', $ua, $matches)) {
  352. $browser_name = 'Mozilla Firefox';
  353. $browser_code = 'firefox';
  354. $browser_ver = '4'.$matches[2];
  355. if (preg_match('/Windows/i', $ua)) {
  356. list($os_name, $os_code, $os_ver) = self:: CID_windows_detect_os($ua);
  357. } else {
  358. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  359. }
  360. }
  361. ( (Firefox|Phoenix|Firebird|BonEcho|GranParadiso|Minefield|Iceweasel)/([a-zA-Z0-9.] )#i', $ua, $matches)) {
  362. $browser_name = 'Mozilla Firefox' ;
  363. $browser_code = 'firefox';
  364. $browser_ver = $matches[2];
  365. if (preg_match('/Windows/i', $ua)) {
  366. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua);
  367. } else {
  368. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  369. } elseif (preg_match('#Minimo/([a-zA-Z0-9.] )#i', $ua, $matches)) {
  370. $browser_name = 'Minimo';
  371. $ browser_code = 'mozilla';
  372. $browser_ver = $matches[1];
  373. if (preg_match('/Windows/i', $ua)) {
  374. list($os_name, $os_code, $os_ver ) = self::CID_windows_detect_os($ua);
  375. } else {
  376. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  377. } $browser_name = 'MultiZilla';
  378. $browser_code = 'mozilla' ;
  379. $browser_ver = $matches[1];
  380. if (preg_match('/Windows/i', $ua)) {
  381. list($os_name, $os_code, $os_ver) = self:: CID_windows_detect_os($ua);
  382. } else {
  383. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  384. }
  385. }
  386. ( SE 2([a-zA-Z0-9.] )#i', $ua, $matches)) {
  387. $browser_name = '搜尋狗瀏覽器';
  388. $browser_code = '搜狗';
  389. $browser_ver = '2'.$matches[1];
  390. if (preg_match('/Windows/i', $ua)) {
  391. list($os_name, $os_code, $os_ver) = self: : CID_windows_detect_os($ua);
  392. } else {
  393. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  394. }
  395. } }
  396. } $browser_name = '百度瀏覽器';
  397. $browser_code = 'baidubrowser';
  398. $ browser_ver = $matches[1];
  399. if (preg_match('/Windows/i', $ua)) {
  400. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ ua) ;
  401. } else {
  402. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  403. }
  404. } elseif (preg_m$ua);
  405. }
  406. } elseif (preg_match('#360( a- zA-Z0-9.] )#i', $ua, $matches)) {
  407. $browser_name = '360瀏覽器';
  408. $browser_code = '360se';
  409. $browser_ver = $browser_code = '360se';
  410. $browser_ver = $matches[ 1];
  411. if (preg_match('/Windows/i', $ua)) {
  412. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua);
  413. } else {
  414. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  415. }
  416. } elseif (preg_match('#QQBrowser('#QQB -Z0- 9.] )#i', $ua, $matches)) {
  417. $browser_name = 'QQ瀏覽器';
  418. $browser_code = 'qqbrowser';
  419. $browser_ver = $matches[ 1];
  420. if (preg_match('/Windows/i', $ua)) {
  421. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua);
  422. } else {
  423. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  424. }
  425. } elseif (preg_match('/PSP (PlayStation Portable🎜> } elseif (preg_match('/PSP (PlayStation Portable)); ([a-zA-Z0-9.] )/', $ua, $matches)) {
  426. $pda_name = "Sony PSP";
  427. $pda_code = "sony-psp";
  428. $ pda_ver = $matches[1];
  429. } elseif (preg_match('#Galeon/([a-zA-Z0-9.] )#i', $ua, $matches)) {
  430. $browser_name = 'Galeon';
  431. $browser_code = 'galeon';
  432. $browser_ver = $matches[1];
  433. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  434. } elseif (preg_match('#iCab/([a-zA-Z0-9.] )#i', $ua, $matches)) {
  435. $browser_name = 'iCab';
  436. $ browser_code = 'icab';
  437. $browser_ver = $matches[1];
  438. $os_name = "Mac OS";
  439. $os_code = "macos";
  440. if (preg_match('#Mac OS ) ) X#i', $ua)) {
  441. $os_ver = "X";
  442. }
  443. } elseif (preg_match('#K-Meleon/([a-zA-Z0-9. ] ) #i', $ua, $matches)) {
  444. $browser_name = 'K-Meleon';
  445. $browser_code = 'kmeleon';
  446. $browser_ver = $matches[1];
  447. if (preg_match('/Windows/i', $ua)) { 列表($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua); } else {列表( $os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua); } }elseif (preg_match('#Lynx/([a-zA-Z0-9.] )#i', $ua, $matches)) {
  448. $browser_name = 'Lynx';
  449. $browser_code = 'lynx ';
  450. $browser_ver = $matches[1];
  451. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  452. } elseif (preg_match('#Links \ (([a-zA-Z0-9.] )#i', $ua, $matches)) {
  453. $browser_name = '連結';
  454. $browser_code = 'lynx';
  455. $browser_ver = $matches[1];
  456. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  457. } elseif (preg_match('#ELinks[/ ]([a-zA -Z0-9.] )#i', $ua, $matches)) {
  458. $browser_name = 'ELinks';
  459. $browser_code = 'lynx';
  460. $browser_ver = $matches[1] ;
  461. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  462. } elseif (preg_match('#ELinks \(([a-zA-Z0-9.] ) #i', $ua, $matches)) {
  463. $browser_name = 'ELinks';
  464. $browser_code = 'lynx';
  465. $browser_ver = $matches[1];
  466. list($ os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  467. } elseif (preg_match('#Konqueror/([a-zA-Z0-9.] )#i', $ua, $匹配)) {
  468. $browser_name = 'Konqueror';
  469. $browser_code = 'konqueror';
  470. $browser_ver = $matches[1];
  471. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  472. if (!$os_name) {
  473. list($os_name, $os_code, $os_ver) = self::CID_pda_detect_os($ua);
  474. }
  475. } elseif (preg_match('#NetPositive/([a-zA-Z0-9.] )#i', $ua, $matches)) {
  476. $browser_name = 'NetPositive';
  477. $browser_code = $browser_name = 'NetPositive';
  478. $browser_code = 'netpositive';
  479. $browser_ver = $matches[1];
  480. $os_name = "BeOS";
  481. $os_code = "beos";
  482. } elseif (preg_match('#OmniWeb#i' , $ua)) {
  483. $browser_name = 'OmniWeb';
  484. $browser_code = 'omniweb';
  485. $os_name = "Mac OS";
  486. $os_code = "macos";
  487. $os_ver = "X";
  488. } elseif (preg_match('#Chrome/([a-zA-Z0-9.] )#i', $ua, $matches)) {
  489. $browser_name = '谷歌瀏覽器'; $browser_code = 'chrome'; $browser_ver = $matches[1];
  490. if (preg_match('/Windows/i', $ua)) {
  491. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua ) ) );
  492. } else {
  493. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  494. } } elseif (preg_match('Arora/preg_match('Arora)/preg_matchif ( [ a-zA-Z0-9.] )#i', $ua, $matches)) {
  495. $browser_name = 'Arora';
  496. $browser_code = 'arora';
  497. $browser_ver = $符合[1];
  498. if (preg_match('/Windows/i', $ua)) {
  499. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua);
  500. } else {
  501. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  502. }
  503. } elseif (preg_match('Max🎜> }
  504. } elseif (preg_match('Max🎜》('Max🎜(#/)(#[ a - zA-Z0-9.] )#i', $ua,$matches)) {
  505. $browser_name = 'Maxthon';
  506. $browser_code = 'maxthon';
  507. $browser_ver = $matches [ 2 ];
  508. if (preg_match('/Win/i', $ua)) {
  509. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua);
  510. } else {
  511. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  512. }
  513. } elseif (preg_match('#CriOS/([a-zzA-Z0 - 9) .] )#i', $ua, $matches)) {
  514. $browser_name = 'iOS 版Chrome';
  515. $browser_code = 'crios';
  516. $browser_ver = $matches[11 ] ;
  517. if (preg_match('/Windows/i', $ua)) {
  518. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua);
  519. } else {
  520. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  521. }
  522. } elseif (preg_match('#Safari/([a-zA-Z0-9 . ] ) #i', $ua, $matches)) {
  523. $browser_name = 'Safari';
  524. $browser_code = 'safari';
  525. $browser_ver = $matches[1];
  526. if (preg_match ('/Windows/i', $ua)) {
  527. 列表($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua);
  528. } else {
  529. 列表( $os_name , $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  530. }
  531. } elseif (preg_match('#opera mini#i', $ua)) {
  532. $browser_name = 'Opera Mini';
  533. $browser_code = 'opera';
  534. preg_match('#Opera/([a-zA-Z0-9.] )#i', $ua, $matches);
  535. $browser_ver = $matches[1];
  536. if (preg_match('/Windows/i', $ua)) {
  537. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ ua) );
  538. } else {
  539. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  540. }
  541. } elseif (preg_match('#🎜> }
  542. } elseif (preg_match('#Opera.(.) ) )版本[ /]([a-zA-Z0-9.] )#i', $ua, $matches)) {
  543. $browser_name = 'Opera';
  544. $browser_code = 'opera';
  545. $browser_ver = $matches[2];
  546. if (preg_match('/Windows/i', $ua)) {
  547. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os ( $ ua);
  548. } else {
  549. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  550. }
  551. if (!$os_name) {
  552. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  553. }
  554. if (!$os_name) {
  555. list($os_name, $os_code, $os_verver , $ pda_name, $pda_code, $pda_ver) = self::CID_pda_detect_os($ua);
  556. }
  557. if (!$os_name) {
  558. if (preg_match('/Wii/i', $uaWii/i', $ua ) ) {
  559. $os_name = "任天堂 Wii";
  560. $os_code = "任天堂-wii";
  561. } } }elseif (preg_match('#Opera/([a-zA-Z0-9.] )#i', $ua, $matches)) {
  562. $browser_name = 'Opera Mini';
  563. $browser_code = ' opera';
  564. $browser_ver = $matches[1];
  565. if (preg_match('/Windows/i', $ua)) {
  566. list($os_name, $os_code, $os_ver) = self ::CID_windows_detect_os($ua);
  567. } else {
  568. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  569. }
  570. } $browser_name = 'WebPro';
  571. $browser_code = 'webpro';
  572. $browser_ver = $matches[1];
  573. $os_name = "PalmOS";
  574. $os_code = "palmos";
  575. } elseif (preg_match('#WebPro#i', $ua, $matches )) {
  576. $browser_name = 'WebPro';
  577. $browser_code = 'webpro';
  578. $os_name = "PalmOS";
  579. $os_code = "palmos";
  580. } elseif (preg_matchif ('#Netfront/([a-zA-Z0-9.] )#i', $ua, $matches)) {
  581. $browser_name = 'Netfront';
  582. $browser_code = 'netfront';
  583. $browser_ver = $matches[1];
  584. list($os_name, $os_code, $os_ver, $pda_name, $pda_code, $pda_ver) = self::CID_pda_detect_os($ua); $browser_name = 'Xiino';
  585. $browser_code = 'xiino';
  586. $browser_ver = $matches[1];
  587. } elseif (preg_match('/wp-blackberry/([a-zA-Z0-9.]*)/i', $ua, $matches)) {
  588. $browser_name = "BlackBerry 版WordPress";
  589. $browser_code = "wordpress";
  590. $browser_ver = $matches[1];
  591. $pda_name = "BlackBerry";
  592. $
  593. $pda_codename = "BlackBerry";
  594. $
  595. $pda_codename = "BlackBerry";
  596. $da_code = "黑莓";
  597. } elseif (preg_match('#Blackberry([0-9] )#i', $ua, $matches)) {
  598. $pda_name = "黑莓";
  599. $pda_code = "黑莓";
  600. $pda_ver = $matches[1];
  601. } elseif (preg_match('#Blackberry#i', $ua)) {
  602. $pda_name = "黑莓";
  603. $pda_code = "blackberry";
  604. } elseif (preg_match('#SPV ([0-9a-zA-Z.] )#i', $ua, $matches)) {
  605. $pda_name = "橘色SPV";
  606. $pda_code = "orange";
  607. $pda_ver = $matches[1];
  608. } elseif (preg_match('#LGE-([a-zA-Z0-9] )#i ', $ua, $matches)) {
  609. $pda_name = "LG";
  610. $pda_code = 'lg';
  611. $pda_ver = $matches[1];
  612. } elseif (preg_match( '#MOT-([a-zA-Z0-9] )#i', $ua, $matches)) {
  613. $pda_name = "摩托羅拉";
  614. $pda_code = 'motorola';
  615. $pda_ver = $matches[1];
  616. } elseif (preg_match('#Nokia ?([0-9] )#i', $ua, $matches)) {
  617. $pda_name = " Nokia";
  618. $pda_code = "Nokia";
  619. $pda_ver = $matches[1];
  620. } elseif (preg_match('#NokiaN-Gage#i', $ua)) {
  621. $pda_name = " Nokia";
  622. $pda_code = " 諾基亞";
  623. $pda_ver = "N-Gage";
  624. } elseif (preg_match('#Blazer[ /]?([a-zA-Z0-9 .]*)#i', $ua, $matches)) {
  625. $browser_name = "Blazer";
  626. $browser_code = "blazer";
  627. $browser_ver = $matches[1];
  628. $os_name = "Palm OS";
  629. $os_code = "palm";
  630. } elseif (preg_match('#SIE-([a-zA-Z0-9] )#i', $ua, $匹配)) {
  631. $pda_name = "西門子";
  632. $pda_code = "西門子";
  633. $pda_ver = $matches[1];
  634. } elseif (preg_match('#SECches-([1]);
  635. } elseif (preg_match('#SECches-([1]); a-zA-Z0-9] )#i', $ua, $matches)) {
  636. $pda_name = "三星";
  637. $pda_code = "三星";
  638. $pda_ver = $matches[ 1];
  639. } elseif (preg_match('/wp-iphone/([a-zA-Z0-9.]*)/i', $ua, $matches)) {
  640. $browser_name = "WordPress對於iOS";
  641. $browser_code = "wordpress";
  642. $browser_ver = $matches[1];
  643. $pda_name = "iPhone 和iPad";
  644. $pda_code = "ipad";
  645. } elseif (preg_match('/wp-android/([a-zA-Z0-9.]*)/i', $ua, $matches)) {
  646. $browser_name = "WordPress for Android";
  647. $browser_code = "wordpress";
  648. $browser_ver = $matches[1];
  649. $pda_name = "Android";
  650. $pda_code = "android";
  651. } elseif (> $pda_code = "android";
  652. } elseif( /wp-windowsphone/([a-zA-Z0-9.]*)/i', $ua, $matches)) {
  653. $browser_name = "適用於Windows Phone 7 的WordPress";
  654. $ browser_code = "wordpress";
  655. $browser_ver = $matches[1];
  656. $pda_name = "Windows Phone 7";
  657. $pda_code = "windows_phone7";
  658. } elseif' wp- Nokia/([a-zA-Z0-9.]*)/i', $ua, $matches)) {
  659. $browser_name = " 諾基亞的WordPress";
  660. $browser_code = "wordpress" ;
  661. $browser_ver = $matches[1];
  662. $pda_name = " 諾基亞";
  663. $pda_code = " 諾基亞";
  664. } elseif (preg_match('#SAMSUNG-(S.H-[a -zA] -Z0-9_/.] )#i', $ua, $matches)) {
  665. $pda_name = "三星";
  666. $pda_code = "三星";
  667. $pda_ver = $ matches[1 ]; if (preg_match('#(j2me|midp)#i', $ua)) { $browser_name = "J2ME/MIDP 瀏覽器"; $browser_code = "j2me "; } }elseif (preg_match('#SonyEricsson ?([a-zA-Z0-9] )#i', $ua, $matches)) {
  668. $pda_name = "SonyEricsson";
  669. $pda_code = "sonyericsson" ;
  670. $pda_ver = $matches[1];
  671. } elseif (preg_match('#(j2me|midp)#i', $ua)) {
  672. $browser_name = "J2ME/MIDP 瀏覽器" ;
  673. $browser_code = "j2me";
  674. // 老鼠
  675. } elseif (preg_match('/GreenBrowser/i', $ua)) {
  676. $browser_name = 'GreenBrowser';
  677. $
  678. $
  679. $
  680. $
  681. $
  682. $
  683. $
  684. $
  685. $
  686. $
  687. $
  688. $
  689. $
  690. $
  691. $
  692. $
  693. $
  694. $
  695. $
  696. $
  697. $
  698. $
  699. $
  700. $
  701. $
  702. $
  703. $
  704. $
  705. $
  706. $ if (preg_match('/Win/i', $ua)) {
  707. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua);
  708. } else {
  709. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  710. }
  711. } elseif (preg_match('#🎜> }
  712. } elseif (preg_match('#Tencentzler ([Tencentzler Z0-9.] )#i', $ua, $matches)) {
  713. $browser_name = '騰訊TT瀏覽器';
  714. $browser_code = 'tencenttraveler';
  715. $browser_ver = $matches[ 1];
  716. if (preg_match('/Windows/i', $ua)) {
  717. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua);
  718. } else {
  719. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  720. }
  721. } elseif (preg_match('#UCWEB([a-zzA-Z0-9 ) ) .] )#i', $ua, $matches)) {
  722. $browser_name = 'UCWEB';
  723. $browser_code = 'ucweb';
  724. $browser_ver = $matches[1];
  725. if (preg_match('/Windows/i', $ua)) {
  726. 列表($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua);
  727. } else {
  728. 列表($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  729. }
  730. } elseif (preg_match('#MSIE ([a-zA-Z0-9.] )# i ' , $ua, $matches)) {
  731. $browser_name = 'Internet Explorer';
  732. $browser_ver = $matches[1];
  733. if ( strpos($browser_ver, '7') != =假 || strpos($browser_ver, '8') !== false)
  734. $browser_code = 'ie8';
  735. elseif ( strpos($browser_ver, '9') !== false)
  736. $browser_code = 'browser_code = ' ie9';
  737. elseif ( strpos($browser_ver, '10') !== false)
  738. $browser_code = 'ie10';
  739. else
  740. $browser_code = 'ie';
  741. else
  742. $browser_code = 'ie'; list ($os_name, $os_code, $os_ver, $pda_name, $pda_code, $pda_ver) = self::CID_windows_detect_os($ua);
  743. } elseif (preg_match('#Universe/([0-9.] )# i', $ua, $matches)) {
  744. $browser_name = 'Universe';
  745. $browser_code = 'universe';
  746. $browser_ver = $matches[1];
  747. list($os_name , $os_code, $os_ver, $pda_name, $pda_code, $pda_ver) = self::CID_pda_detect_os($ua);
  748. }elseif (preg_match('#Netscape[0-9]?/([a-zA- Z0-9.] )#i', $ua, $matches)) {
  749. $browser_name = 'Netscape';
  750. $browser_code = 'netscape';
  751. $browser_ver = $matches[1];
  752. if (preg_match('/Windows/i', $ua)) {
  753. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ua);
  754. } else {
  755. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  756. }
  757. } elseif (preg_match('#^Mozilla/5.0#i', $ua) & pregreg ('#rv:([a-zA-Z0-9.] )#i', $ua, $matches)) {
  758. $browser_name = 'Mozilla';
  759. $browser_code = 'mozilla';
  760. $browser_ver = $matches[1];
  761. if (preg_match('/Windows/i', $ua)) {
  762. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os( $ua);
  763. } else {
  764. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  765. }
  766. } elseif (preg_match ) ) /([a-zA-Z0-9.] )#i', $ua, $matches)) {
  767. $browser_name = 'Netscape Navigator';
  768. $browser_code = 'netscape';
  769. $ browser_ver = $matches[1];
  770. if (preg_match('/Win/i', $ua)) {
  771. list($os_name, $os_code, $os_ver) = self::CID_windows_detect_os($ ua) ) ;
  772. } else {
  773. list($os_name, $os_code, $os_ver) = self::CID_unix_detect_os($ua);
  774. }
  775. }else{ $bser🎜> $bsername = '未知瀏覽器';
  776. $browser_code = 'null';
  777. }
  778. if (!$pda_name && !$os_name){
  779. $pda_name = '未知網絡'; $pda_code = '其他';
  780. $os_name = '未知網路';
  781. $os_code = '其他';
  782. } return array($browser_name, $browser_code, $browser_ver, $os_namever, $os_name , $os_code, $os_ver, $pda_name, $pda_code, $pda_ver); } ////取得訪客瀏覽器類型 function Get_Useragent(){ if(!empty($ _SERVER['HTTP_USER_AGENT) '])){ return self::CID_detect_browser($_SERVER['HTTP_USER_AGENT']); } else{ return> }; 🎜> } ////取得訪客真實ip function Get_Ip_Addr(){ if(!empty($_SERVER["HTTP_CLIENT_IP"])){ $ip = $> $ip = $ _SERVER["HTTP_CLIENT_IP" ]; } if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){ //取得代理ip $ips =explode(',',$_SERVER[',$_SERVER[' HTTP_X_FORWARDED_FOR']); } if($ip){ $ips = array_unshift($ips,$ip); } $count = count($ips); for($i=0;$i if(!preg_match("/^(10| 172.16|192.168)./i",$ips[$i])){//修復消防防火管ip $ip = $ips[$i];break; } }
  783. $tip = empty($_SERVER['REMOTE_ADDR']) ? $ip : $_SERVER['REMOTE_ADDR'];
  784. if($tip=="127.0.0.1"){ //取得本地真實IPIP
  785. return self::get_onlineip();
  786. }
  787. else{
  788. return $tip;
  789. }
  790. }
  791. ////取得本地真實IP
  792. }
  793. ////取得本地真實IP
  794. }
  795. ////取得本地真實IP
  796. }
  797. ////取得本地真實IP
  798. }
  799. ////取得本地真實IP
  800. function get_onlineip() {
  801. $ip_json = @file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=myip");
  802. $ip_arr=json_decode(stripslashes($ ip_json),1);
  803. if($ip_arr['code']==0)
  804. {
  805. return $ip_arr['data']['ip'];
  806. }
  807. }
  808. ////依ip取得訪客所在地地名
  809. function Get_Ip_From($ip=''){
  810. if(empty($ip)){
  811. $ip = self::Getip();
  812. }
  813. $ip_json=@file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=".$ip);//根據taobao ip
  814. $ip_arr=json_decode(stripslashes($ip_json),1);
if($ip_arr['code']==0)
{ return $ip_arr['data']; }
else
}
}
}


}
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板