2 rcs_id('$Id: Session.php,v 1.1 2004-11-01 10:43:58 rurban Exp $');
3 /* Copyright (C) 2004 $ThePhpWikiProgrammingTeam
7 * Support reuse of existing user session from another application.
8 * You have to define which session variable holds the userid, and
9 * at what level is that user then. 1: BogoUser, 2: PassUser
10 * define('AUTH_SESS_USER','userid');
11 * define('AUTH_SESS_LEVEL',2);
13 class _SessionPassUser
16 function _SessionPassUser($UserName='',$prefs=false) {
17 if ($prefs) $this->_prefs = $prefs;
18 if (!defined("AUTH_SESS_USER") or !defined("AUTH_SESS_LEVEL")) {
20 "AUTH_SESS_USER or AUTH_SESS_LEVEL is not defined for the SessionPassUser method",
24 $sess =& $GLOBALS['HTTP_SESSION_VARS'];
25 // user hash: "[user][userid]" or object "user->id"
26 if (strstr(AUTH_SESS_USER,"][")) {
27 $sess = $GLOBALS['HTTP_SESSION_VARS'];
28 // recurse into hashes: "[user][userid]", sess = sess[user] => sess = sess[userid]
29 foreach (split("][",AUTH_SESS_USER) as $v) {
30 $v = str_replace(array("[","]"),'',$v);
33 $this->_userid = $sess;
34 } elseif (strstr(AUTH_SESS_USER,"->")) {
35 // object "user->id" (no objects inside hashes supported!)
36 list($obj,$key) = split("->",AUTH_SESS_USER);
37 $this->_userid = $sess[$obj]->$key;
39 $this->_userid = $sess[AUTH_SESS_USER];
41 if (!isset($this->_prefs->_method))
42 _PassUser::_PassUser($this->_userid);
43 $this->_level = AUTH_SESS_LEVEL;
44 $this->_authmethod = 'Session';
46 function userExists() {
47 return !empty($this->_userid);
49 function checkPass($submitted_password) {
50 return $this->userExists() and $this->_level;
52 function mayChangePass() {
57 // $Log: not supported by cvs2svn $
63 // c-hanging-comment-ender-p: nil
64 // indent-tabs-mode: nil