fix to allow '=' in urls and a lot of space to tab conversation in skwashd's comments

This commit is contained in:
Ralf Becker 2003-09-21 14:04:13 +00:00
parent c30487281b
commit 90331f1b45

View File

@ -25,97 +25,97 @@
/* $Id$ */ /* $Id$ */
if (empty($GLOBALS['phpgw_info']['server']['sessions_type'])) if (empty($GLOBALS['phpgw_info']['server']['sessions_type']))
{ {
$GLOBALS['phpgw_info']['server']['sessions_type'] = 'db'; $GLOBALS['phpgw_info']['server']['sessions_type'] = 'db';
} }
include_once(PHPGW_API_INC.'/class.sessions_'.$GLOBALS['phpgw_info']['server']['sessions_type'].'.inc.php'); include_once(PHPGW_API_INC.'/class.sessions_'.$GLOBALS['phpgw_info']['server']['sessions_type'].'.inc.php');
/** /**
* Session Management Libabray * Session Management Libabray
* *
* This allows phpGroupWare to use php4 or database sessions * This allows phpGroupWare to use php4 or database sessions
* *
* @package phpgwapi * @package phpgwapi
* @subpackage sessions * @subpackage sessions
* @abstract * @abstract
* @author NetUSE AG Boris Erdmann, Kristian Koehntopp <br> hacked on by phpGW * @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 * @copyright &copy; 1998-2000 NetUSE AG Boris Erdmann, Kristian Koehntopp <br> &copy; 2003 FreeSoftware Foundation
* @license LGPL * @license LGPL
* @link http://www.sanisoft.com/phplib/manual/DB_sql.php * @link http://www.sanisoft.com/phplib/manual/DB_sql.php
* @uses db * @uses db
*/ */
class sessions_ class sessions_
{ {
/** /**
* @var string current user login * @var string current user login
*/ */
var $login; var $login;
/** /**
* @var string current user password * @var string current user password
*/ */
var $passwd; var $passwd;
/** /**
* @var int current user db/ldap account id * @var int current user db/ldap account id
*/ */
var $account_id; var $account_id;
/** /**
* @var string current user account login id - ie user@domain * @var string current user account login id - ie user@domain
*/ */
var $account_lid; var $account_lid;
/** /**
* @var string previous page call id - repost prevention * @var string previous page call id - repost prevention
*/ */
var $history_id; var $history_id;
/** /**
* @var string domain for current user * @var string domain for current user
*/ */
var $account_domain; var $account_domain;
/** /**
* @var session type flag, A - anonymous session, N - None, normal session * @var session type flag, A - anonymous session, N - None, normal session
*/ */
var $session_flags; var $session_flags;
/** /**
* @var string current user session id * @var string current user session id
*/ */
var $sessionid; var $sessionid;
/** /**
* @var string not sure what this does, but it is important :) * @var string not sure what this does, but it is important :)
*/ */
var $kp3; var $kp3;
/** /**
* @var string encryption key? * @var string encryption key?
*/ */
var $key; var $key;
/** /**
* @var string iv == ivegotnoidea ;) (skwashd) * @var string iv == ivegotnoidea ;) (skwashd)
*/ */
var $iv; var $iv;
/** /**
* @var session data * @var session data
*/ */
var $data; var $data;
/** /**
* @var object holder for the database object * @var object holder for the database object
*/ */
var $db; var $db;
/** /**
* @var array publicly available methods * @var array publicly available methods
*/ */
var $public_functions = array( var $public_functions = array(
'list_methods' => True, 'list_methods' => True,
'update_dla' => True, 'update_dla' => True,
@ -124,14 +124,14 @@
); );
/** /**
* @var string domain for cookies * @var string domain for cookies
*/ */
var $cookie_domain; var $cookie_domain;
/** /**
* @var name of XML-RPC/SOAP method called * @var name of XML-RPC/SOAP method called
*/ */
var $xmlrpc_method_called; var $xmlrpc_method_called;
/** /**
* Constructor just loads up some defaults from cookies * Constructor just loads up some defaults from cookies
@ -207,13 +207,13 @@
} }
/** /**
* Introspection for XML-RPC/SOAP * Introspection for XML-RPC/SOAP
* Diabled - why?? * Diabled - why??
* *
* @param string $_type tpye of introspection being sought * @param string $_type tpye of introspection being sought
* @return array available methods and args * @return array available methods and args
*/ */
function DONTlist_methods($_type) function DONTlist_methods($_type)
{ {
if (is_array($_type)) if (is_array($_type))
{ {
@ -247,13 +247,13 @@
} }
/** /**
* Check to see if a session is still current and valid * Check to see if a session is still current and valid
* *
* @param string $sessionid session id to be verfied * @param string $sessionid session id to be verfied
* @param string $kp3 ?? to be verified * @param string $kp3 ?? to be verified
* @return bool is the session valid? * @return bool is the session valid?
*/ */
function verify($sessionid='',$kp3='') function verify($sessionid='',$kp3='')
{ {
if(empty($sessionid) || !$sessionid) if(empty($sessionid) || !$sessionid)
{ {
@ -407,22 +407,22 @@
* Functions for creating and verifying the session * Functions for creating and verifying the session
*/ */
/** /**
* Get the ip address of current users * Get the ip address of current users
* *
* @return string ip address * @return string ip address
*/ */
function getuser_ip() function getuser_ip()
{ {
return (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']); return (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']);
} }
/** /**
* Set the domain used for cookies * Set the domain used for cookies
* *
* @return string domain * @return string domain
*/ */
function phpgw_set_cookiedomain() function phpgw_set_cookiedomain()
{ {
$dom = $_SERVER['HTTP_HOST']; $dom = $_SERVER['HTTP_HOST'];
if (preg_match("/^(.*):(.*)$/",$dom,$arr)) if (preg_match("/^(.*):(.*)$/",$dom,$arr))
@ -454,13 +454,13 @@
} }
/** /**
* Set a cookie * Set a cookie
* *
* @param string $cookiename name of cookie to be set * @param string $cookiename name of cookie to be set
* @param string $cookievalue value to be used, if unset cookie is cleared (optional) * @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) * @param int $cookietime when cookie should expire, 0 for session only (optional)
*/ */
function phpgw_setcookie($cookiename,$cookievalue='',$cookietime=0) function phpgw_setcookie($cookiename,$cookievalue='',$cookietime=0)
{ {
if (!$this->cookie_domain) if (!$this->cookie_domain)
{ {
@ -470,14 +470,14 @@
} }
/** /**
* Create a new session * Create a new session
* *
* @param string $login user login * @param string $login user login
* @param string $passwd user password * @param string $passwd user password
* @param string $passwd_type type of password being used, ie plaintext, md5, sha1 * @param string $passwd_type type of password being used, ie plaintext, md5, sha1
* @return string session id * @return string session id
*/ */
function create($login,$passwd = '',$passwd_type = '') function create($login,$passwd = '',$passwd_type = '')
{ {
if (is_array($login)) if (is_array($login))
{ {
@ -678,13 +678,13 @@
} }
/** /**
* Verfy a peer server access request * Verfy a peer server access request
* *
* @param string $sessionid session id to verfiy * @param string $sessionid session id to verfiy
* @param string $kp3 ?? * @param string $kp3 ??
* @return bool verfied? * @return bool verfied?
*/ */
function verify_server($sessionid, $kp3) function verify_server($sessionid, $kp3)
{ {
$GLOBALS['phpgw']->interserver = CreateObject('phpgwapi.interserver'); $GLOBALS['phpgw']->interserver = CreateObject('phpgwapi.interserver');
$this->sessionid = $sessionid; $this->sessionid = $sessionid;
@ -808,13 +808,13 @@
} }
/** /**
* Validate a peer server login request * Validate a peer server login request
* *
* @param string $login login name * @param string $login login name
* @param string $password password * @param string $password password
* @return bool login ok? * @return bool login ok?
*/ */
function create_server($login,$passwd) function create_server($login,$passwd)
{ {
$GLOBALS['phpgw']->interserver = CreateObject('phpgwapi.interserver'); $GLOBALS['phpgw']->interserver = CreateObject('phpgwapi.interserver');
$this->login = $login; $this->login = $login;
@ -883,12 +883,12 @@
/** /**
* Functions for appsession data and session cache * Functions for appsession data and session cache
*/ */
/** /**
* Is this also useless?? (skwashd) * Is this also useless?? (skwashd)
*/ */
function read_repositories($cached='',$write_cache=True) function read_repositories($cached='',$write_cache=True)
{ {
$GLOBALS['phpgw']->acl->acl($this->account_id); $GLOBALS['phpgw']->acl->acl($this->account_id);
$GLOBALS['phpgw']->accounts->accounts($this->account_id); $GLOBALS['phpgw']->accounts->accounts($this->account_id);
@ -919,8 +919,8 @@
} }
/** /**
* Is this also useless?? (skwashd) * Is this also useless?? (skwashd)
*/ */
function setup_cache($write_cache=True) function setup_cache($write_cache=True)
{ {
$this->user = $GLOBALS['phpgw']->accounts->read_repository(); $this->user = $GLOBALS['phpgw']->accounts->read_repository();
@ -945,13 +945,13 @@
} }
} }
/** /**
* This looks to be useless * This looks to be useless
* This will capture everything in the $GLOBALS['phpgw_info'] including server info, * 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 * 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 * from appsession as the saved user info is really in ['user'] rather than the root of
* the structure, which is what this class likes. * the structure, which is what this class likes.
*/ */
function save_repositories() function save_repositories()
{ {
$phpgw_info_temp = $GLOBALS['phpgw_info']; $phpgw_info_temp = $GLOBALS['phpgw_info'];
@ -981,8 +981,8 @@
} }
/** /**
* Save the current values of all registered variables * Save the current values of all registered variables
*/ */
function save() function save()
{ {
if (is_array($this->variableNames)) if (is_array($this->variableNames))
@ -1001,10 +1001,10 @@
} }
/** /**
* Create a list a variable names, which data needs to be restored * Create a list a variable names, which data needs to be restored
* *
* @param string $_variableName name of variable to be registered * @param string $_variableName name of variable to be registered
*/ */
function register($_variableName) function register($_variableName)
{ {
$this->variableNames[$_variableName]='registered'; $this->variableNames[$_variableName]='registered';
@ -1012,10 +1012,10 @@
} }
/** /**
* Mark variable as unregistered * Mark variable as unregistered
* *
* @param string $_variableName name of variable to deregister * @param string $_variableName name of variable to deregister
*/ */
function unregister($_variableName) function unregister($_variableName)
{ {
$this->variableNames[$_variableName]='unregistered'; $this->variableNames[$_variableName]='unregistered';
@ -1023,11 +1023,11 @@
} }
/** /**
* Check if we have a variable registred already * Check if we have a variable registred already
* *
* @param string $_variableName name of variable to check * @param string $_variableName name of variable to check
* @return bool was the variable found? * @return bool was the variable found?
*/ */
function is_registered($_variableName) function is_registered($_variableName)
{ {
if ($this->variableNames[$_variableName] == 'registered') if ($this->variableNames[$_variableName] == 'registered')
@ -1040,10 +1040,10 @@
} }
} }
/** /**
* Additional tracking of user actions - prevents reposts/use of back button * Additional tracking of user actions - prevents reposts/use of back button
* *
* @author skwashd * @author skwashd
* @return string current history id * @return string current history id
*/ */
function generate_click_history() function generate_click_history()
{ {
@ -1062,9 +1062,9 @@
} }
/** /**
* Detects if the page has already been called before - good for forms * Detects if the page has already been called before - good for forms
* *
* @author skwashd * @author skwashd
* @param bool $diplay_error when implemented will use the generic error handling code * @param bool $diplay_error when implemented will use the generic error handling code
* @return True if called previously, else False - call ok * @return True if called previously, else False - call ok
*/ */
@ -1091,12 +1091,12 @@
} }
/** /**
* Generate a url which supports url or cookies based sessions * Generate a url which supports url or cookies based sessions
* *
* @param string $url a url relative to the phpgroupware install root * @param string $url a url relative to the phpgroupware install root
* @param array $extravars query string arguements * @param array $extravars query string arguements
* @return string generated url * @return string generated url
*/ */
function link($url, $extravars = '') function link($url, $extravars = '')
{ {
/* first we process the $url to build the full scriptname */ /* first we process the $url to build the full scriptname */
@ -1151,7 +1151,7 @@
$i = 0; $i = 0;
while ($i < count($a)) while ($i < count($a))
{ {
$b = split('=', $a[$i]); $b = split('=', $a[$i],2);
$new_extravars[$b[0]] = $b[1]; $new_extravars[$b[0]] = $b[1];
$i++; $i++;
} }
@ -1184,8 +1184,7 @@
if (is_array($extravars)) if (is_array($extravars))
{ {
$new_extravars = ''; $new_extravars = '';
reset($extravars); foreach($extravars as $key => $value)
while(list($key,$value) = each($extravars))
{ {
if (!empty($new_extravars)) if (!empty($new_extravars))
{ {
@ -1198,16 +1197,17 @@
/* if no extravars then we return the cleaned up url/scriptname */ /* if no extravars then we return the cleaned up url/scriptname */
return $url; return $url;
} }
/**
* The remaining methods are abstract - as they are unique for each session handler /**
*/ * The remaining methods are abstract - as they are unique for each session handler
*/
/**
* Load user's session information /**
* * Load user's session information
* @param string $sessionid user's session id string *
* @return mixed the session data * @param string $sessionid user's session id string
*/ * @return mixed the session data
*/
function read_session($sessionid) function read_session($sessionid)
{} {}
@ -1218,76 +1218,76 @@
{} {}
/** /**
* Set paramaters for cookies - only implemented in PHP4 sessions * Set paramaters for cookies - only implemented in PHP4 sessions
* *
* @param string $domain domain name to use in cookie * @param string $domain domain name to use in cookie
*/ */
function set_cookie_params($domain) function set_cookie_params($domain)
{} {}
/** /**
* Create a new session * Create a new session
* *
* @param string $login user login * @param string $login user login
* @param string $user_ip users ip address * @param string $user_ip users ip address
* @param int $now time now as a unix timestamp * @param int $now time now as a unix timestamp
* @param string $session_flags A = Anonymous, N = Normal * @param string $session_flags A = Anonymous, N = Normal
*/ */
function register_session($login,$user_ip,$now,$session_flags) function register_session($login,$user_ip,$now,$session_flags)
{} {}
/** /**
* Update the date last active info for the session, so the login does not expire * Update the date last active info for the session, so the login does not expire
* *
* @return bool did it suceed? * @return bool did it suceed?
*/ */
function update_dla() function update_dla()
{} {}
/** /**
* Terminate a session * Terminate a session
* *
* @param string $sessionid the id of the session to be terminated * @param string $sessionid the id of the session to be terminated
* @param string $kp3 - NOT SURE * @param string $kp3 - NOT SURE
* @return bool did it suceed? * @return bool did it suceed?
*/ */
function destroy($sessionid, $kp3) function destroy($sessionid, $kp3)
{} {}
/** /**
* Functions for appsession data and session cache * Functions for appsession data and session cache
*/ */
/** /**
* Delete all data from the session cache for a user * Delete all data from the session cache for a user
* *
* @param int $accountid user account id, defaults to current user (optional) * @param int $accountid user account id, defaults to current user (optional)
*/ */
function delete_cache($accountid='') function delete_cache($accountid='')
{} {}
/** /**
* Stores or retrieves information from the sessions cache * Stores or retrieves information from the sessions cache
* *
* @param string $location identifier for data * @param string $location identifier for data
* @param string $appname name of app which is responsbile for the 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) * @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 * @return mixed data from cache, only returned if $data arg is not used
*/ */
function appsession($location = 'default', $appname = '', $data = '##NOTHING##') function appsession($location = 'default', $appname = '', $data = '##NOTHING##')
{} {}
/** /**
* Get list of normal / non-anonymous sessions * Get list of normal / non-anonymous sessions
* Note: The data from the session-files get cached in the app_session phpgwapi/php4_session_cache * Note: The data from the session-files get cached in the app_session phpgwapi/php4_session_cache
* *
* @author ralfbecker * @author ralfbecker
* @param int $start session to start at * @param int $start session to start at
* @param string $order field to sort on * @param string $order field to sort on
* @param string $sort sort order * @param string $sort sort order
* @param bool $all_no_sort list all with out sorting (optional) default False * @param bool $all_no_sort list all with out sorting (optional) default False
* @return array info for all current sessions * @return array info for all current sessions
*/ */
function list_sessions($start,$order,$sort,$all_no_sort = False) function list_sessions($start,$order,$sort,$all_no_sort = False)
{} {}
@ -1295,8 +1295,8 @@
/** /**
* Get the number of normal / non-anonymous sessions * Get the number of normal / non-anonymous sessions
* *
* @author ralfbecker * @author ralfbecker
* @return int number of sessions * @return int number of sessions
*/ */
function total() function total()
{} {}