Home  >  Article  >  Backend Development  >  Get visitor operating system

Get visitor operating system

WBOY
WBOYOriginal
2016-07-25 09:10:081153browse
Get visitor operating system
  1. function osinfo() {
  2. $os="";
  3. $Agent = $GLOBALS["HTTP_USER_AGENT"];
  4. if (eregi('win',$Agent) && strpos($Agent, '95')) { //OsPHP.COM.CN
  5. $os="Windows 95";
  6. }
  7. elseif (eregi('win 9x',$Agent) && strpos($Agent, '4.90')) {
  8. $os="Windows ME";
  9. }
  10. elseif (eregi('win',$Agent) && ereg('98',$Agent)) {
  11. //Open source OSPhP.COM.CN
  12. $os="Windows 98 ";
  13. }
  14. elseif (eregi('win',$Agent) && eregi('nt 5.0',$Agent)) {
  15. $os="Windows 2000";
  16. }
  17. elseif (eregi('win',$ Agent) && eregi('nt',$Agent)) {
  18. //OSPHP.COM.CnOpen Source
  19. $os="Windows NT";
  20. }
  21. elseif (eregi('win',$Agent) && eregi(' nt 5.1',$Agent)) {
  22. $os="Windows XP";
  23. }
  24. elseif (eregi('win',$Agent) && ereg('32',$Agent)) {
  25. //Open source OSPhP. COM.CN
  26. $os="Windows 32";
  27. }
  28. elseif (eregi('linux',$Agent)) {
  29. $os="Linux";
  30. }
  31. elseif (eregi('unix',$Agent) ) {
  32. $os="Unix"; //PHP open source code
  33. }
  34. elseif (eregi('sun',$Agent) && eregi('os',$Agent)) {
  35. $os="SunOS";
  36. }
  37. elseif (eregi('ibm',$Agent) && eregi('os',$Agent)) { //OSPHP.COm.CN
  38. $os="IBM OS/2";
  39. }
  40. elseif (eregi( 'Mac',$Agent) && eregi('PC',$Agent)) {
  41. $os="Macintosh";
  42. }
  43. elseif (eregi('PowerPC',$Agent)) { //OSPHP.com.CN
  44. $os="PowerPC";
  45. }
  46. elseif (eregi('AIX',$Agent)) {
  47. $os="AIX";
  48. }
  49. elseif (eregi('HPUX',$Agent)) {
  50. $ os="HPUX";
  51. //Open source code OSPhP.COm.CN
  52. }
  53. elseif (eregi('NetBSD',$Agent)) {
  54. $os="NetBSD";
  55. }
  56. elseif (eregi('BSD' ,$Agent)) {
  57. $os="BSD";
  58. }
  59. elseif (ereg('OSF1',$Agent)) {
  60. //Open source code OSPHP.COM.Cn
  61. $os="OSF1";
  62. }
  63. elseif (ereg('IRIX',$Agent)) {
  64. $os="IRIX";
  65. }
  66. elseif (eregi('FreeBSD',$Agent)) {
  67. $os="FreeBSD";
  68. //oSPHP .COM.CN
  69. }
  70. if ($os=='') $os = "Unknown";
  71. return $os;
  72. }
  73. //Call method $os=os_infor();
  74. ?>
Copy Code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn