diff options
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/.htaccess | 1 | ||||
-rw-r--r-- | extensions/FunnyDot.php | 43 | ||||
-rw-r--r-- | extensions/LLAuthPlugin.php | 264 | ||||
-rw-r--r-- | extensions/README | 3 |
4 files changed, 311 insertions, 0 deletions
diff --git a/extensions/.htaccess b/extensions/.htaccess new file mode 100644 index 00000000..b63d4018 --- /dev/null +++ b/extensions/.htaccess @@ -0,0 +1 @@ +Deny from All diff --git a/extensions/FunnyDot.php b/extensions/FunnyDot.php new file mode 100644 index 00000000..81636bb4 --- /dev/null +++ b/extensions/FunnyDot.php @@ -0,0 +1,43 @@ +<?php + +if ( defined( 'MEDIAWIKI' ) ) { + +global $wgHooks; +$wgHooks['ArticleSave'][] = 'checkAntiSpamHash'; + + +function checkAntiSpamHash() + { + global $wgAntiSpamHash, $wgAntiSpamTimeout, $wgAntiSpamWait; + + $now = time(); + + if (!empty($_COOKIE['AntiSpamTime']) && !empty($_COOKIE['AntiSpamHash'])) + { + $time = intval($_COOKIE['AntiSpamTime']); + $hash = $_COOKIE['AntiSpamHash']; + + if ($hash != sha1($time.$wgAntiSpamHash)) + { + return false; + } + + if ($now - $time > $wgAntiSpamTimeout) + { + return false; + } + elseif ($now - $time < $wgAntiSpamWait) + { + return false; + } + } + else + { + return false; + } + + return true; + } + +} # End invocation guard +?>
\ No newline at end of file diff --git a/extensions/LLAuthPlugin.php b/extensions/LLAuthPlugin.php new file mode 100644 index 00000000..2a5d8bd3 --- /dev/null +++ b/extensions/LLAuthPlugin.php @@ -0,0 +1,264 @@ +<?php +/** + * @package MediaWiki + */ +# Copyright (C) 2004 Brion Vibber <brion@pobox.com> +# http://www.mediawiki.org/ +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# http://www.gnu.org/copyleft/gpl.html + +/** + * Authentication plugin interface. Instantiate a subclass of AuthPlugin + * and set $wgAuth to it to authenticate against some external tool. + * + * The default behavior is not to do anything, and use the local user + * database for all authentication. A subclass can require that all + * accounts authenticate externally, or use it only as a fallback; also + * you can transparently create internal wiki accounts the first time + * someone logs in who can be authenticated externally. + * + * This interface is new, and might change a bit before 1.4.0 final is + * done... + * + * @package MediaWiki + */ +class AuthPlugin { + + private $dbLink = null; + + function __construct() + { + global $wgDBuser, $wgDBpassword; + $this->dbLink = mysqli_connect('localhost', $wgDBuser, $wgDBpassword, 'current'); + } + + function __destruct() + { + mysqli_close($this->dbLink); + } + + function getUserData($username) + { + $result = mysqli_query($this->dbLink, 'SELECT id, email, realname FROM users WHERE name = \''.mysqli_escape_string($this->dbLink, $username).'\''); + $data = mysqli_fetch_assoc($result); + mysqli_free_result($result); + + return $data; + } + /** + * Check whether there exists a user account with the given name. + * The name will be normalized to MediaWiki's requirements, so + * you might need to munge it (for instance, for lowercase initial + * letters). + * + * @param $username String: username. + * @return bool + * @public + */ + function userExists( $username ) { + $result = mysqli_query($this->dbLink, 'SELECT id FROM users WHERE name = \''.mysqli_escape_string($this->dbLink, $username).'\''); + $exists = mysqli_num_rows($result) > 0; + mysqli_free_result($result); + + return $exists; + } + + /** + * Check if a username+password pair is a valid login. + * The name will be normalized to MediaWiki's requirements, so + * you might need to munge it (for instance, for lowercase initial + * letters). + * + * @param $username String: username. + * @param $password String: user password. + * @return bool + * @public + */ + function authenticate( $username, $password ) { + $result = mysqli_query($this->dbLink, 'SELECT id FROM users WHERE name = \''.mysqli_escape_string($this->dbLink, $username).'\' AND password = \''.mysqli_escape_string($this->dbLink, sha1($password)).'\' '); + $authenticated = mysqli_num_rows($result) > 0; + mysqli_free_result($result); + + return $authenticated; + } + + /** + * Modify options in the login template. + * + * @param $template UserLoginTemplate object. + * @public + */ + function modifyUITemplate( &$template ) { + # Override this! + $template->set( 'usedomain', false ); + $template->set('link', 'Um Dich hier anzumelden, nutze Deine Konto-Daten aus dem <a href="http://www.laber-land.de/?page=Forums;id=20">archlinux.de-Forum</a>.'); + } + + /** + * Set the domain this plugin is supposed to use when authenticating. + * + * @param $domain String: authentication domain. + * @public + */ + function setDomain( $domain ) { + $this->domain = $domain; + } + + /** + * Check to see if the specific domain is a valid domain. + * + * @param $domain String: authentication domain. + * @return bool + * @public + */ + function validDomain( $domain ) { + # Override this! + return true; + } + + /** + * When a user logs in, optionally fill in preferences and such. + * For instance, you might pull the email address or real name from the + * external user database. + * + * The User object is passed by reference so it can be modified; don't + * forget the & on your function declaration. + * + * @param User $user + * @public + */ + function updateUser( &$user ) { + return $this->initUser($user); + } + + + /** + * Return true if the wiki should create a new local account automatically + * when asked to login a user who doesn't exist locally but does in the + * external auth database. + * + * If you don't automatically create accounts, you must still create + * accounts in some way. It's not possible to authenticate without + * a local account. + * + * This is just a question, and shouldn't perform any actions. + * + * @return bool + * @public + */ + function autoCreate() { + return true; + } + + /** + * Can users change their passwords? + * + * @return bool + */ + function allowPasswordChange() { + return false; + } + + /** + * Set the given password in the authentication database. + * Return true if successful. + * + * @param $password String: password. + * @return bool + * @public + */ + function setPassword( $password ) { + return false; + } + + /** + * Update user information in the external authentication database. + * Return true if successful. + * + * @param $user User object. + * @return bool + * @public + */ + function updateExternalDB( $user ) { + return false; + } + + /** + * Check to see if external accounts can be created. + * Return true if external accounts can be created. + * @return bool + * @public + */ + function canCreateAccounts() { + return false; + } + + /** + * Add a user to the external authentication database. + * Return true if successful. + * + * @param User $user + * @param string $password + * @return bool + * @public + */ + function addUser( $user, $password ) { + return false; + } + + + /** + * Return true to prevent logins that don't authenticate here from being + * checked against the local database's password fields. + * + * This is just a question, and shouldn't perform any actions. + * + * @return bool + * @public + */ + function strict() { + return true; + } + + /** + * When creating a user account, optionally fill in preferences and such. + * For instance, you might pull the email address or real name from the + * external user database. + * + * The User object is passed by reference so it can be modified; don't + * forget the & on your function declaration. + * + * @param $user User object. + * @public + */ + function initUser( &$user ) { + $data = $this->getUserData($user->getName()); + $user->setEmail($data['email']); + $user->confirmEmail(); + $user->setRealName($data['realname']); + return true; + } + + /** + * If you want to munge the case of an account name before the final + * check, now is your chance. + */ + function getCanonicalName( $username ) { + return $username; + } +} + +?> diff --git a/extensions/README b/extensions/README new file mode 100644 index 00000000..cc931160 --- /dev/null +++ b/extensions/README @@ -0,0 +1,3 @@ +Some extensions (such as the hieroglyphic module WikiHiero) are +distributed separately. Drop them into this extensions directory +and enable as per the extension's directions. |