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