From 5c2e88ae33f908608b6a8439d5848b899313f024 Mon Sep 17 00:00:00 2001 From: dairiki Date: Wed, 23 Jan 2002 20:18:21 +0000 Subject: [PATCH] New configuration define: REQUIRE_SIGNIN_BEFORE_EDIT If set, user is asked to signin when/if he tries to edit a page. git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@1528 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- index.php | 9 ++++++- lib/main.php | 37 +++++++++++++---------------- themes/default/templates/login.tmpl | 7 +++--- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/index.php b/index.php index d1de6bdfa..3f629ba2d 100644 --- a/index.php +++ b/index.php @@ -80,7 +80,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA define ('PHPWIKI_VERSION', '1.3.2-jeffs-hacks'); require "lib/prepend.php"; -rcs_id('$Id: index.php,v 1.71 2002-01-20 19:02:00 rurban Exp $'); +rcs_id('$Id: index.php,v 1.72 2002-01-23 20:18:21 dairiki Exp $'); ///////////////////////////////////////////////////////////////////// // @@ -110,6 +110,7 @@ define('ADMIN_PASSWD', ""); // require no authentication. define('ZIPDUMP_AUTH', false); + // This setting determines the type of page dumps. Must be one of // "quoted-printable" or "binary". $pagedump_format = "quoted-printable"; @@ -135,6 +136,12 @@ define("MINOR_EDIT_TIMEOUT", 7 * 24 * 3600); // 2) is a valid WikiWord (matches $WikiNameRegexp.) define('ALLOW_BOGO_LOGIN', true); +// If set, then if an anonymous user attempts to edit a page he will +// be required to sign in. (If ALLOW_BOGO_LOGIN is true, of course, +// no password is required, but the user must still sign in under +// some sort of BogoUserId.) +define('REQUIRE_SIGNIN_BEFORE_EDIT', false); + // The login code now uses PHP's session support. Usually, the default // configuration of PHP is to store the session state information in // /tmp. That probably will work fine, but fails e.g. on clustered diff --git a/lib/main.php b/lib/main.php index c1ad26ced..32c723cb2 100644 --- a/lib/main.php +++ b/lib/main.php @@ -1,5 +1,5 @@ getArg('pref')) { $this->setArg('pref', false); - $this->_setPreferences($new_prefs); + foreach ($new_prefs as $key => $val) + $this->_prefs->set($key, $val); } // Handle authentication request, if any. @@ -117,13 +118,16 @@ class WikiRequest extends Request { $this->setArg('auth', false); $this->_handleAuthRequest($auth_args); // possible NORETURN } - - if (!$auth_args && !$this->_user->isSignedIn()) { - // Try to sign in as saved user. + elseif ( ! $this->_user->isSignedIn() ) { + // If not auth request, try to sign in as saved user. if (($saved_user = $this->getPref('userid')) != false) $this->_signIn($saved_user); } + // Save preferences + $this->setSessionVar('user_prefs', $this->_prefs); + $this->setCookieVar('WIKI_PREFS', $this->_prefs, 365); + // Ensure user has permissions for action $require_level = $this->requiredAuthority($this->getArg('action')); if (! $this->_user->hasAuthority($require_level)) @@ -203,11 +207,10 @@ class WikiRequest extends Request { function _setUser ($user) { $this->_user = $user; $this->setSessionVar('auth_state', $user); + // Save userid to prefs.. - if ($user->isSignedIn()) - $this->_setPreferences(array('userid' => $user->getId())); - else - $this->_setPreferences(array('userid' => false)); + $this->_prefs->set('userid', + $user->isSignedIn() ? $user->getId() : ''); } function _notAuthorized ($require_level) { @@ -238,10 +241,14 @@ class WikiRequest extends Request { return WIKIAUTH_ANON; case 'zip': + if (defined('ZIPDUMP_AUTH') && ZIPDUMP_AUTH) + return WIKIAUTH_ADMIN; return WIKIAUTH_ANON; case 'edit': case 'save': // FIXME delete + if (defined('REQUIRE_SIGNIN_BEFORE_EDIT') && REQUIRE_SIGNIN_BEFORE_EDIT) + return WIKIAUTH_BOGO; return WIKIAUTH_ANON; // return WIKIAUTH_BOGO; @@ -256,18 +263,6 @@ class WikiRequest extends Request { } } - function _setPreferences ($new_prefs) { - if (!is_array($new_prefs)) - return; - - // Update and save preferences. - foreach ($new_prefs as $name => $value) - $this->_prefs->set($name, $value); - - $this->setSessionVar('user_prefs', $this->_prefs); - $this->setCookieVar('WIKI_PREFS', $this->_prefs, 365); - } - function deflowerDatabase () { if ($this->getArg('action') != 'browse') return; diff --git a/themes/default/templates/login.tmpl b/themes/default/templates/login.tmpl index 91fe0e887..6b6be0731 100644 --- a/themes/default/templates/login.tmpl +++ b/themes/default/templates/login.tmpl @@ -1,10 +1,9 @@ - + - -

-

+ +


-- 2.45.0