Changeset 39000
- Timestamp:
- 2024-05-07T14:46:46+12:00 (2 weeks ago)
- Location:
- main/trunk/greenstone2/runtime-src/src/recpt
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/runtime-src/src/recpt/cgiwrapper.cpp
r30373 r39000 388 388 << " from the command line as it would be when run from your\n" 389 389 << " web server.\n"; 390 if (configinfo.usecookies )391 cout << " cookies are enabled\n";390 if (configinfo.usecookiesForUID) 391 cout << "UID will be saved as a cookie\n"; 392 392 else 393 cout << "cookies are disabled\n"; 393 cout << "UID not saved as a cookie\n"; 394 if (configinfo.usecookiesForE) 395 cout << "The e arg will be saved as a cookie\n"; 396 else 397 cout << "The e arg is not saved as a cookie - set usecookiesForE to true to use cookies for e \n"; 394 398 if (configinfo.logcgiargs) 395 399 cout << "logging is enabled\n"; -
main/trunk/greenstone2/runtime-src/src/recpt/receptionist.cpp
r31980 r39000 63 63 macrofiles.erase(macrofiles.begin(), macrofiles.end()); 64 64 saveconf.clear(); 65 usecookies = false; 65 usecookiesForUID = false; 66 usecookiesForE = true; 66 67 logcgiargs = false; 67 68 LogDateFormat = LocalTime; … … 251 252 } 252 253 else if (key == "saveconf") configinfo.saveconf = cfgline[0]; 253 else if (key == "usecookies") configinfo.usecookies = (cfgline[0] == "true"); 254 // keep usecookies here for backwards compatibility 255 else if (key == "usecookies" || key == "usecookiesForUID") configinfo.usecookiesForUID = (cfgline[0] == "true"); 256 else if (key == "usecookiesForE") configinfo.usecookiesForE = (cfgline[0] == "true"); 254 257 else if (key == "logcgiargs") configinfo.logcgiargs = (cfgline[0] == "true"); 255 258 else if (key == "maintainer") configinfo.maintainer = cfgline[0]; … … 594 597 args.clear(); 595 598 split_cgi_args (argsinfo, argstr, args); 596 599 600 // get e cookie 601 if (configinfo.usecookiesForE) get_named_cookie(args["e"], "GSDL_E", fcgienv); 597 602 // expand the compressed argument (if there was one) 598 603 if (!expand_save_args (argsinfo, configinfo.saveconf, args, logout)) return false; … … 605 610 606 611 // get the cookie 607 if (configinfo.usecookies ) get_cookie(args["z"], fcgienv);612 if (configinfo.usecookiesForUID) get_uid_cookie(args["z"], fcgienv); 608 613 609 614 // if we're changing languages, set the encoding to the default for the new language … … 672 677 673 678 679 // Returns true if cookie exists, false if not 680 bool receptionist::get_named_cookie (text_t &cookie, text_t cookie_name, text_tmap &fcgienv) 681 { 682 683 // See if we can get the cookies 684 text_t cookiestring = gsdl_getenv ("HTTP_COOKIE", fcgienv); 685 if (cookiestring.empty()) return false; 686 // This should really be handled by the findword function... 687 688 // Check if the cookie contains 'cookie_name' 689 text_t cid = cookie_name+"="; 690 text_t::iterator cid_start = findword(cookiestring.begin(), cookiestring.end(), cid); 691 if (cid_start != cookiestring.end()) 692 { 693 // Yes, so extract its value 694 cookie = substr(cid_start + cid.size(), findchar(cid_start + cid.size(), cookiestring.end(), ';')); 695 return true; 696 } 697 return false; 698 } 699 674 700 // Returns true if cookie already existed, false if it was generated 675 bool receptionist::get_ cookie (text_t &cookie, text_tmap &fcgienv)701 bool receptionist::get_uid_cookie (text_t &cookie, text_tmap &fcgienv) 676 702 { 677 703 // See if we can get the GSDL_UID cookie 678 text_t cookiestring = gsdl_getenv ("HTTP_COOKIE", fcgienv); 679 if (!cookiestring.empty()) // This should really be handled by the findword function... 680 { 681 // Check if the cookie contains GSDL_UID 682 text_t gsdl_uid = "GSDL_UID="; 683 text_t::iterator gsdl_uid_start = findword(cookiestring.begin(), cookiestring.end(), gsdl_uid); 684 if (gsdl_uid_start != cookiestring.end()) 685 { 686 // Yes, so extract its value 687 cookie = substr(gsdl_uid_start + gsdl_uid.size(), findchar(gsdl_uid_start + gsdl_uid.size(), cookiestring.end(), ';')); 688 return true; 689 } 690 } 691 704 bool found = get_named_cookie(cookie, "GSDL_UID", fcgienv); 705 if (found) return true; 692 706 // Generate a new key "[host]-[epoch time]", e.g. test.com-1256764496 693 707 cookie.clear(); … … 706 720 707 721 // Same as above but just tests if cookie exists 708 bool receptionist:: get_cookie (text_tmap &fcgienv)722 bool receptionist::has_uid_cookie (text_tmap &fcgienv) 709 723 { 710 724 text_t cookie_jar = ""; 711 return get_cookie(cookie_jar, fcgienv); 725 return get_named_cookie(cookie_jar, "GSDL_UID", fcgienv); 726 712 727 } 713 728 … … 957 972 958 973 // add cookie if required 959 if (configinfo.usecookies && !get_cookie(fcgienv))974 if (configinfo.usecookiesForUID && !has_uid_cookie(fcgienv)) 960 975 response_data += "\nSet-Cookie: GSDL_UID=" + args["z"] 961 976 + "; expires=Fri, 25-Dec-2037 00:00:00 GMT"; 977 if (configinfo.usecookiesForE) { 978 // set the GSDL_E cookie 979 response_data += "\nSet-Cookie: GSDL_E=" + get_compressed_arg (args, logout) 980 + "; expires=Fri, 25-Dec-2037 00:00:00 GMT"; 981 } 982 962 983 } 963 984 } … … 1476 1497 1477 1498 1478 text_t compressedoptions = get_compressed_arg(args, logout); 1499 text_t compressedoptions = ""; 1500 if (!configinfo.usecookiesForE) { 1501 compressedoptions = get_compressed_arg(args, logout); 1502 } 1479 1503 disp.setmacro ("compressedoptions", displayclass::defaultpackage, dm_safe(compressedoptions)); 1480 1504 //disp.setmacro ("compressedoptionsUrlsafe", displayclass::defaultpackage, encodeForURL(dm_safe(compressedoptions))); // seems to be unnecessary after testing e=hack or e=hack<collect>... or e=...<collect>hack in a live server … … 1498 1522 // the old version was dm_safed, so make a dm safe version in case we need it 1499 1523 disp.setmacro ("decodedcompressedoptionsAttrDmsafe", displayclass::defaultpackage, encodeForHTMLAttr(dm_safe(dmacrovalue))); 1524 1500 1525 1501 1526 #if defined (__WIN32__) -
main/trunk/greenstone2/runtime-src/src/recpt/receptionist.h
r19109 r39000 88 88 text_tset macrofiles; 89 89 text_t saveconf; 90 bool usecookies; // true if we want cookies set 90 bool usecookiesForUID; // true if we want to save user id as a cookie 91 bool usecookiesForE; // true if want to save the e arg as a cookie instead of passing it round as an arg 91 92 bool logcgiargs; // true if we want to log cgi arguments 92 93 … … 143 144 ostream &logout); 144 145 145 bool get_cookie (text_t &cookie, text_tmap &fcgienv); 146 bool get_cookie (text_tmap &fcgienv); 147 146 bool get_uid_cookie (text_t &cookie, text_tmap &fcgienv); 147 bool has_uid_cookie (text_tmap &fcgienv); 148 bool get_named_cookie (text_t &cookie, const text_t cookie_name, text_tmap &fcgienv); 149 148 150 // get the default encoding for the given language - if it fails for any 149 151 // reason, return "" -
main/trunk/greenstone2/runtime-src/src/recpt/statusaction.cpp
r28911 r39000 171 171 << "\"</td></tr>\n"; 172 172 173 // usecookies 174 textout << outconvert << "<tr valign=top><th>usecookies</th><td>\""; 175 if (rcinfo.usecookies) textout << outconvert << "true"; 173 // usecookiesForUID 174 textout << outconvert << "<tr valign=top><th>usecookiesForUID</th><td>\""; 175 if (rcinfo.usecookiesForUID) textout << outconvert << "true"; 176 else textout << outconvert << "false"; 177 textout << outconvert << "\"</td></tr>\n"; 178 // usecookiesForE 179 textout << outconvert << "<tr valign=top><th>usecookiesForE</th><td>\""; 180 if (rcinfo.usecookiesForE) textout << outconvert << "true"; 176 181 else textout << outconvert << "false"; 177 182 textout << outconvert << "\"</td></tr>\n";
Note:
See TracChangeset
for help on using the changeset viewer.