3 /* Copyright (C) 2004 ReiniUrban
4 * This file is part of PhpWiki. Terms and Conditions see LICENSE. (GPL2)
10 * Check users defined in a .htaccess style file
13 * Preferences are handled in _PassUser
16 var $_file, $_may_change;
18 // This can only be called from _PassUser, because the parent class
19 // sets the pref methods, before this class is initialized.
20 function _FilePassUser($UserName='', $prefs=false, $file='') {
21 if (!$this->_prefs and isa($this, "_FilePassUser")) {
22 if ($prefs) $this->_prefs = $prefs;
23 if (!isset($this->_prefs->_method))
24 _PassUser::_PassUser($UserName);
26 $this->_userid = $UserName;
27 // read the .htaccess style file. We use our own copy of the standard pear class.
28 $this->_may_change = defined('AUTH_USER_FILE_STORABLE') && AUTH_USER_FILE_STORABLE;
29 if (empty($file) and defined('AUTH_USER_FILE'))
30 $file = AUTH_USER_FILE;
31 // same style as in main.php
32 include_once(dirname(__FILE__)."/../pear/File_Passwd.php");
33 // "__PHP_Incomplete_Class"
34 if (!empty($file) or empty($this->_file) or !isa($this->_file, "File_Passwd"))
35 $this->_file = new File_Passwd($file, false, $file.'.lock');
41 function mayChangePass() {
42 return $this->_may_change;
45 function userExists() {
46 if (!$this->isValidName()) {
47 return $this->_tryNextUser();
49 $this->_authmethod = 'File';
50 if (isset($this->_file->users[$this->_userid]))
53 return $this->_tryNextUser();
56 function checkPass($submitted_password) {
57 if (!$this->isValidName()) {
58 trigger_error(_("Invalid username."),E_USER_WARNING);
59 return $this->_tryNextPass($submitted_password);
61 if (!$this->_checkPassLength($submitted_password)) {
62 return WIKIAUTH_FORBIDDEN;
64 //include_once 'lib/pear/File_Passwd.php';
65 if ($this->_file->verifyPassword($this->_userid, $submitted_password)) {
66 $this->_authmethod = 'File';
67 $this->_level = WIKIAUTH_USER;
68 if ($this->isAdmin()) // member of the Administrators group
69 $this->_level = WIKIAUTH_ADMIN;
73 return $this->_tryNextPass($submitted_password);
76 function storePass($submitted_password) {
77 if (!$this->isValidName()) {
80 if ($this->_may_change) {
81 $this->_file = new File_Passwd($this->_file->filename, true,
82 $this->_file->filename.'.lock');
83 $result = $this->_file->modUser($this->_userid, $submitted_password);
84 $this->_file->close();
85 $this->_file = new File_Passwd($this->_file->filename, false);
93 // $Log: not supported by cvs2svn $
94 // Revision 1.7 2005/08/06 13:21:37 rurban
97 // Revision 1.6 2005/05/04 05:37:34 rurban
98 // fix #1191096 by Karel
100 // Revision 1.5 2005/02/14 12:28:27 rurban
101 // fix policy strict. Thanks to Mikhail Vladimirov
103 // Revision 1.4 2004/12/26 17:11:16 rurban
106 // Revision 1.3 2004/12/20 16:05:01 rurban
107 // gettext msg unification
109 // Revision 1.2 2004/12/19 00:58:02 rurban
110 // Enforce PASSWORD_LENGTH_MINIMUM in almost all PassUser checks,
111 // Provide an errormessage if so. Just PersonalPage and BogoLogin not.
112 // Simplify httpauth logout handling and set sessions for all methods.
113 // fix main.php unknown index "x" getLevelDescription() warning.
115 // Revision 1.1 2004/11/01 10:43:58 rurban
116 // seperate PassUser methods into seperate dir (memory usage)
117 // fix WikiUser (old) overlarge data session
118 // remove wikidb arg from various page class methods, use global ->_dbi instead
126 // c-hanging-comment-ender-p: nil
127 // indent-tabs-mode: nil