diff --git a/lib/cookieless.php b/lib/cookieless.php new file mode 100644 index 00000000000..8c96c1227ef --- /dev/null +++ b/lib/cookieless.php @@ -0,0 +1,130 @@ +usesid=true; +* in config.php. +* Based on code from php manual by Richard at postamble.co.uk +* Attempts to use cookies if cookies not present then uses session ids attached to all urls and forms to pass session id from page to page. +* If site is open to google, google is given guest access as usual and there are no sessions. No session ids will be attached to urls for googlebot. +* This doesn't require trans_sid to be turned on but this is recommended for better performance +* you should put : +* session.use_trans_sid = 1 +* in your php.ini file and make sure that you don't have a line like this in your php.ini +* session.use_only_cookies = 1 +* @author Richard at postamble.co.uk and Jamie Pratt +* @license http://www.gnu.org/copyleft/gpl.html GNU Public License +*/ +/** +* You won't call this function directly. This function is used to process +* text buffered by php in an output buffer. All output is run through this function +* before it is ouput. +* @param string $buffer is the output sent from php +* @return string the output sent to the browser +*/ +function sid_ob_rewrite($buffer){ + $replacements = array( + '/(<\s*(a|link|script|frame|area)\s[^>]*(href|src)\s*=\s*")([^"]*)(")/i', + '/(<\s*(a|link|script|frame|area)\s[^>]*(href|src)\s*=\s*\')([^\']*)(\')/i'); + + $buffer = preg_replace_callback($replacements, "sid_rewrite_link_tag", $buffer); + $buffer = preg_replace('/