Just wondering, but where actually is the Session class going to anyway?
Not for php3 i guess since php4 functions are used in it.

I'm just wondering how useful all this effort still is.

Grtz,

Brian


-----Oorspronkelijk bericht-----
Van: uw [mailto:[EMAIL PROTECTED]]
Verzonden: dinsdag 29 mei 2001 13:12
Aan: [EMAIL PROTECTED]
Onderwerp: [phplib-dev] cvs commit


From: uw
Date: Tue May 29 13:12:03 2001
Modified files:
      php-lib/php/session/session4_custom.inc

Log message:
- read it and by that beautified/reformatted the code partly
- changed $setCookie() to setCookie() looked like a typo as there's not
  $setCookie declared



Index: php-lib/php/session/session4_custom.inc
diff -u php-lib/php/session/session4_custom.inc:1.7
php-lib/php/session/session4_custom.inc:1.8
--- php-lib/php/session/session4_custom.inc:1.7 Fri Feb 23 09:20:53 2001
+++ php-lib/php/session/session4_custom.inc     Tue May 29 13:11:32 2001
@@ -9,13 +9,13 @@
  * some of the code taken from Teodor Cimpoesu's session4 class
  * Copyright (c) 2000 Teodor Cimpoesu <[EMAIL PROTECTED]>
  *
- * $Id: session4_custom.inc,v 1.7 2001/02/23 08:20:53 max Exp $
+ * $Id: session4_custom.inc,v 1.8 2001/05/29 11:11:32 uw Exp $
  *
  */ 
 
 class Session {
 
-  var $class_name;                   ## Used here for comaptibility
+  var $class_name;                  ## Used here for comaptibility
   var $id;
   var $name;
   
@@ -24,26 +24,26 @@
   var $cookie_path = '/';
   var $cookiename;
   var $lifetime = 0;
-  var $cookie_domain = '';           ## If set, the domain for which
the
-                                      ## session cookie is set.

-  var $allowcache = "passive";        ## "passive", "no", "private",
"public"
-  var $allowcache_expire = 1440;      ## If you allowcache, data
expires in this
-                                      ## many minutes.
-  var $module = "user";                      // session storage module
- user, files or mm
-  var $save_path;                    // where to save session files if
module == files
-  var $that_class = "";               ## Name of data storage container

+  var $cookie_domain = '';          ## If set, the domain for which the
+                                    ## session cookie is set.

+  var $allowcache = 'passive';      ## "passive", "no", "private",
"public"
+  var $allowcache_expire = 1440;    ## If you allowcache, data expires
in this
+                                    ## many minutes.
+  var $module = 'user';             ## session storage module - user,
files or mm
+  var $save_path;                   ## where to save session files if
module == files
+  var $that_class = '';             ## Name of data storage container

   var $that;
   
-  var $gc_time = 1440;               ## Purge all session data older
than 1440 minutes.
+  var $gc_time = 1440;              ## Purge all session data older
than 1440 minutes.
   
-  var $trans_sid_used;               // set it to true if PHP is
compiled with --enable-trans-sid
+  var $trans_sid_used;              ## set it to true if PHP is
compiled with --enable-trans-sid
 
   // compatibility properties
   var $fallback_mode;
-  var $gc_probability;               ## set this in php.ini or
httpd.conf (.htaccess)
-  var $secure_auto_init = 1;          ## Set to 0 only, if all pages
call
-  var $in = false;                    ## Marker: Did we already include
the autoinit file?
-  var $magic = "";                   ## Some string you should change.
+  var $gc_probability;              ## set this in php.ini or
httpd.conf (.htaccess)
+  var $secure_auto_init = 1;        ## Set to 0 only, if all pages call
+  var $in = false;                  ## Marker: Did we already include
the autoinit file?
+  var $magic = '';                  ## Some string you should change.
   
 
   
@@ -66,17 +66,18 @@
   
   
   function unregister ($things) {
-       $ok = true;
-       foreach (explode (',', $things) as $var_name) {
-               $ok = $ok && session_unregister (trim ($var_name) );
-       }
-       return $ok;
+  
+    $ok = true;
+    foreach (explode (',', $things) as $var_name) {
+      $ok = $ok && session_unregister (trim ($var_name) );
+    }
+    
+    return $ok;
   }
   
   
   function get_id() {
-    $id = session_id();
-    $this->id = $id;
+    $this->id = session_id();
   }
 
   /**
@@ -85,16 +86,19 @@
    abandon a session. 
    */
   function put_id() {
-       if (get_cfg_var ('session.use_cookies') == 1) {
-               $cookie_params = session_get_cookie_params();
-               $setCookie ($this->name, '',0, 
-                       $cookie_params['path'],
$cookie_params['domain']);
-               
-               global $HTTP_COOKIE_VARS;
-               $HTTP_COOKIE_VARS[$this->name] = "";
-       }
-       session_unset();
-       return true; 
+    global $HTTP_COOKIE_VARS;
+
+    if (get_cfg_var ('session.use_cookies') == 1) {
+    
+      $cookie_params = session_get_cookie_params();
+      setCookie ($this->name, '', 0,  $cookie_params['path'],
$cookie_params['domain']);
+      $HTTP_COOKIE_VARS[$this->name] = "";
+      
+    }
+
+    session_unset();
+
+    return true; 
   }
   
 
@@ -103,19 +107,20 @@
    * Hint: now PHP has --enable-trans-sid for this
   */
   function url ($url) {
-      if ($this->trans_sid_used) return $url;
-      
-      global $HTTP_COOKIE_VARS;
+    global $HTTP_COOKIE_VARS;
     
-      $url=ereg_replace("[&?]+$", "", $url); 
-      if (strstr($url, $this->name)) return $url;
+    if ($this->trans_sid_used) 
+      return $url;
+    
+    $url = ereg_replace("[&?]+$", "", $url); 
+    if (strstr($url, $this->name)) 
+      return $url;
 
-      if (!$HTTP_COOKIE_VARS[$this->name]) {
-         $url .= ( strpos($url, "?") != false ?  "&" : "?" ) 
-                 . urlencode($this->name)."=".$this->id;
-      }
+    if (!$HTTP_COOKIE_VARS[$this->name]) {
+      $url .= ( strpos($url, "?") != false ?  "&" : "?" ) .
urlencode($this->name) . "=" . $this->id;
+    }
 
-      return $url;
+    return $url;
   }
 
   function purl($url) {
@@ -125,7 +130,7 @@
   function self_url() {
     global $PHP_SELF, $QUERY_STRING;
     return $this->url($PHP_SELF.
-                    ((isset($QUERY_STRING) && ("" != $QUERY_STRING)) ?
"?".$QUERY_STRING : ""));
+               ((isset($QUERY_STRING) && ("" != $QUERY_STRING)) ?
"?".$QUERY_STRING : ""));
   }   
   
   function pself_url() {
@@ -136,12 +141,13 @@
    * Stores session id in a hidden variable (part of a form)
    */
   function get_hidden_session() {
-      if ($this->trans_sid_used) return;
-      return 
-               sprintf("<input type=\"hidden\" name=\"%s\"
value=\"%s\">\n", 
-               $this->name, 
-               $this->id
-               );
+    if ($this->trans_sid_used) 
+      return;
+
+    return sprintf("<input type=\"hidden\" name=\"%s\"
value=\"%s\">\n", 
+                      $this->name, 
+                      $this->id
+              );
   }
 
   function hidden_session() {
@@ -151,9 +157,7 @@
   function add_query ($qarray) {
     global $QUERY_STRING, $HTTP_COOKIE_VARS;
 
-    $sep_char = ((isset($QUERY_STRING) && ("" != $QUERY_STRING))  
-                || $HTTP_COOKIE_VARS[$this->name]) 
-           ? "&" : "?";
+    $sep_char = ((isset($QUERY_STRING) && ("" != $QUERY_STRING))  ||
$HTTP_COOKIE_VARS[$this->name]) ? "&" : "?";
 
     $qstring = "";
     while (list($k, $v) = each($qarray)) {
@@ -161,7 +165,7 @@
       $sep_char = "&";
     }
     return $qstring;
-  }                        
+  }
 
       
   function padd_query ($qarray) {
@@ -174,7 +178,7 @@
    * @return string
    */
   function serialize () {
-       return session_encode();
+    return session_encode();
   }
   
   /**
@@ -183,7 +187,7 @@
    * @return boolean
    */
   function unserialize (&$data_string) {
-       return session_decode ($data_string);
+    return session_decode ($data_string);
   }
 
   function reimport_get_vars() {
@@ -200,7 +204,7 @@
 
   function reimport_any_vars($arrayname) {
     global $$arrayname;
-   $GLOBALS = array_merge ($GLOBALS, $arrayname);
+    $GLOBALS = array_merge ($GLOBALS, $arrayname);
   }
 
   function get_lock() {
@@ -220,7 +224,8 @@
     $this->set_tokenname(); 
     $this->put_headers();
     @session_start();
-    if ($this->module != 'user') $this->get_id(); // otherwise get_id()
is called in custom open() method
+    if ($this->module != 'user') 
+      $this->get_id(); // otherwise get_id() is called in custom open()
method
   }
   
   function open() {
@@ -237,11 +242,13 @@
    * delete the current session destroying all registered data
    */
   function delete () {
+    
     if ($this->module == 'user') {
-       $this->that->ac_delete($this->id, $this->name);
-       $this->put_id();
-       return true;
+      $this->that->ac_delete($this->id, $this->name);
+      $this->put_id();
+      return true;
     }
+    
     return true;
   }
   
@@ -252,10 +259,10 @@
     */
   function freeze () {
     if ($this->module == 'user') {
-       $str = session_encode();
-       $r = $this->that->ac_store($this->id, $this->name, $str);  
-       #$this->release_lock();
-       return $r;
+      $str = session_encode();
+      $r = $this->that->ac_store($this->id, $this->name, $str);  
+      #$this->release_lock();
+      return $r;
     }
     return true;
   }
@@ -264,11 +271,12 @@
      get frozen session vars
      */
   function thaw() {
+  
       if ($this->module == 'user') {
-         #   $this->get_lock();
-         $vals = $this->that->ac_get_value($this->id, $this->name); 
-         return $vals;
+        # $this->get_lock();
+        return $this->that->ac_get_value($this->id, $this->name);;
       }
+      
       return true;
   }
     
@@ -276,42 +284,54 @@
      Destroy all session data older than $this->gc_time
    */
   function gc() {
-      if ($this->module == 'user') {
-         if (!$this->gc_time ) $this->gc_time =
get_cfg_var("session.gc_maxlifetime");
-         return $this->that->ac_gc($this->gc_time, $this->name);
-      }
-      return true;
+    if ($this->module == 'user') {
+    
+      if (!$this->gc_time ) 
+        $this->gc_time = get_cfg_var("session.gc_maxlifetime");
+    
+      return $this->that->ac_gc($this->gc_time, $this->name);
+    }
+    
+    return true;
   }
 
 
   // helper functions used in initialization
 
   function set_container(){
+  
     switch ($this->module) {
-       case "user" :
-               session_module_name('user');
-               $name = $this->that_class;
-               $this->that = new $name;
-   
-               $this->that->ac_start();
-               // set custom session handlers
-               session_set_save_handler(array (&$this, 'open'),
-                                       array (&$this, 'close'),
-                                       array (&$this, 'thaw'),
-                                       array (&$this, 'freeze'),
-                                       array (&$this, 'delete'),
-                                       array (&$this, 'gc')
-                                       );
-               break;
-       case "mm":
-               session_module_name('mm');
-               break;
-       case "files" :
-       default:
-               if ($this->save_path)
session_save_path($this->save_path);
-               session_module_name('files');
-               break;
+      case "user" :
+        
+        session_module_name('user');
+        
+        $name = $this->that_class;
+        $this->that = new $name;
+        $this->that->ac_start();
+        
+        // set custom session handlers
+        session_set_save_handler(array (&$this, 'open'),
+            array (&$this, 'close'),
+            array (&$this, 'thaw'),
+            array (&$this, 'freeze'),
+            array (&$this, 'delete'),
+            array (&$this, 'gc')
+        );
+        break;
+    
+      case "mm":
+        session_module_name('mm');
+        break;
+        
+      case "files" :
+      default:
+        if ($this->save_path) 
+          session_save_path($this->save_path);
+          
+        session_module_name('files');
+        break;
     }
+    
   }
 
   function set_tokenname(){
@@ -319,22 +339,23 @@
       session_name ($this->name);
       
       if (!$this->cookie_domain) {
-         $this->cookie_domain = get_cfg_var ("session.cookie_domain");
+        $this->cookie_domain = get_cfg_var ("session.cookie_domain");
       }
       
       if (!$this->cookie_path && get_cfg_var('session.cookie_path')) {
-         $this->cookie_path = get_cfg_var('session.cookie_path');
+        $this->cookie_path = get_cfg_var('session.cookie_path');
+      } elseif (!$this->cookie_path) {
+        $this->cookie_path = "/";
       }
-      elseif (!$this->cookie_path) {
-         $this->cookie_path = "/";
-      }
       
       if ($this->lifetime > 0) {
-         $lifetime = time()+$this->lifetime*60;
+        $lifetime = time()+$this->lifetime*60;
+      } else {
+        $lifetime = 0;
       }
-      else $lifetime = 0;
+      
       session_set_cookie_params($lifetime, $this->cookie_path,
$this->cookie_domain);
-  }   
+  }
 
   function put_headers() {
     # set session.cache_limiter corresponding to $this->allowcache.
@@ -355,5 +376,6 @@
       break;
     }
   }
+  
 }
 ?>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to