add a LICENSE and a README to things are all nice at GitHub :)
[php-utility-classes.git] / tests / ua_test.php
CommitLineData
b8db1df4 1<?php
39814159 2include('../classes/useragent.php-class');
1c666195 3
9c17eb15
RK
4// set default time zone - right now, always the one the server is in!
5date_default_timezone_set('Europe/Vienna');
6
39814159
RK
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"]);
b8db1df4 16}
17else {
18 $ua = new userAgent;
19}
20
39814159 21print("<h1>User Agent Test</h1>\n");
b8db1df4 22
1c666195 23print("I read the following user agent string from ".(strlen($httpvars["ua"])?"your input":"your browser").":\n<br>");
e742e507 24print("<b>".$ua->getUAString()."</b>\n");
b8db1df4 25
e742e507 26print("<br><br>The browser brand is reported as &quot;<b>".$ua->getBrand()."</b>&quot;\n");
726d345a 27print("<br>The browser version is reported as &quot;<b>".$ua->getVersion()."</b>&quot;\n");
e742e507 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");
a3e499ad
RK
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}
726d345a 37print("<br><br>I conclude this must be <b>".$ua->getBrand()." ".$ua->getVersion()."</b>\n");
e742e507 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");
b8db1df4 44
1c666195 45print("<br><br>Test the following UA string (leave empty to read it from your browser):\n");
b8db1df4 46print("<form method=\"POST\" action=\"\"><p>\n");
4a778b7e 47print("<input type=\"text\" name=\"ua\" value=\"".htmlentities($ua->getUAString())."\" size=\"80\" maxlength=\"150\">\n");
b8db1df4 48print("<br><input type=\"submit\" value=\"Test\"></p></form>\n");
39814159
RK
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");
b8db1df4 54?>