Changeset 864

Show
Ignore:
Timestamp:
25.01.2000 11:53:09 (20 years ago)
Author:
sjboddie
Message:

a few small changes to get fastcgi working properly here at Waikato -
hopefully changes will work everywhere ...

Location:
trunk/gsdl/src/recpt
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/receptionist.cpp

    r806 r864  
    2828/* 
    2929   $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 
    3034   Revision 1.43  1999/12/06 01:14:16  sjboddie 
    3135   added arabic encoding 
     
    609613// if there was a major problem with the cgi arguments. 
    610614bool receptionist::parse_cgi_args (const text_t &argstr, cgiargsclass &args,  
    611                    ostream &logout) { 
     615                   ostream &logout, text_tmap &fcgienv) { 
    612616  outconvertclass text_t2ascii; 
    613617 
     
    623627 
    624628  // get the cookie 
    625   if (configinfo.usecookies) get_cookie(args["z"]); 
     629  if (configinfo.usecookies) get_cookie(args["z"], fcgienv); 
    626630   
    627631  // get the input encoding 
     
    680684// returns true if cookie already existed, false 
    681685// if it was generated 
    682 bool receptionist::get_cookie (text_t &cookie) { 
    683  
    684   char *c = getenv("HTTP_COOKIE"); 
    685   if (c != NULL) { 
     686bool 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 
     715bool receptionist::get_cookie (text_tmap &fcgienv) { 
     716 
     717  text_t c = gsdl_getenv("HTTP_COOKIE", fcgienv); 
     718  if (!c.empty()) { 
    686719    text_t cookiestring = c; 
    687720     
    688721    text_t::const_iterator end = cookiestring.end();   
    689722    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  } 
    706729  return false; 
    707730} 
    708731 
    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) { 
     732bool receptionist::log_cgi_args (cgiargsclass &args, ostream &logout, text_tmap &fcgienv) { 
    726733 
    727734  // see if we want to log the cgi arguments 
    728735  if (!configinfo.logcgiargs) return true; 
    729736   
    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); 
    736740  time_t ttime = time(NULL); 
    737741 
     
    811815// will return false 
    812816bool receptionist::produce_cgi_page (cgiargsclass &args, ostream &contentout,  
    813                      ostream &logout) { 
     817                     ostream &logout, text_tmap &fcgienv) { 
    814818  outconvertclass text_t2ascii; 
    815819 
     
    818822 
    819823  // produce cgi header 
    820   get_cgihead_info (args, response, response_data, logout); 
     824  get_cgihead_info (args, response, response_data, logout, fcgienv); 
    821825  if (response == location) { 
    822826    // location response (url may contain macros!!) 
     
    849853// Note that images can now be produced by the receptionist. 
    850854void 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) { 
    852857  outconvertclass text_t2ascii; 
    853858 
     
    872877      response_data += "; charset=GBK"; 
    873878    } else if (args["w"] == "a") { 
    874       response_data += "; charset=ISO-8859-6"; 
     879      response_data += "; charset=windows-1256"; 
    875880    } else { 
    876881      response_data += "; charset=ISO-8859-1";       
     
    878883 
    879884    // add cookie if required 
    880     if (configinfo.usecookies && !get_cookie()) 
     885    if (configinfo.usecookies && !get_cookie(fcgienv)) 
    881886      response_data += "\nSet-Cookie: GSDL_UID=" + args["z"] 
    882887    + "; expires=25-Dec-37 00:00:00 GMT"; 
     
    10731078  if (!configinfo.collection.empty()) args["c"] = configinfo.collection; 
    10741079 
    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; 
    10991102    } 
    1100     rprotolist_here ++; 
    11011103      } 
    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(), ',')); 
    11071104    } 
    11081105  } 
     
    12191216  disp.setmacro ("httpimg", "Global", configinfo.httpimg); 
    12201217  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); 
    12221225 
    12231226  // set _cgiargX_ macros for each cgi argument 
     
    12401243    argshere ++; 
    12411244  } 
     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"); 
    12421249 
    12431250  // set collection specific macros 
  • trunk/gsdl/src/recpt/receptionist.h

    r799 r864  
    9494                   ostream &logout); 
    9595 
    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); 
    9898 
    9999  virtual void define_general_macros (cgiargsclass &args, outconvertclass &outconvert,  
     
    165165  // This function should be called for each page request. It returns false 
    166166  // 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); 
    170171 
    171172  text_t expandmacros (const text_t &astring, cgiargsclass &args,  
     
    177178  // will return false 
    178179  virtual bool produce_cgi_page (cgiargsclass &args, ostream &contentout,  
    179                  ostream &logout); 
     180                 ostream &logout, text_tmap &fcgienv); 
    180181   
    181182  // get_cgihead_info determines the cgi header information for 
     
    185186  // Note that images can now be produced by the receptionist. 
    186187  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); 
    188190   
    189191  // produce the page content