Commit ae138970ad34084b5336083638cbe8bd5e45f892
1 parent
af03ef34
initial revision of phpsniff
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@763 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
7 changed files
with
1681 additions
and
0 deletions
phpSniff/CHANGES
0 → 100644
| 1 | +$Id: CHANGES,v 1.11 2002/09/13 21:40:34 epsilon7 Exp $ | |
| 2 | + | |
| 3 | +======================================================================== | |
| 4 | +Changes for version 2.1.1 | |
| 5 | +======================================================================== | |
| 6 | +[2002.09.13] | |
| 7 | +gdavison : now correctly identifies MAC OSX | |
| 8 | + | |
| 9 | +======================================================================== | |
| 10 | +Changes for version 2.1.0 | |
| 11 | +======================================================================== | |
| 12 | +[2002.09.10] | |
| 13 | +rraymond : return false if user agent is not found | |
| 14 | +rraymond : fixed browser detection for browsers without a minor version | |
| 15 | +rraymond : correct detection of netscape 7 | |
| 16 | + | |
| 17 | +[2002.04.25] | |
| 18 | +rraymond : added check for Mac OSX | |
| 19 | + : $client->property('os') = 'osx' | |
| 20 | +rraymond : added new setting $_temp_file_path = '/tmp/'; | |
| 21 | + : this needs to be modified for the class to work on your server | |
| 22 | +rraymond : modified test_cookie routine to work on more platforms | |
| 23 | +medianes : cookie check fix | |
| 24 | +medianes : session and stored cookie checks | |
| 25 | +besfred : getenv insufficient fix | |
| 26 | +rraymond : simplified class instantiation | |
| 27 | + | |
| 28 | +[2002.03.06] | |
| 29 | +rraymond : modified _get_gecko() function to pull mozilla rv version | |
| 30 | +rraymond : new browser property gecko_ver returns mozilla rv version | |
| 31 | + : $client->property('gecko_ver'); | |
| 32 | + | |
| 33 | +[2002.02.11] | |
| 34 | +rraymond : renamed _insert() to _set_browser() in core | |
| 35 | +rraymond : new private function _set_feature() and _set_quirk() | |
| 36 | + : added to core | |
| 37 | +rraymond : added browser features and browser quirks settings | |
| 38 | +rraymond : modified _javascript_versions array to fix report for IE5UP | |
| 39 | +rraymond : added new methods has_feature() and has_quirk() | |
| 40 | + : $client->has_feature('css2'); | |
| 41 | + : $client->has_quirk('avoid_popup_windows'); | |
| 42 | +rraymond : added ability to search down from a version | |
| 43 | + : $client->is('b:ns4dn'); | |
| 44 | +rraymond : fixed PHP Warnings about undefined array index | |
| 45 | + : in _perform_browser_search() | |
| 46 | +rraymond : support added for Links and HotJava browsers (untested) | |
| 47 | + | |
| 48 | +======================================================================== | |
| 49 | +Changes for version 2.0.6 | |
| 50 | +======================================================================== | |
| 51 | +[2002.01.02] | |
| 52 | +rraymond : changed license from GPL to LGPL | |
| 53 | + | |
| 54 | +======================================================================== | |
| 55 | +Changes for version 2.0.5a | |
| 56 | +======================================================================== | |
| 57 | +[2001.12.21] | |
| 58 | +rraymond : fixed undeclared constants in check cookie routine | |
| 59 | + | |
| 60 | +======================================================================== | |
| 61 | +Changes for version 2.0.5 | |
| 62 | +======================================================================== | |
| 63 | +[2001.12.20] | |
| 64 | +rraymond : added support for Windows XP | |
| 65 | +rraymond : fixed some old Windows 98 version 9x 4.90 detection problems | |
| 66 | +rraymond : added Windows XP HTTP_USER_AGENT to user_agent.inc | |
| 67 | + | |
| 68 | +======================================================================== | |
| 69 | +Changes for version 2.0.4 | |
| 70 | +======================================================================== | |
| 71 | +[2001.12.17] | |
| 72 | +rraymond : added browser_is() method | |
| 73 | +rraymond : added language_is() method | |
| 74 | +rraymond : added get_property() alias for property() method | |
| 75 | +rraymond : added gecko property; reports mozilla build number (YYYYMMDD) | |
| 76 | +rraymond : added _browser_search_regex class var | |
| 77 | +rraymond : added _language_search_regex class var | |
| 78 | +rraymond : updated demo to use new methods | |
| 79 | + | |
| 80 | +======================================================================== | |
| 81 | +Changes for version 2.0.3 | |
| 82 | +======================================================================== | |
| 83 | +[2001.12.13] | |
| 84 | +rraymond : initialized variables | |
| 85 | +rraymond : fixed undeclared constants | |
| 86 | +rraymond : added new property long_name | |
| 87 | + : $client->property('long_name'); | |
| 88 | +rraymond : updated demo to display new long_name property | |
| 89 | + | ... | ... |
phpSniff/LICENSE
0 → 100644
| 1 | + GNU LESSER GENERAL PUBLIC LICENSE | |
| 2 | + Version 2.1, February 1999 | |
| 3 | + | |
| 4 | + Copyright (C) 1991, 1999 Free Software Foundation, Inc. | |
| 5 | + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 6 | + Everyone is permitted to copy and distribute verbatim copies | |
| 7 | + of this license document, but changing it is not allowed. | |
| 8 | + | |
| 9 | +[This is the first released version of the Lesser GPL. It also counts | |
| 10 | + as the successor of the GNU Library Public License, version 2, hence | |
| 11 | + the version number 2.1.] | |
| 12 | + | |
| 13 | + Preamble | |
| 14 | + | |
| 15 | + The licenses for most software are designed to take away your | |
| 16 | +freedom to share and change it. By contrast, the GNU General Public | |
| 17 | +Licenses are intended to guarantee your freedom to share and change | |
| 18 | +free software--to make sure the software is free for all its users. | |
| 19 | + | |
| 20 | + This license, the Lesser General Public License, applies to some | |
| 21 | +specially designated software packages--typically libraries--of the | |
| 22 | +Free Software Foundation and other authors who decide to use it. You | |
| 23 | +can use it too, but we suggest you first think carefully about whether | |
| 24 | +this license or the ordinary General Public License is the better | |
| 25 | +strategy to use in any particular case, based on the explanations below. | |
| 26 | + | |
| 27 | + When we speak of free software, we are referring to freedom of use, | |
| 28 | +not price. Our General Public Licenses are designed to make sure that | |
| 29 | +you have the freedom to distribute copies of free software (and charge | |
| 30 | +for this service if you wish); that you receive source code or can get | |
| 31 | +it if you want it; that you can change the software and use pieces of | |
| 32 | +it in new free programs; and that you are informed that you can do | |
| 33 | +these things. | |
| 34 | + | |
| 35 | + To protect your rights, we need to make restrictions that forbid | |
| 36 | +distributors to deny you these rights or to ask you to surrender these | |
| 37 | +rights. These restrictions translate to certain responsibilities for | |
| 38 | +you if you distribute copies of the library or if you modify it. | |
| 39 | + | |
| 40 | + For example, if you distribute copies of the library, whether gratis | |
| 41 | +or for a fee, you must give the recipients all the rights that we gave | |
| 42 | +you. You must make sure that they, too, receive or can get the source | |
| 43 | +code. If you link other code with the library, you must provide | |
| 44 | +complete object files to the recipients, so that they can relink them | |
| 45 | +with the library after making changes to the library and recompiling | |
| 46 | +it. And you must show them these terms so they know their rights. | |
| 47 | + | |
| 48 | + We protect your rights with a two-step method: (1) we copyright the | |
| 49 | +library, and (2) we offer you this license, which gives you legal | |
| 50 | +permission to copy, distribute and/or modify the library. | |
| 51 | + | |
| 52 | + To protect each distributor, we want to make it very clear that | |
| 53 | +there is no warranty for the free library. Also, if the library is | |
| 54 | +modified by someone else and passed on, the recipients should know | |
| 55 | +that what they have is not the original version, so that the original | |
| 56 | +author's reputation will not be affected by problems that might be | |
| 57 | +introduced by others. | |
| 58 | + | |
| 59 | + Finally, software patents pose a constant threat to the existence of | |
| 60 | +any free program. We wish to make sure that a company cannot | |
| 61 | +effectively restrict the users of a free program by obtaining a | |
| 62 | +restrictive license from a patent holder. Therefore, we insist that | |
| 63 | +any patent license obtained for a version of the library must be | |
| 64 | +consistent with the full freedom of use specified in this license. | |
| 65 | + | |
| 66 | + Most GNU software, including some libraries, is covered by the | |
| 67 | +ordinary GNU General Public License. This license, the GNU Lesser | |
| 68 | +General Public License, applies to certain designated libraries, and | |
| 69 | +is quite different from the ordinary General Public License. We use | |
| 70 | +this license for certain libraries in order to permit linking those | |
| 71 | +libraries into non-free programs. | |
| 72 | + | |
| 73 | + When a program is linked with a library, whether statically or using | |
| 74 | +a shared library, the combination of the two is legally speaking a | |
| 75 | +combined work, a derivative of the original library. The ordinary | |
| 76 | +General Public License therefore permits such linking only if the | |
| 77 | +entire combination fits its criteria of freedom. The Lesser General | |
| 78 | +Public License permits more lax criteria for linking other code with | |
| 79 | +the library. | |
| 80 | + | |
| 81 | + We call this license the "Lesser" General Public License because it | |
| 82 | +does Less to protect the user's freedom than the ordinary General | |
| 83 | +Public License. It also provides other free software developers Less | |
| 84 | +of an advantage over competing non-free programs. These disadvantages | |
| 85 | +are the reason we use the ordinary General Public License for many | |
| 86 | +libraries. However, the Lesser license provides advantages in certain | |
| 87 | +special circumstances. | |
| 88 | + | |
| 89 | + For example, on rare occasions, there may be a special need to | |
| 90 | +encourage the widest possible use of a certain library, so that it becomes | |
| 91 | +a de-facto standard. To achieve this, non-free programs must be | |
| 92 | +allowed to use the library. A more frequent case is that a free | |
| 93 | +library does the same job as widely used non-free libraries. In this | |
| 94 | +case, there is little to gain by limiting the free library to free | |
| 95 | +software only, so we use the Lesser General Public License. | |
| 96 | + | |
| 97 | + In other cases, permission to use a particular library in non-free | |
| 98 | +programs enables a greater number of people to use a large body of | |
| 99 | +free software. For example, permission to use the GNU C Library in | |
| 100 | +non-free programs enables many more people to use the whole GNU | |
| 101 | +operating system, as well as its variant, the GNU/Linux operating | |
| 102 | +system. | |
| 103 | + | |
| 104 | + Although the Lesser General Public License is Less protective of the | |
| 105 | +users' freedom, it does ensure that the user of a program that is | |
| 106 | +linked with the Library has the freedom and the wherewithal to run | |
| 107 | +that program using a modified version of the Library. | |
| 108 | + | |
| 109 | + The precise terms and conditions for copying, distribution and | |
| 110 | +modification follow. Pay close attention to the difference between a | |
| 111 | +"work based on the library" and a "work that uses the library". The | |
| 112 | +former contains code derived from the library, whereas the latter must | |
| 113 | +be combined with the library in order to run. | |
| 114 | + | |
| 115 | + GNU LESSER GENERAL PUBLIC LICENSE | |
| 116 | + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
| 117 | + | |
| 118 | + 0. This License Agreement applies to any software library or other | |
| 119 | +program which contains a notice placed by the copyright holder or | |
| 120 | +other authorized party saying it may be distributed under the terms of | |
| 121 | +this Lesser General Public License (also called "this License"). | |
| 122 | +Each licensee is addressed as "you". | |
| 123 | + | |
| 124 | + A "library" means a collection of software functions and/or data | |
| 125 | +prepared so as to be conveniently linked with application programs | |
| 126 | +(which use some of those functions and data) to form executables. | |
| 127 | + | |
| 128 | + The "Library", below, refers to any such software library or work | |
| 129 | +which has been distributed under these terms. A "work based on the | |
| 130 | +Library" means either the Library or any derivative work under | |
| 131 | +copyright law: that is to say, a work containing the Library or a | |
| 132 | +portion of it, either verbatim or with modifications and/or translated | |
| 133 | +straightforwardly into another language. (Hereinafter, translation is | |
| 134 | +included without limitation in the term "modification".) | |
| 135 | + | |
| 136 | + "Source code" for a work means the preferred form of the work for | |
| 137 | +making modifications to it. For a library, complete source code means | |
| 138 | +all the source code for all modules it contains, plus any associated | |
| 139 | +interface definition files, plus the scripts used to control compilation | |
| 140 | +and installation of the library. | |
| 141 | + | |
| 142 | + Activities other than copying, distribution and modification are not | |
| 143 | +covered by this License; they are outside its scope. The act of | |
| 144 | +running a program using the Library is not restricted, and output from | |
| 145 | +such a program is covered only if its contents constitute a work based | |
| 146 | +on the Library (independent of the use of the Library in a tool for | |
| 147 | +writing it). Whether that is true depends on what the Library does | |
| 148 | +and what the program that uses the Library does. | |
| 149 | + | |
| 150 | + 1. You may copy and distribute verbatim copies of the Library's | |
| 151 | +complete source code as you receive it, in any medium, provided that | |
| 152 | +you conspicuously and appropriately publish on each copy an | |
| 153 | +appropriate copyright notice and disclaimer of warranty; keep intact | |
| 154 | +all the notices that refer to this License and to the absence of any | |
| 155 | +warranty; and distribute a copy of this License along with the | |
| 156 | +Library. | |
| 157 | + | |
| 158 | + You may charge a fee for the physical act of transferring a copy, | |
| 159 | +and you may at your option offer warranty protection in exchange for a | |
| 160 | +fee. | |
| 161 | + | |
| 162 | + 2. You may modify your copy or copies of the Library or any portion | |
| 163 | +of it, thus forming a work based on the Library, and copy and | |
| 164 | +distribute such modifications or work under the terms of Section 1 | |
| 165 | +above, provided that you also meet all of these conditions: | |
| 166 | + | |
| 167 | + a) The modified work must itself be a software library. | |
| 168 | + | |
| 169 | + b) You must cause the files modified to carry prominent notices | |
| 170 | + stating that you changed the files and the date of any change. | |
| 171 | + | |
| 172 | + c) You must cause the whole of the work to be licensed at no | |
| 173 | + charge to all third parties under the terms of this License. | |
| 174 | + | |
| 175 | + d) If a facility in the modified Library refers to a function or a | |
| 176 | + table of data to be supplied by an application program that uses | |
| 177 | + the facility, other than as an argument passed when the facility | |
| 178 | + is invoked, then you must make a good faith effort to ensure that, | |
| 179 | + in the event an application does not supply such function or | |
| 180 | + table, the facility still operates, and performs whatever part of | |
| 181 | + its purpose remains meaningful. | |
| 182 | + | |
| 183 | + (For example, a function in a library to compute square roots has | |
| 184 | + a purpose that is entirely well-defined independent of the | |
| 185 | + application. Therefore, Subsection 2d requires that any | |
| 186 | + application-supplied function or table used by this function must | |
| 187 | + be optional: if the application does not supply it, the square | |
| 188 | + root function must still compute square roots.) | |
| 189 | + | |
| 190 | +These requirements apply to the modified work as a whole. If | |
| 191 | +identifiable sections of that work are not derived from the Library, | |
| 192 | +and can be reasonably considered independent and separate works in | |
| 193 | +themselves, then this License, and its terms, do not apply to those | |
| 194 | +sections when you distribute them as separate works. But when you | |
| 195 | +distribute the same sections as part of a whole which is a work based | |
| 196 | +on the Library, the distribution of the whole must be on the terms of | |
| 197 | +this License, whose permissions for other licensees extend to the | |
| 198 | +entire whole, and thus to each and every part regardless of who wrote | |
| 199 | +it. | |
| 200 | + | |
| 201 | +Thus, it is not the intent of this section to claim rights or contest | |
| 202 | +your rights to work written entirely by you; rather, the intent is to | |
| 203 | +exercise the right to control the distribution of derivative or | |
| 204 | +collective works based on the Library. | |
| 205 | + | |
| 206 | +In addition, mere aggregation of another work not based on the Library | |
| 207 | +with the Library (or with a work based on the Library) on a volume of | |
| 208 | +a storage or distribution medium does not bring the other work under | |
| 209 | +the scope of this License. | |
| 210 | + | |
| 211 | + 3. You may opt to apply the terms of the ordinary GNU General Public | |
| 212 | +License instead of this License to a given copy of the Library. To do | |
| 213 | +this, you must alter all the notices that refer to this License, so | |
| 214 | +that they refer to the ordinary GNU General Public License, version 2, | |
| 215 | +instead of to this License. (If a newer version than version 2 of the | |
| 216 | +ordinary GNU General Public License has appeared, then you can specify | |
| 217 | +that version instead if you wish.) Do not make any other change in | |
| 218 | +these notices. | |
| 219 | + | |
| 220 | + Once this change is made in a given copy, it is irreversible for | |
| 221 | +that copy, so the ordinary GNU General Public License applies to all | |
| 222 | +subsequent copies and derivative works made from that copy. | |
| 223 | + | |
| 224 | + This option is useful when you wish to copy part of the code of | |
| 225 | +the Library into a program that is not a library. | |
| 226 | + | |
| 227 | + 4. You may copy and distribute the Library (or a portion or | |
| 228 | +derivative of it, under Section 2) in object code or executable form | |
| 229 | +under the terms of Sections 1 and 2 above provided that you accompany | |
| 230 | +it with the complete corresponding machine-readable source code, which | |
| 231 | +must be distributed under the terms of Sections 1 and 2 above on a | |
| 232 | +medium customarily used for software interchange. | |
| 233 | + | |
| 234 | + If distribution of object code is made by offering access to copy | |
| 235 | +from a designated place, then offering equivalent access to copy the | |
| 236 | +source code from the same place satisfies the requirement to | |
| 237 | +distribute the source code, even though third parties are not | |
| 238 | +compelled to copy the source along with the object code. | |
| 239 | + | |
| 240 | + 5. A program that contains no derivative of any portion of the | |
| 241 | +Library, but is designed to work with the Library by being compiled or | |
| 242 | +linked with it, is called a "work that uses the Library". Such a | |
| 243 | +work, in isolation, is not a derivative work of the Library, and | |
| 244 | +therefore falls outside the scope of this License. | |
| 245 | + | |
| 246 | + However, linking a "work that uses the Library" with the Library | |
| 247 | +creates an executable that is a derivative of the Library (because it | |
| 248 | +contains portions of the Library), rather than a "work that uses the | |
| 249 | +library". The executable is therefore covered by this License. | |
| 250 | +Section 6 states terms for distribution of such executables. | |
| 251 | + | |
| 252 | + When a "work that uses the Library" uses material from a header file | |
| 253 | +that is part of the Library, the object code for the work may be a | |
| 254 | +derivative work of the Library even though the source code is not. | |
| 255 | +Whether this is true is especially significant if the work can be | |
| 256 | +linked without the Library, or if the work is itself a library. The | |
| 257 | +threshold for this to be true is not precisely defined by law. | |
| 258 | + | |
| 259 | + If such an object file uses only numerical parameters, data | |
| 260 | +structure layouts and accessors, and small macros and small inline | |
| 261 | +functions (ten lines or less in length), then the use of the object | |
| 262 | +file is unrestricted, regardless of whether it is legally a derivative | |
| 263 | +work. (Executables containing this object code plus portions of the | |
| 264 | +Library will still fall under Section 6.) | |
| 265 | + | |
| 266 | + Otherwise, if the work is a derivative of the Library, you may | |
| 267 | +distribute the object code for the work under the terms of Section 6. | |
| 268 | +Any executables containing that work also fall under Section 6, | |
| 269 | +whether or not they are linked directly with the Library itself. | |
| 270 | + | |
| 271 | + 6. As an exception to the Sections above, you may also combine or | |
| 272 | +link a "work that uses the Library" with the Library to produce a | |
| 273 | +work containing portions of the Library, and distribute that work | |
| 274 | +under terms of your choice, provided that the terms permit | |
| 275 | +modification of the work for the customer's own use and reverse | |
| 276 | +engineering for debugging such modifications. | |
| 277 | + | |
| 278 | + You must give prominent notice with each copy of the work that the | |
| 279 | +Library is used in it and that the Library and its use are covered by | |
| 280 | +this License. You must supply a copy of this License. If the work | |
| 281 | +during execution displays copyright notices, you must include the | |
| 282 | +copyright notice for the Library among them, as well as a reference | |
| 283 | +directing the user to the copy of this License. Also, you must do one | |
| 284 | +of these things: | |
| 285 | + | |
| 286 | + a) Accompany the work with the complete corresponding | |
| 287 | + machine-readable source code for the Library including whatever | |
| 288 | + changes were used in the work (which must be distributed under | |
| 289 | + Sections 1 and 2 above); and, if the work is an executable linked | |
| 290 | + with the Library, with the complete machine-readable "work that | |
| 291 | + uses the Library", as object code and/or source code, so that the | |
| 292 | + user can modify the Library and then relink to produce a modified | |
| 293 | + executable containing the modified Library. (It is understood | |
| 294 | + that the user who changes the contents of definitions files in the | |
| 295 | + Library will not necessarily be able to recompile the application | |
| 296 | + to use the modified definitions.) | |
| 297 | + | |
| 298 | + b) Use a suitable shared library mechanism for linking with the | |
| 299 | + Library. A suitable mechanism is one that (1) uses at run time a | |
| 300 | + copy of the library already present on the user's computer system, | |
| 301 | + rather than copying library functions into the executable, and (2) | |
| 302 | + will operate properly with a modified version of the library, if | |
| 303 | + the user installs one, as long as the modified version is | |
| 304 | + interface-compatible with the version that the work was made with. | |
| 305 | + | |
| 306 | + c) Accompany the work with a written offer, valid for at | |
| 307 | + least three years, to give the same user the materials | |
| 308 | + specified in Subsection 6a, above, for a charge no more | |
| 309 | + than the cost of performing this distribution. | |
| 310 | + | |
| 311 | + d) If distribution of the work is made by offering access to copy | |
| 312 | + from a designated place, offer equivalent access to copy the above | |
| 313 | + specified materials from the same place. | |
| 314 | + | |
| 315 | + e) Verify that the user has already received a copy of these | |
| 316 | + materials or that you have already sent this user a copy. | |
| 317 | + | |
| 318 | + For an executable, the required form of the "work that uses the | |
| 319 | +Library" must include any data and utility programs needed for | |
| 320 | +reproducing the executable from it. However, as a special exception, | |
| 321 | +the materials to be distributed need not include anything that is | |
| 322 | +normally distributed (in either source or binary form) with the major | |
| 323 | +components (compiler, kernel, and so on) of the operating system on | |
| 324 | +which the executable runs, unless that component itself accompanies | |
| 325 | +the executable. | |
| 326 | + | |
| 327 | + It may happen that this requirement contradicts the license | |
| 328 | +restrictions of other proprietary libraries that do not normally | |
| 329 | +accompany the operating system. Such a contradiction means you cannot | |
| 330 | +use both them and the Library together in an executable that you | |
| 331 | +distribute. | |
| 332 | + | |
| 333 | + 7. You may place library facilities that are a work based on the | |
| 334 | +Library side-by-side in a single library together with other library | |
| 335 | +facilities not covered by this License, and distribute such a combined | |
| 336 | +library, provided that the separate distribution of the work based on | |
| 337 | +the Library and of the other library facilities is otherwise | |
| 338 | +permitted, and provided that you do these two things: | |
| 339 | + | |
| 340 | + a) Accompany the combined library with a copy of the same work | |
| 341 | + based on the Library, uncombined with any other library | |
| 342 | + facilities. This must be distributed under the terms of the | |
| 343 | + Sections above. | |
| 344 | + | |
| 345 | + b) Give prominent notice with the combined library of the fact | |
| 346 | + that part of it is a work based on the Library, and explaining | |
| 347 | + where to find the accompanying uncombined form of the same work. | |
| 348 | + | |
| 349 | + 8. You may not copy, modify, sublicense, link with, or distribute | |
| 350 | +the Library except as expressly provided under this License. Any | |
| 351 | +attempt otherwise to copy, modify, sublicense, link with, or | |
| 352 | +distribute the Library is void, and will automatically terminate your | |
| 353 | +rights under this License. However, parties who have received copies, | |
| 354 | +or rights, from you under this License will not have their licenses | |
| 355 | +terminated so long as such parties remain in full compliance. | |
| 356 | + | |
| 357 | + 9. You are not required to accept this License, since you have not | |
| 358 | +signed it. However, nothing else grants you permission to modify or | |
| 359 | +distribute the Library or its derivative works. These actions are | |
| 360 | +prohibited by law if you do not accept this License. Therefore, by | |
| 361 | +modifying or distributing the Library (or any work based on the | |
| 362 | +Library), you indicate your acceptance of this License to do so, and | |
| 363 | +all its terms and conditions for copying, distributing or modifying | |
| 364 | +the Library or works based on it. | |
| 365 | + | |
| 366 | + 10. Each time you redistribute the Library (or any work based on the | |
| 367 | +Library), the recipient automatically receives a license from the | |
| 368 | +original licensor to copy, distribute, link with or modify the Library | |
| 369 | +subject to these terms and conditions. You may not impose any further | |
| 370 | +restrictions on the recipients' exercise of the rights granted herein. | |
| 371 | +You are not responsible for enforcing compliance by third parties with | |
| 372 | +this License. | |
| 373 | + | |
| 374 | + 11. If, as a consequence of a court judgment or allegation of patent | |
| 375 | +infringement or for any other reason (not limited to patent issues), | |
| 376 | +conditions are imposed on you (whether by court order, agreement or | |
| 377 | +otherwise) that contradict the conditions of this License, they do not | |
| 378 | +excuse you from the conditions of this License. If you cannot | |
| 379 | +distribute so as to satisfy simultaneously your obligations under this | |
| 380 | +License and any other pertinent obligations, then as a consequence you | |
| 381 | +may not distribute the Library at all. For example, if a patent | |
| 382 | +license would not permit royalty-free redistribution of the Library by | |
| 383 | +all those who receive copies directly or indirectly through you, then | |
| 384 | +the only way you could satisfy both it and this License would be to | |
| 385 | +refrain entirely from distribution of the Library. | |
| 386 | + | |
| 387 | +If any portion of this section is held invalid or unenforceable under any | |
| 388 | +particular circumstance, the balance of the section is intended to apply, | |
| 389 | +and the section as a whole is intended to apply in other circumstances. | |
| 390 | + | |
| 391 | +It is not the purpose of this section to induce you to infringe any | |
| 392 | +patents or other property right claims or to contest validity of any | |
| 393 | +such claims; this section has the sole purpose of protecting the | |
| 394 | +integrity of the free software distribution system which is | |
| 395 | +implemented by public license practices. Many people have made | |
| 396 | +generous contributions to the wide range of software distributed | |
| 397 | +through that system in reliance on consistent application of that | |
| 398 | +system; it is up to the author/donor to decide if he or she is willing | |
| 399 | +to distribute software through any other system and a licensee cannot | |
| 400 | +impose that choice. | |
| 401 | + | |
| 402 | +This section is intended to make thoroughly clear what is believed to | |
| 403 | +be a consequence of the rest of this License. | |
| 404 | + | |
| 405 | + 12. If the distribution and/or use of the Library is restricted in | |
| 406 | +certain countries either by patents or by copyrighted interfaces, the | |
| 407 | +original copyright holder who places the Library under this License may add | |
| 408 | +an explicit geographical distribution limitation excluding those countries, | |
| 409 | +so that distribution is permitted only in or among countries not thus | |
| 410 | +excluded. In such case, this License incorporates the limitation as if | |
| 411 | +written in the body of this License. | |
| 412 | + | |
| 413 | + 13. The Free Software Foundation may publish revised and/or new | |
| 414 | +versions of the Lesser General Public License from time to time. | |
| 415 | +Such new versions will be similar in spirit to the present version, | |
| 416 | +but may differ in detail to address new problems or concerns. | |
| 417 | + | |
| 418 | +Each version is given a distinguishing version number. If the Library | |
| 419 | +specifies a version number of this License which applies to it and | |
| 420 | +"any later version", you have the option of following the terms and | |
| 421 | +conditions either of that version or of any later version published by | |
| 422 | +the Free Software Foundation. If the Library does not specify a | |
| 423 | +license version number, you may choose any version ever published by | |
| 424 | +the Free Software Foundation. | |
| 425 | + | |
| 426 | + 14. If you wish to incorporate parts of the Library into other free | |
| 427 | +programs whose distribution conditions are incompatible with these, | |
| 428 | +write to the author to ask for permission. For software which is | |
| 429 | +copyrighted by the Free Software Foundation, write to the Free | |
| 430 | +Software Foundation; we sometimes make exceptions for this. Our | |
| 431 | +decision will be guided by the two goals of preserving the free status | |
| 432 | +of all derivatives of our free software and of promoting the sharing | |
| 433 | +and reuse of software generally. | |
| 434 | + | |
| 435 | + NO WARRANTY | |
| 436 | + | |
| 437 | + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO | |
| 438 | +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. | |
| 439 | +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR | |
| 440 | +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY | |
| 441 | +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE | |
| 442 | +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 443 | +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE | |
| 444 | +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME | |
| 445 | +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. | |
| 446 | + | |
| 447 | + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN | |
| 448 | +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY | |
| 449 | +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU | |
| 450 | +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR | |
| 451 | +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE | |
| 452 | +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING | |
| 453 | +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A | |
| 454 | +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF | |
| 455 | +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH | |
| 456 | +DAMAGES. | |
| 457 | + | |
| 458 | + END OF TERMS AND CONDITIONS | |
| 459 | + | |
| 460 | + | ... | ... |
phpSniff/index.php
0 → 100644
| 1 | +<?php | |
| 2 | +error_reporting(E_ALL); | |
| 3 | +/******************************************************************************* | |
| 4 | + $Id: index.php,v 1.10 2002/09/13 21:40:34 epsilon7 Exp $ | |
| 5 | + | |
| 6 | + phpSniff: HTTP_USER_AGENT Client Sniffer for PHP | |
| 7 | + Copyright (C) 2001 Roger Raymond ~ epsilon7@users.sourceforge.net | |
| 8 | + | |
| 9 | + This library is free software; you can redistribute it and/or | |
| 10 | + modify it under the terms of the GNU Lesser General Public | |
| 11 | + License as published by the Free Software Foundation; either | |
| 12 | + version 2.1 of the License, or (at your option) any later version. | |
| 13 | + | |
| 14 | + This library is distributed in the hope that it will be useful, | |
| 15 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 17 | + Lesser General Public License for more details. | |
| 18 | + | |
| 19 | + You should have received a copy of the GNU Lesser General Public | |
| 20 | + License along with this library; if not, write to the Free Software | |
| 21 | + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 | +*******************************************************************************/ | |
| 23 | + | |
| 24 | +// email me the user agent strings | |
| 25 | +// i only do this so i can see what people are using | |
| 26 | +// so that i can continually update the code | |
| 27 | +//mail('roger@asphyxia.com','[phpsniff-user-agent] '.$_SERVER['HTTP_USER_AGENT'],$_SERVER['HTTP_USER_AGENT'],"From: epsilon7\r\n"); | |
| 28 | + | |
| 29 | +require_once('phpSniff.class.php'); | |
| 30 | +require_once('phpTimer.class.php'); | |
| 31 | + | |
| 32 | +// initialize some vars | |
| 33 | +if(!isset($UA)) $UA = ''; | |
| 34 | +if(!isset($cc)) $cc = ''; | |
| 35 | +if(!isset($dl)) $dl = ''; | |
| 36 | +if(!isset($am)) $am = ''; | |
| 37 | + | |
| 38 | +$timer = new phpTimer(); | |
| 39 | +$timer->start('main'); | |
| 40 | +$timer->start('client1'); | |
| 41 | +$sniffer_settings = array('check_cookies'=>$cc, | |
| 42 | + 'default_language'=>$dl, | |
| 43 | + 'allow_masquerading'=>$am); | |
| 44 | +$client = new phpSniff($UA,$sniffer_settings); | |
| 45 | + | |
| 46 | +$timer->stop('client1'); | |
| 47 | + | |
| 48 | +$c1_bg = '#cccccc'; | |
| 49 | +$c2_bg = '#ffffff'; | |
| 50 | +$c3_bg = '#000000'; | |
| 51 | + | |
| 52 | +function makeSelectOption ($link,$text) | |
| 53 | +{ global $client; | |
| 54 | + $o = "<option value=\"$link\""; | |
| 55 | + $o .= $client->property('ua') == strtolower($link) ? ' selected' : ''; | |
| 56 | + $o .= ">$text</option>"; | |
| 57 | + print $o; | |
| 58 | +} | |
| 59 | + | |
| 60 | +function example ($search,$output) | |
| 61 | +{ global $c2_bg, $c1_bg, $client; | |
| 62 | + ?> | |
| 63 | + <tr> | |
| 64 | + <td bgcolor="<?php print $c1_bg; ?>"><?php print $search; ?></td> | |
| 65 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $output ? 'true' : 'false'; ?></td> | |
| 66 | + </tr> | |
| 67 | + <?php | |
| 68 | +} | |
| 69 | + | |
| 70 | +function is ($search) | |
| 71 | +{ global $client; | |
| 72 | + example($search,$client->is($search)); | |
| 73 | +} | |
| 74 | +function language_is ($search) | |
| 75 | +{ global $client; | |
| 76 | + example($search,$client->language_is($search)); | |
| 77 | +} | |
| 78 | + | |
| 79 | +function browser_is ($search) | |
| 80 | +{ global $client; | |
| 81 | + example($search,$client->browser_is($search)); | |
| 82 | +} | |
| 83 | + | |
| 84 | +function has_feature ($feature) | |
| 85 | +{ global $client; | |
| 86 | + example($feature,$client->has_feature($feature)); | |
| 87 | +} | |
| 88 | + | |
| 89 | +function has_quirk ($quirk) | |
| 90 | +{ global $client; | |
| 91 | + example($quirk,$client->has_quirk($quirk)); | |
| 92 | +} | |
| 93 | + | |
| 94 | +?> | |
| 95 | +<html> | |
| 96 | +<head><title>phpSniff <?php print $client->_version; ?> on SourceForge</title></head> | |
| 97 | +<body> | |
| 98 | +<?php | |
| 99 | +// fix for cgi versions of php ~ 6/28/2001 ~ RR | |
| 100 | +$script_path = getenv('PATH_INFO') ? getenv('PATH_INFO') : getenv('SCRIPT_NAME'); | |
| 101 | +?> | |
| 102 | +<form name="user_agent_string" method="get" action="<?php print $script_path; ?>"> | |
| 103 | +<p><a href="http://sourceforge.net/project/showfiles.php?group_id=26044">Download</a> | | |
| 104 | +<a href="http://sourceforge.net/projects/phpsniff/">SourceForge Project Page</a> | | |
| 105 | +<a href="index.phps">Index Source Code</a> | | |
| 106 | +<a href="phpSniff.core.phps">phpSniff.core Source Code</a> | | |
| 107 | +<a href="phpSniff.class.phps">phpSniff.class Source Code</a> | | |
| 108 | +<a href="CHANGES">CHANGE LOG</a> | |
| 109 | +</p> | |
| 110 | +<table border="0" cellpadding="3" cellspacing="0" bgcolor="<?php print $c3_bg; ?>" width="100%"> | |
| 111 | +<tr> | |
| 112 | +<td align="left" valign="top"> | |
| 113 | + <font color="#ffffff"><b>CURRENT BROWSER INFORMATION</b></font><br> | |
| 114 | + <font color="#ffffff" size="-1"> | |
| 115 | + <?php printf('phpSniff version : %s - php version : %s</font>',$client->_version, PHP_VERSION); ?> | |
| 116 | + </font> | |
| 117 | +</td> | |
| 118 | +<td align="right" valign="top"> | |
| 119 | + <font color="#ffffff"> | |
| 120 | + <select name="UA"> | |
| 121 | + <?php | |
| 122 | + makeSelectOption('','Your current browser'); | |
| 123 | + include('user_agent.inc'); | |
| 124 | + while(list(,$v) = each($user_agent)) | |
| 125 | + { makeSelectOption($v,$v); | |
| 126 | + } | |
| 127 | + ?> | |
| 128 | + </select><br> | |
| 129 | + <input type="checkbox" name="cc" <?php if($client->_check_cookies) print 'checked'; ?> > Check For Cookies | |
| 130 | + <input type="checkbox" name="am" <?php if($client->_allow_masquerading) print 'checked'; ?> > Allow Masquerading | |
| 131 | + <input type="text" name="dl" size="7" value="<?php print $client->_default_language; ?>"> Default Language | |
| 132 | + <input type="submit" name="submit" value="submit"> | |
| 133 | + </font> | |
| 134 | +</td> | |
| 135 | +</tr> | |
| 136 | +</table> | |
| 137 | + | |
| 138 | +<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="<?php print $c3_bg; ?>"><tr> | |
| 139 | +<td align="right" valign="top"> | |
| 140 | + <table border="0" cellpadding="3" cellspacing="1" width="100%"> | |
| 141 | + <tr><td colspan="2" nowrap><font color="#ffcc00">Current Configuration</font></td></tr> | |
| 142 | + <tr> | |
| 143 | + <td colspan="2"bgcolor="<?php print $c1_bg; ?>"><b>regex used to search HTTP_USER_AGENT string</b><br> | |
| 144 | + preg_match_all("<?php print $client->_browser_regex; ?>");</td> | |
| 145 | + </tr> | |
| 146 | + <tr> | |
| 147 | + <td bgcolor="<?php print $c1_bg; ?>">$_check_cookies</td> | |
| 148 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->_check_cookies ? 'true' : 'false'; ?></td> | |
| 149 | + </tr> | |
| 150 | + <tr> | |
| 151 | + <td bgcolor="<?php print $c1_bg; ?>">$_default_language</td> | |
| 152 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->_default_language; ?></td> | |
| 153 | + </tr> | |
| 154 | + <tr> | |
| 155 | + <td bgcolor="<?php print $c1_bg; ?>">$_allow_masquerading</td> | |
| 156 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->_allow_masquerading ? 'true' : 'false'; ?></td> | |
| 157 | + </tr> | |
| 158 | + | |
| 159 | + <tr><td colspan="2" nowrap><font color="#ffcc00">$client->property(<i>property_name</i>);</font></td></tr> | |
| 160 | + <tr> | |
| 161 | + <td bgcolor="<?php print $c1_bg; ?>"><b>property_name</b></td> | |
| 162 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><b>return value</b></td> | |
| 163 | + </tr> | |
| 164 | + <tr> | |
| 165 | + <td bgcolor="<?php print $c1_bg; ?>">ua</td> | |
| 166 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->get_property('ua');?></td> | |
| 167 | + </tr> | |
| 168 | + <tr> | |
| 169 | + <td bgcolor="<?php print $c1_bg; ?>">browser</td> | |
| 170 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->property('browser'); ?></td> | |
| 171 | + </tr> | |
| 172 | + <tr> | |
| 173 | + <td bgcolor="<?php print $c1_bg; ?>">long_name</td> | |
| 174 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->property('long_name');?></td> | |
| 175 | + </tr> | |
| 176 | + <tr> | |
| 177 | + <td bgcolor="<?php print $c1_bg; ?>">version</td> | |
| 178 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->property('version');?></td> | |
| 179 | + </tr> | |
| 180 | + <tr> | |
| 181 | + <td bgcolor="<?php print $c1_bg; ?>">maj_ver</td> | |
| 182 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->property('maj_ver');?></td> | |
| 183 | + </tr> | |
| 184 | + <tr> | |
| 185 | + <td bgcolor="<?php print $c1_bg; ?>">min_ver</td> | |
| 186 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->property('min_ver');?></td> | |
| 187 | + </tr> | |
| 188 | + <tr> | |
| 189 | + <td bgcolor="<?php print $c1_bg; ?>">letter_ver</td> | |
| 190 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->property('letter_ver');?></td> | |
| 191 | + </tr> | |
| 192 | + <tr> | |
| 193 | + <td bgcolor="<?php print $c1_bg; ?>">javascript</td> | |
| 194 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->property('javascript');?></td> | |
| 195 | + </tr> | |
| 196 | + <tr> | |
| 197 | + <td bgcolor="<?php print $c1_bg; ?>">platform</td> | |
| 198 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->property('platform');?></td> | |
| 199 | + </tr> | |
| 200 | + <tr> | |
| 201 | + <td bgcolor="<?php print $c1_bg; ?>">os</td> | |
| 202 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->property('os');?></td> | |
| 203 | + </tr> | |
| 204 | + <tr> | |
| 205 | + <td bgcolor="<?php print $c1_bg; ?>">session cookies</td> | |
| 206 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print ($ssc=$client->property('ss_cookies'))=='Unknown'?$ssc:($ssc?'true':'false');?></td> | |
| 207 | + | |
| 208 | + </tr> | |
| 209 | + <tr> | |
| 210 | + <td bgcolor="<?php print $c1_bg; ?>">stored cookies</td> | |
| 211 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print ($stc=$client->property('st_cookies'))=='Unknown'?$stc:($stc?'true':'false');?></td> | |
| 212 | + </tr> | |
| 213 | + <tr> | |
| 214 | + <td bgcolor="<?php print $c1_bg; ?>">ip</td> | |
| 215 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->property('ip');?></td> | |
| 216 | + </tr> | |
| 217 | + <tr> | |
| 218 | + <td bgcolor="<?php print $c1_bg; ?>">language</td> | |
| 219 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->property('language');?></td> | |
| 220 | + </tr> | |
| 221 | + <tr> | |
| 222 | + <td bgcolor="<?php print $c1_bg; ?>">gecko</td> | |
| 223 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->property('gecko');?></td> | |
| 224 | + </tr> | |
| 225 | + <tr> | |
| 226 | + <td bgcolor="<?php print $c1_bg; ?>">gecko_ver</td> | |
| 227 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>"><?php print $client->property('gecko_ver');?></td> | |
| 228 | + </tr> | |
| 229 | + </table> | |
| 230 | +</td> | |
| 231 | +<td align="left" valign="top"> | |
| 232 | + <table border="0" cellpadding="3" cellspacing="1" width="100%"> | |
| 233 | + <tr><td colspan="2" nowrap><font color="#ffcc00"> </font></td></tr> | |
| 234 | + <tr> | |
| 235 | + <td bgcolor="<?php print $c1_bg; ?>" nowrap><b>search_phrase</b></td> | |
| 236 | + <td width="100%" bgcolor="<?php print $c2_bg; ?>" nowrap><b>return boolean</b></td> | |
| 237 | + </tr> | |
| 238 | + | |
| 239 | + <!-- feature search --> | |
| 240 | + <tr> | |
| 241 | + <td bgcolor="<?php print $c3_bg; ?>" colspan="2" nowrap><font color="#ffcc00">$client->has_feature(<i>feature</i>)</font></td> | |
| 242 | + </tr> | |
| 243 | + <?php | |
| 244 | + has_feature('html'); | |
| 245 | + has_feature('images'); | |
| 246 | + has_feature('frames'); | |
| 247 | + has_feature('tables'); | |
| 248 | + has_feature('java'); | |
| 249 | + has_feature('plugins'); | |
| 250 | + has_feature('css2'); | |
| 251 | + has_feature('css1'); | |
| 252 | + has_feature('iframes'); | |
| 253 | + has_feature('xml'); | |
| 254 | + has_feature('dom'); | |
| 255 | + has_feature('hdml'); | |
| 256 | + has_feature('wml'); | |
| 257 | + ?> | |
| 258 | + <!-- quirks --> | |
| 259 | + <tr> | |
| 260 | + <td bgcolor="<?php print $c3_bg; ?>" colspan="2" nowrap><font color="#ffcc00">$client->has_quirk(<i>quirk</i>)</font></td> | |
| 261 | + </tr> | |
| 262 | + <?php | |
| 263 | + has_quirk('must_cache_forms'); | |
| 264 | + has_quirk('avoid_popup_windows'); | |
| 265 | + has_quirk('cache_ssl_downloads'); | |
| 266 | + has_quirk('break_disposition_header'); | |
| 267 | + has_quirk('empty_file_input_value'); | |
| 268 | + has_quirk('scrollbar_in_way'); | |
| 269 | + ?> | |
| 270 | + <!-- browser_is search --> | |
| 271 | + <tr> | |
| 272 | + <td bgcolor="<?php print $c3_bg; ?>" colspan="2" nowrap><font color="#ffcc00">$client->browser_is(<i>browser</i>)</font></td> | |
| 273 | + </tr> | |
| 274 | + <?php | |
| 275 | + browser_is('aol'); | |
| 276 | + browser_is('ie6up'); | |
| 277 | + browser_is('ns4up'); | |
| 278 | + ?> | |
| 279 | + <!-- language_is search --> | |
| 280 | + <tr> | |
| 281 | + <td bgcolor="<?php print $c3_bg; ?>" colspan="2" nowrap><font color="#ffcc00">$client->language_is(<i>language</i>)</font></td> | |
| 282 | + </tr> | |
| 283 | + <?php | |
| 284 | + language_is('en'); | |
| 285 | + language_is('en-us'); | |
| 286 | + language_is('fr-ca'); | |
| 287 | + ?> | |
| 288 | + <!-- old style search --> | |
| 289 | + <tr> | |
| 290 | + <td bgcolor="<?php print $c3_bg; ?>" colspan="2" nowrap><font color="#ffcc00">$client->is(<i>search</i>)</font></td> | |
| 291 | + </tr> | |
| 292 | + <?php | |
| 293 | + is('b:ns4up'); | |
| 294 | + is('l:en-us'); | |
| 295 | + ?> | |
| 296 | + </table> | |
| 297 | +</td></tr></table> | |
| 298 | +</form> | |
| 299 | +<p> | |
| 300 | +<?php | |
| 301 | +$timer->stop('main'); | |
| 302 | +printf("<pre>\n". | |
| 303 | + "client instantiation time : %s\n" . | |
| 304 | + "page execution time : %s\n" . | |
| 305 | + "</pre>" , | |
| 306 | + $timer->get_current('client1'), | |
| 307 | + $timer->get_current('main')); | |
| 308 | +?> | |
| 309 | +</p> | |
| 310 | +<?php | |
| 311 | +print ('<p align="left"><font size="-2">_______________________________<br>'); | |
| 312 | +print ('Copyleft 2001-2002 PHyX8 Studio<br></font></p>'); | |
| 313 | +?> | |
| 314 | +<!A href="http://sourceforge.net"> <!IMG src="http://sourceforge.net/sflogo.php?group_id=26044" width="88" height="31" border="0" alt="SourceForge Logo"></A> | |
| 315 | +</body> | |
| 316 | +</html> | |
| 0 | 317 | \ No newline at end of file | ... | ... |
phpSniff/phpSniff.class.php
0 → 100644
| 1 | +<?php | |
| 2 | +/******************************************************************************* | |
| 3 | + $Id: phpSniff.class.php,v 1.11 2002/09/13 21:40:34 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 | +require_once('phpSniff.core.php'); | |
| 23 | + | |
| 24 | +class phpSniff extends phpSniff_core | |
| 25 | +{ var $_version = '2.1.1'; | |
| 26 | + /** | |
| 27 | + * Configuration | |
| 28 | + * | |
| 29 | + * $_temp_file_path | |
| 30 | + * default : /tmp/ | |
| 31 | + * desc : directory writable by the server to store cookie check files. | |
| 32 | + * : trailing slash is needed. only used if you use the check cookie routine | |
| 33 | + * | |
| 34 | + * $_check_cookies | |
| 35 | + * default : null | |
| 36 | + * desc : Allow for the script to redirect the browser in order | |
| 37 | + * : to check for cookies. In order for this to work, this | |
| 38 | + * : class must be instantiated before any headers are sent. | |
| 39 | + * | |
| 40 | + * $_default_language | |
| 41 | + * default : en-us | |
| 42 | + * desc : language to report as if no languages are found | |
| 43 | + * | |
| 44 | + * $_allow_masquerading | |
| 45 | + * default : null | |
| 46 | + * desc : Allow for browser to Masquerade as another. | |
| 47 | + * : (ie: Opera identifies as MSIE 5.0) | |
| 48 | + * | |
| 49 | + * $_browsers | |
| 50 | + * desc : 2D Array of browsers we wish to search for | |
| 51 | + * : in key => value pairs. | |
| 52 | + * : key = browser to search for [as in HTTP_USER_AGENT] | |
| 53 | + * : value = value to return as 'browser' property | |
| 54 | + * | |
| 55 | + * $_javascript_versions | |
| 56 | + * desc : 2D Array of javascript version supported by which browser | |
| 57 | + * : in key => value pairs. | |
| 58 | + * : key = javascript version | |
| 59 | + * : value = search parameter for browsers that support the | |
| 60 | + * : javascript version listed in the key (comma delimited) | |
| 61 | + * : note: the search parameters rely on the values | |
| 62 | + * : set in the $_browsers array | |
| 63 | + * | |
| 64 | + * $_browser_features | |
| 65 | + * desc : 2D Array of browser features supported by which browser | |
| 66 | + * : in key => value pairs. | |
| 67 | + * : key = feature | |
| 68 | + * : value = search parameter for browsers that support the | |
| 69 | + * : feature listed in the key (comma delimited) | |
| 70 | + * : note: the search parameters rely on the values | |
| 71 | + * : set in the $_browsers array | |
| 72 | + * | |
| 73 | + * $_browser_quirks | |
| 74 | + * desc : 2D Array of browser quirks present in which browser | |
| 75 | + * : in key => value pairs. | |
| 76 | + * : key = quirk | |
| 77 | + * : value = search parameter for browsers that feature the | |
| 78 | + * : quirk listed in the key (comma delimited) | |
| 79 | + * : note: the search parameters rely on the values | |
| 80 | + * : set in the $_browsers array | |
| 81 | + **/ | |
| 82 | + | |
| 83 | + var $_temp_file_path = '/tmp/'; // with trailing slash | |
| 84 | + var $_check_cookies = NULL; | |
| 85 | + var $_default_language = 'en-us'; | |
| 86 | + var $_allow_masquerading = NULL; | |
| 87 | + var $_php_version = ''; | |
| 88 | + | |
| 89 | + var $_browsers = array( | |
| 90 | + 'microsoft internet explorer' => 'ie', | |
| 91 | + 'msie' => 'ie', | |
| 92 | + 'netscape6' => 'ns', | |
| 93 | + 'netscape' => 'ns', | |
| 94 | + 'mozilla' => 'moz', | |
| 95 | + 'opera' => 'op', | |
| 96 | + 'konqueror' => 'konq', | |
| 97 | + 'icab' => 'icab', | |
| 98 | + 'lynx' => 'lynx', | |
| 99 | + 'links' => 'links', | |
| 100 | + 'ncsa mosaic' => 'mosaic', | |
| 101 | + 'amaya' => 'amaya', | |
| 102 | + 'omniweb' => 'ow', | |
| 103 | + 'hotjava' => 'hj' | |
| 104 | + ); | |
| 105 | + | |
| 106 | + var $_javascript_versions = array( | |
| 107 | + '1.5' => 'IE5.5UP,NS5UP', | |
| 108 | + '1.4' => '', | |
| 109 | + '1.3' => 'NS4.05UP,OP5UP,IE5UP', | |
| 110 | + '1.2' => 'NS4UP,IE4UP', | |
| 111 | + '1.1' => 'NS3UP,OP,KQ', | |
| 112 | + '1.0' => 'NS2UP,IE3UP', | |
| 113 | + '0' => 'LN,LX,HJ' | |
| 114 | + ); | |
| 115 | + | |
| 116 | + var $_browser_features = array( | |
| 117 | + /** | |
| 118 | + * the following are true by default | |
| 119 | + * (see phpSniff.core.php $_feature_set array) | |
| 120 | + * browsers listed here will be set to false | |
| 121 | + **/ | |
| 122 | + 'html' => '', | |
| 123 | + 'images' => 'LN,LX', | |
| 124 | + 'frames' => 'LN,LX', | |
| 125 | + 'tables' => '', | |
| 126 | + 'java' => 'OP3,LX,LN,NS1,MO,IE1,IE2', | |
| 127 | + 'plugins' => 'IE1,IE2,LX,LN', | |
| 128 | + /** | |
| 129 | + * the following are false by default | |
| 130 | + * (see phpSniff.core.php $_feature_set array) | |
| 131 | + * browsers listed here will be set to true | |
| 132 | + **/ | |
| 133 | + 'css2' => 'NS5UP,IE5UP', | |
| 134 | + 'css1' => 'NS4UP,IE4UP', | |
| 135 | + 'iframes' => 'IE3UP,NS5UP', | |
| 136 | + 'xml' => 'IE5UP,NS5UP', | |
| 137 | + 'dom' => 'IE5UP,NS5UP', | |
| 138 | + 'hdml' => '', | |
| 139 | + 'wml' => '' | |
| 140 | + ); | |
| 141 | + | |
| 142 | + var $_browser_quirks = array( | |
| 143 | + 'must_cache_forms' => 'NS', | |
| 144 | + 'avoid_popup_windows' => 'IE3,LX,LN', | |
| 145 | + 'cache_ssl_downloads' => 'IE', | |
| 146 | + 'break_disposition_header' => 'IE5.5', | |
| 147 | + 'empty_file_input_value' => 'KQ', | |
| 148 | + 'scrollbar_in_way' => 'IE6' | |
| 149 | + ); | |
| 150 | + | |
| 151 | + function phpSniff($UA='',$settings = true) | |
| 152 | + { // populate the HTTP_USER_AGENT string | |
| 153 | + // 20020425 :: rraymond | |
| 154 | + // routine for easier configuration of the client at runtime | |
| 155 | + if(is_array($settings)) { | |
| 156 | + $run = true; | |
| 157 | + extract($settings); | |
| 158 | + $this->_check_cookies = $check_cookies; | |
| 159 | + $this->_default_language = $default_language; | |
| 160 | + $this->_allow_masquerading = $allow_masquerading; | |
| 161 | + } else { | |
| 162 | + // for backwards compatibility with 2.0.x series | |
| 163 | + $run = $settings; | |
| 164 | + } | |
| 165 | + | |
| 166 | + // 20020425 :: besfred | |
| 167 | + if(empty($UA)) $UA = getenv('HTTP_USER_AGENT'); | |
| 168 | + if(empty($UA)) { | |
| 169 | + $pv = explode(".", PHP_VERSION); | |
| 170 | + $UA = ( $pv[0] > 3 && $pv[1] > 0 ) ? $_SERVER['HTTP_USER_AGENT'] : $HTTP_SERVER_VARS['HTTP_USER_AGENT']; | |
| 171 | + } | |
| 172 | + // 20020910 :: rraymond | |
| 173 | + if(empty($UA)) return false; | |
| 174 | + | |
| 175 | + $this->_set_browser('ua',$UA); | |
| 176 | + if($run) $this->init(); | |
| 177 | + } | |
| 178 | +} | |
| 179 | +?> | |
| 0 | 180 | \ No newline at end of file | ... | ... |
phpSniff/phpSniff.core.php
0 → 100644
| 1 | +<?php | |
| 2 | +/******************************************************************************* | |
| 3 | + $Id: phpSniff.core.php,v 1.8 2002/09/13 21:49:43 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 | + | |
| 23 | +class phpSniff_core | |
| 24 | +{ // initialize some vars | |
| 25 | + var $_browser_info = array( | |
| 26 | + 'ua' => '', | |
| 27 | + 'browser' => 'Unknown', | |
| 28 | + 'version' => 0, | |
| 29 | + 'maj_ver' => 0, | |
| 30 | + 'min_ver' => 0, | |
| 31 | + 'letter_ver' => '', | |
| 32 | + 'javascript' => '0.0', | |
| 33 | + 'platform' => 'Unknown', | |
| 34 | + 'os' => 'Unknown', | |
| 35 | + 'ip' => 'Unknown', | |
| 36 | + 'cookies' => 'Unknown', // remains for backwards compatability | |
| 37 | + 'ss_cookies' => 'Unknown', | |
| 38 | + 'st_cookies' => 'Unknown', | |
| 39 | + 'language' => '', | |
| 40 | + 'long_name' => '', | |
| 41 | + 'gecko' => '', | |
| 42 | + 'gecko_ver' => '' | |
| 43 | + ); | |
| 44 | + | |
| 45 | + var $_feature_set = array( | |
| 46 | + 'html' => true, | |
| 47 | + 'images' => true, | |
| 48 | + 'frames' => true, | |
| 49 | + 'tables' => true, | |
| 50 | + 'java' => true, | |
| 51 | + 'plugins' => true, | |
| 52 | + 'iframes' => false, | |
| 53 | + 'css2' => false, | |
| 54 | + 'css1' => false, | |
| 55 | + 'xml' => false, | |
| 56 | + 'dom' => false, | |
| 57 | + 'wml' => false, | |
| 58 | + 'hdml' => false | |
| 59 | + ); | |
| 60 | + | |
| 61 | + var $_quirks = array( | |
| 62 | + 'must_cache_forms' => false, | |
| 63 | + 'avoid_popup_windows' => false, | |
| 64 | + 'cache_ssl_downloads' => false, | |
| 65 | + 'break_disposition_header' => false, | |
| 66 | + 'empty_file_input_value' => false, | |
| 67 | + 'scrollbar_in_way' => false | |
| 68 | + ); | |
| 69 | + | |
| 70 | + var $_get_languages_ran_once = false; | |
| 71 | + var $_browser_search_regex = '([a-z]+)([0-9]*)([0-9.]*)(up|dn)?'; | |
| 72 | + var $_language_search_regex = '([a-z-]{2,})'; | |
| 73 | + | |
| 74 | + /** | |
| 75 | + * init | |
| 76 | + * this method starts the madness | |
| 77 | + **/ | |
| 78 | + function init () | |
| 79 | + { | |
| 80 | + // collect the ip | |
| 81 | + $this->_get_ip(); | |
| 82 | + // run the cookie check routine first | |
| 83 | + // [note: method only runs if allowed] | |
| 84 | + $this->_test_cookies(); | |
| 85 | + // rip the user agent to pieces | |
| 86 | + $this->_get_browser_info(); | |
| 87 | + // look for other languages | |
| 88 | + $this->_get_languages(); | |
| 89 | + // establish the operating platform | |
| 90 | + $this->_get_os_info(); | |
| 91 | + // determine javascript version | |
| 92 | + $this->_get_javascript(); | |
| 93 | + // determine current feature set | |
| 94 | + $this->_get_features(); | |
| 95 | + // point out any quirks | |
| 96 | + $this->_get_quirks(); | |
| 97 | + // gecko build | |
| 98 | + $this->_get_gecko(); | |
| 99 | + } | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * property | |
| 103 | + * @param $p property to return . optional (null returns entire array) | |
| 104 | + * @return array/string entire array or value of property | |
| 105 | + **/ | |
| 106 | + function property ($p=null) | |
| 107 | + { if($p==null) | |
| 108 | + { return $this->_browser_info; | |
| 109 | + } | |
| 110 | + else | |
| 111 | + { return $this->_browser_info[strtolower($p)]; | |
| 112 | + } | |
| 113 | + } | |
| 114 | + | |
| 115 | + /** | |
| 116 | + * get_property | |
| 117 | + * alias for property | |
| 118 | + **/ | |
| 119 | + function get_property ($p) | |
| 120 | + { return $this->property($p); | |
| 121 | + } | |
| 122 | + | |
| 123 | + /** | |
| 124 | + * is | |
| 125 | + * @param $s string search phrase format = l:lang;b:browser | |
| 126 | + * @return bool true on success | |
| 127 | + * ex: $client->is('b:OP5Up'); | |
| 128 | + **/ | |
| 129 | + function is ($s) | |
| 130 | + { // perform language search | |
| 131 | + if(preg_match('/l:'.$this->_language_search_regex.'/i',$s,$match)) | |
| 132 | + { if($match) return $this->_perform_language_search($match); | |
| 133 | + } | |
| 134 | + // perform browser search | |
| 135 | + elseif(preg_match('/b:'.$this->_browser_search_regex.'/i',$s,$match)) | |
| 136 | + { if($match) return $this->_perform_browser_search($match); | |
| 137 | + } | |
| 138 | + return false; | |
| 139 | + } | |
| 140 | + | |
| 141 | + /** | |
| 142 | + * browser_is | |
| 143 | + * @param $s string search phrase for browser | |
| 144 | + * @return bool true on success | |
| 145 | + * ex: $client->browser_is('OP5Up'); | |
| 146 | + **/ | |
| 147 | + function browser_is ($s) | |
| 148 | + { preg_match('/'.$this->_browser_search_regex.'/i',$s,$match); | |
| 149 | + if($match) return $this->_perform_browser_search($match); | |
| 150 | + } | |
| 151 | + | |
| 152 | + /** | |
| 153 | + * language_is | |
| 154 | + * @param $s string search phrase for language | |
| 155 | + * @return bool true on success | |
| 156 | + * ex: $client->language_is('en-US'); | |
| 157 | + **/ | |
| 158 | + function language_is ($s) | |
| 159 | + { preg_match('/'.$this->_language_search_regex.'/i',$s,$match); | |
| 160 | + if($match) return $this->_perform_language_search($match); | |
| 161 | + } | |
| 162 | + | |
| 163 | + /** | |
| 164 | + * has_feature | |
| 165 | + * @param $s string feature we're checking on | |
| 166 | + * @return bool true on success | |
| 167 | + * ex: $client->has_feature('html'); | |
| 168 | + **/ | |
| 169 | + function has_feature ($s) | |
| 170 | + { return $this->_feature_set[$s]; | |
| 171 | + } | |
| 172 | + | |
| 173 | + /** | |
| 174 | + * has_quirk | |
| 175 | + * @param $s string quirk we're looking for | |
| 176 | + * @return bool true on success | |
| 177 | + * ex: $client->has_quirk('avoid_popup_windows'); | |
| 178 | + **/ | |
| 179 | + function has_quirk ($s) | |
| 180 | + { return $this->_quirks[$s]; | |
| 181 | + } | |
| 182 | + | |
| 183 | + /** | |
| 184 | + * _perform_browser_search | |
| 185 | + * @param $data string what we're searching for | |
| 186 | + * @return bool true on success | |
| 187 | + * @private | |
| 188 | + **/ | |
| 189 | + function _perform_browser_search ($data) | |
| 190 | + { $search = array(); | |
| 191 | + $search['phrase'] = isset($data[0]) ? $data[0] : ''; | |
| 192 | + $search['name'] = isset($data[1]) ? strtolower($data[1]) : ''; | |
| 193 | + $search['maj_ver'] = isset($data[2]) ? $data[2] : ''; | |
| 194 | + $search['min_ver'] = isset($data[3]) ? $data[3] : ''; | |
| 195 | + $search['direction'] = isset($data[4]) ? strtolower($data[4]) : ''; | |
| 196 | + | |
| 197 | + $looking_for = $search['maj_ver'].$search['min_ver']; | |
| 198 | + if($search['name'] == 'aol' || $search['name'] == 'webtv') | |
| 199 | + { return stristr($this->_browser_info['ua'],$search['name']); | |
| 200 | + } | |
| 201 | + elseif($this->_browser_info['browser'] == $search['name']) | |
| 202 | + { $majv = $search['maj_ver'] ? $this->_browser_info['maj_ver'] : ''; | |
| 203 | + $minv = $search['min_ver'] ? $this->_browser_info['min_ver'] : ''; | |
| 204 | + $what_we_are = $majv.$minv; | |
| 205 | + if($search['direction'] == 'up' && ($what_we_are >= $looking_for)) | |
| 206 | + { return true; | |
| 207 | + } | |
| 208 | + elseif($search['direction'] == 'dn' && ($what_we_are <= $looking_for)) | |
| 209 | + { return true; | |
| 210 | + } | |
| 211 | + elseif($what_we_are == $looking_for) | |
| 212 | + { return true; | |
| 213 | + } | |
| 214 | + } | |
| 215 | + return false; | |
| 216 | + } | |
| 217 | + | |
| 218 | + function _perform_language_search ($data) | |
| 219 | + { // if we've not grabbed the languages, then do so. | |
| 220 | + $this->_get_languages(); | |
| 221 | + return stristr($this->_browser_info['language'],$data[1]); | |
| 222 | + } | |
| 223 | + | |
| 224 | + function _get_languages () | |
| 225 | + { // capture available languages and insert into container | |
| 226 | + if(!$this->_get_languages_ran_once) | |
| 227 | + { if($languages = getenv('HTTP_ACCEPT_LANGUAGE')) | |
| 228 | + { $languages = preg_replace('/(;q=[0-9]+.[0-9]+)/i','',$languages); | |
| 229 | + } | |
| 230 | + else | |
| 231 | + { $languages = $this->_default_language; | |
| 232 | + } | |
| 233 | + $this->_set_browser('language',$languages); | |
| 234 | + $this->_get_languages_ran_once = true; | |
| 235 | + } | |
| 236 | + } | |
| 237 | + | |
| 238 | + function _get_os_info () | |
| 239 | + { // regexes to use | |
| 240 | + $regex_windows = '/([^dar]win[dows]*)[\s]?([0-9a-z]*)[\w\s]?([a-z0-9.]*)/i'; | |
| 241 | + $regex_mac = '/(68[k0]{1,3})|(ppc mac os x)|([p\S]{1,5}pc)|(darwin)/i'; | |
| 242 | + $regex_os2 = '/os\/2|ibm-webexplorer/i'; | |
| 243 | + $regex_sunos = '/(sun|i86)[os\s]*([0-9]*)/i'; | |
| 244 | + $regex_irix = '/(irix)[\s]*([0-9]*)/i'; | |
| 245 | + $regex_hpux = '/(hp-ux)[\s]*([0-9]*)/i'; | |
| 246 | + $regex_aix = '/aix([0-9]*)/i'; | |
| 247 | + $regex_dec = '/dec|osfl|alphaserver|ultrix|alphastation/i'; | |
| 248 | + $regex_vms = '/vax|openvms/i'; | |
| 249 | + $regex_sco = '/sco|unix_sv/i'; | |
| 250 | + $regex_linux = '/x11|inux/i'; | |
| 251 | + $regex_bsd = '/(free)?(bsd)/i'; | |
| 252 | + | |
| 253 | + // look for Windows Box | |
| 254 | + if(preg_match_all($regex_windows,$this->_browser_info['ua'],$match)) | |
| 255 | + { /** Windows has some of the most ridiculous HTTP_USER_AGENT strings */ | |
| 256 | + //$match[1][count($match[0])-1]; | |
| 257 | + $v = $match[2][count($match[0])-1]; | |
| 258 | + $v2 = $match[3][count($match[0])-1]; | |
| 259 | + // Establish NT 5.1 as Windows XP | |
| 260 | + if(stristr($v,'NT') && $v2 == 5.1) $v = 'xp'; | |
| 261 | + // Establish NT 5.0 and Windows 2000 as win2k | |
| 262 | + elseif($v == '2000') $v = '2k'; | |
| 263 | + elseif(stristr($v,'NT') && $v2 == 5.0) $v = '2k'; | |
| 264 | + // Establish 9x 4.90 as Windows 98 | |
| 265 | + elseif(stristr($v,'9x') && $v2 == 4.9) $v = '98'; | |
| 266 | + // See if we're running windows 3.1 | |
| 267 | + elseif($v.$v2 == '16bit') $v = '31'; | |
| 268 | + // otherwise display as is (31,95,98,NT,ME,XP) | |
| 269 | + else $v .= $v2; | |
| 270 | + // update browser info container array | |
| 271 | + if(empty($v)) $v = 'win'; | |
| 272 | + $this->_set_browser('os',strtolower($v)); | |
| 273 | + $this->_set_browser('platform','win'); | |
| 274 | + } | |
| 275 | + // look for OS2 | |
| 276 | + elseif( preg_match($regex_os2,$this->_browser_info['ua'])) | |
| 277 | + { $this->_set_browser('os','os2'); | |
| 278 | + $this->_set_browser('platform','os2'); | |
| 279 | + } | |
| 280 | + // look for mac | |
| 281 | + // sets: platform = mac ; os = 68k or ppc | |
| 282 | + elseif( preg_match($regex_mac,$this->_browser_info['ua'],$match) ) | |
| 283 | + { $this->_set_browser('platform','mac'); | |
| 284 | + $os = !empty($match[1]) ? '68k' : ''; | |
| 285 | + $os = !empty($match[2]) ? 'osx' : $os; | |
| 286 | + $os = !empty($match[3]) ? 'ppc' : $os; | |
| 287 | + $os = !empty($match[4]) ? 'osx' : $os; | |
| 288 | + $this->_set_browser('os',$os); | |
| 289 | + } | |
| 290 | + // look for *nix boxes | |
| 291 | + // sunos sets: platform = *nix ; os = sun|sun4|sun5|suni86 | |
| 292 | + elseif(preg_match($regex_sunos,$this->_browser_info['ua'],$match)) | |
| 293 | + { $this->_set_browser('platform','*nix'); | |
| 294 | + if(!stristr('sun',$match[1])) $match[1] = 'sun'.$match[1]; | |
| 295 | + $this->_set_browser('os',$match[1].$match[2]); | |
| 296 | + } | |
| 297 | + // irix sets: platform = *nix ; os = irix|irix5|irix6|... | |
| 298 | + elseif(preg_match($regex_irix,$this->_browser_info['ua'],$match)) | |
| 299 | + { $this->_set_browser('platform','*nix'); | |
| 300 | + $this->_set_browser('os',$match[1].$match[2]); | |
| 301 | + } | |
| 302 | + // hp-ux sets: platform = *nix ; os = hpux9|hpux10|... | |
| 303 | + elseif(preg_match($regex_hpux,$this->_browser_info['ua'],$match)) | |
| 304 | + { $this->_set_browser('platform','*nix'); | |
| 305 | + $match[1] = str_replace('-','',$match[1]); | |
| 306 | + $match[2] = (int) $match[2]; | |
| 307 | + $this->_set_browser('os',$match[1].$match[2]); | |
| 308 | + } | |
| 309 | + // aix sets: platform = *nix ; os = aix|aix1|aix2|aix3|... | |
| 310 | + elseif(preg_match($regex_aix,$this->_browser_info['ua'],$match)) | |
| 311 | + { $this->_set_browser('platform','*nix'); | |
| 312 | + $this->_set_browser('os','aix'.$match[1]); | |
| 313 | + } | |
| 314 | + // dec sets: platform = *nix ; os = dec | |
| 315 | + elseif(preg_match($regex_dec,$this->_browser_info['ua'],$match)) | |
| 316 | + { $this->_set_browser('platform','*nix'); | |
| 317 | + $this->_set_browser('os','dec'); | |
| 318 | + } | |
| 319 | + // vms sets: platform = *nix ; os = vms | |
| 320 | + elseif(preg_match($regex_vms,$this->_browser_info['ua'],$match)) | |
| 321 | + { $this->_set_browser('platform','*nix'); | |
| 322 | + $this->_set_browser('os','vms'); | |
| 323 | + } | |
| 324 | + // sco sets: platform = *nix ; os = sco | |
| 325 | + elseif(preg_match($regex_sco,$this->_browser_info['ua'],$match)) | |
| 326 | + { $this->_set_browser('platform','*nix'); | |
| 327 | + $this->_set_browser('os','sco'); | |
| 328 | + } | |
| 329 | + // unixware sets: platform = *nix ; os = unixware | |
| 330 | + elseif(stristr('unix_system_v',$this->_browser_info['ua'])) | |
| 331 | + { $this->_set_browser('platform','*nix'); | |
| 332 | + $this->_set_browser('os','unixware'); | |
| 333 | + } | |
| 334 | + // mpras sets: platform = *nix ; os = mpras | |
| 335 | + elseif(stristr('ncr',$this->_browser_info['ua'])) | |
| 336 | + { $this->_set_browser('platform','*nix'); | |
| 337 | + $this->_set_browser('os','mpras'); | |
| 338 | + } | |
| 339 | + // reliant sets: platform = *nix ; os = reliant | |
| 340 | + elseif(stristr('reliantunix',$this->_browser_info['ua'])) | |
| 341 | + { $this->_set_browser('platform','*nix'); | |
| 342 | + $this->_set_browser('os','reliant'); | |
| 343 | + } | |
| 344 | + // sinix sets: platform = *nix ; os = sinix | |
| 345 | + elseif(stristr('sinix',$this->_browser_info['ua'])) | |
| 346 | + { $this->_set_browser('platform','*nix'); | |
| 347 | + $this->_set_browser('os','sinix'); | |
| 348 | + } | |
| 349 | + // bsd sets: platform = *nix ; os = bsd|freebsd | |
| 350 | + elseif(preg_match($regex_bsd,$this->_browser_info['ua'],$match)) | |
| 351 | + { $this->_set_browser('platform','*nix'); | |
| 352 | + $this->_set_browser('os',$match[1].$match[2]); | |
| 353 | + } | |
| 354 | + // last one to look for | |
| 355 | + // linux sets: platform = *nix ; os = linux | |
| 356 | + elseif(preg_match($regex_linux,$this->_browser_info['ua'],$match)) | |
| 357 | + { $this->_set_browser('platform','*nix'); | |
| 358 | + $this->_set_browser('os','linux'); | |
| 359 | + } | |
| 360 | + } | |
| 361 | + | |
| 362 | + function _get_browser_info () | |
| 363 | + { $this->_build_regex(); | |
| 364 | + if(preg_match_all($this->_browser_regex,$this->_browser_info['ua'],$results)) | |
| 365 | + { // get the position of the last browser found | |
| 366 | + $count = count($results[0])-1; | |
| 367 | + // if we're allowing masquerading, revert to the next to last browser found | |
| 368 | + // if possible, otherwise stay put | |
| 369 | + if($this->_allow_masquerading && $count > 0) $count--; | |
| 370 | + // insert findings into the container | |
| 371 | + $this->_set_browser('browser',$this->_get_short_name($results[1][$count])); | |
| 372 | + $this->_set_browser('long_name',$results[1][$count]); | |
| 373 | + $this->_set_browser('maj_ver',$results[2][$count]); | |
| 374 | + // parse the minor version string and look for alpha chars | |
| 375 | + preg_match('/([.\0-9]+)?([\.a-z0-9]+)?/i',$results[3][$count],$match); | |
| 376 | + if(isset($match[1])) { | |
| 377 | + $this->_set_browser('min_ver',$match[1]); | |
| 378 | + } else { | |
| 379 | + $this->_set_browser('min_ver','.0'); | |
| 380 | + } | |
| 381 | + if(isset($match[2])) $this->_set_browser('letter_ver',$match[2]); | |
| 382 | + // insert findings into container | |
| 383 | + $this->_set_browser('version',$this->_browser_info['maj_ver'].$this->property('min_ver')); | |
| 384 | + } | |
| 385 | + } | |
| 386 | + | |
| 387 | + function _get_ip () | |
| 388 | + { if(getenv('HTTP_CLIENT_IP')) | |
| 389 | + { $ip = getenv('HTTP_CLIENT_IP'); | |
| 390 | + } | |
| 391 | + else | |
| 392 | + { $ip = getenv('REMOTE_ADDR'); | |
| 393 | + } | |
| 394 | + $this->_set_browser('ip',$ip); | |
| 395 | + } | |
| 396 | + | |
| 397 | + function _build_regex () | |
| 398 | + { $browsers = ''; | |
| 399 | + while(list($k,) = each($this->_browsers)) | |
| 400 | + { if(!empty($browsers)) $browsers .= "|"; | |
| 401 | + $browsers .= $k; | |
| 402 | + } | |
| 403 | + $version_string = "[\/\sa-z]*([0-9]+)([\.0-9a-z]+)?"; | |
| 404 | + $this->_browser_regex = "/($browsers)$version_string/i"; | |
| 405 | + } | |
| 406 | + | |
| 407 | + function _get_short_name ($long_name) | |
| 408 | + { return $this->_browsers[strtolower($long_name)]; | |
| 409 | + } | |
| 410 | + | |
| 411 | + /* | |
| 412 | + function _test_cookies () | |
| 413 | + { global $ctest,$phpSniff_testCookie; | |
| 414 | + if($this->_check_cookies) | |
| 415 | + { if ($ctest != 1) | |
| 416 | + { SetCookie('phpSniff_testCookie','test',0,'/'); | |
| 417 | + // See if we were passed anything in the QueryString we might need | |
| 418 | + $QS = getenv('QUERY_STRING'); | |
| 419 | + // fix compatability issues when PHP is | |
| 420 | + // running as CGI ~ 6/28/2001 v2.0.2 ~ RR | |
| 421 | + $script_path = getenv('PATH_INFO') ? getenv('PATH_INFO') : getenv('SCRIPT_NAME'); | |
| 422 | + $location = $script_path . ($QS=="" ? "?ctest=1" : "?" . $QS . "&ctest=1"); | |
| 423 | + header("Location: $location"); | |
| 424 | + exit; | |
| 425 | + } | |
| 426 | + // Check for the cookie on page reload | |
| 427 | + elseif ($phpSniff_testCookie == "test") | |
| 428 | + { $this->_set_browser('cookies',true); | |
| 429 | + } | |
| 430 | + else | |
| 431 | + { $this->_set_browser('cookies',false); | |
| 432 | + } | |
| 433 | + } | |
| 434 | + else $this->_set_browser('cookies',false); | |
| 435 | + | |
| 436 | + } | |
| 437 | + */ | |
| 438 | + // medianes :: new test cookie routine | |
| 439 | + function _test_cookies() | |
| 440 | + { global $phpSniff_session,$phpSniff_stored; | |
| 441 | + if($this->_check_cookies) | |
| 442 | + { $fp = @fopen($this->_temp_file_path.$this->property('ip'),'r'); | |
| 443 | + if(!$fp) | |
| 444 | + { $fp = @fopen($this->_temp_file_path.$this->property('ip'),'a'); | |
| 445 | + fclose($fp); | |
| 446 | + setcookie('phpSniff_session','ss'); | |
| 447 | + setcookie('phpSniff_stored','st',time()+3600*24*365); | |
| 448 | + $QS=getenv('QUERY_STRING'); | |
| 449 | + $script_path=getenv('PATH_INFO')?getenv('PATH_INFO'):getenv('SCRIPT_NAME'); | |
| 450 | + if(is_integer($pos=strpos(strrev($script_path),"php.xedni/"))&&!$pos) { | |
| 451 | + $script_path=strrev(substr(strrev($script_path),9)); | |
| 452 | + } | |
| 453 | + $location='http://'.getenv('SERVER_NAME').$script_path.($QS==''?'':'?'.$QS); | |
| 454 | + header("Location: $location"); | |
| 455 | + exit; | |
| 456 | + } | |
| 457 | + else | |
| 458 | + { unlink($this->_temp_file_path.$this->property('ip')); | |
| 459 | + fclose($fp); | |
| 460 | + // remains for backwards compatability | |
| 461 | + $this->_set_browser('cookies',$phpSniff_session=='ss'?'true':'false'); | |
| 462 | + // new cookie settings | |
| 463 | + $this->_set_browser('ss_cookies',$phpSniff_session=='ss'?'true':'false'); | |
| 464 | + $this->_set_browser('st_cookies',$phpSniff_stored=='st'?'true':'false'); | |
| 465 | + setcookie('phpSniff_stored',''); | |
| 466 | + } | |
| 467 | + } | |
| 468 | + } | |
| 469 | + | |
| 470 | + function _get_javascript() | |
| 471 | + { $set=false; | |
| 472 | + // see if we have any matches | |
| 473 | + while(list($version,$browser) = each($this->_javascript_versions)) | |
| 474 | + { $browser = explode(',',$browser); | |
| 475 | + while(list(,$search) = each($browser)) | |
| 476 | + { if($this->is('b:'.$search)) | |
| 477 | + { $this->_set_browser('javascript',$version); | |
| 478 | + $set = true; | |
| 479 | + break; | |
| 480 | + } | |
| 481 | + } | |
| 482 | + if($set) break; | |
| 483 | + } | |
| 484 | + } | |
| 485 | + | |
| 486 | + function _get_features () | |
| 487 | + { while(list($feature,$browser) = each($this->_browser_features)) | |
| 488 | + { $browser = explode(',',$browser); | |
| 489 | + while(list(,$search) = each($browser)) | |
| 490 | + { if($this->browser_is($search)) | |
| 491 | + { $this->_set_feature($feature); | |
| 492 | + break; | |
| 493 | + } | |
| 494 | + } | |
| 495 | + } | |
| 496 | + } | |
| 497 | + | |
| 498 | + function _get_quirks () | |
| 499 | + { while(list($quirk,$browser) = each($this->_browser_quirks)) | |
| 500 | + { $browser = explode(',',$browser); | |
| 501 | + while(list(,$search) = each($browser)) | |
| 502 | + { if($this->browser_is($search)) | |
| 503 | + { $this->_set_quirk($quirk); | |
| 504 | + break; | |
| 505 | + } | |
| 506 | + } | |
| 507 | + } | |
| 508 | + } | |
| 509 | + | |
| 510 | + function _get_gecko () | |
| 511 | + { if(preg_match('/gecko\/([0-9]+)/i',$this->property('ua'),$match)) | |
| 512 | + { $this->_set_browser('gecko',$match[1]); | |
| 513 | + if (preg_match('/rv:([0-9a-z.+]+)/i',$this->property('ua'),$mozv)) | |
| 514 | + { $this->_set_browser('gecko_ver',$mozv[1]); | |
| 515 | + } | |
| 516 | + elseif (preg_match('/(m[0-9]+)/i',$this->property('ua'),$mozv)) | |
| 517 | + { $this->_set_browser('gecko_ver',$mozv[1]); | |
| 518 | + } | |
| 519 | + } | |
| 520 | + } | |
| 521 | + | |
| 522 | + function _set_browser ($k,$v) | |
| 523 | + { $this->_browser_info[strtolower($k)] = strtolower($v); | |
| 524 | + } | |
| 525 | + | |
| 526 | + function _set_feature ($k) | |
| 527 | + { $this->_feature_set[strtolower($k)] = !$this->_feature_set[strtolower($k)]; | |
| 528 | + } | |
| 529 | + | |
| 530 | + function _set_quirk ($k) | |
| 531 | + { $this->_quirks[strtolower($k)] = true; | |
| 532 | + } | |
| 533 | +} | |
| 534 | +?> | |
| 0 | 535 | \ No newline at end of file | ... | ... |
phpSniff/phpTimer.class.php
0 → 100644
| 1 | +<?php | |
| 2 | +/******************************************************************************* | |
| 3 | + phpTimer: A simple script to time script execution | |
| 4 | + Copyright (C) 2001 Roger Raymond ~ epsilon7@users.sourceforge.net | |
| 5 | + | |
| 6 | + This library is free software; you can redistribute it and/or | |
| 7 | + modify it under the terms of the GNU Lesser General Public | |
| 8 | + License as published by the Free Software Foundation; either | |
| 9 | + version 2.1 of the License, or (at your option) any later version. | |
| 10 | + | |
| 11 | + This library is distributed in the hope that it will be useful, | |
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | + Lesser General Public License for more details. | |
| 15 | + | |
| 16 | + You should have received a copy of the GNU Lesser General Public | |
| 17 | + License along with this library; if not, write to the Free Software | |
| 18 | + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 19 | +*******************************************************************************/ | |
| 20 | + | |
| 21 | +if(!defined('_PHP_TIMER_INCLUDED')) define('_PHP_TIMER_INCLUDED',1); | |
| 22 | +class phpTimer { | |
| 23 | + | |
| 24 | +function phpTimer () | |
| 25 | +{ $this->_version = '0.1'; | |
| 26 | + $this->_enabled = true; | |
| 27 | +} | |
| 28 | + | |
| 29 | +function start ($name = 'default') | |
| 30 | +{ if($this->_enabled) | |
| 31 | + { $this->_timing_start_times[$name] = explode(' ', microtime()); | |
| 32 | + } | |
| 33 | +} | |
| 34 | + | |
| 35 | +function stop ($name = 'default') | |
| 36 | +{ if($this->_enabled) | |
| 37 | + { $this->_timing_stop_times[$name] = explode(' ', microtime()); | |
| 38 | + } | |
| 39 | +} | |
| 40 | + | |
| 41 | +function get_current ($name = 'default') | |
| 42 | +{ if($this->_enabled) | |
| 43 | + { if (!isset($this->_timing_start_times[$name])) | |
| 44 | + { return 0; | |
| 45 | + } | |
| 46 | + if (!isset($this->_timing_stop_times[$name])) | |
| 47 | + { $stop_time = explode(' ', microtime()); | |
| 48 | + } | |
| 49 | + else | |
| 50 | + { $stop_time = $this->_timing_stop_times[$name]; | |
| 51 | + } | |
| 52 | + // do the big numbers first so the small ones aren't lost | |
| 53 | + $current = $stop_time[1] - $this->_timing_start_times[$name][1]; | |
| 54 | + $current += $stop_time[0] - $this->_timing_start_times[$name][0]; | |
| 55 | + return sprintf("%.10f",$current); | |
| 56 | + } | |
| 57 | + else | |
| 58 | + { return 0; | |
| 59 | + } | |
| 60 | +} | |
| 61 | + | |
| 62 | +} | |
| 0 | 63 | \ No newline at end of file | ... | ... |
phpSniff/user_agent.inc
0 → 100644
| 1 | +<?php | |
| 2 | +/******************************************************************************* | |
| 3 | + user_agent.inc: an array containing browser HTTP_USER_AGENT values for testing | |
| 4 | + Copyright (C) 2001 Roger Raymond ~ epsilon7@users.sourceforge.net | |
| 5 | + | |
| 6 | + This library is free software; you can redistribute it and/or | |
| 7 | + modify it under the terms of the GNU Lesser General Public | |
| 8 | + License as published by the Free Software Foundation; either | |
| 9 | + version 2.1 of the License, or (at your option) any later version. | |
| 10 | + | |
| 11 | + This library is distributed in the hope that it will be useful, | |
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | + Lesser General Public License for more details. | |
| 15 | + | |
| 16 | + You should have received a copy of the GNU Lesser General Public | |
| 17 | + License along with this library; if not, write to the Free Software | |
| 18 | + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 19 | +*******************************************************************************/ | |
| 20 | +$user_agent = array( | |
| 21 | +'mozilla/5.0 (macintosh; u; darwin power macintosh; rv:0.9.9+) gecko/20020223', | |
| 22 | +'Mozilla/3.0 (compatible; Opera/3.0; Windows 95/NT4)', | |
| 23 | +'Mozilla/4.0 (compatible; MSIE 5.0; Windows 2000) Opera 5.11 [en]', | |
| 24 | +'Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)', | |
| 25 | +'Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.0)', | |
| 26 | +'Mozilla/4.5 [en] (Win95; U)', | |
| 27 | +'Mozilla/4.5 (Macintosh; U; PPC)', | |
| 28 | +'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9+) Gecko/20010509', | |
| 29 | +'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; m18) Gecko/20010131 Netscape6/6.01', | |
| 30 | +'Opera/5.11 (Windows 2000; U) [en]', | |
| 31 | +'NCSA Mosaic/2.6b1 (X11;UNIX_SV 4.2MP R4000) libwww/2.12 modified', | |
| 32 | +'Lynx/2.7 libwww-FM/2.14', | |
| 33 | +'amaya/V4.3.2 libwww/5.3.1', | |
| 34 | +'Mozilla/4.0 (compatible; MSIE 5.5; Mac_PowerPC; OmniWeb/4.0)', | |
| 35 | +'mozilla/4.0 (compatible; msie 5.0; linux 2.4.16 i686) opera 5.0 [en]', | |
| 36 | +'mozilla/5.0 (compatible; konqueror/2.2.1; linux)', | |
| 37 | +'mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; q312461)', | |
| 38 | +'mozilla/4.0 (compatible; msie 5.5; windows 98; win 9x 4.90)', | |
| 39 | +'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.0.0) Gecko/20020529' | |
| 40 | +); | |
| 41 | +?> | |
| 0 | 42 | \ No newline at end of file | ... | ... |