Commit | Line | Data |
---|---|---|
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 | 6 | include('../classes/useragent.php-class'); |
432328ee | 7 | include('../classes/document.php-class'); |
1c666195 | 8 | |
9c17eb15 RK |
9 | // set default time zone - right now, always the one the server is in! |
10 | date_default_timezone_set('Europe/Vienna'); | |
11 | ||
432328ee RK |
12 | // Start HTML document as a DOM object. |
13 | extract(ExtendedDocument::initHTML5()); // sets $document, $html, $head, $title, $body | |
14 | $document->formatOutput = true; // we want a nice output | |
15 | ||
16 | $style = $head->appendElement('link'); | |
17 | $style->setAttribute('rel', 'stylesheet'); | |
18 | $style->setAttribute('href', 'test.css'); | |
19 | $title->appendText('User Agent Test'); | |
20 | $h1 = $body->appendElement('h1', 'User Agent Test'); | |
39814159 RK |
21 | |
22 | if (strlen($_REQUEST["ua"])) { | |
23 | $ua = new userAgent($_REQUEST["ua"]); | |
b8db1df4 | 24 | } |
25 | else { | |
26 | $ua = new userAgent; | |
27 | } | |
28 | ||
432328ee RK |
29 | $para = $body->appendElement('p', 'I read the following user agent string from '.(strlen($httpvars['ua'])?'your input':'your browser').':'); |
30 | $para->appendElement('br'); | |
31 | $para->appendElement('b', $ua->getUAString()); | |
b8db1df4 | 32 | |
432328ee RK |
33 | $ulist = $body->appendElement('ul'); |
34 | $ulist->setAttribute('class', 'flat'); | |
35 | $litem = $ulist->appendElement('li'); | |
36 | $litem->appendText('The browser brand is reported as "'); | |
37 | $litem->appendElement('b', $ua->getBrand()); | |
38 | $litem->appendText('"'); | |
39 | $litem = $ulist->appendElement('li'); | |
40 | $litem->appendText('The browser version is reported as "'); | |
41 | $litem->appendElement('b', $ua->getVersion()); | |
42 | $litem->appendText('"'); | |
43 | $litem = $ulist->appendElement('li'); | |
44 | $litem->appendText('The browser engine is reported as "'); | |
45 | $litem->appendElement('b', $ua->getEngine()); | |
46 | $litem->appendText('"'); | |
47 | $litem = $ulist->appendElement('li'); | |
48 | $litem->appendText('The engine version is reported as "'); | |
49 | $litem->appendElement('b', $ua->getEngineVersion()); | |
50 | $litem->appendText('"'); | |
51 | $litem = $ulist->appendElement('li'); | |
52 | $litem->appendText('The operating system is reported as "'); | |
53 | $litem->appendElement('b', $ua->getOS()); | |
54 | $litem->appendText('"'); | |
55 | $litem = $ulist->appendElement('li'); | |
56 | $litem->appendText('The system platform is reported as "'); | |
57 | $litem->appendElement('b', $ua->getPlatform()); | |
58 | $litem->appendText('"'); | |
59 | $litem = $ulist->appendElement('li'); | |
60 | $litem->appendText('The browser language is reported as "'); | |
61 | $litem->appendElement('b', $ua->getLanguage()); | |
62 | $litem->appendText('"'); | |
a3e499ad | 63 | if ($ua->hasEngine('gecko')) { |
432328ee RK |
64 | $litem = $ulist->appendElement('li'); |
65 | $litem->appendText('The Gecko date is reported as "'); | |
66 | $litem->appendElement('b', $ua->getGeckoDate()); | |
67 | $litem->appendText('"'); | |
68 | $litem = $ulist->appendElement('li'); | |
69 | $litem->appendText('The full Gecko date/time is reported as "'); | |
70 | $litem->appendElement('b', date('r',$ua->getGeckoTime())); | |
71 | $litem->appendText('"'); | |
72 | } | |
73 | $litem = $ulist->appendElement('li'); | |
74 | $litem->setAttribute('class', 'summary'); | |
75 | $litem->appendText('I conclude this must be '); | |
76 | $litem->appendElement('b', $ua->getBrand()." ".$ua->getVersion()); | |
77 | $litem->appendText('.'); | |
78 | $litem = $ulist->appendElement('li'); | |
79 | $litem->appendText('This is '); | |
80 | $litem->appendElement('b', ($ua->isBot()?'an':'no')); | |
81 | $litem->appendText(' automated robot.'); | |
82 | ||
83 | $para = $body->appendElement('p', 'Accepted Languages:'); | |
84 | foreach ($acclang as $lang=>$q) { | |
85 | $para->appendText($lang.'('.$q.') '); | |
a3e499ad | 86 | } |
432328ee RK |
87 | |
88 | $para = $body->appendElement('p', 'Test the following UA string (leave empty to read it from your browser):'); | |
89 | $form = $body->appendForm('', 'POST', 'uaform'); | |
90 | $form->appendInputText('ua', 150, 80, null, $ua->getUAString()); | |
91 | $form->appendElement('br'); | |
92 | $form->appendInputSubmit(_('Test')); | |
93 | ||
94 | $footer = $body->appendElement('footer', 'Page code under Mozilla Public License, code available at '); | |
95 | $footer->setAttribute('id', 'copyright'); | |
96 | $footer->appendLink('https://github.com/KaiRo-at/php-utility-classes', 'GitHub'); | |
97 | $footer->appendText('.'); | |
98 | ||
99 | // Send HTML to client. | |
100 | print($document->saveHTML()); | |
b8db1df4 | 101 | ?> |