Commit | Line | Data |
---|---|---|
b8db1df4 | 1 | <?php |
880bcb60 RK |
2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, | |
4 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
5 | ||
39814159 | 6 | include('../classes/useragent.php-class'); |
1c666195 | 7 | |
9c17eb15 RK |
8 | // set default time zone - right now, always the one the server is in! |
9 | date_default_timezone_set('Europe/Vienna'); | |
10 | ||
39814159 RK |
11 | print("<!DOCTYPE html>\n"); |
12 | print("<html>\n<head>\n"); | |
13 | print(" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n"); | |
14 | print(" <link rel=\"stylesheet\" type=\"text/css\" href=\"test.css\">\n"); | |
15 | print(" <title>".'User Agent Test'."</title>\n"); | |
16 | print("</head>\n<body>\n"); | |
17 | ||
18 | if (strlen($_REQUEST["ua"])) { | |
19 | $ua = new userAgent($_REQUEST["ua"]); | |
b8db1df4 | 20 | } |
21 | else { | |
22 | $ua = new userAgent; | |
23 | } | |
24 | ||
39814159 | 25 | print("<h1>User Agent Test</h1>\n"); |
b8db1df4 | 26 | |
1c666195 | 27 | print("I read the following user agent string from ".(strlen($httpvars["ua"])?"your input":"your browser").":\n<br>"); |
e742e507 | 28 | print("<b>".$ua->getUAString()."</b>\n"); |
b8db1df4 | 29 | |
e742e507 | 30 | print("<br><br>The browser brand is reported as "<b>".$ua->getBrand()."</b>"\n"); |
726d345a | 31 | print("<br>The browser version is reported as "<b>".$ua->getVersion()."</b>"\n"); |
e742e507 | 32 | print("<br>The browser engine is reported as "<b>".$ua->getEngine()."</b>"\n"); |
33 | print("<br>The engine version is reported as "<b>".$ua->getEngineVersion()."</b>"\n"); | |
34 | print("<br>The operating system is reported as "<b>".$ua->getOS()."</b>"\n"); | |
35 | print("<br>The system platform is reported as "<b>".$ua->getPlatform()."</b>"\n"); | |
36 | print("<br>The browser language is reported as "<b>".$ua->getLanguage()."</b>"\n"); | |
a3e499ad RK |
37 | if ($ua->hasEngine('gecko')) { |
38 | print("<br>The Gecko date is reported as "<b>".$ua->getGeckoDate()."</b>"\n"); | |
39 | print("<br>The full Gecko date/time is reported as "<b>".date('r',$ua->getGeckoTime())."</b>"\n"); | |
40 | } | |
726d345a | 41 | print("<br><br>I conclude this must be <b>".$ua->getBrand()." ".$ua->getVersion()."</b>\n"); |
e742e507 | 42 | print("<br>This is <b>".($ua->isBot()?"an":"no")."</b> automated robot.\n"); |
43 | ||
44 | $acclang = $ua->getAcceptLanguages(); | |
45 | print("<br><br>Accepted Languages: "); | |
46 | foreach ($acclang as $lang=>$q) { print($lang."(".$q.") "); } | |
47 | print("\n"); | |
b8db1df4 | 48 | |
1c666195 | 49 | print("<br><br>Test the following UA string (leave empty to read it from your browser):\n"); |
b8db1df4 | 50 | print("<form method=\"POST\" action=\"\"><p>\n"); |
4a778b7e | 51 | print("<input type=\"text\" name=\"ua\" value=\"".htmlentities($ua->getUAString())."\" size=\"80\" maxlength=\"150\">\n"); |
b8db1df4 | 52 | print("<br><input type=\"submit\" value=\"Test\"></p></form>\n"); |
39814159 RK |
53 | |
54 | print("<div id=\"copyright\">\n"); | |
55 | print("Page code under Mozilla Public License, code available at <a href=\"https://github.com/KaiRo-at/php-utility-classes\">GitHub</a>.\n"); | |
56 | print("</div>\n"); | |
57 | print("</body></html>\n"); | |
b8db1df4 | 58 | ?> |