[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 /******************************************************************************* 3 $Id: phpSniff.class.php,v 1.21 2003/07/02 23:28:35 epsilon7 Exp $ 4 5 phpSniff: HTTP_USER_AGENT Client Sniffer for PHP 6 Copyright (C) 2001 Roger Raymond ~ epsilon7@users.sourceforge.net 7 8 This library is free software; you can redistribute it and/or 9 modify it under the terms of the GNU Lesser General Public 10 License as published by the Free Software Foundation; either 11 version 2.1 of the License, or (at your option) any later version. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 *******************************************************************************/ 22 lt_include( PLOG_CLASS_PATH.'class/net/http/phpsniff/phpSniff.core.php'); 23 24 //=============================================================== 25 // the following defines are used to create the short 26 // browser name used throughout the script. 27 // change these to suit your needs 28 //=============================================================== 29 30 /** 31 * \ingroup Net_HTTP 32 * 33 * The PHPSniff package provides support for detecting the browser capabilities at run-time. 34 * 35 */ 36 class phpSniff extends phpSniff_core 37 { var $_version = '2.1.3'; 38 /** 39 * Configuration 40 * 41 * $_temp_file_path 42 * default : /tmp/ 43 * desc : directory writable by the server to store cookie check files. 44 * : trailing slash is needed. only used if you use the check cookie routine 45 * 46 * $_check_cookies 47 * default : null 48 * desc : Allow for the script to redirect the browser in order 49 * : to check for cookies. In order for this to work, this 50 * : class must be instantiated before any headers are sent. 51 * 52 * $_default_language 53 * default : en-us 54 * desc : language to report as if no languages are found 55 * 56 * $_allow_masquerading 57 * default : null 58 * desc : Allow for browser to Masquerade as another. 59 * : (ie: Opera identifies as MSIE 5.0) 60 * 61 * $_browsers 62 * desc : 2D Array of browsers we wish to search for 63 * : in key => value pairs. 64 * : key = browser to search for [as in HTTP_USER_AGENT] 65 * : value = value to return as 'browser' property 66 * 67 * $_javascript_versions 68 * desc : 2D Array of javascript version supported by which browser 69 * : in key => value pairs. 70 * : key = javascript version 71 * : value = search parameter for browsers that support the 72 * : javascript version listed in the key (comma delimited) 73 * : note: the search parameters rely on the values 74 * : set in the $_browsers array 75 * 76 * $_browser_features 77 * desc : 2D Array of browser features supported by which browser 78 * : in key => value pairs. 79 * : key = feature 80 * : value = search parameter for browsers that support the 81 * : feature listed in the key (comma delimited) 82 * : note: the search parameters rely on the values 83 * : set in the $_browsers array 84 * 85 * $_browser_quirks 86 * desc : 2D Array of browser quirks present in which browser 87 * : in key => value pairs. 88 * : key = quirk 89 * : value = search parameter for browsers that feature the 90 * : quirk listed in the key (comma delimited) 91 * : note: the search parameters rely on the values 92 * : set in the $_browsers array 93 **/ 94 95 var $_temp_file_path = '/tmp/'; // with trailing slash 96 var $_check_cookies = NULL; 97 var $_default_language = 'en-us'; 98 var $_allow_masquerading = NULL; 99 var $_php_version = ''; 100 101 var $_browsers = array( 102 'microsoft internet explorer' => 'IE', 103 'msie' => 'IE', 104 'netscape6' => 'NS', 105 'netscape' => 'NS', 106 'galeon' => 'GA', 107 'phoenix' => 'PX', 108 'mozilla firebird' => 'FB', 109 'firebird' => 'FB', 110 'chimera' => 'CH', 111 'camino' => 'CA', 112 'safari' => 'SF', 113 'k-meleon' => 'KM', 114 'mozilla' => 'MZ', 115 'opera' => 'OP', 116 'konqueror' => 'KQ', 117 'icab' => 'IC', 118 'lynx' => 'LX', 119 'links' => 'LI', 120 'ncsa mosaic' => 'MO', 121 'amaya' => 'AM', 122 'omniweb' => 'OW', 123 'hotjava' => 'HJ', 124 'browsex' => 'BX', 125 'amigavoyager' => 'AV', 126 'amiga-aweb' => 'AW', 127 'ibrowse' => 'IB' 128 ); 129 130 var $_javascript_versions = array( 131 '1.5' => 'NS5+,MZ,PX,FB,GA,CH,CA,SF,KQ3+,KM', // browsers that support JavaScript 1.5 132 '1.4' => '', 133 '1.3' => 'NS4.05+,OP5+,IE5+', 134 '1.2' => 'NS4+,IE4+', 135 '1.1' => 'NS3+,OP,KQ', 136 '1.0' => 'NS2+,IE3+', 137 '0' => 'LI,LX,HJ' 138 ); 139 140 var $_browser_features = array( 141 /** 142 * the following are true by default 143 * (see phpSniff.core.php $_feature_set array) 144 * browsers listed here will be set to false 145 **/ 146 'html' => '', 147 'images' => 'LI,LX', 148 'frames' => 'LI,LX', 149 'tables' => '', 150 'java' => 'OP3,LI,LX,NS1,MO,IE1,IE2', 151 'plugins' => 'IE1,IE2,LI,LX', 152 /** 153 * the following are false by default 154 * (see phpSniff.core.php $_feature_set array) 155 * browsers listed here will be set to true 156 **/ 157 'css2' => 'NS5+,IE5+,MZ,PX,FB,CH,CA,SF,GA,KQ3+,OP7+,KM', 158 'css1' => 'NS4+,IE4+,MZ,PX,FB,CH,CA,SF,GA,KQ,OP7+,KM', 159 'iframes' => 'IE3+,NS5+,MZ,PX,FB,CH,CA,SF,GA,KQ,OP7+,KM', 160 'xml' => 'IE5+,NS5+,MZ,PX,FB,CH,CA,SF,GA,KQ,OP7+,KM', 161 'dom' => 'IE5+,NS5+,MZ,PX,FB,CH,CA,SF,GA,KQ,OP7+,KM', 162 'hdml' => '', 163 'wml' => '', 164 'xmlhttpreq'=> 'IE5+,NS5+,MZ,SF' 165 ); 166 167 var $_browser_quirks = array( 168 'must_cache_forms' => 'NS,MZ,FB,PX', 169 'avoid_popup_windows' => 'IE3,LI,LX', 170 'cache_ssl_downloads' => 'IE', 171 'break_disposition_header' => 'IE5.5', 172 'empty_file_input_value' => 'KQ', 173 'scrollbar_in_way' => 'IE6' 174 ); 175 176 function phpSniff($UA='',$settings = true) 177 { // populate the HTTP_USER_AGENT string 178 // 20020425 :: rraymond 179 // routine for easier configuration of the client at runtime 180 if(is_array($settings)) { 181 $run = true; 182 extract($settings); 183 $this->_check_cookies = $check_cookies; 184 $this->_default_language = $default_language; 185 $this->_allow_masquerading = $allow_masquerading; 186 } else { 187 // for backwards compatibility with 2.0.x series 188 $run = $settings; 189 } 190 191 // 20020425 :: besfred 192 if(empty($UA)) $UA = getenv('HTTP_USER_AGENT'); 193 if(empty($UA)) { 194 global $HTTP_SERVER_VARS; 195 if( !isset( $_SERVER['HTTP_USER_AGENT'] )) $_SERVER['HTTP_USER_AGENT'] = ''; 196 if( !isset( $HTTP_SERVER_VARS['HTTP_USER_AGENT'] )) $HTTP_SERVER_VARS['HTTP_USER_AGENT'] = ''; 197 $UA = ( phpversion() >= "4.1.0" ) ? $_SERVER['HTTP_USER_AGENT'] : $HTTP_SERVER_VARS['HTTP_USER_AGENT']; 198 } 199 // 20020910 :: rraymond 200 if(empty($UA)) return false; 201 202 $this->_set_browser('ua',$UA); 203 if($run) $this->init(); 204 } 205 } 206 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |