📄 phpsniff.core.php
字号:
else $v .= $v2; // update browser info container array if(empty($v)) $v = 'win'; $this->_set_browser('os',strtolower($v)); $this->_set_browser('platform','win'); } // look for amiga OS elseif(preg_match($regex_amiga,$this->_browser_info['ua'],$match)) { $this->_set_browser('platform','amiga'); if(stristr($this->_browser_info['ua'],'morphos')) { // checking for MorphOS $this->_set_browser('os','morphos'); } elseif(stristr($this->_browser_info['ua'],'mc680x0')) { // checking for MC680x0 $this->_set_browser('os','mc680x0'); } elseif(stristr($this->_browser_info['ua'],'ppc')) { // checking for PPC $this->_set_browser('os','ppc'); } elseif(preg_match('/(AmigaOS [\.1-9]?)/i',$this->_browser_info['ua'],$match)) { // checking for AmigaOS version string $this->_set_browser('os',$match[1]); } } // look for OS2 elseif( preg_match($regex_os2,$this->_browser_info['ua'])) { $this->_set_browser('os','os2'); $this->_set_browser('platform','os2'); } // look for mac // sets: platform = mac ; os = 68k or ppc elseif( preg_match($regex_mac,$this->_browser_info['ua'],$match) ) { $this->_set_browser('platform','mac'); $os = !empty($match[1]) ? '68k' : ''; $os = !empty($match[2]) ? 'osx' : $os; $os = !empty($match[3]) ? 'ppc' : $os; $os = !empty($match[4]) ? 'osx' : $os; $this->_set_browser('os',$os); } // look for *nix boxes // sunos sets: platform = *nix ; os = sun|sun4|sun5|suni86 elseif(preg_match($regex_sunos,$this->_browser_info['ua'],$match)) { $this->_set_browser('platform','*nix'); if(!stristr('sun',$match[1])) $match[1] = 'sun'.$match[1]; $this->_set_browser('os',$match[1].$match[2]); } // irix sets: platform = *nix ; os = irix|irix5|irix6|... elseif(preg_match($regex_irix,$this->_browser_info['ua'],$match)) { $this->_set_browser('platform','*nix'); $this->_set_browser('os',$match[1].$match[2]); } // hp-ux sets: platform = *nix ; os = hpux9|hpux10|... elseif(preg_match($regex_hpux,$this->_browser_info['ua'],$match)) { $this->_set_browser('platform','*nix'); $match[1] = str_replace('-','',$match[1]); $match[2] = (int) $match[2]; $this->_set_browser('os',$match[1].$match[2]); } // aix sets: platform = *nix ; os = aix|aix1|aix2|aix3|... elseif(preg_match($regex_aix,$this->_browser_info['ua'],$match)) { $this->_set_browser('platform','*nix'); $this->_set_browser('os','aix'.$match[1]); } // dec sets: platform = *nix ; os = dec elseif(preg_match($regex_dec,$this->_browser_info['ua'],$match)) { $this->_set_browser('platform','*nix'); $this->_set_browser('os','dec'); } // vms sets: platform = *nix ; os = vms elseif(preg_match($regex_vms,$this->_browser_info['ua'],$match)) { $this->_set_browser('platform','*nix'); $this->_set_browser('os','vms'); } // sco sets: platform = *nix ; os = sco elseif(preg_match($regex_sco,$this->_browser_info['ua'],$match)) { $this->_set_browser('platform','*nix'); $this->_set_browser('os','sco'); } // unixware sets: platform = *nix ; os = unixware elseif(stristr($this->_browser_info['ua'],'unix_system_v')) { $this->_set_browser('platform','*nix'); $this->_set_browser('os','unixware'); } // mpras sets: platform = *nix ; os = mpras elseif(stristr($this->_browser_info['ua'],'ncr')) { $this->_set_browser('platform','*nix'); $this->_set_browser('os','mpras'); } // reliant sets: platform = *nix ; os = reliant elseif(stristr($this->_browser_info['ua'],'reliantunix')) { $this->_set_browser('platform','*nix'); $this->_set_browser('os','reliant'); } // sinix sets: platform = *nix ; os = sinix elseif(stristr($this->_browser_info['ua'],'sinix')) { $this->_set_browser('platform','*nix'); $this->_set_browser('os','sinix'); } // bsd sets: platform = *nix ; os = bsd|freebsd elseif(preg_match($regex_bsd,$this->_browser_info['ua'],$match)) { $this->_set_browser('platform','*nix'); $this->_set_browser('os',$match[1].$match[2]); } // last one to look for // linux sets: platform = *nix ; os = linux elseif(preg_match($regex_linux,$this->_browser_info['ua'],$match)) { $this->_set_browser('platform','*nix'); $this->_set_browser('os','linux'); } } function _get_browser_info () { $this->_build_regex(); if(preg_match_all($this->_browser_regex,$this->_browser_info['ua'],$results)) { // get the position of the last browser found $count = count($results[0])-1; // if we're allowing masquerading, revert to the next to last browser found // if possible, otherwise stay put if($this->_allow_masquerading && $count > 0) $count--; // insert findings into the container $this->_set_browser('browser',$this->_get_short_name($results[1][$count])); $this->_set_browser('long_name',$results[1][$count]); $this->_set_browser('maj_ver',$results[2][$count]); // parse the minor version string and look for alpha chars preg_match('/([.\0-9]+)?([\.a-z0-9]+)?/i',$results[3][$count],$match); if(isset($match[1])) { $this->_set_browser('min_ver',$match[1]); } else { $this->_set_browser('min_ver','.0'); } if(isset($match[2])) $this->_set_browser('letter_ver',$match[2]); // insert findings into container $this->_set_browser('version',$this->_browser_info['maj_ver'].$this->property('min_ver')); } } function _get_ip () { if(getenv('HTTP_CLIENT_IP')) { $ip = getenv('HTTP_CLIENT_IP'); } else { $ip = getenv('REMOTE_ADDR'); } $this->_set_browser('ip',$ip); } function _build_regex () { $browsers = ''; while(list($k,) = each($this->_browsers)) { if(!empty($browsers)) $browsers .= "|"; $browsers .= $k; } $version_string = "[\/\sa-z(]*([0-9]+)([\.0-9a-z]+)?"; $this->_browser_regex = "/($browsers)$version_string/i"; } function _get_short_name ($long_name) { return $this->_browsers[strtolower($long_name)]; } // medianes :: new test cookie routine function _test_cookies() { global $HTTP_COOKIE_VARS; $cookies = array(); if(isset($_COOKIE)) { $cookies = $_COOKIE; } elseif(isset($HTTP_COOKIE_VARS)) { $cookies = $HTTP_COOKIE_VARS; } if($this->_check_cookies) { $fp = @fopen($this->_temp_file_path.$this->property('ip'),'r'); if(!$fp) { $fp = @fopen($this->_temp_file_path.$this->property('ip'),'a'); fclose($fp); setcookie('phpSniff_session','ss',0,'/'); setcookie('phpSniff_stored','st',time()+3600*24*365,'/'); $QS=getenv('QUERY_STRING'); $script_path=getenv('PATH_INFO')?getenv('PATH_INFO'):getenv('SCRIPT_NAME'); if(is_integer($pos=strpos(strrev($script_path),"php.xedni/"))&&!$pos) { $script_path=strrev(substr(strrev($script_path),9)); } $location='http://'.getenv('SERVER_NAME').$script_path.($QS==''?'':'?'.$QS); header("Location: $location"); exit; } else { unlink($this->_temp_file_path.$this->property('ip')); fclose($fp); $this->_set_browser('ss_cookies',isset($cookies['phpSniff_session'])?'true':'false'); $this->_set_browser('st_cookies',isset($cookies['phpSniff_stored'])?'true':'false'); // delete the old cookies setcookie('phpSniff_session','',0,'/'); setcookie('phpSniff_stored','',0,'/'); } } } function _get_javascript() { $set=false; // see if we have any matches while(list($version,$browser) = each($this->_javascript_versions)) { $browser = explode(',',$browser); while(list(,$search) = each($browser)) { if($this->is('b:'.$search)) { $this->_set_browser('javascript',$version); $set = true; break; } } if($set) break; } } function _get_features () { while(list($feature,$browser) = each($this->_browser_features)) { $browser = explode(',',$browser); while(list(,$search) = each($browser)) { if($this->browser_is($search)) { $this->_set_feature($feature); break; } } } } function _get_quirks () { while(list($quirk,$browser) = each($this->_browser_quirks)) { $browser = explode(',',$browser); while(list(,$search) = each($browser)) { if($this->browser_is($search)) { $this->_set_quirk($quirk); break; } } } } function _get_gecko () { if(preg_match('/gecko\/([0-9]+)/i',$this->property('ua'),$match)) { $this->_set_browser('gecko',$match[1]); if (preg_match('/rv[: ]?([0-9a-z.+]+)/i',$this->property('ua'),$mozv)) { // mozilla release $this->_set_browser('gecko_ver',$mozv[1]); } elseif (preg_match('/(m[0-9]+)/i',$this->property('ua'),$mozv)) { // mozilla milestone version $this->_set_browser('gecko_ver',$mozv[1]); } // if this is a mozilla browser, get the rv: information if($this->browser_is($this->_get_short_name('mozilla'))) { if(preg_match('/([0-9]+)([\.0-9]+)([a-z0-9+]?)/i',$mozv[1],$match)) { $this->_set_browser('version',$mozv[1]); $this->_set_browser('maj_ver',$match[1]); $this->_set_browser('min_ver',$match[2]); $this->_set_browser('letter_ver',$match[3]); } } } elseif($this->is('b:'.$this->_get_short_name('mozilla'))) { // this is probably a netscape browser or compatible $this->_set_browser('long_name','netscape'); $this->_set_browser('browser',$this->_get_short_name('netscape')); } } function _set_browser ($k,$v) { $this->_browser_info[strtolower($k)] = strtolower($v); } function _set_feature ($k) { $this->_feature_set[strtolower($k)] = !$this->_feature_set[strtolower($k)]; } function _set_quirk ($k) { $this->_quirks[strtolower($k)] = true; }}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -