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