2 rcs_id('$Id: Db.php,v 1.2 2004-12-26 17:11:15 rurban Exp $');
3 /* Copyright (C) 2004 ReiniUrban
4 * This file is part of PhpWiki. Terms and Conditions see LICENSE. (GPL2)
8 * Baseclass for PearDB and ADODB PassUser's
9 * Authenticate against a database, to be able to use shared users.
10 * internal: no different $DbAuthParams['dsn'] defined, or
11 * external: different $DbAuthParams['dsn']
12 * The magic is done in the symbolic SQL statements in config/config.ini, similar to
15 * We support only the SQL and ADODB backends.
16 * The other WikiDB backends (flat, cvs, dba, ...) should be used for pages,
17 * not for auth stuff. If one would like to use e.g. dba for auth, he should
18 * use PearDB (SQL) with the right $DBAuthParam['auth_dsn'].
19 * (Not supported yet, since we require SQL. SQLite would make since when
20 * it will come to PHP)
24 * Preferences are handled in the parent class _PassUser, because the
25 * previous classes may also use DB pref_select and pref_update.
27 * Flat files auth is handled by the auth method "File".
32 var $_authselect, $_authupdate, $_authcreate;
34 // This can only be called from _PassUser, because the parent class
35 // sets the auth_dbi and pref methods, before this class is initialized.
36 function _DbPassUser($UserName='',$prefs=false) {
38 if ($prefs) $this->_prefs = $prefs;
40 if (!isset($this->_prefs->_method))
41 _PassUser::_PassUser($UserName);
42 elseif (!$this->isValidName($UserName)) {
43 trigger_error(_("Invalid username."),E_USER_WARNING);
46 $this->_authmethod = 'Db';
47 //$this->getAuthDbh();
48 //$this->_auth_crypt_method = @$GLOBALS['DBAuthParams']['auth_crypt_method'];
49 $dbi =& $GLOBALS['request']->_dbi;
50 $dbtype = $dbi->getParam('dbtype');
51 if ($dbtype == 'ADODB') {
52 include_once("lib/WikiUser/AdoDb.php");
53 if (check_php_version(5))
54 return new _AdoDbPassUser($UserName,$this->_prefs);
56 $user = new _AdoDbPassUser($UserName,$this->_prefs);
57 eval("\$this = \$user;");
61 elseif ($dbtype == 'SQL') {
62 include_once("lib/WikiUser/PearDb.php");
63 if (check_php_version(5))
64 return new _PearDbPassUser($UserName,$this->_prefs);
66 $user = new _PearDbPassUser($UserName,$this->_prefs);
67 eval("\$this = \$user;");
74 function mayChangePass() {
75 return !isset($this->_authupdate);
80 // $Log: not supported by cvs2svn $
81 // Revision 1.1 2004/11/01 10:43:58 rurban
82 // seperate PassUser methods into seperate dir (memory usage)
83 // fix WikiUser (old) overlarge data session
84 // remove wikidb arg from various page class methods, use global ->_dbi instead
92 // c-hanging-comment-ender-p: nil
93 // indent-tabs-mode: nil