Ejemplo n.º 1
0
 function _SessionPassUser($UserName = '', $prefs = false)
 {
     if ($prefs) {
         $this->_prefs = $prefs;
     }
     if (!defined("AUTH_SESS_USER") or !defined("AUTH_SESS_LEVEL")) {
         trigger_error("AUTH_SESS_USER or AUTH_SESS_LEVEL is not defined for the SessionPassUser method", E_USER_ERROR);
         exit;
     }
     $sess =& $GLOBALS['HTTP_SESSION_VARS'];
     // user hash: "[user][userid]" or object "user->id"
     if (strstr(AUTH_SESS_USER, "][")) {
         $sess = $GLOBALS['HTTP_SESSION_VARS'];
         // recurse into hashes: "[user][userid]", sess = sess[user] => sess = sess[userid]
         foreach (explode("][", AUTH_SESS_USER) as $v) {
             $v = str_replace(array("[", "]"), '', $v);
             $sess = $sess[$v];
         }
         $this->_userid = $sess;
     } elseif (strstr(AUTH_SESS_USER, "->")) {
         // object "user->id" (no objects inside hashes supported!)
         list($obj, $key) = explode("->", AUTH_SESS_USER);
         $this->_userid = $sess[$obj]->{$key};
     } else {
         $this->_userid = $sess[AUTH_SESS_USER];
     }
     if (!isset($this->_prefs->_method)) {
         _PassUser::_PassUser($this->_userid);
     }
     $this->_level = AUTH_SESS_LEVEL;
     $this->_authmethod = 'Session';
 }
Ejemplo n.º 2
0
 function _FilePassUser($UserName = '', $prefs = false, $file = '')
 {
     if (!$this->_prefs and isa($this, "_FilePassUser")) {
         if ($prefs) {
             $this->_prefs = $prefs;
         }
         if (!isset($this->_prefs->_method)) {
             _PassUser::_PassUser($UserName);
         }
     }
     $this->_userid = $UserName;
     // read the .htaccess style file. We use our own copy of the standard pear class.
     $this->_may_change = defined('AUTH_USER_FILE_STORABLE') && AUTH_USER_FILE_STORABLE;
     if (empty($file) and defined('AUTH_USER_FILE')) {
         $file = AUTH_USER_FILE;
     }
     // same style as in main.php
     include_once dirname(__FILE__) . "/../pear/File_Passwd.php";
     // "__PHP_Incomplete_Class"
     if (!empty($file) or empty($this->_file) or !isa($this->_file, "File_Passwd")) {
         $this->_file = new File_Passwd($file, false, $file . '.lock');
     } else {
         return false;
     }
     return $this;
 }
Ejemplo n.º 3
0
 function _EMailConfirmPassUser($UserName = '', $prefs = false, $file = '')
 {
     if (!$this->_prefs and isa($this, "_EMailPassUser")) {
         if ($prefs) {
             $this->_prefs = $prefs;
         }
         if (!isset($this->_prefs->_method)) {
             _PassUser::_PassUser($UserName);
         }
     }
     $this->_userid = $UserName;
     return $this;
 }
Ejemplo n.º 4
0
 function _DbPassUser($UserName = '', $prefs = false)
 {
     if (!$this->_prefs) {
         if ($prefs) {
             $this->_prefs = $prefs;
         }
     }
     if (!isset($this->_prefs->_method)) {
         _PassUser::_PassUser($UserName);
     } elseif (!$this->isValidName($UserName)) {
         trigger_error(_("Invalid username."), E_USER_WARNING);
         return false;
     }
     $this->_authmethod = 'Db';
     //$this->getAuthDbh();
     //$this->_auth_crypt_method = @$GLOBALS['DBAuthParams']['auth_crypt_method'];
     $dbi =& $GLOBALS['request']->_dbi;
     $dbtype = $dbi->getParam('dbtype');
     if ($dbtype == 'ADODB') {
         include_once "lib/WikiUser/AdoDb.php";
         if (check_php_version(5)) {
             return new _AdoDbPassUser($UserName, $this->_prefs);
         } else {
             $user = new _AdoDbPassUser($UserName, $this->_prefs);
             eval("\$this = \$user;");
             return $user;
         }
     } elseif ($dbtype == 'SQL') {
         include_once "lib/WikiUser/PearDb.php";
         if (check_php_version(5)) {
             return new _PearDbPassUser($UserName, $this->_prefs);
         } else {
             $user = new _PearDbPassUser($UserName, $this->_prefs);
             eval("\$this = \$user;");
             return $user;
         }
     } elseif ($dbtype == 'PDO') {
         include_once "lib/WikiUser/PdoDb.php";
         if (check_php_version(5)) {
             return new _PdoDbPassUser($UserName, $this->_prefs);
         } else {
             $user = new _PdoDbPassUser($UserName, $this->_prefs);
             eval("\$this = \$user;");
             return $user;
         }
     }
     return false;
 }
Ejemplo n.º 5
0
 function _PdoDbPassUser($UserName = '', $prefs = false)
 {
     if (!$this->_prefs and isa($this, "_PdoDbPassUser")) {
         if ($prefs) {
             $this->_prefs = $prefs;
         }
     }
     if (!isset($this->_prefs->_method)) {
         _PassUser::_PassUser($UserName);
     } elseif (!$this->isValidName($UserName)) {
         trigger_error(_("Invalid username."), E_USER_WARNING);
         return false;
     }
     $this->_userid = $UserName;
     // make use of session data. generally we only initialize this every time,
     // but do auth checks only once
     $this->_auth_crypt_method = $GLOBALS['request']->_dbi->getAuthParam('auth_crypt_method');
     return $this;
 }
Ejemplo n.º 6
0
 function _AdoDbPassUser($UserName = '', $prefs = false)
 {
     if (!$this->_prefs and isa($this, "_AdoDbPassUser")) {
         if ($prefs) {
             $this->_prefs = $prefs;
         }
         if (!isset($this->_prefs->_method)) {
             _PassUser::_PassUser($UserName);
         }
     }
     if (!$this->isValidName($UserName)) {
         trigger_error(_("Invalid username."), E_USER_WARNING);
         return false;
     }
     $this->_userid = $UserName;
     $this->getAuthDbh();
     $this->_auth_crypt_method = $GLOBALS['request']->_dbi->getAuthParam('auth_crypt_method');
     // Don't prepare the configured auth statements anymore
     return $this;
 }
Ejemplo n.º 7
0
 function _HttpAuthUpperPassUser($UserName = '', $prefs = false)
 {
     if ($prefs) {
         $this->_prefs = $prefs;
     }
     if (!isset($this->_prefs->_method)) {
         _PassUser::_PassUser($UserName);
     }
     if ($UserName) {
         $this->_userid = $UserName;
     }
     $this->_authmethod = 'HttpAuthUpper';
     // Is this double check really needed?
     // It is not expensive so we keep it for now.
     if ($this->userExists()) {
         return $this;
     } else {
         return $GLOBALS['ForbiddenUser'];
     }
 }
Ejemplo n.º 8
0
 /** A PersonalPagePassUser requires PASSWORD_LENGTH_MINIMUM.
  *  BUT if the user already has a homepage with an empty password
  *  stored, allow login but warn him to change it.
  */
 function checkPass($submitted_password)
 {
     if ($this->userExists()) {
         $stored_password = $this->_prefs->get('passwd');
         if (empty($stored_password)) {
             if (PASSWORD_LENGTH_MINIMUM > 0) {
                 trigger_error(sprintf(_("PersonalPage login method:") . "\n" . _("You stored an empty password in your '%s' page.") . "\n" . _("Your access permissions are only for a BogoUser.") . "\n" . _("Please set a password in UserPreferences."), $this->_userid), E_USER_WARNING);
                 $this->_level = WIKIAUTH_BOGO;
             } else {
                 if (!empty($submitted_password)) {
                     trigger_error(sprintf(_("PersonalPage login method:") . "\n" . _("You stored an empty password in your '%s' page.") . "\n" . _("Given password ignored.") . "\n" . _("Please set a password in UserPreferences."), $this->_userid), E_USER_WARNING);
                 }
                 $this->_level = WIKIAUTH_USER;
             }
             return $this->_level;
         }
         if ($this->_checkPass($submitted_password, $stored_password)) {
             return $this->_level = WIKIAUTH_USER;
         }
         return _PassUser::checkPass($submitted_password);
     } else {
         return WIKIAUTH_ANON;
     }
 }
Ejemplo n.º 9
0
 function _CodendiPassUser($UserName = '', $prefs = false)
 {
     if ($prefs) {
         $this->_prefs = $prefs;
     }
     /* Actually, we cannot set preferences here because PhpWiki instanciate
         * _PassUser class before. So we had to modify _PassUser constructor to
        instanciate CodendiUserPreferences instead of UserPreferences.
         * if (!$this->_prefs) {
            $this->_prefs = new CodendiUserPreferences();
            $this->hasHomePage();
            $this->getPreferences();
            print_r($this->_prefs);
        }*/
     $this->_userid = $UserName;
     if (!isset($this->_prefs->_method)) {
         _PassUser::_PassUser($this->_userid);
     }
     switch ($this->_userid) {
         case '':
         case 'NA':
             $this->_level = WIKIAUTH_ANON;
             break;
         case 'admin':
             $this->_level = WIKIAUTH_ADMIN;
             // admin Codendi
             break;
         default:
             $this->_level = WIKIAUTH_USER;
     }
     if (user_ismember(GROUP_ID, 'W2')) {
         $this->_level = WIKIAUTH_ADMIN;
     }
     //admin wiki
     $this->_authmethod = 'Codendi';
 }
Ejemplo n.º 10
0
 function storePass($submitted_password)
 {
     if ($this->_userid == ADMIN_USER) {
         return false;
     } else {
         // should not happen! only ADMIN_USER should use this class.
         return parent::storePass($submitted_password);
     }
 }
Ejemplo n.º 11
0
 /**
  * Constructor
  * 
  * @param object $request The global WikiRequest object. ignored
  */
 function GroupDb()
 {
     global $DBAuthParams, $DBParams;
     //$this->request = &$GLOBALS['request'];
     $this->username = $this->_getUserName();
     $this->membership = array();
     if (empty($DBAuthParams['group_members']) or empty($DBAuthParams['user_groups']) or empty($DBAuthParams['is_member'])) {
         trigger_error(_("No or not enough GROUP_DB SQL statements defined"), E_USER_WARNING);
         return new GroupNone();
     }
     // FIXME: This only works with ENABLE_USER_NEW
     if (empty($this->user)) {
         // use _PassUser::prepare instead
         if (isa($request->getUser(), '_PassUser')) {
             $user = $request->getUser();
         } else {
             $user = new _PassUser($this->username);
         }
     } elseif (!isa($this->user, '_PassUser')) {
         $user = new _PassUser($this->username);
     } else {
         $user =& $this->user;
     }
     if (isa($this->user, '_PassUser')) {
         // TODO: safety by Charles Corrigan
         $this->_is_member = $user->prepare($DBAuthParams['is_member'], array('userid', 'groupname'));
         $this->_group_members = $user->prepare($DBAuthParams['group_members'], 'groupname');
         $this->_user_groups = $user->prepare($DBAuthParams['user_groups'], 'userid');
         $this->dbh = $user->_auth_dbi;
     }
 }