From ff48a9a442206d0cdaffa5dc77a9681839d399c8 Mon Sep 17 00:00:00 2001 From: rurban Date: Tue, 3 Feb 2004 09:45:39 +0000 Subject: [PATCH] LDAP cleanup, start of new Pref classes git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@2979 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- config/config-dist.php | 2 +- index.php | 20 +++++++++- lib/WikiGroup.php | 32 +++++++++++++--- lib/WikiUserNew.php | 59 +++++++++++++++++++++++------ lib/main.php | 13 ++++--- lib/plugin/RedirectTo.php | 10 ++++- themes/default/templates/login.tmpl | 22 +++++++++-- 7 files changed, 127 insertions(+), 31 deletions(-) diff --git a/config/config-dist.php b/config/config-dist.php index ca8b1733f..28e4f2128 100644 --- a/config/config-dist.php +++ b/config/config-dist.php @@ -333,7 +333,7 @@ if (!defined('REQUIRE_SIGNIN_BEFORE_EDIT')) define('REQUIRE_SIGNIN_BEFORE_EDIT', //if (!defined('ALLOW_LDAP_LOGIN')) define('ALLOW_LDAP_LOGIN', true and function_exists('ldap_connect')); //if (!defined('LDAP_AUTH_HOST')) define('LDAP_AUTH_HOST', 'localhost:443'); // Give the right LDAP root search information in the next statement. -//if (!defined('LDAP_AUTH_SEARCH')) define('LDAP_AUTH_SEARCH', "ou=mycompany.com,o=My Company"); +//if (!defined('LDAP_BASE_DN')) define('LDAP_BASE_DN', "ou=mycompany.com,o=My Company"); // IMAP auth: check userid/passwords from a imap server, defaults to localhost //if (!defined('ALLOW_IMAP_LOGIN')) define('ALLOW_IMAP_LOGIN', true and function_exists('imap_open')); diff --git a/index.php b/index.php index b781c4b37..bb1c35df1 100644 --- a/index.php +++ b/index.php @@ -73,7 +73,7 @@ define('ENABLE_USER_NEW',true); define ('PHPWIKI_VERSION', '1.3.8pre'); require "lib/prepend.php"; -rcs_id('$Id: index.php,v 1.119 2004-02-01 09:14:10 rurban Exp $'); +rcs_id('$Id: index.php,v 1.120 2004-02-03 09:45:39 rurban Exp $'); ///////////////////////////////////////////////////////////////////// // @@ -526,7 +526,7 @@ if (!defined('GROUP_METHOD')) define('GROUP_METHOD', "WIKIPAGE"); //if (!defined('GROUP_METHOD')) define('GROUP_METHOD', "LDAP"); //if (!defined('AUTH_GROUP_FILE')) define('AUTH_GROUP_FILE', '/etc/groups'); // or '/etc/httpd/.htgroup' // not yet! -//if (!defined('GROUP_LDAP_QUERY')) define('GROUP_LDAP_QUERY', 'member='); +//if (!defined('GROUP_LDAP_QUERY')) define('GROUP_LDAP_QUERY', 'ou=Groups'); // Seperate DB User Authentication. // Can be external, like radius, phpnuke, courier authmysql, @@ -906,6 +906,22 @@ if (defined('VIRTUAL_PATH') and defined('USE_PATH_INFO')) { include "lib/main.php"; // $Log: not supported by cvs2svn $ +// Revision 1.119 2004/02/01 09:14:10 rurban +// Started with Group_Ldap (not yet ready) +// added new _AuthInfo plugin to help in auth problems (warning: may display passwords) +// fixed some configurator vars +// renamed LDAP_AUTH_SEARCH to LDAP_BASE_DN +// changed PHPWIKI_VERSION from 1.3.8a to 1.3.8pre +// USE_DB_SESSION defaults to true on SQL +// changed GROUP_METHOD definition to string, not constants +// changed sample user DBAuthParams from UPDATE to REPLACE to be able to +// create users. (Not to be used with external databases generally, but +// with the default internal user table) +// +// fixed the IndexAsConfigProblem logic. this was flawed: +// scripts which are the same virtual path defined their own lib/main call +// (hmm, have to test this better, phpwiki.sf.net/demo works again) +// // Revision 1.118 2004/01/28 14:34:13 rurban // session table takes the common prefix // + various minor stuff diff --git a/lib/WikiGroup.php b/lib/WikiGroup.php index c5740a944..594e53a5d 100644 --- a/lib/WikiGroup.php +++ b/lib/WikiGroup.php @@ -1,7 +1,7 @@ username = null; $this->membership = array(); - if (empty($DBAuthParams['group_members']) or empty($DBAuthParams['user_groups'])) { - trigger_error(_("No GROUP_DB statements defined"), E_USER_WARNING); + if (empty($DBAuthParams['group_members']) or + empty($DBAuthParams['user_groups']) or + empty($DBAuthParams['is_member'])) { + trigger_error(_("No GROUP_DB SQL statements defined"), E_USER_WARNING); return false; } $dbh = _PassUser::getAuthDbh(); @@ -678,6 +682,22 @@ class GroupLdap extends WikiGroup { } // $Log: not supported by cvs2svn $ +// Revision 1.9 2004/02/01 09:14:11 rurban +// Started with Group_Ldap (not yet ready) +// added new _AuthInfo plugin to help in auth problems (warning: may display passwords) +// fixed some configurator vars +// renamed LDAP_AUTH_SEARCH to LDAP_BASE_DN +// changed PHPWIKI_VERSION from 1.3.8a to 1.3.8pre +// USE_DB_SESSION defaults to true on SQL +// changed GROUP_METHOD definition to string, not constants +// changed sample user DBAuthParams from UPDATE to REPLACE to be able to +// create users. (Not to be used with external databases generally, but +// with the default internal user table) +// +// fixed the IndexAsConfigProblem logic. this was flawed: +// scripts which are the same virtual path defined their own lib/main call +// (hmm, have to test this better, phpwiki.sf.net/demo works again) +// // Revision 1.8 2004/01/27 23:23:39 rurban // renamed ->Username => _userid for consistency // renamed mayCheckPassword => mayCheckPass diff --git a/lib/WikiUserNew.php b/lib/WikiUserNew.php index 4ffdbca55..1a1da2f98 100644 --- a/lib/WikiUserNew.php +++ b/lib/WikiUserNew.php @@ -1,5 +1,5 @@ _userid; if ($ldap = ldap_connect(LDAP_AUTH_HOST)) { // must be a valid LDAP server! $r = @ldap_bind($ldap); // this is an anonymous bind - $st_search = "uid=$userid"; // Need to set the right root search information. see ../index.php - $sr = ldap_search($ldap, LDAP_BASE_DN, - "$st_search"); + $sr = ldap_search($ldap, LDAP_BASE_DN, "uid=$userid"); $info = ldap_get_entries($ldap, $sr); // there may be more hits with this userid. try every for ($i = 0; $i < $info["count"]; $i++) { $dn = $info[$i]["dn"]; @@ -1213,13 +1211,10 @@ extends _PassUser function userExists() { $userid = $this->_userid; if ($ldap = ldap_connect(LDAP_AUTH_HOST)) { // must be a valid LDAP server! - $r = @ldap_bind($ldap); // this is an anonymous bind - $st_search = "uid=$userid"; - // Need to set the right root search information. see ../index.php - $sr = ldap_search($ldap, LDAP_BASE_DN, - "$st_search"); - $info = ldap_get_entries($ldap, $sr); // there may be more hits with this userid. try every - if ($info["count"]) { + $r = @ldap_bind($ldap); // this is an anonymous bind + $sr = ldap_search($ldap, LDAP_BASE_DN, "uid=$userid"); + $info = ldap_get_entries($ldap, $sr); + if ($info["count"] > 0) { ldap_close($ldap); return true; } @@ -1551,7 +1546,7 @@ extends _UserPreference * * This object holds the $request->_prefs subobjects. * A simple packed array of non-default values get's stored as cookie, - * homepage, and database, which are converted to the array of + * homepage, or database, which are converted to the array of * ->_prefs objects. * We don't store the objects, because otherwise we will * not be able to upgrade any subobject. And it's a waste of space also. @@ -1706,8 +1701,48 @@ class UserPreferences } } +class CookieUserPreferences +extends UserPreferences +{ + function CookieUserPreferences ($saved_prefs = false) { + UserPreferences::UserPreferences($saved_prefs); + } +} + +class PageUserPreferences +extends UserPreferences +{ + function PageUserPreferences ($saved_prefs = false) { + UserPreferences::UserPreferences($saved_prefs); + } +} + +class DbUserPreferences +extends UserPreferences +{ + function DbUserPreferences ($saved_prefs = false) { + UserPreferences::UserPreferences($saved_prefs); + } +} + // $Log: not supported by cvs2svn $ +// Revision 1.10 2004/02/01 09:14:11 rurban +// Started with Group_Ldap (not yet ready) +// added new _AuthInfo plugin to help in auth problems (warning: may display passwords) +// fixed some configurator vars +// renamed LDAP_AUTH_SEARCH to LDAP_BASE_DN +// changed PHPWIKI_VERSION from 1.3.8a to 1.3.8pre +// USE_DB_SESSION defaults to true on SQL +// changed GROUP_METHOD definition to string, not constants +// changed sample user DBAuthParams from UPDATE to REPLACE to be able to +// create users. (Not to be used with external databases generally, but +// with the default internal user table) +// +// fixed the IndexAsConfigProblem logic. this was flawed: +// scripts which are the same virtual path defined their own lib/main call +// (hmm, have to test this better, phpwiki.sf.net/demo works again) +// // Revision 1.9 2004/01/30 19:57:58 rurban // fixed DBAuthParams['pref_select']: wrong _auth_dbi object used. // diff --git a/lib/main.php b/lib/main.php index 32400d1fa..16f56353d 100644 --- a/lib/main.php +++ b/lib/main.php @@ -1,5 +1,5 @@ _deduceUsername(); $user = WikiUser($userid); + // todo: upgrade later at updateAuthAndPrefs() if (isset($this->_user)) $user = UpgradeUser($this->_user,$user); $this->_user = $user; @@ -535,7 +536,7 @@ class WikiRequest extends Request { if ($user = $this->getSessionVar('wiki_user')) { // users might switch in a session between the two objects - // restore old auth level? + // restore old auth level here or in updateAuthAndPrefs()? if (isa($user,WikiUserClassname()) and !empty($user->_level)) { if (empty($this->_user)) { $c = get_class($user); @@ -545,10 +546,9 @@ class WikiRequest extends Request { else $this->_user = new $c($this,$userid,$user->_level); } - if ($user = UpgradeUser($this->_user,$user)) - $this->_user = $user; + //if ($user = UpgradeUser($this->_user,$user)) + // $this->_user = $user; $this->_user->_authhow = 'session'; - } if (isa($user,WikiUserClassname())) return $user->UserName(); @@ -854,6 +854,9 @@ main(); // $Log: not supported by cvs2svn $ +// Revision 1.109 2004/01/30 19:57:58 rurban +// fixed DBAuthParams['pref_select']: wrong _auth_dbi object used. +// // Revision 1.108 2004/01/28 14:34:14 rurban // session table takes the common prefix // + various minor stuff diff --git a/lib/plugin/RedirectTo.php b/lib/plugin/RedirectTo.php index 591096aef..c30f0a861 100644 --- a/lib/plugin/RedirectTo.php +++ b/lib/plugin/RedirectTo.php @@ -1,5 +1,5 @@ * * BUGS/COMMENTS: + * Todo: fix with USE_PATH_INFO = false * * This plugin could probably result in a lot of confusion, especially when * redirecting to external sites. (Perhaps it can even be used for dastardly @@ -52,7 +53,7 @@ extends WikiPlugin function getVersion() { return preg_replace("/[Revision: $]/", '', - "\$Revision: 1.11 $"); + "\$Revision: 1.12 $"); } function getDefaultArguments() { @@ -115,6 +116,11 @@ extends WikiPlugin }; // $Log: not supported by cvs2svn $ +// Revision 1.11 2003/11/22 17:54:50 carstenklapp +// Minor internal change: Removed redundant call to gettext within +// fmt(). (locale make: RedirectTo.php:81: warning: keyword nested in +// keyword arg) +// // Revision 1.10 2003/02/24 00:40:09 carstenklapp // PHP's closing tag \?\> within // cvs log comments caused the trailing comments to display as literal text on the PluginManager page. // diff --git a/themes/default/templates/login.tmpl b/themes/default/templates/login.tmpl index 5676f4c7b..dd78891bc 100644 --- a/themes/default/templates/login.tmpl +++ b/themes/default/templates/login.tmpl @@ -1,5 +1,5 @@ - + @@ -18,9 +18,25 @@ $examplechars = $examplechars . "天道あかね"; }*/ ?> \n"); + } $t = TransformText(_("You may sign in using any [WikiWord|AddingPages] as a user id. (%s etc. may be used too). The user id will be used as a link in RecentChanges to your home page."), 2.0, true); - printf(asXML($t), $examplechars); ?> + printf(asXML($t), $examplechars); + /* On disabled DbPrefs (PagePrefs only) note the user to create his PersonalPage. */ + if (!(!empty($GLOBALS['DBAuthParams']['pref_update']) and $GLOBALS['DBParams']['dbtype'] == 'SQL')) { + printf(TransformText(_("Note: If you create your personal HomePage with same the pagename as your UserId, you will be able to store your UserPreferences also. Otherwise not."))); + } + ?>

@@ -37,7 +53,7 @@ getDbh(); -- 2.45.0