|
|
1.2 paf 1: /** @file
1.5 paf 2: Parser: @b request class.
1.2 paf 3:
1.1 paf 4: Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)
1.2 paf 5:
1.1 paf 6: Author: Alexander Petrosyan <paf@design.ru>(http://design.ru/paf)
7:
1.7 ! parser 8: $Id: pa_vrequest.C,v 1.6 2001/05/10 13:10:37 paf Exp $
1.1 paf 9: */
10:
11: #include "pa_vrequest.h"
12: #include "pa_request.h"
13:
1.7 ! parser 14: // request: CLASS,method,field
1.1 paf 15: Value *VRequest::get_element(const String& aname) {
1.4 paf 16: // $browser
17: if(aname=="browser") {
18: VHash *vhash=NEW VHash(pool());
19:
20: // analize
21: bool ie=true;
22: const char *version=0;
23: const char *agent=frequest.info.user_agent;
24: if(agent) {
25: if(strstr(agent, "compatible")) {
26: if(const char *msie=strstr(agent, "MSIE ")) {
27: ie=true;
28: version=msie+5;
29: }
30: } else {
31: if(!strncasecmp(agent, "MOZILLA/", 8)) {
32: ie=false;
33: version=agent+8;
34: }
35: }
36: }
37:
38: // set $browser.type
39: vhash->hash().put(*NEW String(pool(), "type"),
40: NEW VString(*NEW String(pool(), ie?"ie":"nn")));
41: if(version) { // we know the version
42: // set $browser.version
43: vhash->hash().put(*NEW String(pool(), "version"),
44: NEW VDouble(pool(), atof(version)));
45: }
46: //
47: return vhash;
48: }
49:
1.1 paf 50: // $query $uri
51: const char *cstr=0;
52: if(aname=="query")
53: cstr=frequest.info.query_string;
54: if(aname=="uri")
55: cstr=frequest.info.uri;
56:
57: String& string=*NEW String(pool());
1.6 paf 58: string.APPEND_TAINTED(cstr?cstr:"", 0, "request", 0);
1.1 paf 59: return NEW VString(string);
60: }
61: