3 /* Copyright (C) 2004 ReiniUrban
4 * This file is part of PhpWiki. Terms and Conditions see LICENSE. (GPL2)
8 * Support reuse of existing user session from another application.
9 * You have to define which session variable holds the userid, and
10 * at what level is that user then. 1: BogoUser, 2: PassUser
11 * define('AUTH_SESS_USER','userid');
12 * define('AUTH_SESS_LEVEL',2);
14 class _SessionPassUser
17 function _SessionPassUser($UserName='',$prefs=false) {
18 if ($prefs) $this->_prefs = $prefs;
19 if (!defined("AUTH_SESS_USER") or !defined("AUTH_SESS_LEVEL")) {
21 "AUTH_SESS_USER or AUTH_SESS_LEVEL is not defined for the SessionPassUser method",
25 $sess =& $GLOBALS['HTTP_SESSION_VARS'];
26 // user hash: "[user][userid]" or object "user->id"
27 if (strstr(AUTH_SESS_USER,"][")) {
28 $sess = $GLOBALS['HTTP_SESSION_VARS'];
29 // recurse into hashes: "[user][userid]", sess = sess[user] => sess = sess[userid]
30 foreach (split("][",AUTH_SESS_USER) as $v) {
31 $v = str_replace(array("[","]"),'',$v);
34 $this->_userid = $sess;
35 } elseif (strstr(AUTH_SESS_USER,"->")) {
36 // object "user->id" (no objects inside hashes supported!)
37 list($obj,$key) = split("->",AUTH_SESS_USER);
38 $this->_userid = $sess[$obj]->$key;
40 $this->_userid = $sess[AUTH_SESS_USER];
42 if (!isset($this->_prefs->_method))
43 _PassUser::_PassUser($this->_userid);
44 $this->_level = AUTH_SESS_LEVEL;
45 $this->_authmethod = 'Session';
47 function userExists() {
48 return !empty($this->_userid);
50 function checkPass($submitted_password) {
51 return $this->userExists() and $this->_level > -1;
53 function mayChangePass() {
58 // $Log: not supported by cvs2svn $
59 // Revision 1.2 2004/12/19 00:58:02 rurban
60 // Enforce PASSWORD_LENGTH_MINIMUM in almost all PassUser checks,
61 // Provide an errormessage if so. Just PersonalPage and BogoLogin not.
62 // Simplify httpauth logout handling and set sessions for all methods.
63 // fix main.php unknown index "x" getLevelDescription() warning.
65 // Revision 1.1 2004/11/01 10:43:58 rurban
66 // seperate PassUser methods into seperate dir (memory usage)
67 // fix WikiUser (old) overlarge data session
68 // remove wikidb arg from various page class methods, use global ->_dbi instead
76 // c-hanging-comment-ender-p: nil
77 // indent-tabs-mode: nil