put clear MPL2 license headers on all files
[php-utility-classes.git] / tests / ua_test.php
1 <?php
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
6 include('../classes/useragent.php-class');
7
8 // set default time zone - right now, always the one the server is in!
9 date_default_timezone_set('Europe/Vienna');
10
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"]);
20 }
21 else {
22   $ua = new userAgent;
23 }
24
25 print("<h1>User Agent Test</h1>\n");
26
27 print("I read the following user agent string from ".(strlen($httpvars["ua"])?"your input":"your browser").":\n<br>");
28 print("<b>".$ua->getUAString()."</b>\n");
29
30 print("<br><br>The browser brand is reported as &quot;<b>".$ua->getBrand()."</b>&quot;\n");
31 print("<br>The browser version is reported as &quot;<b>".$ua->getVersion()."</b>&quot;\n");
32 print("<br>The browser engine is reported as &quot;<b>".$ua->getEngine()."</b>&quot;\n");
33 print("<br>The engine version is reported as &quot;<b>".$ua->getEngineVersion()."</b>&quot;\n");
34 print("<br>The operating system is reported as &quot;<b>".$ua->getOS()."</b>&quot;\n");
35 print("<br>The system platform is reported as &quot;<b>".$ua->getPlatform()."</b>&quot;\n");
36 print("<br>The browser language is reported as &quot;<b>".$ua->getLanguage()."</b>&quot;\n");
37 if ($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 }
41 print("<br><br>I conclude this must be <b>".$ua->getBrand()." ".$ua->getVersion()."</b>\n");
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");
48
49 print("<br><br>Test the following UA string (leave empty to read it from your browser):\n");
50 print("<form method=\"POST\" action=\"\"><p>\n");
51 print("<input type=\"text\" name=\"ua\" value=\"".htmlentities($ua->getUAString())."\" size=\"80\" maxlength=\"150\">\n");
52 print("<br><input type=\"submit\" value=\"Test\"></p></form>\n");
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");
58 ?>