Thread: [Phplib-commit] CVS: php-lib/php/session session3.inc,1.4,1.5
Brought to you by:
nhruby,
richardarcher
From: Richard A. <ric...@us...> - 2001-08-18 02:45:08
|
Update of /cvsroot/phplib/php-lib/php/session In directory usw-pr-cvs1:/tmp/cvs-serv32229 Modified Files: session3.inc Log Message: changes to comments and whitespace only - syncing devel and stable trees Index: session3.inc =================================================================== RCS file: /cvsroot/phplib/php-lib/php/session/session3.inc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** session3.inc 2001/08/12 04:58:36 1.4 --- session3.inc 2001/08/18 02:45:05 1.5 *************** *** 8,15 **** * $Id$ * ! */ class Session { - var $classname = "Session"; ## Needed for object serialization. --- 8,14 ---- * $Id$ * ! */ class Session { var $classname = "Session"; ## Needed for object serialization. *************** *** 80,84 **** } - ## get_id(): ## --- 79,82 ---- *************** *** 90,96 **** global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS, $QUERY_STRING; $newid=true; ! $this->name = $this->cookiename==""?$this->classname:$this->cookiename; ! if (empty($id)) { $newid=false; --- 88,94 ---- global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS, $QUERY_STRING; $newid=true; ! $this->name = $this->cookiename==""?$this->classname:$this->cookiename; ! if (empty($id)) { $newid=false; *************** *** 104,108 **** break; case "cookie": ! $id = isset($HTTP_COOKIE_VARS[$this->name]) ? $HTTP_COOKIE_VARS[$this->name] : ""; break; --- 102,106 ---- break; case "cookie": ! $id = isset($HTTP_COOKIE_VARS[$this->name]) ? $HTTP_COOKIE_VARS[$this->name] : ""; break; *************** *** 112,123 **** } } ! if ( "" == $id ) { $newid=true; $id = $this->that->ac_newid(md5(uniqid($this->magic)), $this->name); } ! ! ! switch ($this->mode) { case "cookie": --- 110,119 ---- } } ! if ( "" == $id ) { $newid=true; $id = $this->that->ac_newid(md5(uniqid($this->magic)), $this->name); } ! switch ($this->mode) { case "cookie": *************** *** 128,134 **** SetCookie($this->name, $id, time()+$this->lifetime*60, "/", $this->cookie_domain); } ! // Remove session ID info from QUERY String - it is in cookie ! if ( !empty($QUERY_STRING) ) { $QUERY_STRING = ereg_replace( --- 124,130 ---- SetCookie($this->name, $id, time()+$this->lifetime*60, "/", $this->cookie_domain); } ! // Remove session ID info from QUERY String - it is in cookie ! if ( !empty($QUERY_STRING) ) { $QUERY_STRING = ereg_replace( *************** *** 147,156 **** ; break; ! } $this->id = $id; } ## put_id(): ! ## ## Stop using the current session id (unset cookie, ...) and ## abandon a session. --- 143,152 ---- ; break; ! } $this->id = $id; } ## put_id(): ! ## ## Stop using the current session id (unset cookie, ...) and ## abandon a session. *************** *** 163,167 **** $HTTP_COOKIE_VARS[$this->name] = ''; break; ! default: // do nothing. We don't need to die for modes other than cookie here. --- 159,163 ---- $HTTP_COOKIE_VARS[$this->name] = ''; break; ! default: // do nothing. We don't need to die for modes other than cookie here. *************** *** 169,177 **** } } ! ## delete(): ## ## Delete the current session record and put the session id. ! function delete() { $this->that->ac_delete($this->id, $this->name); --- 165,173 ---- } } ! ## delete(): ## ## Delete the current session record and put the session id. ! function delete() { $this->that->ac_delete($this->id, $this->name); *************** *** 181,188 **** ## url($url): ## ! ## Helper function: returns $url concatenated with the current ## session $id. ! ! function url($url){ // Remove existing session info from url: if (strstr($url, $this->name) != false) --- 177,184 ---- ## url($url): ## ! ## Helper function: returns $url concatenated with the current ## session $id. ! ! function url($url) { // Remove existing session info from url: if (strstr($url, $this->name) != false) *************** *** 190,198 **** $url = ereg_replace("&*".$this->name."=[[:alnum:]]+", "", $url); } ! // Remove trailing ?/& if needed $url=ereg_replace("[&?]+$", "", $url); ! ! switch ($this->mode) { case "get": --- 186,193 ---- $url = ereg_replace("&*".$this->name."=[[:alnum:]]+", "", $url); } ! // Remove trailing ?/& if needed $url=ereg_replace("[&?]+$", "", $url); ! switch ($this->mode) { case "get": *************** *** 200,203 **** --- 195,201 ---- urlencode($this->name)."=".$this->id; break; + default: + ; + break; } return $url; *************** *** 210,213 **** --- 208,212 ---- function self_url() { global $PHP_SELF, $QUERY_STRING; + return $this->url($PHP_SELF. ((!empty($QUERY_STRING)) ? "?".$QUERY_STRING : "")); *************** *** 217,224 **** print $this->self_url(); } ! function get_hidden_session() { ! return sprintf("<input type=\"hidden\" name=\"%s\" value=\"%s\">\n", ! $this->name, $this->id); } --- 216,223 ---- print $this->self_url(); } ! function get_hidden_session() { ! return sprintf("<input type=\"hidden\" name=\"%s\" value=\"%s\">\n", ! $this->name, $this->id); } *************** *** 227,231 **** print $this->get_hidden_session(); } ! function get_hidden_id() { switch($this->mode) { --- 226,230 ---- print $this->get_hidden_session(); } ! function get_hidden_id() { switch($this->mode) { *************** *** 235,239 **** } } ! function hidden_id() { print $this->get_hidden_id(); --- 234,238 ---- } } ! function hidden_id() { print $this->get_hidden_id(); *************** *** 244,249 **** global $QUERY_STRING; ! if ( !empty($QUERY_STRING) ! || ($this->mode == "get")) { $sep_char = "&"; } else { --- 243,248 ---- global $QUERY_STRING; ! if ( !empty($QUERY_STRING) ! || ($this->mode == "get")) { $sep_char = "&"; } else { *************** *** 306,310 **** } } - '); --- 305,308 ---- *************** *** 325,330 **** break; } - - # print "<br>var $var t $t str $str<br>\n"; } --- 323,326 ---- *************** *** 355,363 **** } } ! $r = $this->that->ac_store($this->id, $this->name, $str); $this->release_lock(); ! if(!$r) $this->that->ac_halt("Session: freeze() failed."); } --- 351,359 ---- } } ! $r = $this->that->ac_store($this->id, $this->name, $str); $this->release_lock(); ! if (!$r) $this->that->ac_halt("Session: freeze() failed."); } *************** *** 404,408 **** ## ! function set_container(){ $name = $this->that_class; $this->that = new $name; --- 400,404 ---- ## ! function set_container() { $name = $this->that_class; $this->that = new $name; *************** *** 411,470 **** } ! function set_tokenname(){ $this->name = $this->cookiename==""?$this->classname:$this->cookiename; } ! function release_token( $sid = "" ) ! { global $HTTP_COOKIE_VARS, $HTTP_POST_VARS, $HTTP_GET_VARS, $HTTP_HOST, $HTTPS; - - if ( isset($this->fallback_mode) - && ( "get" == $this->fallback_mode ) - && ( "cookie" == $this->mode ) - && ( ! isset($HTTP_COOKIE_VARS[$this->name]) ) - ) - { ! // Looks like no cookie here - check GET/POST params ! if ( isset($HTTP_GET_VARS[$this->name]) || ! isset($HTTP_POST_VARS[$this->name]) ) ! { ! // Session info passed via GET/POST - go to fallback_mode ! $this->mode = $this->fallback_mode; ! } ! else ! { ! // It seems to be the first load of this page - ! // no cookie and no GET/POST params ! ! header("Status: 302 Moved Temporarily"); ! ! // Generate session ID and setup cookie. ! $this->get_id($sid); ! ! // Next line is to generate correct self_url() later ! $this->mode = $this->fallback_mode; ! ! if( isset($HTTPS) && $HTTPS == 'on' ) { ! ## You will need to fix suexec as well, ! ## if you use Apache and CGI PHP ! $PROTOCOL='https'; ! } else { ! $PROTOCOL='http'; ! } ! ! header("Location: ". $PROTOCOL. "://".$HTTP_HOST.$this->self_url()); ! exit; } } ! } function put_headers() { # Allowing a limited amount of caching, as suggested by # Padraic Renaghan on ph...@li.... # Note that in HTTP/1.1 the Cache-Control headers override the Expires # headers and HTTP/1.0 ignores headers it does not recognize (e.g, ! # Cache-Control). Mulitple Cache-Control directives are split into # mulitple headers to better support MSIE 4.x. # --- 407,460 ---- } ! function set_tokenname() { $this->name = $this->cookiename==""?$this->classname:$this->cookiename; } ! function release_token($sid = "") { global $HTTP_COOKIE_VARS, $HTTP_POST_VARS, $HTTP_GET_VARS, $HTTP_HOST, $HTTPS; ! if ( isset($this->fallback_mode) ! && ("get" == $this->fallback_mode) ! && ("cookie" == $this->mode) ! && (! isset($HTTP_COOKIE_VARS[$this->name])) ) { ! ! // Looks like no cookie here - check GET/POST params ! if ( isset($HTTP_GET_VARS[$this->name]) ! || isset($HTTP_POST_VARS[$this->name]) ) { ! // Session info passed via GET/POST - go to fallback_mode ! $this->mode = $this->fallback_mode; ! } else { ! // It seems to be the first load of this page - ! // no cookie and no GET/POST params ! ! header("Status: 302 Moved Temporarily"); ! ! // Generate session ID and setup cookie. ! $this->get_id($sid); ! ! // Next line is to generate correct self_url() later ! $this->mode = $this->fallback_mode; ! ! if ( isset($HTTPS) && $HTTPS == 'on' ) { ! ## You will need to fix suexec as well, if you ! ## use Apache and CGI PHP ! $PROTOCOL='https'; ! } else { ! $PROTOCOL='http'; } + header("Location: ". $PROTOCOL. "://".$HTTP_HOST.$this->self_url()); + exit; } ! } ! } function put_headers() { # Allowing a limited amount of caching, as suggested by # Padraic Renaghan on ph...@li.... + # # Note that in HTTP/1.1 the Cache-Control headers override the Expires # headers and HTTP/1.0 ignores headers it does not recognize (e.g, ! # Cache-Control). Mulitple Cache-Control directives are split into # mulitple headers to better support MSIE 4.x. # *************** *** 475,479 **** case "passive": ! $mod_gmt = gmdate("D, d M Y H:i:s", getlastmod()) . " GMT"; header("Last-Modified: " . $mod_gmt); # possibly ie5 needs the pre-check line. This needs testing. --- 465,469 ---- case "passive": ! $mod_gmt = gmdate("D, d M Y H:i:s", getlastmod()) . " GMT"; header("Last-Modified: " . $mod_gmt); # possibly ie5 needs the pre-check line. This needs testing. *************** *** 483,487 **** case "public": $exp_gmt = gmdate("D, d M Y H:i:s", time() + $this->allowcache_expire * 60) . " GMT"; ! $mod_gmt = gmdate("D, d M Y H:i:s", getlastmod()) . " GMT"; header("Expires: " . $exp_gmt); header("Last-Modified: " . $mod_gmt); --- 473,477 ---- case "public": $exp_gmt = gmdate("D, d M Y H:i:s", time() + $this->allowcache_expire * 60) . " GMT"; ! $mod_gmt = gmdate("D, d M Y H:i:s", getlastmod()) . " GMT"; header("Expires: " . $exp_gmt); header("Last-Modified: " . $mod_gmt); *************** *** 489,493 **** header("Cache-Control: max-age=" . $this->allowcache_expire * 60); break; ! case "private": $mod_gmt = gmdate("D, d M Y H:i:s", getlastmod()) . " GMT"; --- 479,483 ---- header("Cache-Control: max-age=" . $this->allowcache_expire * 60); break; ! case "private": $mod_gmt = gmdate("D, d M Y H:i:s", getlastmod()) . " GMT"; *************** *** 521,525 **** } - ## ## Initialization --- 511,514 ---- *************** *** 528,532 **** function start($sid = "") { $this->set_container(); ! $this->set_tokenname(); $this->put_headers(); $this->release_token($sid); --- 517,521 ---- function start($sid = "") { $this->set_container(); ! $this->set_tokenname(); $this->put_headers(); $this->release_token($sid); |