From 5332586e6420689beb0facfc017de4c16e82b8bb Mon Sep 17 00:00:00 2001 From: rurban Date: Sun, 29 Feb 2004 04:10:56 +0000 Subject: [PATCH] new POP3 auth (thanks to BiloBilo: pentothal at despammed dot com) fixed syntax error in index.php git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@3099 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- index.php | 23 +++++++++++----- lib/WikiUserNew.php | 64 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 79 insertions(+), 8 deletions(-) diff --git a/index.php b/index.php index d8bd4a386..0e5bc39d3 100644 --- a/index.php +++ b/index.php @@ -73,7 +73,7 @@ define('ENABLE_USER_NEW',true); // this will disappear with 1.4.0 define ('PHPWIKI_VERSION', '1.3.8'); require "lib/prepend.php"; -rcs_id('$Id: index.php,v 1.128 2004-02-29 02:06:05 rurban Exp $'); +rcs_id('$Id: index.php,v 1.129 2004-02-29 04:10:55 rurban Exp $'); ///////////////////////////////////////////////////////////////////// // @@ -468,6 +468,7 @@ if (!defined('ALLOW_USER_PASSWORDS')) define('ALLOW_USER_PASSWORDS', true); // ADODB only. // LDAP: Authenticate against LDAP_AUTH_HOST with LDAP_BASE_DN // IMAP: Authenticate against IMAP_AUTH_HOST (email account) +// POP3: Authenticate against POP3_AUTH_HOST (email account) // File: Store username:crypted-passwords in .htaccess like files. // Use Apache's htpasswd to manage this file. // HttpAuth: Use the protection by the webserver (.htaccess) or @@ -482,9 +483,10 @@ if (defined('ALLOW_USER_PASSWORDS')) { // "BogoLogin", "PersonalPage", "Db", -// "LDAP", // define LDAP_AUTH_HOST and LDAP_BASE_DN -// "IMAP", // define IMAP_AUTH_HOST -// "File", // define AUTH_USER_FILE and opt. AUTH_USER_FILE_STORABLE +// "LDAP", // define LDAP_AUTH_HOST and LDAP_BASE_DN +// "IMAP", // define IMAP_AUTH_HOST +// "POP3", // define POP3_AUTH_HOST +// "File", // define AUTH_USER_FILE and opt. AUTH_USER_FILE_STORABLE // "HttpAuth", ) ; @@ -523,13 +525,15 @@ if (!defined('LDAP_BASE_DN')) define('LDAP_BASE_DN', "ou=Users,o=Development,dc= // define(LDAP_SEARCH_FIELD, 'sAMAccountName'); // might be different from uid, // here's its a Windows/Samba account - // IMAP auth: // check userid/passwords from a imap server, defaults to localhost if (!defined('IMAP_AUTH_HOST')) define('IMAP_AUTH_HOST', 'localhost:143/imap/notls'); // Some IMAP_AUTH_HOST samples: // "localhost", "localhost:143/imap/notls", // "localhost:993/imap/ssl/novalidate-cert" (SuSE refuses non-SSL conections) +// POP3 auth: +//if (!defined('POP3_AUTH_HOST')) define('POP3_AUTH_HOST', 'localhost'); +//if (!defined('POP3_AUTH_PORT')) define('POP3_AUTH_HOST', '110'); // File auth: //if (!defined('AUTH_USER_FILE')) define('AUTH_USER_FILE', '/etc/shadow'); // or '/etc/httpd/.htpasswd' @@ -896,7 +900,7 @@ if (!defined('AUTHORPAGE_URL')) define('AUTHORPAGE_URL', */ //if (!defined('DISABLE_HTTP_REDIRECT')) define ('DISABLE_HTTP_REDIRECT', true); -if (defined('WIKI_SOAP')) and WIKI_SOAP) return; +if (defined('WIKI_SOAP') and WIKI_SOAP) return; //////////////////////////////////////////////////////////////// // PrettyWiki @@ -933,6 +937,13 @@ if (defined('VIRTUAL_PATH') and defined('USE_PATH_INFO')) { //include "lib/main.php"; // $Log: not supported by cvs2svn $ +// Revision 1.128 2004/02/29 02:06:05 rurban +// And this is the SOAP server. Just a view methods for now. (page content) +// I would like to see common-wiki soap wdsl. +// +// "SOAP is a bloated, over engineered mess of a perfectly trivial concept. Sigh." +// -- http://www.wlug.org.nz/SOAP +// // Revision 1.127 2004/02/28 21:18:29 rurban // new SQL auth_create, don't ever use REPLACE sql calls! // moved HttpAuth to the end of the chain diff --git a/lib/WikiUserNew.php b/lib/WikiUserNew.php index 2a0507161..faf7b4d51 100644 --- a/lib/WikiUserNew.php +++ b/lib/WikiUserNew.php @@ -1,5 +1,5 @@ _prefs->get('passwd'))) return true; @@ -1733,7 +1734,54 @@ extends _PassUser function mayChangePass() { return false; } +} + +class _POP3PassUser +extends _IMAPPassUser { +/** + * Define the var POP3_AUTH_HOST in index.php + * Preferences are handled in _PassUser + */ + function checkPass($submitted_password) { + $userid = $this->_userid; + $pass = $submitted_password; + $host = defined('POP3_AUTH_HOST') ? POP3_AUTH_HOST : 'localhost'; + $port = defined('POP3_AUTH_PORT') ? POP3_AUTH_PORT : 110; + $retval = false; + $fp = fsockopen($host, $port, $errno, $errstr, 10); + if ($fp) { + // Get welcome string + $line = fgets($fp, 1024); + if (! strncmp("+OK ", $line, 4)) { + // Send user name + fputs($fp, "user $user\n"); + // Get response + $line = fgets($fp, 1024); + if (! strncmp("+OK ", $line, 4)) { + // Send password + fputs($fp, "pass $pass\n"); + // Get response + $line = fgets($fp, 1024); + if (! strncmp("+OK ", $line, 4)) { + $retval = true; + } + } + } + // quit the connection + fputs($fp, "quit\n"); + // Get the sayonara message + $line = fgets($fp, 1024); + fclose($fp); + } + $this->_authmethod = 'POP3'; + if ($retval) { + $this->_level = WIKIAUTH_USER; + } else { + $this->_level = WIKIAUTH_ANON; + } + return $this->_level; + } } class _FilePassUser @@ -1991,6 +2039,7 @@ extends _UserPreference * ->_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. + * */ class UserPreferences { @@ -2217,6 +2266,17 @@ extends UserPreferences // $Log: not supported by cvs2svn $ +// Revision 1.25 2004/02/28 22:25:07 rurban +// First PagePerm implementation: +// +// $Theme->setAnonEditUnknownLinks(false); +// +// Layout improvement with dangling links for mostly closed wiki's: +// If false, only users with edit permissions will be presented the +// special wikiunknown class with "?" and Tooltip. +// If true (default), any user will see the ?, but will be presented +// the PrintLoginForm on a click. +// // Revision 1.24 2004/02/28 21:14:08 rurban // generally more PHPDOC docs // see http://xarch.tu-graz.ac.at/home/rurban/phpwiki/xref/ -- 2.45.0