Changeset 864
- Timestamp:
- 2000-01-25T11:53:09+13:00 (24 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/receptionist.cpp
r806 r864 28 28 /* 29 29 $Log$ 30 Revision 1.44 2000/01/24 22:53:09 sjboddie 31 a few small changes to get fastcgi working properly here at Waikato - 32 hopefully changes will work everywhere ... 33 30 34 Revision 1.43 1999/12/06 01:14:16 sjboddie 31 35 added arabic encoding … … 609 613 // if there was a major problem with the cgi arguments. 610 614 bool receptionist::parse_cgi_args (const text_t &argstr, cgiargsclass &args, 611 ostream &logout ) {615 ostream &logout, text_tmap &fcgienv) { 612 616 outconvertclass text_t2ascii; 613 617 … … 623 627 624 628 // get the cookie 625 if (configinfo.usecookies) get_cookie(args["z"] );629 if (configinfo.usecookies) get_cookie(args["z"], fcgienv); 626 630 627 631 // get the input encoding … … 680 684 // returns true if cookie already existed, false 681 685 // if it was generated 682 bool receptionist::get_cookie (text_t &cookie) { 683 684 char *c = getenv("HTTP_COOKIE"); 685 if (c != NULL) { 686 bool receptionist::get_cookie (text_t &cookie, text_tmap &fcgienv) { 687 688 text_t cookiestring = gsdl_getenv ("HTTP_COOKIE", fcgienv); 689 690 text_t::const_iterator end = cookiestring.end(); 691 text_t::const_iterator here = findchar (cookiestring.begin(), end, 'G'); 692 693 while (here+9 < end) { 694 695 if (substr(here, here+8) == "GSDL_UID") { 696 cookie = substr (here+9, findchar (here+9, end, ';')); 697 return true; 698 } 699 here = findchar (cookiestring.begin(), end, 'G'); 700 } 701 702 cookie.clear(); 703 text_t host = gsdl_getenv("REMOTE_ADDR", fcgienv); 704 time_t ttime = time(NULL); 705 if (!host.empty()) { 706 cookie += host; 707 cookie.push_back ('-'); 708 } 709 cookie += text_t(ttime); 710 711 return false; 712 } 713 714 // as above but just tests if cookie exists 715 bool receptionist::get_cookie (text_tmap &fcgienv) { 716 717 text_t c = gsdl_getenv("HTTP_COOKIE", fcgienv); 718 if (!c.empty()) { 686 719 text_t cookiestring = c; 687 720 688 721 text_t::const_iterator end = cookiestring.end(); 689 722 text_t::const_iterator here = findchar (cookiestring.begin(), end, 'G'); 690 691 if (substr(here, here+8) == "GSDL_UID") { 692 cookie = substr (here+9, findchar (here+9, end, ';')); 693 return true; 694 } 695 } 696 697 cookie.clear(); 698 char *host = getenv("REMOTE_ADDR"); 699 time_t ttime = time(NULL); 700 if (host != NULL) { 701 cookie += host; 702 cookie.push_back ('-'); 703 } 704 cookie += text_t(ttime); 705 723 724 while (here+9 < end) { 725 if (substr(here, here+8) == "GSDL_UID") return true; 726 here = findchar (cookiestring.begin(), end, 'G'); 727 } 728 } 706 729 return false; 707 730 } 708 731 709 // as above but just tests if cookie exists 710 bool receptionist::get_cookie () { 711 712 char *c = getenv("HTTP_COOKIE"); 713 if (c != NULL) { 714 text_t cookiestring = c; 715 716 text_t::const_iterator end = cookiestring.end(); 717 text_t::const_iterator here = findchar (cookiestring.begin(), end, 'G'); 718 719 if (substr(here, here+8) == "GSDL_UID") 720 return true; 721 } 722 return false; 723 } 724 725 bool receptionist::log_cgi_args (cgiargsclass &args, ostream &logout) { 732 bool receptionist::log_cgi_args (cgiargsclass &args, ostream &logout, text_tmap &fcgienv) { 726 733 727 734 // see if we want to log the cgi arguments 728 735 if (!configinfo.logcgiargs) return true; 729 736 730 char *host; 731 host = getenv("REMOTE_HOST"); 732 if (host == NULL) host = getenv ("REMOTE_ADDR"); 733 if (host == NULL) host = ""; 734 char *browser = getenv("HTTP_USER_AGENT"); 735 if (browser == NULL) browser = ""; 737 text_t host = gsdl_getenv ("REMOTE_HOST", fcgienv); 738 if (host.empty()) host = gsdl_getenv ("REMOTE_ADDR", fcgienv); 739 text_t browser = gsdl_getenv ("HTTP_USER_AGENT", fcgienv); 736 740 time_t ttime = time(NULL); 737 741 … … 811 815 // will return false 812 816 bool receptionist::produce_cgi_page (cgiargsclass &args, ostream &contentout, 813 ostream &logout ) {817 ostream &logout, text_tmap &fcgienv) { 814 818 outconvertclass text_t2ascii; 815 819 … … 818 822 819 823 // produce cgi header 820 get_cgihead_info (args, response, response_data, logout );824 get_cgihead_info (args, response, response_data, logout, fcgienv); 821 825 if (response == location) { 822 826 // location response (url may contain macros!!) … … 849 853 // Note that images can now be produced by the receptionist. 850 854 void receptionist::get_cgihead_info (cgiargsclass &args, response_t &response, 851 text_t &response_data, ostream &logout) { 855 text_t &response_data, ostream &logout, 856 text_tmap &fcgienv) { 852 857 outconvertclass text_t2ascii; 853 858 … … 872 877 response_data += "; charset=GBK"; 873 878 } else if (args["w"] == "a") { 874 response_data += "; charset= ISO-8859-6";879 response_data += "; charset=windows-1256"; 875 880 } else { 876 881 response_data += "; charset=ISO-8859-1"; … … 878 883 879 884 // add cookie if required 880 if (configinfo.usecookies && !get_cookie( ))885 if (configinfo.usecookies && !get_cookie(fcgienv)) 881 886 response_data += "\nSet-Cookie: GSDL_UID=" + args["z"] 882 887 + "; expires=25-Dec-37 00:00:00 GMT"; … … 1073 1078 if (!configinfo.collection.empty()) args["c"] = configinfo.collection; 1074 1079 1075 // if cross-collection is turned on make "cc" default to 1076 // all available collections and "c" default to any 1077 // valid collection 1078 if (args["ccs"] == "1") { 1079 if (args["cc"].empty()) { 1080 recptprotolistclass::iterator rprotolist_here = protocols.begin(); 1081 recptprotolistclass::iterator rprotolist_end = protocols.end(); 1082 bool first = true; 1083 while (rprotolist_here != rprotolist_end) { 1084 if ((*rprotolist_here).p != NULL) { 1085 text_tarray collist; 1086 comerror_t err; 1087 (*rprotolist_here).p->get_collection_list (collist, err, logout); 1088 if (err == noError) { 1089 text_tarray::iterator collist_here = collist.begin(); 1090 text_tarray::iterator collist_end = collist.end(); 1091 while (collist_here != collist_end) { 1092 if (!first) args["cc"].push_back (','); 1093 else if (args["c"].empty()) args["c"] = *collist_here; 1094 args["cc"] += *collist_here; 1095 first = false; 1096 collist_here ++; 1097 } 1098 } 1080 // if current collection uses ccscols make sure 1081 // "ccs" argument is set and make "cc" default to 1082 // all collections in "ccs" 1083 if (!args["c"].empty()) { 1084 1085 text_t &arg_c = args["c"]; 1086 ColInfoResponse_t cinfo; 1087 comerror_t err; 1088 recptproto *collectproto = protocols.getrecptproto (arg_c, logout); 1089 collectproto->get_collectinfo (arg_c, cinfo, err, logout); 1090 1091 if (!cinfo.ccsCols.empty()) { 1092 args["ccs"] = 1; 1093 if (args["cc"].empty()) { 1094 text_tarray::const_iterator col_here = cinfo.ccsCols.begin(); 1095 text_tarray::const_iterator col_end = cinfo.ccsCols.end(); 1096 bool first = true; 1097 while (col_here != col_end) { 1098 if (!first) args["cc"].push_back (','); 1099 args["cc"] += *col_here; 1100 col_here ++; 1101 first = false; 1099 1102 } 1100 rprotolist_here ++;1101 1103 } 1102 } else if (args["c"].empty()) {1103 text_t argcc = args["cc"];1104 decode_cgi_arg (argcc);1105 text_t::const_iterator it = argcc.begin();1106 args["c"] = substr (it, findchar (it, argcc.end(), ','));1107 1104 } 1108 1105 } … … 1219 1216 disp.setmacro ("httpimg", "Global", configinfo.httpimg); 1220 1217 disp.setmacro ("httpprefix", "Global", configinfo.httpprefix); 1221 disp.setmacro ("compressedoptions", "Global", get_compressed_arg(args, logout)); 1218 text_t compressedoptions = get_compressed_arg(args, logout); 1219 disp.setmacro ("compressedoptions", "Global", compressedoptions); 1220 // need a decoded version of compressedoptions for use within forms 1221 // as browsers encode values from forms before sending to server 1222 // (e.g. %25 becomes %2525) 1223 decode_cgi_arg (compressedoptions); 1224 disp.setmacro ("decodedcompressedoptions", "Global", compressedoptions); 1222 1225 1223 1226 // set _cgiargX_ macros for each cgi argument … … 1240 1243 argshere ++; 1241 1244 } 1245 1246 // display text right to left if language is arabic (and if browser can support it) 1247 if (args["l"] == "ar") 1248 disp.setmacro ("htmlextra", "Global", " dir=rtl"); 1242 1249 1243 1250 // set collection specific macros -
trunk/gsdl/src/recpt/receptionist.h
r799 r864 94 94 ostream &logout); 95 95 96 bool get_cookie (text_t &cookie );97 bool get_cookie ( );96 bool get_cookie (text_t &cookie, text_tmap &fcgienv); 97 bool get_cookie (text_tmap &fcgienv); 98 98 99 99 virtual void define_general_macros (cgiargsclass &args, outconvertclass &outconvert, … … 165 165 // This function should be called for each page request. It returns false 166 166 // if there was a major problem with the cgi arguments. 167 virtual bool parse_cgi_args (const text_t &argstr, cgiargsclass &args, ostream &logout); 168 169 virtual bool log_cgi_args (cgiargsclass &args, ostream &logout); 167 virtual bool parse_cgi_args (const text_t &argstr, cgiargsclass &args, 168 ostream &logout, text_tmap &fcgienv); 169 170 virtual bool log_cgi_args (cgiargsclass &args, ostream &logout, text_tmap &fcgienv); 170 171 171 172 text_t expandmacros (const text_t &astring, cgiargsclass &args, … … 177 178 // will return false 178 179 virtual bool produce_cgi_page (cgiargsclass &args, ostream &contentout, 179 ostream &logout );180 ostream &logout, text_tmap &fcgienv); 180 181 181 182 // get_cgihead_info determines the cgi header information for … … 185 186 // Note that images can now be produced by the receptionist. 186 187 virtual void get_cgihead_info (cgiargsclass &args, response_t &response, 187 text_t &response_data, ostream &logout); 188 text_t &response_data, ostream &logout, 189 text_tmap &fcgienv); 188 190 189 191 // produce the page content
Note:
See TracChangeset
for help on using the changeset viewer.