phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: phpgwapi/inc class.sessions.inc.php, 1.104.4.13,


From: Dave Hall <address@hidden>
Subject: [Phpgroupware-cvs] CVS: phpgwapi/inc class.sessions.inc.php, 1.104.4.13, 1.104.4.14 class.sessions_db.inc.php, 1.2.2.10.2.6, 1.2.2.10.2.7 class.sessions_php4.inc.php, 1.6.2.10.2.5, 1.6.2.10.2.6
Date: Thu, 17 Jul 2003 18:23:53 -0400

Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv10637

Modified Files:
      Tag: Version-0_9_16-branch
        class.sessions.inc.php class.sessions_db.inc.php 
        class.sessions_php4.inc.php 
Log Message:
some OOP changes and phpdocs

Index: class.sessions.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.sessions.inc.php,v
retrieving revision 1.104.4.13
retrieving revision 1.104.4.14
diff -C2 -r1.104.4.13 -r1.104.4.14
*** class.sessions.inc.php      21 Jun 2003 23:46:11 -0000      1.104.4.13
--- class.sessions.inc.php      17 Jul 2003 22:23:50 -0000      1.104.4.14
***************
*** 24,36 ****
    \**************************************************************************/
  
!       /* $Id$ */
  
!       /*
!       ** Reserved session_flags
!       ** A - anonymous session
!       ** N - None, normal session
!       */
! 
!       if (empty($GLOBALS['phpgw_info']['server']['sessions_type']))
        {
                $GLOBALS['phpgw_info']['server']['sessions_type'] = 'db';
--- 24,30 ----
    \**************************************************************************/
  
!   /* $Id$ */
  
!        if (empty($GLOBALS['phpgw_info']['server']['sessions_type']))
        {
                $GLOBALS['phpgw_info']['server']['sessions_type'] = 'db';
***************
*** 38,57 ****
        
include_once(PHPGW_API_INC.'/class.sessions_'.$GLOBALS['phpgw_info']['server']['sessions_type'].'.inc.php');
  
!       class sessions extends sessions_
        {
!               var $login;
                var $passwd;
                var $account_id;
                var $account_lid;
                var $history_id;
                var $account_domain;
                var $session_flags;
                var $sessionid;
                var $kp3;
                var $key;
                var $iv;
  
                var $data;
                var $db;
                var $public_functions = array(
                        'list_methods' => True,
--- 32,120 ----
        
include_once(PHPGW_API_INC.'/class.sessions_'.$GLOBALS['phpgw_info']['server']['sessions_type'].'.inc.php');
  
!       /**
!        * Session Management Libabray
!        * 
!        * This allows phpGroupWare to use php4 or database sessions 
!        *
!        * @package phpgwapi
!        * @subpackage sessions
!        * @abstract
!        * @author NetUSE AG Boris Erdmann, Kristian Koehntopp <br> hacked on 
by phpGW
!        * @copyright &copy; 1998-2000 NetUSE AG Boris Erdmann, Kristian 
Koehntopp <br> &copy; 2003 FreeSoftware Foundation
!        * @license LGPL
!        * @link http://www.sanisoft.com/phplib/manual/DB_sql.php
!        * @uses db
!        */
! 
!       class sessions_
        {
!               /**
!         * @var string current user login
!         */
!         var $login;
!         
!         /**
!         * @var sting current user password
!         */
                var $passwd;
+         
+         /**
+         * @var int current user db/ldap account id
+         */
                var $account_id;
+         
+         /**
+         * @var string current user account login id - ie address@hidden
+         */
                var $account_lid;
+         
+         /**
+         * @var string previous page call id - repost prevention
+         */
                var $history_id;
+         
+         /**
+         * @var string domain for current user
+         */
                var $account_domain;
+         
+         /**
+         * @var session type flag, A - anonymous session, N - None, normal 
session
+         */
                var $session_flags;
+         
+         /**
+         * @var string current user session id
+         */
                var $sessionid;
+         
+         /**
+         * @var string not sure what this does, but it is important :)
+         */
                var $kp3;
+         
+         /**
+         * @var string encryption key?
+         */
                var $key;
+         
+         /**
+         * @var string iv == ivegotnoidea ;) (skwashd)
+         */
                var $iv;
  
+         /**
+         * @var session data
+         */
                var $data;
+         
+         /**
+         * @var object holder for the database object
+         */ 
                var $db;
+         
+         /**
+         * @var array publicly available methods
+         */
                var $public_functions = array(
                        'list_methods' => True,
***************
*** 61,71 ****
                );
  
!               var $cookie_domain;
!               var $xmlrpc_method_called;
  
!               
/*************************************************************************\
!               * Constructor just loads up some defaults from cookies          
          *
!               
\*************************************************************************/
!               function sessions()
                {
  
--- 124,141 ----
                );
  
!               /**
!         * @var string domain for cookies
!         */
!         var $cookie_domain;
!               
!         /**
!         * @var name of XML-RPC/SOAP method called
!         */
!         var $xmlrpc_method_called;
  
!               /**
!               * Constructor just loads up some defaults from cookies
!               */
!               function sessions_()
                {
  
***************
*** 135,144 ****
                                unset($config);
                        }
- 
-                       // call the constructor of the extended class
-                       $this->sessions_();
                }
  
!               function DONTlist_methods($_type)
                {
                        if (is_array($_type))
--- 205,218 ----
                                unset($config);
                        }
                }
  
!               /**
!         * Introspection for XML-RPC/SOAP
!         * Diabled - why??
!         *
!         * @param string $_type tpye of introspection being sought
!         * @return array available methods and args
!         */
!         function DONTlist_methods($_type)
                {
                        if (is_array($_type))
***************
*** 173,177 ****
                }
  
!               function verify($sessionid='',$kp3='')
                {
                        if(empty($sessionid) || !$sessionid)
--- 247,258 ----
                }
  
!               /**
!         * Check to see if a session is still current and valid
!         *
!         * @param string $sessionid session id to be verfied
!         * @param string $kp3 ?? to be verified
!         * @return bool is the session valid?
!         */
!         function verify($sessionid='',$kp3='')
                {
                        if(empty($sessionid) || !$sessionid)
***************
*** 323,329 ****
                }
  
!               
/*************************************************************************\
!               * Functions for creating and verifying the session              
          *
!               
\*************************************************************************/
                function getuser_ip()
                {
--- 404,416 ----
                }
  
!               /**
!               * Functions for creating and verifying the session
!               */
!         
!         /**
!         * Get the ip address of current users
!         *
!         * @return string ip address
!         */
                function getuser_ip()
                {
***************
*** 331,335 ****
                }
  
!               function phpgw_set_cookiedomain()
                {
                        $dom = $_SERVER['HTTP_HOST'];
--- 418,427 ----
                }
  
!               /**
!         * Set the domain used for cookies
!         *
!         * @return string domain
!         */
!         function phpgw_set_cookiedomain()
                {
                        $dom = $_SERVER['HTTP_HOST'];
***************
*** 362,366 ****
                }
  
!               function 
phpgw_setcookie($cookiename,$cookievalue='',$cookietime=0)
                {
                        if (!$this->cookie_domain)
--- 454,465 ----
                }
  
!               /**
!         * Set a cookie
!         *
!         * @param string $cookiename name of cookie to be set
!         * @param string $cookievalue value to be used, if unset cookie is 
cleared (optional)
!         * @param int $cookietime when cookie should expire, 0 for session 
only (optional)
!         */
!         function phpgw_setcookie($cookiename,$cookievalue='',$cookietime=0)
                {
                        if (!$this->cookie_domain)
***************
*** 371,375 ****
                }
  
!               function create($login,$passwd = '',$passwd_type = '')
                {
                        if (is_array($login))
--- 470,482 ----
                }
  
!               /**
!         * Create a new session
!         *
!         * @param string $login user login
!         * @param string $passwd user password
!         * @param string $passwd_type type of password being used, ie 
plaintext, md5, sha1
!         * @return string session id
!         */
!         function create($login,$passwd = '',$passwd_type = '')
                {
                        if (is_array($login))
***************
*** 484,495 ****
                }
  
!               /*!
!               @function log_access
!               @abstract write or update (for logout) the access_log
!               @function 
log_access($now,$sessionid,$login='',$user_ip='',$account_id='')
!               @param $sessionid id of session or 0 for unsuccessful logins
!               @param $login account_lid (evtl. with domain) or '' for settion 
the logout-time
!               @param $user_ip ip to log
!               @param $account_id numerical account_id
                */
                function 
log_access($sessionid,$login='',$user_ip='',$account_id='')
--- 591,601 ----
                }
  
!               /**
!         * Write or update (for logout) the access_log
!               *
!               * @param string $sessionid id of session or 0 for unsuccessful 
logins
!               * @param string $login account_lid (evtl. with domain) or '' 
for settion the logout-time
!               * @param string $user_ip ip to log
!               * @param int $account_id numerical account_id
                */
                function 
log_access($sessionid,$login='',$user_ip='',$account_id='')
***************
*** 516,526 ****
                }
  
!               /*!
!               @function login_blocked
!               @abstract shield against brute-force-attacks, block login if to 
many unsuccessful logins
!               @function login_blocked($login,$ip)
!               @param $login account_lid (evtl. with domain)
!               @param $ip ip of the user
!               @returns True if blocked, else False
                */
                function login_blocked($login,$ip)
--- 622,631 ----
                }
  
!               /**
!               * Protect against brute force attacks, block login if too many 
unsuccessful login attmepts
!         *
!               * @param string $login account_lid (evtl. with domain)
!               * @param string $ip ip of the user
!               * @returns bool login blocked?
                */
                function login_blocked($login,$ip)
***************
*** 573,577 ****
                }
  
!               function verify_server($sessionid, $kp3)
                {
                        $GLOBALS['phpgw']->interserver = 
CreateObject('phpgwapi.interserver');
--- 678,689 ----
                }
  
!               /**
!         * Verfy a peer server access request
!         * 
!         * @param string $sessionid session id to verfiy
!         * @param string $kp3 ??
!         * @return bool verfied?
!         */
!         function verify_server($sessionid, $kp3)
                {
                        $GLOBALS['phpgw']->interserver = 
CreateObject('phpgwapi.interserver');
***************
*** 696,700 ****
                }
  
!               function create_server($login,$passwd)
                {
                        $GLOBALS['phpgw']->interserver = 
CreateObject('phpgwapi.interserver');
--- 808,819 ----
                }
  
!               /**
!         * Validate a peer server login request
!         *
!         * @param string $login login name
!         * @param string $password password
!         * @return bool login ok?
!         */
!         function create_server($login,$passwd)
                {
                        $GLOBALS['phpgw']->interserver = 
CreateObject('phpgwapi.interserver');
***************
*** 763,770 ****
                }
  
!               
/*************************************************************************\
!               * Functions for appsession data and session cache               
          *
!               
\*************************************************************************/
!               function read_repositories($cached='',$write_cache=True)
                {
                        $GLOBALS['phpgw']->acl->acl($this->account_id);
--- 882,893 ----
                }
  
!               /**
!               * Functions for appsession data and session cache
!         */
! 
!               /**
!         * Is this also useless?? (skwashd)
!         */
!         function read_repositories($cached='',$write_cache=True)
                {
                        $GLOBALS['phpgw']->acl->acl($this->account_id);
***************
*** 796,799 ****
--- 919,925 ----
                }
  
+               /**
+         * Is this also useless?? (skwashd)
+         */
                function setup_cache($write_cache=True)
                {
***************
*** 819,828 ****
                        }
                }
! 
! // This looks to be useless
! // This will capture everything in the $GLOBALS['phpgw_info'] including 
server info,
! // and store it in appsessions.  This is really incompatible with any type of 
restoring
! // from appsession as the saved user info is really in ['user'] rather than 
the root of
! // the structure, which is what this class likes.
                function save_repositories()
                {
--- 945,956 ----
                        }
                }
!         
!         /**
!         * This looks to be useless
!         * This will capture everything in the $GLOBALS['phpgw_info'] 
including server info,
!         * and store it in appsessions.  This is really incompatible with any 
type of restoring
!         * from appsession as the saved user info is really in ['user'] rather 
than the root of
!         * the structure, which is what this class likes.
!         */
                function save_repositories()
                {
***************
*** 841,848 ****
                        $sessionData = $this->appsession('sessiondata');
                        
!                       if (is_array($sessionData))
                        {
!                               reset($sessionData);
!                               while(list($key,$value) = each($sessionData))
                                {
                                        global $$key;
--- 969,975 ----
                        $sessionData = $this->appsession('sessiondata');
                        
!                       if (!empty($sessionData) && is_array($sessionData))
                        {
!                               foreach($sessionData as $key => $value)
                                {
                                        global $$key;
***************
*** 854,858 ****
                }
  
!               // save the current values of the variables
                function save()
                {
--- 981,987 ----
                }
  
!               /**
!         * Save the current values of all registered variables
!         */
                function save()
                {
***************
*** 872,876 ****
                }
  
!               // create a list a variable names, wich data need's to be 
restored
                function register($_variableName)
                {
--- 1001,1009 ----
                }
  
!               /**
!         * Create a list a variable names, which data needs to be restored
!         *
!         * @param string $_variableName name of variable to be registered
!         */
                function register($_variableName)
                {
***************
*** 879,883 ****
                }
  
!               // mark variable as unregistered
                function unregister($_variableName)
                {
--- 1012,1020 ----
                }
  
!               /**
!         * Mark variable as unregistered
!         *
!         * @param string $_variableName name of variable to deregister
!         */
                function unregister($_variableName)
                {
***************
*** 886,890 ****
                }
  
!               // check if we have a variable registred already
                function is_registered($_variableName)
                {
--- 1023,1032 ----
                }
  
!               /**
!         * Check if we have a variable registred already
!         *
!         * @param string $_variableName name of variable to check
!         * @return bool was the variable found?
!         */
                function is_registered($_variableName)
                {
***************
*** 898,906 ****
                        }
                }
!                               /*!
!               @function generate_click_history
!               @abstract additional tracking of user actions - prevents 
reposts/use of back button
!               @returns string current history id
!               @author Dave Hall
                */
                function generate_click_history()
--- 1040,1048 ----
                        }
                }
!               /**
!         * Additional tracking of user actions - prevents reposts/use of back 
button
!         *
!         * @author skwashd
!         * @return string current history id
                */
                function generate_click_history()
***************
*** 920,930 ****
                }
                
!               /*!
!               @function is_repost
!               @abstract detects if the page has already been called before - 
good for forms
!               @function is_repost($diplay_error)
!               @param $diplay_error - when implemented will use the generic 
error handling code
!               @returns True if called previously, else False - call ok
!               @author Dave Hall
                */
                function is_repost($display_error = False)
--- 1062,1071 ----
                }
                
!               /**
!         * Detects if the page has already been called before - good for forms
!         *
!         * @author skwashd
!               * @param bool $diplay_error when implemented will use the 
generic error handling code
!               * @return True if called previously, else False - call ok
                */
                function is_repost($display_error = False)
***************
*** 950,956 ****
                }
  
!               
/*************************************************************************\
!               * Function to handle session support via url or cookies         
          *
!               
\*************************************************************************/
                function link($url, $extravars = '')
                {
--- 1091,1101 ----
                }
  
!               /**
!         * Generate a url which supports url or cookies based sessions
!         *
!         * @param string $url a url relative to the phpgroupware install root
!         * @param array $extravars query string arguements
!         * @return string generated url
!         */
                function link($url, $extravars = '')
                {
***************
*** 1054,1056 ****
                        return $url;
                }
!       }
--- 1199,1303 ----
                        return $url;
                }
!        /**
!         * The remaining methods are abstract - as they are unique for each 
session handler
!         */
!         
!         /**
!         * Load user's session information
!         *
!         * @param string $sessionid user's session id string
!         * @return mixed the session data
!         */
!               function read_session($sessionid)
!               {}
! 
!               /**
!         * Remove stale sessions out of the database
!         */
!               function clean_sessions()
!               {}
! 
!               /**
!         * Set paramaters for cookies - only implemented in PHP4 sessions
!         *
!         * @param string $domain domain name to use in cookie
!         */
!         
!         function set_cookie_params($domain)
!               {}
! 
!               /**
!         * Create a new session
!         *
!         * @param string $login user login
!         * @param string $user_ip users ip address
!         * @param int $now time now as a unix timestamp
!         * @param string $session_flags A = Anonymous, N = Normal
!         */
!         function register_session($login,$user_ip,$now,$session_flags)
!               {}
! 
!               /**
!         * Update the date last active info for the session, so the login does 
not expire
!         *
!         * @return bool did it suceed?
!         */
!               function update_dla()
!               {}
! 
!               /**
!         * Terminate a session
!         *
!         * @param string $sessionid the id of the session to be terminated
!         * @param string $kp3 - NOT SURE
!         * @return bool did it suceed?
!         */
!         function destroy($sessionid, $kp3)
!               {}
! 
!               /**
!               * Functions for appsession data and session cache
!               */
!         
!         /**
!         * Delete all data from the session cache for a user
!         * 
!         * @param int $accountid user account id, defaults to current user 
(optional)
!         */
!               function delete_cache($accountid='')
!               {}
! 
!               /**
!         * Stores or retrieves information from the sessions cache
!         * 
!         * @param string $location identifier for data
!         * @param string $appname name of app which is responsbile for the data
!         * @param mixed $data data to be stored, if left blank data is 
retreived (optional)
!         * @return mixed data from cache, only returned if $data arg is not 
used 
!         */
!         function appsession($location = 'default', $appname = '', $data = 
'##NOTHING##')
!               {}
! 
!               /**
!               * Get list of normal / non-anonymous sessions
!               * Note: The data from the session-files get cached in the 
app_session phpgwapi/php4_session_cache
!         *
!               * @author ralfbecker
!         * @param int $start session to start at
!         * @param string $order field to sort on
!         * @param string $sort sort order
!         * @param bool $all_no_sort list all with out sorting (optional) 
default False
!         * @return array info for all current sessions  
!               */
!               function list_sessions($start,$order,$sort,$all_no_sort = False)
!               {}
!               
!               /**
!               * Get the number of normal / non-anonymous sessions
!               * 
!         * @author ralfbecker
!         * @return int number of sessions
!               */
!               function total()
!               {}
!       }
\ No newline at end of file

Index: class.sessions_db.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.sessions_db.inc.php,v
retrieving revision 1.2.2.10.2.6
retrieving revision 1.2.2.10.2.7
diff -C2 -r1.2.2.10.2.6 -r1.2.2.10.2.7
*** class.sessions_db.inc.php   18 May 2003 08:37:42 -0000      1.2.2.10.2.6
--- class.sessions_db.inc.php   17 Jul 2003 22:23:50 -0000      1.2.2.10.2.7
***************
*** 24,32 ****
        /* $Id$ */
  
!       class sessions_
        {
!               function sessions_()
                {
!                       // empty for now, but needed
                }
                
--- 24,32 ----
        /* $Id$ */
  
!       class sessions extends sessions_
        {
!               function sessions()
                {
!                       $this->sessions_();
                }
                
***************
*** 53,66 ****
                }
  
-               function set_cookie_params($domain)
-               {
-                       // only for php4-sessions
-               }
- 
                function register_session($login,$user_ip,$now,$session_flags)
                {
                        $GLOBALS['phpgw']->db->query("INSERT INTO 
phpgw_sessions VALUES ('" . $this->sessionid
                                . "','".$login."','" . $user_ip . "','"
!                               . $now . "','" . $now . "','" . 
$GLOBALS['PHP_SELF'] . "','" . $session_flags
                                . "')",__LINE__,__FILE__);
                }
--- 53,61 ----
                }
  
                function register_session($login,$user_ip,$now,$session_flags)
                {
                        $GLOBALS['phpgw']->db->query("INSERT INTO 
phpgw_sessions VALUES ('" . $this->sessionid
                                . "','".$login."','" . $user_ip . "','"
!                               . $now . "','" . $now . "','" . 
$_SERVER['PHP_SELF'] . "','" . $session_flags
                                . "')",__LINE__,__FILE__);
                }
***************
*** 191,195 ****
                }
  
!               function list_sessions($start,$order,$sort)
                {
                        $values = array();
--- 186,190 ----
                }
  
!               function list_sessions($start, $order, $sort, $all_no_sort = 
False)
                {
                        $values = array();

Index: class.sessions_php4.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.sessions_php4.inc.php,v
retrieving revision 1.6.2.10.2.5
retrieving revision 1.6.2.10.2.6
diff -C2 -r1.6.2.10.2.5 -r1.6.2.10.2.6
*** class.sessions_php4.inc.php 18 May 2003 19:15:02 -0000      1.6.2.10.2.5
--- class.sessions_php4.inc.php 17 Jul 2003 22:23:51 -0000      1.6.2.10.2.6
***************
*** 25,33 ****
        /* $Id$ */
  
!       class sessions_
        {
!               function sessions_()
                {
!                       //controls the time out for php4 sessions - skwashd 
18-May-2003
                        ini_set('session.gc_maxlifetime', 
$GLOBALS['phpgw_info']['server']['sessions_timeout']);
                        define('PHPGW_PHPSESSID', ini_get('session.name'));
--- 25,34 ----
        /* $Id$ */
  
!       class sessions extends sessions_
        {
!               function sessions()
                {
!                       $this->sessions_();
!                 //controls the time out for php4 sessions - skwashd 
18-May-2003
                        ini_set('session.gc_maxlifetime', 
$GLOBALS['phpgw_info']['server']['sessions_timeout']);
                        define('PHPGW_PHPSESSID', ini_get('session.name'));
***************
*** 38,47 ****
                        session_start();
                        return $GLOBALS['phpgw_session'] = 
$_SESSION['phpgw_session'];
-               }
- 
-               // This will remove stale sessions out of the database
-               function clean_sessions()
-               {
-                       // With php4 sessions support this isnt really our job
                }
  
--- 39,42 ----





reply via email to

[Prev in Thread] Current Thread [Next in Thread]