- Timestamp:
- 2009-10-29T10:41:38+13:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/runtime-src/src/recpt/receptionist.cpp
r19259 r20856 670 670 } 671 671 672 // returns true if cookie already existed, false 673 // if it was generated 674 bool receptionist::get_cookie (text_t &cookie, text_tmap &fcgienv) { 675 672 673 // Returns true if cookie already existed, false if it was generated 674 bool receptionist::get_cookie (text_t &cookie, text_tmap &fcgienv) 675 { 676 // See if we can get the GSDL_UID cookie 676 677 text_t cookiestring = gsdl_getenv ("HTTP_COOKIE", fcgienv); 677 if (!cookiestring.empty()) 678 if (!cookiestring.empty()) // This should really be handled by the findword function... 678 679 { 679 text_t::const_iterator end = cookiestring.end(); 680 text_t::const_iterator here = findchar ((text_t::const_iterator)cookiestring.begin(), end, 'G'); 681 682 while (here+9 < end) { 683 684 if (substr(here, here+8) == "GSDL_UID") { 685 cookie = substr (here+9, findchar (here+9, end, ';')); 686 return true; 687 } 688 ++here; 689 here = findchar (here, end, 'G'); 690 } 691 } 692 680 // Check if the cookie contains GSDL_UID 681 text_t gsdl_uid = "GSDL_UID="; 682 text_t::const_iterator gsdl_uid_start = findword(cookiestring.begin(), cookiestring.end(), gsdl_uid); 683 if (gsdl_uid_start != cookiestring.end()) 684 { 685 // Yes, so extract its value 686 cookie = substr(gsdl_uid_start + gsdl_uid.size(), findchar(gsdl_uid_start + gsdl_uid.size(), cookiestring.end(), ';')); 687 return true; 688 } 689 } 690 691 // Generate a new key "[host]-[epoch time]", e.g. test.com-1256764496 693 692 cookie.clear(); 694 693 text_t host = gsdl_getenv("REMOTE_ADDR", fcgienv); 695 694 time_t ttime = time(NULL); 696 if (!host.empty()) { 695 if (!host.empty()) 696 { 697 697 cookie += host; 698 698 cookie.push_back ('-'); 699 699 } 700 700 cookie += text_t(ttime); 701 701 702 702 return false; 703 703 } 704 704 705 // as above but just tests if cookie exists 706 bool receptionist::get_cookie (text_tmap &fcgienv) { 707 708 text_t c = gsdl_getenv("HTTP_COOKIE", fcgienv); 709 if (!c.empty()) { 710 text_t cookiestring = c; 711 712 text_t::const_iterator end = cookiestring.end(); 713 text_t::const_iterator here = findchar ((text_t::const_iterator)cookiestring.begin(), end, 'G'); 714 715 while (here+9 < end) { 716 if (substr(here, here+8) == "GSDL_UID") return true; 717 ++here; 718 here = findchar (here, end, 'G'); 719 } 720 } 721 return false; 722 } 705 706 // Same as above but just tests if cookie exists 707 bool receptionist::get_cookie (text_tmap &fcgienv) 708 { 709 text_t cookie_jar = ""; 710 return get_cookie(cookie_jar, fcgienv); 711 } 712 723 713 724 714 bool receptionist::log_cgi_args (cgiargsclass &args, ostream &logout, text_tmap &fcgienv) {
Note:
See TracChangeset
for help on using the changeset viewer.