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