4 * @addtogroup SpecialPage
10 function wfSpecialUserlogin() {
12 if( session_id() == '' ) {
16 $form = new LoginForm( $wgRequest );
21 * implements Special:Login
22 * @addtogroup SpecialPage
29 const WRONG_PLUGIN_PASS
= 3;
36 var $mName, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted;
37 var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword;
38 var $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage;
42 * @param WebRequest $request A WebRequest object passed by reference
44 function LoginForm( &$request ) {
45 global $wgLang, $wgAllowRealName, $wgEnableEmail;
48 $this->mType
= $request->getText( 'type' );
49 $this->mName
= $request->getText( 'wpName' );
50 $this->mPassword
= $request->getText( 'wpPassword' );
51 $this->mRetype
= $request->getText( 'wpRetype' );
52 $this->mDomain
= $request->getText( 'wpDomain' );
53 $this->mReturnTo
= $request->getVal( 'returnto' );
54 $this->mCookieCheck
= $request->getVal( 'wpCookieCheck' );
55 $this->mPosted
= $request->wasPosted();
56 $this->mCreateaccount
= $request->getCheck( 'wpCreateaccount' );
57 $this->mCreateaccountMail
= $request->getCheck( 'wpCreateaccountMail' )
59 $this->mMailmypassword
= $request->getCheck( 'wpMailmypassword' )
61 $this->mLoginattempt
= $request->getCheck( 'wpLoginattempt' );
62 $this->mAction
= $request->getVal( 'action' );
63 $this->mRemember
= $request->getCheck( 'wpRemember' );
64 $this->mLanguage
= $request->getText( 'uselang' );
66 if( $wgEnableEmail ) {
67 $this->mEmail
= $request->getText( 'wpEmail' );
71 if( $wgAllowRealName ) {
72 $this->mRealName
= $request->getText( 'wpRealName' );
74 $this->mRealName
= '';
77 if( !$wgAuth->validDomain( $this->mDomain
) ) {
78 $this->mDomain
= 'invaliddomain';
80 $wgAuth->setDomain( $this->mDomain
);
82 # When switching accounts, it sucks to get automatically logged out
83 if( $this->mReturnTo
== $wgLang->specialPage( 'Userlogout' ) ) {
84 $this->mReturnTo
= '';
89 if ( !is_null( $this->mCookieCheck
) ) {
90 $this->onCookieRedirectCheck( $this->mCookieCheck
);
92 } else if( $this->mPosted
) {
93 if( $this->mCreateaccount
) {
94 return $this->addNewAccount();
95 } else if ( $this->mCreateaccountMail
) {
96 return $this->addNewAccountMailPassword();
97 } else if ( $this->mMailmypassword
) {
98 return $this->mailPassword();
99 } else if ( ( 'submitlogin' == $this->mAction
) ||
$this->mLoginattempt
) {
100 return $this->processLogin();
103 $this->mainLoginForm( '' );
109 function addNewAccountMailPassword() {
112 if ('' == $this->mEmail
) {
113 $this->mainLoginForm( wfMsg( 'noemail', htmlspecialchars( $this->mName
) ) );
117 $u = $this->addNewaccountInternal();
123 // Wipe the initial password and mail a temporary one
124 $u->setPassword( null );
126 $result = $this->mailPasswordInternal( $u, false, 'createaccount-title', 'createaccount-text' );
128 wfRunHooks( 'AddNewAccount', array( $u ) );
130 $wgOut->setPageTitle( wfMsg( 'accmailtitle' ) );
131 $wgOut->setRobotpolicy( 'noindex,nofollow' );
132 $wgOut->setArticleRelated( false );
134 if( WikiError
::isError( $result ) ) {
135 $this->mainLoginForm( wfMsg( 'mailerror', $result->getMessage() ) );
137 $wgOut->addWikiText( wfMsg( 'accmailtext', $u->getName(), $u->getEmail() ) );
138 $wgOut->returnToMain( false );
147 function addNewAccount() {
148 global $wgUser, $wgEmailAuthentication;
150 # Create the account and abort if there's a problem doing so
151 $u = $this->addNewAccountInternal();
155 # If we showed up language selection links, and one was in use, be
156 # smart (and sensible) and save that language as the user's preference
157 global $wgLoginLanguageSelector;
158 if( $wgLoginLanguageSelector && $this->mLanguage
)
159 $u->setOption( 'language', $this->mLanguage
);
161 # Save user settings and send out an email authentication message if needed
163 if( $wgEmailAuthentication && User
::isValidEmailAddr( $u->getEmail() ) ) {
165 $error = $u->sendConfirmationMail();
166 if( WikiError
::isError( $error ) ) {
167 $wgOut->addWikiText( wfMsg( 'confirmemail_sendfailed', $error->getMessage() ) );
169 $wgOut->addWikiText( wfMsg( 'confirmemail_oncreate' ) );
173 # If not logged in, assume the new account as the current one and set session cookies
174 # then show a "welcome" message or a "need cookies" message as needed
175 if( $wgUser->isAnon() ) {
177 $wgUser->setCookies();
178 wfRunHooks( 'AddNewAccount', array( $wgUser ) );
179 if( $this->hasSessionCookie() ) {
180 return $this->successfulLogin( wfMsg( 'welcomecreation', $wgUser->getName() ), false );
182 return $this->cookieRedirectCheck( 'new' );
185 # Confirm that the account was created
187 $self = SpecialPage
::getTitleFor( 'Userlogin' );
188 $wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) );
189 $wgOut->setArticleRelated( false );
190 $wgOut->setRobotPolicy( 'noindex,nofollow' );
191 $wgOut->addHtml( wfMsgWikiHtml( 'accountcreatedtext', $u->getName() ) );
192 $wgOut->returnToMain( false, $self );
193 wfRunHooks( 'AddNewAccount', array( $u ) );
201 function addNewAccountInternal() {
202 global $wgUser, $wgOut;
203 global $wgEnableSorbs, $wgProxyWhitelist;
204 global $wgMemc, $wgAccountCreationThrottle;
205 global $wgAuth, $wgMinimalPasswordLength;
206 global $wgEmailConfirmToEdit;
208 // If the user passes an invalid domain, something is fishy
209 if( !$wgAuth->validDomain( $this->mDomain
) ) {
210 $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
214 // If we are not allowing users to login locally, we should
215 // be checking to see if the user is actually able to
216 // authenticate to the authentication server before they
217 // create an account (otherwise, they can create a local account
218 // and login as any domain user). We only need to check this for
219 // domains that aren't local.
220 if( 'local' != $this->mDomain
&& '' != $this->mDomain
) {
221 if( !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $this->mName
) ||
!$wgAuth->authenticate( $this->mName
, $this->mPassword
) ) ) {
222 $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
227 if ( wfReadOnly() ) {
228 $wgOut->readOnlyPage();
233 if ( !$wgUser->isAllowed( 'createaccount' ) ) {
234 $this->userNotPrivilegedMessage();
236 } elseif ( $wgUser->isBlockedFromCreateAccount() ) {
237 $this->userBlockedMessage();
242 if ( $wgEnableSorbs && !in_array( $ip, $wgProxyWhitelist ) &&
243 $wgUser->inSorbsBlacklist( $ip ) )
245 $this->mainLoginForm( wfMsg( 'sorbs_create_account_reason' ) . ' (' . htmlspecialchars( $ip ) . ')' );
249 # Now create a dummy user ($u) and check if it is valid
250 $name = trim( $this->mName
);
251 $u = User
::newFromName( $name, 'creatable' );
252 if ( is_null( $u ) ) {
253 $this->mainLoginForm( wfMsg( 'noname' ) );
257 if ( 0 != $u->idForName() ) {
258 $this->mainLoginForm( wfMsg( 'userexists' ) );
262 if ( 0 != strcmp( $this->mPassword
, $this->mRetype
) ) {
263 $this->mainLoginForm( wfMsg( 'badretype' ) );
267 if ( !$u->isValidPassword( $this->mPassword
) ) {
268 $this->mainLoginForm( wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
272 # if you need a confirmed email address to edit, then obviously you need an email address.
273 if ( $wgEmailConfirmToEdit && empty( $this->mEmail
) ) {
274 $this->mainLoginForm( wfMsg( 'noemailtitle' ) );
278 if( !empty( $this->mEmail
) && !User
::isValidEmailAddr( $this->mEmail
) ) {
279 $this->mainLoginForm( wfMsg( 'invalidemailaddress' ) );
283 # Set some additional data so the AbortNewAccount hook can be
284 # used for more than just username validation
285 $u->setEmail( $this->mEmail
);
286 $u->setRealName( $this->mRealName
);
289 if( !wfRunHooks( 'AbortNewAccount', array( $u, &$abortError ) ) ) {
290 // Hook point to add extra creation throttles and blocks
291 wfDebug( "LoginForm::addNewAccountInternal: a hook blocked creation\n" );
292 $this->mainLoginForm( $abortError );
296 if ( $wgAccountCreationThrottle && $wgUser->isPingLimitable() ) {
297 $key = wfMemcKey( 'acctcreate', 'ip', $ip );
298 $value = $wgMemc->incr( $key );
300 $wgMemc->set( $key, 1, 86400 );
302 if ( $value > $wgAccountCreationThrottle ) {
303 $this->throttleHit( $wgAccountCreationThrottle );
308 if( !$wgAuth->addUser( $u, $this->mPassword
, $this->mEmail
, $this->mRealName
) ) {
309 $this->mainLoginForm( wfMsg( 'externaldberror' ) );
313 return $this->initUser( $u, false );
317 * Actually add a user to the database.
318 * Give it a User object that has been initialised with a name.
320 * @param $u User object.
321 * @param $autocreate boolean -- true if this is an autocreation via auth plugin
322 * @return User object.
325 function initUser( $u, $autocreate ) {
330 if ( $wgAuth->allowPasswordChange() ) {
331 $u->setPassword( $this->mPassword
);
334 $u->setEmail( $this->mEmail
);
335 $u->setRealName( $this->mRealName
);
338 $wgAuth->initUser( $u, $autocreate );
340 $u->setOption( 'rememberpassword', $this->mRemember ?
1 : 0 );
344 $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
345 $ssUpdate->doUpdate();
351 * Internally authenticate the login request.
353 * This may create a local account as a side effect if the
354 * authentication plugin allows transparent local account
359 function authenticateUserData() {
360 global $wgUser, $wgAuth;
361 if ( '' == $this->mName
) {
362 return self
::NO_NAME
;
364 $u = User
::newFromName( $this->mName
);
365 if( is_null( $u ) ||
!User
::isUsableName( $u->getName() ) ) {
366 return self
::ILLEGAL
;
368 if ( 0 == $u->getID() ) {
371 * If the external authentication plugin allows it,
372 * automatically create a new account for users that
373 * are externally defined but have not yet logged in.
375 if ( $wgAuth->autoCreate() && $wgAuth->userExists( $u->getName() ) ) {
376 if ( $wgAuth->authenticate( $u->getName(), $this->mPassword
) ) {
377 $u = $this->initUser( $u, true );
379 return self
::WRONG_PLUGIN_PASS
;
382 return self
::NOT_EXISTS
;
388 // Give general extensions, such as a captcha, a chance to abort logins
389 $abort = self
::ABORTED
;
390 if( !wfRunHooks( 'AbortLogin', array( $u, $this->mPassword
, &$abort ) ) ) {
394 if (!$u->checkPassword( $this->mPassword
)) {
395 if( $u->checkTemporaryPassword( $this->mPassword
) ) {
396 // The e-mailed temporary password should not be used
397 // for actual logins; that's a very sloppy habit,
398 // and insecure if an attacker has a few seconds to
399 // click "search" on someone's open mail reader.
401 // Allow it to be used only to reset the password
402 // a single time to a new value, which won't be in
403 // the user's e-mail archives.
405 // For backwards compatibility, we'll still recognize
406 // it at the login form to minimize surprises for
407 // people who have been logging in with a temporary
408 // password for some time.
410 // As a side-effect, we can authenticate the user's
411 // e-mail address if it's not already done, since
412 // the temporary password was sent via e-mail.
414 if( !$u->isEmailConfirmed() ) {
418 // At this point we just return an appropriate code
419 // indicating that the UI should show a password
420 // reset form; bot interfaces etc will probably just
421 // fail cleanly here.
423 $retval = self
::RESET_PASS
;
425 $retval = '' == $this->mPassword ? self
::EMPTY_PASS
: self
::WRONG_PASS
;
428 $wgAuth->updateUser( $u );
431 $retval = self
::SUCCESS
;
433 wfRunHooks( 'LoginAuthenticateAudit', array( $u, $this->mPassword
, $retval ) );
437 function processLogin() {
438 global $wgUser, $wgAuth;
440 switch ($this->authenticateUserData())
443 # We've verified now, update the real record
444 if( (bool)$this->mRemember
!= (bool)$wgUser->getOption( 'rememberpassword' ) ) {
445 $wgUser->setOption( 'rememberpassword', $this->mRemember ?
1 : 0 );
446 $wgUser->saveSettings();
448 $wgUser->invalidateCache();
450 $wgUser->setCookies();
452 if( $this->hasSessionCookie() ) {
453 return $this->successfulLogin( wfMsg( 'loginsuccess', $wgUser->getName() ) );
455 return $this->cookieRedirectCheck( 'login' );
461 $this->mainLoginForm( wfMsg( 'noname' ) );
463 case self
::WRONG_PLUGIN_PASS
:
464 $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
466 case self
::NOT_EXISTS
:
467 $this->mainLoginForm( wfMsg( 'nosuchuser', htmlspecialchars( $this->mName
) ) );
469 case self
::WRONG_PASS
:
470 $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
472 case self
::EMPTY_PASS
:
473 $this->mainLoginForm( wfMsg( 'wrongpasswordempty' ) );
475 case self
::RESET_PASS
:
476 $this->resetLoginForm( wfMsg( 'resetpass_announce' ) );
479 wfDebugDieBacktrace( "Unhandled case value" );
483 function resetLoginForm( $error ) {
485 $wgOut->addWikiText( "<div class=\"errorbox\">$error</div>" );
486 $reset = new PasswordResetForm( $this->mName
, $this->mPassword
);
493 function mailPassword() {
494 global $wgUser, $wgOut, $wgAuth;
496 if( !$wgAuth->allowPasswordChange() ) {
497 $this->mainLoginForm( wfMsg( 'resetpass_forbidden' ) );
501 # Check against blocked IPs
502 # fixme -- should we not?
503 if( $wgUser->isBlocked() ) {
504 $this->mainLoginForm( wfMsg( 'blocked-mailpassword' ) );
508 # Check against the rate limiter
509 if( $wgUser->pingLimiter( 'mailpassword' ) ) {
510 $wgOut->rateLimited();
514 if ( '' == $this->mName
) {
515 $this->mainLoginForm( wfMsg( 'noname' ) );
518 $u = User
::newFromName( $this->mName
);
519 if( is_null( $u ) ) {
520 $this->mainLoginForm( wfMsg( 'noname' ) );
523 if ( 0 == $u->getID() ) {
524 $this->mainLoginForm( wfMsg( 'nosuchuser', $u->getName() ) );
528 # Check against password throttle
529 if ( $u->isPasswordReminderThrottled() ) {
530 global $wgPasswordReminderResendTime;
531 # Round the time in hours to 3 d.p., in case someone is specifying minutes or seconds.
532 $this->mainLoginForm( wfMsg( 'throttled-mailpassword',
533 round( $wgPasswordReminderResendTime, 3 ) ) );
537 $result = $this->mailPasswordInternal( $u, true, 'passwordremindertitle', 'passwordremindertext' );
538 if( WikiError
::isError( $result ) ) {
539 $this->mainLoginForm( wfMsg( 'mailerror', $result->getMessage() ) );
541 $this->mainLoginForm( wfMsg( 'passwordsent', $u->getName() ), 'success' );
548 * @param bool throttle
549 * @param string message name of email title
550 * @param string message name of email text
551 * @return mixed true on success, WikiError on failure
554 function mailPasswordInternal( $u, $throttle = true, $emailTitle = 'passwordremindertitle', $emailText = 'passwordremindertext' ) {
555 global $wgCookiePath, $wgCookieDomain, $wgCookiePrefix, $wgCookieSecure;
556 global $wgServer, $wgScript;
558 if ( '' == $u->getEmail() ) {
559 return new WikiError( wfMsg( 'noemail', $u->getName() ) );
562 $np = $u->randomPassword();
563 $u->setNewpassword( $np, $throttle );
565 setcookie( "{$wgCookiePrefix}Token", '', time() - 3600, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
570 if ( '' == $ip ) { $ip = '(Unknown)'; }
572 $m = wfMsg( $emailText, $ip, $u->getName(), $np, $wgServer . $wgScript );
573 $result = $u->sendMail( wfMsg( $emailTitle ), $m );
580 * @param string $msg Message that will be shown on success
581 * @param bool $auto Toggle auto-redirect to main page; default true
584 function successfulLogin( $msg, $auto = true ) {
588 # Run any hooks; ignore results
590 wfRunHooks('UserLoginComplete', array(&$wgUser));
592 $wgOut->setPageTitle( wfMsg( 'loginsuccesstitle' ) );
593 $wgOut->setRobotpolicy( 'noindex,nofollow' );
594 $wgOut->setArticleRelated( false );
595 $wgOut->addWikiText( $msg );
596 if ( !empty( $this->mReturnTo
) ) {
597 $wgOut->returnToMain( $auto, $this->mReturnTo
);
599 $wgOut->returnToMain( $auto );
604 function userNotPrivilegedMessage() {
607 $wgOut->setPageTitle( wfMsg( 'whitelistacctitle' ) );
608 $wgOut->setRobotpolicy( 'noindex,nofollow' );
609 $wgOut->setArticleRelated( false );
611 $wgOut->addWikiText( wfMsg( 'whitelistacctext' ) );
613 $wgOut->returnToMain( false );
617 function userBlockedMessage() {
618 global $wgOut, $wgUser;
620 # Let's be nice about this, it's likely that this feature will be used
621 # for blocking large numbers of innocent people, e.g. range blocks on
622 # schools. Don't blame it on the user. There's a small chance that it
623 # really is the user's fault, i.e. the username is blocked and they
624 # haven't bothered to log out before trying to create an account to
625 # evade it, but we'll leave that to their guilty conscience to figure
628 $wgOut->setPageTitle( wfMsg( 'cantcreateaccounttitle' ) );
629 $wgOut->setRobotpolicy( 'noindex,nofollow' );
630 $wgOut->setArticleRelated( false );
633 $blocker = User
::whoIs( $wgUser->mBlock
->mBy
);
634 $block_reason = $wgUser->mBlock
->mReason
;
636 $wgOut->addWikiText( wfMsg( 'cantcreateaccount-text', $ip, $block_reason, $blocker ) );
637 $wgOut->returnToMain( false );
643 function mainLoginForm( $msg, $msgtype = 'error' ) {
644 global $wgUser, $wgOut, $wgAllowRealName, $wgEnableEmail;
645 global $wgCookiePrefix, $wgAuth, $wgLoginLanguageSelector;
646 global $wgAuth, $wgEmailConfirmToEdit;
648 if ( $this->mType
== 'signup' ) {
649 if ( !$wgUser->isAllowed( 'createaccount' ) ) {
650 $this->userNotPrivilegedMessage();
652 } elseif ( $wgUser->isBlockedFromCreateAccount() ) {
653 $this->userBlockedMessage();
658 if ( '' == $this->mName
) {
659 if ( $wgUser->isLoggedIn() ) {
660 $this->mName
= $wgUser->getName();
662 $this->mName
= isset( $_COOKIE[$wgCookiePrefix.'UserName'] ) ?
$_COOKIE[$wgCookiePrefix.'UserName'] : null;
666 $titleObj = SpecialPage
::getTitleFor( 'Userlogin' );
668 if ( $this->mType
== 'signup' ) {
669 $template = new UsercreateTemplate();
670 $q = 'action=submitlogin&type=signup';
671 $linkq = 'type=login';
672 $linkmsg = 'gotaccount';
674 $template = new UserloginTemplate();
675 $q = 'action=submitlogin&type=login';
676 $linkq = 'type=signup';
677 $linkmsg = 'nologin';
680 if ( !empty( $this->mReturnTo
) ) {
681 $returnto = '&returnto=' . wfUrlencode( $this->mReturnTo
);
686 # Pass any language selection on to the mode switch link
687 if( $wgLoginLanguageSelector && $this->mLanguage
)
688 $linkq .= '&uselang=' . $this->mLanguage
;
690 $link = '<a href="' . htmlspecialchars ( $titleObj->getLocalUrl( $linkq ) ) . '">';
691 $link .= wfMsgHtml( $linkmsg . 'link' );
694 # Don't show a "create account" link if the user can't
695 if( $this->showCreateOrLoginLink( $wgUser ) )
696 $template->set( 'link', wfMsgHtml( $linkmsg, $link ) );
698 $template->set( 'link', '' );
700 $template->set( 'header', '' );
701 $template->set( 'name', $this->mName
);
702 $template->set( 'password', $this->mPassword
);
703 $template->set( 'retype', $this->mRetype
);
704 $template->set( 'email', $this->mEmail
);
705 $template->set( 'realname', $this->mRealName
);
706 $template->set( 'domain', $this->mDomain
);
708 $template->set( 'action', $titleObj->getLocalUrl( $q ) );
709 $template->set( 'message', $msg );
710 $template->set( 'messagetype', $msgtype );
711 $template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() );
712 $template->set( 'userealname', $wgAllowRealName );
713 $template->set( 'useemail', $wgEnableEmail );
714 $template->set( 'emailrequired', $wgEmailConfirmToEdit );
715 $template->set( 'canreset', $wgAuth->allowPasswordChange() );
716 $template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) or $this->mRemember
);
718 # Prepare language selection links as needed
719 if( $wgLoginLanguageSelector ) {
720 $template->set( 'languages', $this->makeLanguageSelector() );
721 if( $this->mLanguage
)
722 $template->set( 'uselang', $this->mLanguage
);
725 // Give authentication and captcha plugins a chance to modify the form
726 $wgAuth->modifyUITemplate( $template );
727 if ( $this->mType
== 'signup' ) {
728 wfRunHooks( 'UserCreateForm', array( &$template ) );
730 wfRunHooks( 'UserLoginForm', array( &$template ) );
733 $wgOut->setPageTitle( wfMsg( 'userlogin' ) );
734 $wgOut->setRobotpolicy( 'noindex,nofollow' );
735 $wgOut->setArticleRelated( false );
736 $wgOut->disallowUserJs(); // just in case...
737 $wgOut->addTemplate( $template );
743 function showCreateOrLoginLink( &$user ) {
744 if( $this->mType
== 'signup' ) {
746 } elseif( $user->isAllowed( 'createaccount' ) ) {
754 * Check if a session cookie is present.
756 * This will not pick up a cookie set during _this_ request, but is
757 * meant to ensure that the client is returning the cookie which was
758 * set on a previous pass through the system.
762 function hasSessionCookie() {
763 global $wgDisableCookieCheck, $wgRequest;
764 return $wgDisableCookieCheck ?
true : $wgRequest->checkSessionCookie();
770 function cookieRedirectCheck( $type ) {
773 $titleObj = SpecialPage
::getTitleFor( 'Userlogin' );
774 $check = $titleObj->getFullURL( 'wpCookieCheck='.$type );
776 return $wgOut->redirect( $check );
782 function onCookieRedirectCheck( $type ) {
785 if ( !$this->hasSessionCookie() ) {
786 if ( $type == 'new' ) {
787 return $this->mainLoginForm( wfMsg( 'nocookiesnew' ) );
788 } else if ( $type == 'login' ) {
789 return $this->mainLoginForm( wfMsg( 'nocookieslogin' ) );
792 return $this->mainLoginForm( wfMsg( 'error' ) );
795 return $this->successfulLogin( wfMsg( 'loginsuccess', $wgUser->getName() ) );
802 function throttleHit( $limit ) {
805 $wgOut->addWikiText( wfMsg( 'acct_creation_throttle_hit', $limit ) );
809 * Produce a bar of links which allow the user to select another language
810 * during login/registration but retain "returnto"
814 function makeLanguageSelector() {
815 $msg = wfMsgForContent( 'loginlanguagelinks' );
816 if( $msg != '' && !wfEmptyMsg( 'loginlanguagelinks', $msg ) ) {
817 $langs = explode( "\n", $msg );
819 foreach( $langs as $lang ) {
820 $lang = trim( $lang, '* ' );
821 $parts = explode( '|', $lang );
822 $links[] = $this->makeLanguageSelectorLink( $parts[0], $parts[1] );
824 return count( $links ) > 0 ?
wfMsgHtml( 'loginlanguagelabel', implode( ' | ', $links ) ) : '';
831 * Create a language selector link for a particular language
832 * Links back to this page preserving type and returnto
834 * @param $text Link text
835 * @param $lang Language code
837 function makeLanguageSelectorLink( $text, $lang ) {
839 $self = SpecialPage
::getTitleFor( 'Userlogin' );
840 $attr[] = 'uselang=' . $lang;
841 if( $this->mType
== 'signup' )
842 $attr[] = 'type=signup';
843 if( $this->mReturnTo
)
844 $attr[] = 'returnto=' . $this->mReturnTo
;
845 $skin = $wgUser->getSkin();
846 return $skin->makeKnownLinkObj( $self, htmlspecialchars( $text ), implode( '&', $attr ) );