以下为引用的内容: <?php class clientGetObj { function getBrowse() { global $_SERVER; $Agent = $_SERVER[‘HTTP_USER_AGENT’]; $browser = ”; $browserver = ”; $Browser = array(‘Lynx’, ‘MOSAIC’, ‘AOL’, ‘Opera’, ‘JAVA’, ‘MacWeb’, ‘WebExplorer’, ‘OmniWeb’); for($i = 0; $i <= 7; $i ++){ if(strpos($Agent, $Browsers[$i])){ $browser = $Browsers[$i]; $browserver = ”; } } if(ereg(‘Mozilla’, $Agent) && !ereg(‘MSIE’, $Agent)){ $temp = explode(‘(‘, $Agent); $Part = $temp[0]; $temp = explode(‘/’, $Part); $browserver = $temp[1]; $temp = explode(‘ ‘, $browserver); $browserver = $temp[0]; $browserver = preg_replace(‘/([d.]+)/’, ‘1’, $browserver); $browserver = $browserver; $browser = ‘Netscape Navigator’; } if(ereg(‘Mozilla’, $Agent) && ereg(‘Opera’, $Agent)) { $temp = explode(‘(‘, $Agent); $Part = $temp[1]; $temp = explode(‘)’, $Part); $browserver = $temp[1]; $temp = explode(‘ ‘, $browserver); $browserver = $temp[2]; $browserver = preg_replace(‘/([d.]+)/’, ‘1’, $browserver); $browserver = $browserver; $browser = ‘Opera’; } if(ereg(‘Mozilla’, $Agent) && ereg(‘MSIE’, $Agent)){ $temp = explode(‘(‘, $Agent); $Part = $temp[1]; $temp = explode(‘;’, $Part); $Part = $temp[1]; $temp = explode(‘ ‘, $Part); $browserver = $temp[2]; $browserver = preg_replace(‘/([d.]+)/’,‘1’,$browserver); $browserver = $browserver; $browser = ‘Internet Explorer’; } if($browser != ”){ $browseinfo = $browser.‘ ‘.$browserver; } else { $browseinfo = false; } return $browseinfo; } function getIP () function getOS () }?> |
使用方法:
1.将以上框内代码另存为getinfo.php
2.在需要地页面引入getinfo.php
<?php incude(‘getinfo.php’); ?>
3. 使用之前定义的类
以下为引用的内容: <?php $code = new clientGetObj; $str1 = $code->getBrowse();//浏览器: $str2 = $code->getIP();//IP地址: $str3 = $code->getOS();//操作系统: echo “目标浏览器:”.$str1.” OS:”.$str3.” IP:”.$str2; ?> |
发表评论
您必须在 登录 后才能评论.