function wfSpecialUserlogin() {
global $wgCommandLineMode;
global $wgRequest;
- if( !$wgCommandLineMode && !isset( $_COOKIE[ini_get('session.name')] ) ) {
+ if( !$wgCommandLineMode && !isset( $_COOKIE[session_name()] ) ) {
User::SetupSession();
}
global $wgLang, $wgAllowRealName, $wgEnableEmail;
global $wgAuth;
+ $this->mType = $request->getText( 'type' );
$this->mName = $request->getText( 'wpName' );
$this->mPassword = $request->getText( 'wpPassword' );
$this->mRetype = $request->getText( 'wpRetype' );
$wgUser->sendConfirmationMail();
}
+ wfRunHooks( 'AddNewAccount' );
+
if( $this->hasSessionCookie() ) {
return $this->successfulLogin( wfMsg( 'welcomecreation', $wgUser->getName() ) );
} else {
*/
function addNewAccountInternal() {
global $wgUser, $wgOut;
- global $wgMaxNameChars, $wgUseLatin1, $wgEnableSorbs, $wgProxyWhitelist;
- global $wgMemc, $wgAccountCreationThrottle, $wgDBname, $wgIP;
- global $wgMinimalPasswordLength;
- global $wgAuth;
+ global $wgUseLatin1, $wgEnableSorbs, $wgProxyWhitelist;
+ global $wgMemc, $wgAccountCreationThrottle, $wgDBname;
+ global $wgAuth, $wgMinimalPasswordLength;
// If the user passes an invalid domain, something is fishy
if( !$wgAuth->validDomain( $this->mDomain ) ) {
}
}
-
-
if (!$wgUser->isAllowedToCreateAccount()) {
$this->userNotPrivilegedMessage();
return false;
}
- if ( $wgEnableSorbs && !in_array( $wgIP, $wgProxyWhitelist ) &&
- $wgUser->inSorbsBlacklist( $wgIP ) )
+ $ip = wfGetIP();
+ if ( $wgEnableSorbs && !in_array( $ip, $wgProxyWhitelist ) &&
+ $wgUser->inSorbsBlacklist( $ip ) )
{
- $this->mainLoginForm( wfMsg( 'sorbs_create_account_reason' ) );
+ $this->mainLoginForm( wfMsg( 'sorbs_create_account_reason' ) . ' (' . htmlspecialchars( $ip ) . ')' );
return;
}
$name = trim( $this->mName );
$u = User::newFromName( $name );
- if ( is_null( $u ) ||
- ( '' == $name ) ||
- $wgUser->isIP( $name ) ||
- (strpos( $name, '/' ) !== false) ||
- (strlen( $name ) > $wgMaxNameChars) ||
- ucFirst($name) != $u->getName() )
- {
+ if ( is_null( $u ) ) {
$this->mainLoginForm( wfMsg( 'noname' ) );
return false;
}
+
if ( wfReadOnly() ) {
$wgOut->readOnlyPage();
return false;
return false;
}
- if ( strlen( $this->mPassword ) < $wgMinimalPasswordLength ) {
+ if ( !$wgUser->isValidPassword( $this->mPassword ) ) {
$this->mainLoginForm( wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
return false;
}
if ( $wgAccountCreationThrottle ) {
- $key = $wgDBname.':acctcreate:ip:'.$wgIP;
+ $key = $wgDBname.':acctcreate:ip:'.$ip;
$value = $wgMemc->incr( $key );
if ( !$value ) {
$wgMemc->set( $key, 1, 86400 );
global $wgAuth;
$wgAuth->initUser( $u );
- if ( $this->mRemember ) { $r = 1; }
- else { $r = 0; }
- $u->setOption( 'rememberpassword', $r );
+ $u->setOption( 'rememberpassword', $this->mRemember ? 1 : 0 );
return $u;
}
}
if (!$u->checkPassword( $this->mPassword )) {
- $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
+ $this->mainLoginForm( wfMsg( $this->mPassword == '' ? 'wrongpasswordempty' : 'wrongpassword' ) );
return;
}
if( WikiError::isError( $result ) ) {
$this->mainLoginForm( wfMsg( 'mailerror', $result->getMessage() ) );
} else {
- $this->mainLoginForm( wfMsg( 'passwordsent', $u->getName() ) );
+ $this->mainLoginForm( wfMsg( 'passwordsent', $u->getName() ), 'success' );
}
}
* @access private
*/
function mailPasswordInternal( $u ) {
- global $wgPasswordSender, $wgDBname, $wgIP;
+ global $wgPasswordSender, $wgDBname;
global $wgCookiePath, $wgCookieDomain;
if ( '' == $u->getEmail() ) {
$u->saveSettings();
- $ip = $wgIP;
+ $ip = wfGetIP();
if ( '' == $ip ) { $ip = '(Unknown)'; }
- $m = wfMsg( 'passwordremindermailbody', $ip, $u->getName(), wfUrlencode($u->getName()), $np );
- $result = $u->sendMail( wfMsg( 'passwordremindermailsubject' ), $m );
-
+ $m = wfMsg( 'passwordremindertext', $ip, $u->getName(), $np );
+
+ $result = $u->sendMail( wfMsg( 'passwordremindertitle' ), $m );
return $result;
}
/**
* @access private
*/
- function mainLoginForm( $err ) {
+ function mainLoginForm( $msg, $msgtype = 'error' ) {
global $wgUser, $wgOut, $wgLang;
global $wgDBname, $wgAllowRealName, $wgEnableEmail;
global $wgAuth;
}
}
- $q = 'action=submitlogin';
- if ( !empty( $this->mReturnto ) ) {
- $q .= '&returnto=' . wfUrlencode( $this->mReturnto );
- }
$titleObj = Title::makeTitle( NS_SPECIAL, 'Userlogin' );
require_once( 'templates/Userlogin.php' );
- $template =& new UserloginTemplate();
+
+ if ( $this->mType == 'signup' ) {
+ $template =& new UsercreateTemplate();
+ $q = 'action=submitlogin&type=signup';
+ $linkq = 'type=login';
+ $linkmsg = 'gotaccount';
+ } else {
+ $template =& new UserloginTemplate();
+ $q = 'action=submitlogin&type=login';
+ $linkq = 'type=signup';
+ $linkmsg = 'nologin';
+ }
+
+ if ( !empty( $this->mReturnto ) ) {
+ $returnto = '&returnto=' . wfUrlencode( $this->mReturnto );
+ $q .= $returnto;
+ $linkq .= $returnto;
+ }
+
+ $link = '<a href="' . htmlspecialchars ( $titleObj->getLocalUrl( $linkq ) ) . '">';
+ $link .= wfMsgHtml( $linkmsg . 'link' );
+ $link .= '</a>';
+
+ $template->set( 'link', wfMsgHtml( $linkmsg, $link ) );
$template->set( 'name', $this->mName );
$template->set( 'password', $this->mPassword );
$template->set( 'domain', $this->mDomain );
$template->set( 'action', $titleObj->getLocalUrl( $q ) );
- $template->set( 'error', $err );
+ $template->set( 'message', $msg );
+ $template->set( 'messagetype', $msgtype );
$template->set( 'create', $wgUser->isAllowedToCreateAccount() );
$template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() );
$template->set( 'userealname', $wgAllowRealName );
*/
function hasSessionCookie() {
global $wgDisableCookieCheck;
- return ( $wgDisableCookieCheck ) ? true : ( '' != $_COOKIE[session_name()] );
+ return ( $wgDisableCookieCheck ) ? true : ( isset( $_COOKIE[session_name()] ) );
}
/**