<?php
-
+/**
+ *
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
+
+/**
+ *
+ */
require_once('UserMailer.php');
-function wfSpecialUserlogin()
-{
+/**
+ * consutrctor
+ */
+function wfSpecialUserlogin() {
global $wgCommandLineMode;
global $wgRequest;
if( !$wgCommandLineMode && !isset( $_COOKIE[ini_get("session.name")] ) ) {
$form->execute();
}
+/**
+ *
+ * @package MediaWiki
+ * @subpackage SpecialPage
+ */
class LoginForm {
var $mName, $mPassword, $mRetype, $mReturnto, $mCookieCheck, $mPosted;
var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword;
function execute() {
if ( !is_null( $this->mCookieCheck ) ) {
$this->onCookieRedirectCheck( $this->mCookieCheck );
+ return;
} else if( $this->mPosted ) {
if( $this->mCreateaccount ) {
return $this->addNewAccount();
$this->mainLoginForm( "" );
}
- /* private */ function addNewAccountMailPassword()
- {
+ /**
+ * @access private
+ */
+ function addNewAccountMailPassword() {
global $wgOut;
if ("" == $this->mEmail) {
}
- /* private */ function addNewAccount()
- {
+ /**
+ * @access private
+ */
+ function addNewAccount() {
global $wgUser, $wgOut;
global $wgDeferredUpdateList;
}
- /* private */ function addNewAccountInternal()
- {
+ /**
+ * @access private
+ */
+ function addNewAccountInternal() {
global $wgUser, $wgOut;
global $wgMaxNameChars;
global $wgMemc, $wgAccountCreationThrottle, $wgDBname, $wgIP;
- if ( $wgAccountCreationThrottle ) {
- $key = "$wgDBname:acctcreate:ip:$wgIP";
- $value = $wgMemc->incr( $key );
- if ( !$value ) {
- $wgMemc->set( $key, 1, 86400 );
- }
- if ( $value > $wgAccountCreationThrottle ) {
- $this->throttleHit( $wgAccountCreationThrottle );
- return;
- }
- }
-
if (!$wgUser->isAllowedToCreateAccount()) {
$this->userNotPrivilegedMessage();
return;
}
$name = trim( $this->mName );
- if ( ( "" == $name ) ||
+ $u = User::newFromName( $name );
+ if ( is_null( $u ) ||
+ ( "" == $name ) ||
preg_match( "/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/", $name ) ||
(strpos( $name, "/" ) !== false) ||
- (strlen( $name ) > $wgMaxNameChars) )
+ (strlen( $name ) > $wgMaxNameChars) ||
+ ucFirst($name) != $u->getName() )
{
$this->mainLoginForm( wfMsg( "noname" ) );
return;
$wgOut->readOnlyPage();
return;
}
- $u = User::newFromName( $name );
if ( 0 != $u->idForName() ) {
$this->mainLoginForm( wfMsg( "userexists" ) );
return;
}
+
+ if ( $wgAccountCreationThrottle ) {
+ $key = "$wgDBname:acctcreate:ip:$wgIP";
+ $value = $wgMemc->incr( $key );
+ if ( !$value ) {
+ $wgMemc->set( $key, 1, 86400 );
+ }
+ if ( $value > $wgAccountCreationThrottle ) {
+ $this->throttleHit( $wgAccountCreationThrottle );
+ return;
+ }
+ }
+
$u->addToDatabase();
$u->setPassword( $this->mPassword );
$u->setEmail( $this->mEmail );
return $u;
}
-
-
- /* private */ function processLogin()
- {
+ /**
+ * @access private
+ */
+ function processLogin() {
global $wgUser;
global $wgDeferredUpdateList;
return;
}
$u = User::newFromName( $this->mName );
+ if( is_null( $u ) ) {
+ $this->mainLoginForm( wfMsg( "noname" ) );
+ return;
+ }
$id = $u->idForName();
if ( 0 == $id ) {
$this->mainLoginForm( wfMsg( "nosuchuser", $u->getName() ) );
}
$u->setId( $id );
$u->loadFromDatabase();
- $ep = $u->encryptPassword( $this->mPassword );
- if ( 0 != strcmp( $ep, $u->getPassword() ) ) {
- if ( 0 != strcmp( $ep, $u->getNewpassword() ) ) {
- $this->mainLoginForm( wfMsg( "wrongpassword" ) );
- return;
- }
+ if (!$u->checkPassword( $this->mPassword )) {
+ $this->mainLoginForm( wfMsg( "wrongpassword" ) );
+ return;
}
# We've verified now, update the real record
}
}
- /* private */ function mailPassword()
- {
+ /**
+ * @access private
+ */
+ function mailPassword() {
global $wgUser, $wgDeferredUpdateList, $wgOutputEncoding;
global $wgCookiePath, $wgCookieDomain, $wgDBname;
return;
}
$u = User::newFromName( $this->mName );
+ if( is_null( $u ) ) {
+ $this->mainLoginForm( wfMsg( "noname" ) );
+ return;
+ }
$id = $u->idForName();
if ( 0 == $id ) {
$this->mainLoginForm( wfMsg( "nosuchuser", $u->getName() ) );
}
- /* private */ function mailPasswordInternal( $u )
- {
+ /**
+ * @access private
+ */
+ function mailPasswordInternal( $u ) {
global $wgDeferredUpdateList, $wgOutputEncoding;
global $wgPasswordSender, $wgDBname, $wgIP;
global $wgCookiePath, $wgCookieDomain;
if ( "" == $u->getEmail() ) {
- $this->mainLoginForm( wfMsg( "noemail", $u->getName() ) );
- return;
+ return wfMsg( "noemail", $u->getName() );
}
$np = User::randomPassword();
$u->setNewpassword( $np );
}
-
-
-
- /* private */ function successfulLogin( $msg )
- {
+ /**
+ * @access private
+ */
+ function successfulLogin( $msg ) {
global $wgUser;
global $wgDeferredUpdateList;
global $wgOut;
$wgOut->setPageTitle( wfMsg( "loginsuccesstitle" ) );
$wgOut->setRobotpolicy( "noindex,nofollow" );
$wgOut->setArticleRelated( false );
- $wgOut->addHTML( $msg );
+ $wgOut->addWikiText( $msg );
$wgOut->returnToMain();
}
- function userNotPrivilegedMessage()
- {
+ function userNotPrivilegedMessage() {
global $wgOut, $wgUser, $wgLang;
$wgOut->setPageTitle( wfMsg( "whitelistacctitle" ) );
$wgOut->returnToMain( false );
}
- /* private */ function mainLoginForm( $err )
- {
+ /**
+ * @access private
+ */
+ function mainLoginForm( $err ) {
global $wgUser, $wgOut, $wgLang;
global $wgDBname, $wgAllowRealName;
$ca = wfMsg( "createaccount" );
$cam = wfMsg( "createaccountmail" );
$ye = wfMsg( "youremail" );
- if ($wgAllowRealName) {
+ if( $wgAllowRealName ) {
$yrn = wfMsg( "yourrealname" );
} else {
$yrn = '';
$titleObj = Title::makeTitle( NS_SPECIAL, "Userlogin" );
$action = $titleObj->escapeLocalUrl( $q );
- $encName = wfEscapeHTML( $this->mName );
- $encPassword = wfEscapeHTML( $this->mPassword );
- $encRetype = wfEscapeHTML( $this->mRetype );
- $encEmail = wfEscapeHTML( $this->mEmail );
- $encRealName = wfEscapeHTML( $this->mRealName );
+ $encName = htmlspecialchars( $this->mName );
+ $encPassword = htmlspecialchars( $this->mPassword );
+ $encRetype = htmlspecialchars( $this->mRetype );
+ $encEmail = htmlspecialchars( $this->mEmail );
+ $encRealName = htmlspecialchars( $this->mRealName );
if ($wgUser->getID() != 0) {
$cambutton = "<input tabindex='6' type='submit' name=\"wpCreateaccountMail\" value=\"{$cam}\" />";
$wgOut->addHTML( $endText );
}
- /* private */ function hasSessionCookie()
- {
+ /**
+ * @access private
+ */
+ function hasSessionCookie() {
global $wgDisableCookieCheck;
return ( $wgDisableCookieCheck ) ? true : ( "" != $_COOKIE[session_name()] );
}
- /* private */ function cookieRedirectCheck( $type )
- {
+ /**
+ * @access private
+ */
+ function cookieRedirectCheck( $type ) {
global $wgOut, $wgLang;
$titleObj = Title::makeTitle( NS_SPECIAL, "Userlogin" );
return $wgOut->redirect( $check );
}
- /* private */ function onCookieRedirectCheck( $type ) {
+ /**
+ * @access private
+ */
+ function onCookieRedirectCheck( $type ) {
global $wgUser;
if ( !$this->hasSessionCookie() ) {
}
}
- /* private */ function throttleHit( $limit ) {
+ /**
+ * @access private
+ */
+ function throttleHit( $limit ) {
global $wgOut;
$wgOut->addWikiText( wfMsg( 'acct_creation_throttle_hit', $limit ) );