8c1b39ed798e955e43cf699c021ce47fdba05fd1
[lhc/web/wiklou.git] / includes / SpecialUserlogin.php
1 <?php
2 /**
3 *
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 /**
9 * constructor
10 */
11 function wfSpecialUserlogin() {
12 global $wgCommandLineMode;
13 global $wgRequest;
14 if( !$wgCommandLineMode && !isset( $_COOKIE[session_name()] ) ) {
15 User::SetupSession();
16 }
17
18 $form = new LoginForm( $wgRequest );
19 $form->execute();
20 }
21
22 /**
23 *
24 * @package MediaWiki
25 * @subpackage SpecialPage
26 */
27 class LoginForm {
28 var $mName, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted;
29 var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword;
30 var $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage;
31
32 /**
33 * Constructor
34 * @param webrequest $request A webrequest object passed by reference
35 */
36 function LoginForm( &$request ) {
37 global $wgLang, $wgAllowRealName, $wgEnableEmail;
38 global $wgAuth;
39
40 $this->mType = $request->getText( 'type' );
41 $this->mName = $request->getText( 'wpName' );
42 $this->mPassword = $request->getText( 'wpPassword' );
43 $this->mRetype = $request->getText( 'wpRetype' );
44 $this->mDomain = $request->getText( 'wpDomain' );
45 $this->mReturnTo = $request->getVal( 'returnto' );
46 $this->mCookieCheck = $request->getVal( 'wpCookieCheck' );
47 $this->mPosted = $request->wasPosted();
48 $this->mCreateaccount = $request->getCheck( 'wpCreateaccount' );
49 $this->mCreateaccountMail = $request->getCheck( 'wpCreateaccountMail' )
50 && $wgEnableEmail;
51 $this->mMailmypassword = $request->getCheck( 'wpMailmypassword' )
52 && $wgEnableEmail;
53 $this->mLoginattempt = $request->getCheck( 'wpLoginattempt' );
54 $this->mAction = $request->getVal( 'action' );
55 $this->mRemember = $request->getCheck( 'wpRemember' );
56 $this->mLanguage = $request->getText( 'uselang' );
57
58 if( $wgEnableEmail ) {
59 $this->mEmail = $request->getText( 'wpEmail' );
60 } else {
61 $this->mEmail = '';
62 }
63 if( $wgAllowRealName ) {
64 $this->mRealName = $request->getText( 'wpRealName' );
65 } else {
66 $this->mRealName = '';
67 }
68
69 if( !$wgAuth->validDomain( $this->mDomain ) ) {
70 $this->mDomain = 'invaliddomain';
71 }
72 $wgAuth->setDomain( $this->mDomain );
73
74 # When switching accounts, it sucks to get automatically logged out
75 if( $this->mReturnTo == $wgLang->specialPage( 'Userlogout' ) ) {
76 $this->mReturnTo = '';
77 }
78 }
79
80 function execute() {
81 if ( !is_null( $this->mCookieCheck ) ) {
82 $this->onCookieRedirectCheck( $this->mCookieCheck );
83 return;
84 } else if( $this->mPosted ) {
85 if( $this->mCreateaccount ) {
86 return $this->addNewAccount();
87 } else if ( $this->mCreateaccountMail ) {
88 return $this->addNewAccountMailPassword();
89 } else if ( $this->mMailmypassword ) {
90 return $this->mailPassword();
91 } else if ( ( 'submitlogin' == $this->mAction ) || $this->mLoginattempt ) {
92 return $this->processLogin();
93 }
94 }
95 $this->mainLoginForm( '' );
96 }
97
98 /**
99 * @private
100 */
101 function addNewAccountMailPassword() {
102 global $wgOut;
103
104 if ('' == $this->mEmail) {
105 $this->mainLoginForm( wfMsg( 'noemail', htmlspecialchars( $this->mName ) ) );
106 return;
107 }
108
109 $u = $this->addNewaccountInternal();
110
111 if ($u == NULL) {
112 return;
113 }
114
115 $u->saveSettings();
116 $result = $this->mailPasswordInternal($u);
117
118 wfRunHooks( 'AddNewAccount', array( $u ) );
119
120 $wgOut->setPageTitle( wfMsg( 'accmailtitle' ) );
121 $wgOut->setRobotpolicy( 'noindex,nofollow' );
122 $wgOut->setArticleRelated( false );
123
124 if( WikiError::isError( $result ) ) {
125 $this->mainLoginForm( wfMsg( 'mailerror', $result->getMessage() ) );
126 } else {
127 $wgOut->addWikiText( wfMsg( 'accmailtext', $u->getName(), $u->getEmail() ) );
128 $wgOut->returnToMain( false );
129 }
130 $u = 0;
131 }
132
133
134 /**
135 * @private
136 */
137 function addNewAccount() {
138 global $wgUser, $wgEmailAuthentication;
139
140 # Create the account and abort if there's a problem doing so
141 $u = $this->addNewAccountInternal();
142 if( $u == NULL )
143 return;
144
145 # If we showed up language selection links, and one was in use, be
146 # smart (and sensible) and save that language as the user's preference
147 global $wgLoginLanguageSelector;
148 if( $wgLoginLanguageSelector && $this->mLanguage )
149 $u->setOption( 'language', $this->mLanguage );
150
151 # Save user settings and send out an email authentication message if needed
152 $u->saveSettings();
153 if( $wgEmailAuthentication && User::isValidEmailAddr( $u->getEmail() ) )
154 $u->sendConfirmationMail();
155
156 # If not logged in, assume the new account as the current one and set session cookies
157 # then show a "welcome" message or a "need cookies" message as needed
158 if( $wgUser->isAnon() ) {
159 $wgUser = $u;
160 $wgUser->setCookies();
161 wfRunHooks( 'AddNewAccount', array( $wgUser ) );
162 if( $this->hasSessionCookie() ) {
163 return $this->successfulLogin( wfMsg( 'welcomecreation', $wgUser->getName() ), false );
164 } else {
165 return $this->cookieRedirectCheck( 'new' );
166 }
167 } else {
168 # Confirm that the account was created
169 global $wgOut;
170 $skin = $wgUser->getSkin();
171 $self = Title::makeTitle( NS_SPECIAL, 'Userlogin' );
172 $wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) );
173 $wgOut->setArticleRelated( false );
174 $wgOut->setRobotPolicy( 'noindex,nofollow' );
175 $wgOut->addHtml( wfMsgWikiHtml( 'accountcreatedtext', $u->getName() ) );
176 $wgOut->returnToMain( $self->getPrefixedText() );
177 wfRunHooks( 'AddNewAccount', array( $u ) );
178 return true;
179 }
180 }
181
182 /**
183 * @private
184 */
185 function addNewAccountInternal() {
186 global $wgUser, $wgOut;
187 global $wgEnableSorbs, $wgProxyWhitelist;
188 global $wgMemc, $wgAccountCreationThrottle, $wgDBname;
189 global $wgAuth, $wgMinimalPasswordLength, $wgReservedUsernames;
190
191 // If the user passes an invalid domain, something is fishy
192 if( !$wgAuth->validDomain( $this->mDomain ) ) {
193 $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
194 return false;
195 }
196
197 // If we are not allowing users to login locally, we should
198 // be checking to see if the user is actually able to
199 // authenticate to the authentication server before they
200 // create an account (otherwise, they can create a local account
201 // and login as any domain user). We only need to check this for
202 // domains that aren't local.
203 if( 'local' != $this->mDomain && '' != $this->mDomain ) {
204 if( !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $this->mName ) || !$wgAuth->authenticate( $this->mName, $this->mPassword ) ) ) {
205 $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
206 return false;
207 }
208 }
209
210 if ( wfReadOnly() ) {
211 $wgOut->readOnlyPage();
212 return false;
213 }
214
215 if (!$wgUser->isAllowedToCreateAccount()) {
216 $this->userNotPrivilegedMessage();
217 return false;
218 }
219
220 $ip = wfGetIP();
221 if ( $wgEnableSorbs && !in_array( $ip, $wgProxyWhitelist ) &&
222 $wgUser->inSorbsBlacklist( $ip ) )
223 {
224 $this->mainLoginForm( wfMsg( 'sorbs_create_account_reason' ) . ' (' . htmlspecialchars( $ip ) . ')' );
225 return;
226 }
227
228 $name = trim( $this->mName );
229 $u = User::newFromName( $name );
230 if ( is_null( $u ) || in_array( $u->getName(), $wgReservedUsernames ) ) {
231 $this->mainLoginForm( wfMsg( 'noname' ) );
232 return false;
233 }
234
235 if ( 0 != $u->idForName() ) {
236 $this->mainLoginForm( wfMsg( 'userexists' ) );
237 return false;
238 }
239
240 if ( 0 != strcmp( $this->mPassword, $this->mRetype ) ) {
241 $this->mainLoginForm( wfMsg( 'badretype' ) );
242 return false;
243 }
244
245 if ( !$wgUser->isValidPassword( $this->mPassword ) ) {
246 $this->mainLoginForm( wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
247 return false;
248 }
249
250 if ( $wgAccountCreationThrottle ) {
251 $key = $wgDBname.':acctcreate:ip:'.$ip;
252 $value = $wgMemc->incr( $key );
253 if ( !$value ) {
254 $wgMemc->set( $key, 1, 86400 );
255 }
256 if ( $value > $wgAccountCreationThrottle ) {
257 $this->throttleHit( $wgAccountCreationThrottle );
258 return false;
259 }
260 }
261
262 $abortError = '';
263 if( !wfRunHooks( 'AbortNewAccount', array( $u, &$abortError ) ) ) {
264 // Hook point to add extra creation throttles and blocks
265 wfDebug( "LoginForm::addNewAccountInternal: a hook blocked creation\n" );
266 $this->mainLoginForm( $abortError );
267 return false;
268 }
269
270 if( !$wgAuth->addUser( $u, $this->mPassword ) ) {
271 $this->mainLoginForm( wfMsg( 'externaldberror' ) );
272 return false;
273 }
274
275 # Update user count
276 $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
277 $ssUpdate->doUpdate();
278
279 return $this->initUser( $u );
280 }
281
282 /**
283 * Actually add a user to the database.
284 * Give it a User object that has been initialised with a name.
285 *
286 * @param $u User object.
287 * @return User object.
288 * @private
289 */
290 function &initUser( &$u ) {
291 $u->addToDatabase();
292 $u->setPassword( $this->mPassword );
293 $u->setEmail( $this->mEmail );
294 $u->setRealName( $this->mRealName );
295 $u->setToken();
296
297 global $wgAuth;
298 $wgAuth->initUser( $u );
299
300 $u->setOption( 'rememberpassword', $this->mRemember ? 1 : 0 );
301
302 return $u;
303 }
304
305 /**
306 * @private
307 */
308 function processLogin() {
309 global $wgUser, $wgAuth, $wgReservedUsernames;
310
311 if ( '' == $this->mName ) {
312 $this->mainLoginForm( wfMsg( 'noname' ) );
313 return;
314 }
315 $u = User::newFromName( $this->mName );
316 if( is_null( $u ) || in_array( $u->getName(), $wgReservedUsernames ) ) {
317 $this->mainLoginForm( wfMsg( 'noname' ) );
318 return;
319 }
320 if ( 0 == $u->getID() ) {
321 global $wgAuth;
322 /**
323 * If the external authentication plugin allows it,
324 * automatically create a new account for users that
325 * are externally defined but have not yet logged in.
326 */
327 if ( $wgAuth->autoCreate() && $wgAuth->userExists( $u->getName() ) ) {
328 if ( $wgAuth->authenticate( $u->getName(), $this->mPassword ) ) {
329 $u =& $this->initUser( $u );
330 } else {
331 $this->mainLoginForm( wfMsg( 'wrongpassword' ) );
332 return;
333 }
334 } else {
335 $this->mainLoginForm( wfMsg( 'nosuchuser', $u->getName() ) );
336 return;
337 }
338 } else {
339 $u->loadFromDatabase();
340 }
341
342 if (!$u->checkPassword( $this->mPassword )) {
343 $this->mainLoginForm( wfMsg( $this->mPassword == '' ? 'wrongpasswordempty' : 'wrongpassword' ) );
344 return;
345 }
346
347 # We've verified now, update the real record
348 #
349 if ( $this->mRemember ) {
350 $r = 1;
351 } else {
352 $r = 0;
353 }
354 $u->setOption( 'rememberpassword', $r );
355
356 $wgAuth->updateUser( $u );
357
358 $wgUser = $u;
359 $wgUser->setCookies();
360
361 $wgUser->saveSettings();
362
363 if( $this->hasSessionCookie() ) {
364 return $this->successfulLogin( wfMsg( 'loginsuccess', $wgUser->getName() ) );
365 } else {
366 return $this->cookieRedirectCheck( 'login' );
367 }
368 }
369
370 /**
371 * @private
372 */
373 function mailPassword() {
374 global $wgUser, $wgOut;
375
376 # Check against the rate limiter
377 if( $wgUser->pingLimiter( 'mailpassword' ) ) {
378 $wgOut->rateLimited();
379 return;
380 }
381
382 if ( '' == $this->mName ) {
383 $this->mainLoginForm( wfMsg( 'noname' ) );
384 return;
385 }
386 $u = User::newFromName( $this->mName );
387 if( is_null( $u ) ) {
388 $this->mainLoginForm( wfMsg( 'noname' ) );
389 return;
390 }
391 if ( 0 == $u->getID() ) {
392 $this->mainLoginForm( wfMsg( 'nosuchuser', $u->getName() ) );
393 return;
394 }
395
396 $u->loadFromDatabase();
397
398 $result = $this->mailPasswordInternal( $u );
399 if( WikiError::isError( $result ) ) {
400 $this->mainLoginForm( wfMsg( 'mailerror', $result->getMessage() ) );
401 } else {
402 $this->mainLoginForm( wfMsg( 'passwordsent', $u->getName() ), 'success' );
403 }
404 }
405
406
407 /**
408 * @return mixed true on success, WikiError on failure
409 * @private
410 */
411 function mailPasswordInternal( $u ) {
412 global $wgCookiePath, $wgCookieDomain, $wgCookiePrefix, $wgCookieSecure;
413 global $wgServer, $wgScript;
414
415 if ( '' == $u->getEmail() ) {
416 return wfMsg( 'noemail', $u->getName() );
417 }
418
419 $np = $u->randomPassword();
420 $u->setNewpassword( $np );
421
422 setcookie( "{$wgCookiePrefix}Token", '', time() - 3600, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
423
424 $u->saveSettings();
425
426 $ip = wfGetIP();
427 if ( '' == $ip ) { $ip = '(Unknown)'; }
428
429 $m = wfMsg( 'passwordremindertext', $ip, $u->getName(), $np, $wgServer . $wgScript );
430
431 $result = $u->sendMail( wfMsg( 'passwordremindertitle' ), $m );
432 return $result;
433 }
434
435
436 /**
437 * @param string $msg Message that will be shown on success
438 * @param bool $auto Toggle auto-redirect to main page; default true
439 * @private
440 */
441 function successfulLogin( $msg, $auto = true ) {
442 global $wgUser;
443 global $wgOut;
444
445 # Run any hooks; ignore results
446
447 wfRunHooks('UserLoginComplete', array(&$wgUser));
448
449 $wgOut->setPageTitle( wfMsg( 'loginsuccesstitle' ) );
450 $wgOut->setRobotpolicy( 'noindex,nofollow' );
451 $wgOut->setArticleRelated( false );
452 $wgOut->addWikiText( $msg );
453 if ( !empty( $this->mReturnTo ) ) {
454 $wgOut->returnToMain( $auto, $this->mReturnTo );
455 } else {
456 $wgOut->returnToMain( $auto );
457 }
458 }
459
460 /** */
461 function userNotPrivilegedMessage() {
462 global $wgOut;
463
464 $wgOut->setPageTitle( wfMsg( 'whitelistacctitle' ) );
465 $wgOut->setRobotpolicy( 'noindex,nofollow' );
466 $wgOut->setArticleRelated( false );
467
468 $wgOut->addWikiText( wfMsg( 'whitelistacctext' ) );
469
470 $wgOut->returnToMain( false );
471 }
472
473 /** */
474 function userBlockedMessage() {
475 global $wgOut;
476
477 # Let's be nice about this, it's likely that this feature will be used
478 # for blocking large numbers of innocent people, e.g. range blocks on
479 # schools. Don't blame it on the user. There's a small chance that it
480 # really is the user's fault, i.e. the username is blocked and they
481 # haven't bothered to log out before trying to create an account to
482 # evade it, but we'll leave that to their guilty conscience to figure
483 # out.
484
485 $wgOut->setPageTitle( wfMsg( 'cantcreateaccounttitle' ) );
486 $wgOut->setRobotpolicy( 'noindex,nofollow' );
487 $wgOut->setArticleRelated( false );
488
489 $ip = wfGetIP();
490 $wgOut->addWikiText( wfMsg( 'cantcreateaccounttext', $ip ) );
491 $wgOut->returnToMain( false );
492 }
493
494 /**
495 * @private
496 */
497 function mainLoginForm( $msg, $msgtype = 'error' ) {
498 global $wgUser, $wgOut, $wgAllowRealName, $wgEnableEmail;
499 global $wgCookiePrefix, $wgAuth, $wgLoginLanguageSelector;
500
501 if ( $this->mType == 'signup' ) {
502 if ( !$wgUser->isAllowed( 'createaccount' ) ) {
503 $this->userNotPrivilegedMessage();
504 return;
505 } elseif ( $wgUser->isBlockedFromCreateAccount() ) {
506 $this->userBlockedMessage();
507 return;
508 }
509 }
510
511 if ( '' == $this->mName ) {
512 if ( $wgUser->isLoggedIn() ) {
513 $this->mName = $wgUser->getName();
514 } else {
515 $this->mName = @$_COOKIE[$wgCookiePrefix.'UserName'];
516 }
517 }
518
519 $titleObj = Title::makeTitle( NS_SPECIAL, 'Userlogin' );
520
521 if ( $this->mType == 'signup' ) {
522 $template = new UsercreateTemplate();
523 $q = 'action=submitlogin&type=signup';
524 $linkq = 'type=login';
525 $linkmsg = 'gotaccount';
526 } else {
527 $template = new UserloginTemplate();
528 $q = 'action=submitlogin&type=login';
529 $linkq = 'type=signup';
530 $linkmsg = 'nologin';
531 }
532
533 if ( !empty( $this->mReturnTo ) ) {
534 $returnto = '&returnto=' . wfUrlencode( $this->mReturnTo );
535 $q .= $returnto;
536 $linkq .= $returnto;
537 }
538
539 # Pass any language selection on to the mode switch link
540 if( $wgLoginLanguageSelector && $this->mLanguage )
541 $linkq .= '&uselang=' . $this->mLanguage;
542
543 $link = '<a href="' . htmlspecialchars ( $titleObj->getLocalUrl( $linkq ) ) . '">';
544 $link .= wfMsgHtml( $linkmsg . 'link' );
545 $link .= '</a>';
546
547 # Don't show a "create account" link if the user can't
548 if( $this->showCreateOrLoginLink( $wgUser ) )
549 $template->set( 'link', wfMsgHtml( $linkmsg, $link ) );
550 else
551 $template->set( 'link', '' );
552
553 $template->set( 'header', '' );
554 $template->set( 'name', $this->mName );
555 $template->set( 'password', $this->mPassword );
556 $template->set( 'retype', $this->mRetype );
557 $template->set( 'email', $this->mEmail );
558 $template->set( 'realname', $this->mRealName );
559 $template->set( 'domain', $this->mDomain );
560
561 $template->set( 'action', $titleObj->getLocalUrl( $q ) );
562 $template->set( 'message', $msg );
563 $template->set( 'messagetype', $msgtype );
564 $template->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() );
565 $template->set( 'userealname', $wgAllowRealName );
566 $template->set( 'useemail', $wgEnableEmail );
567 $template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) or $this->mRemember );
568
569 # Prepare language selection links as needed
570 if( $wgLoginLanguageSelector ) {
571 $template->set( 'languages', $this->makeLanguageSelector() );
572 if( $this->mLanguage )
573 $template->set( 'uselang', $this->mLanguage );
574 }
575
576 // Give authentication and captcha plugins a chance to modify the form
577 $wgAuth->modifyUITemplate( $template );
578 if ( $this->mType == 'signup' ) {
579 wfRunHooks( 'UserCreateForm', array( &$template ) );
580 } else {
581 wfRunHooks( 'UserLoginForm', array( &$template ) );
582 }
583
584 $wgOut->setPageTitle( wfMsg( 'userlogin' ) );
585 $wgOut->setRobotpolicy( 'noindex,nofollow' );
586 $wgOut->setArticleRelated( false );
587 $wgOut->addTemplate( $template );
588 }
589
590 /**
591 * @private
592 */
593 function showCreateOrLoginLink( &$user ) {
594 if( $this->mType == 'signup' ) {
595 return( true );
596 } elseif( $user->isAllowed( 'createaccount' ) ) {
597 return( true );
598 } else {
599 return( false );
600 }
601 }
602
603 /**
604 * @private
605 */
606 function hasSessionCookie() {
607 global $wgDisableCookieCheck;
608 return ( $wgDisableCookieCheck ) ? true : ( isset( $_COOKIE[session_name()] ) );
609 }
610
611 /**
612 * @private
613 */
614 function cookieRedirectCheck( $type ) {
615 global $wgOut;
616
617 $titleObj = Title::makeTitle( NS_SPECIAL, 'Userlogin' );
618 $check = $titleObj->getFullURL( 'wpCookieCheck='.$type );
619
620 return $wgOut->redirect( $check );
621 }
622
623 /**
624 * @private
625 */
626 function onCookieRedirectCheck( $type ) {
627 global $wgUser;
628
629 if ( !$this->hasSessionCookie() ) {
630 if ( $type == 'new' ) {
631 return $this->mainLoginForm( wfMsg( 'nocookiesnew' ) );
632 } else if ( $type == 'login' ) {
633 return $this->mainLoginForm( wfMsg( 'nocookieslogin' ) );
634 } else {
635 # shouldn't happen
636 return $this->mainLoginForm( wfMsg( 'error' ) );
637 }
638 } else {
639 return $this->successfulLogin( wfMsg( 'loginsuccess', $wgUser->getName() ) );
640 }
641 }
642
643 /**
644 * @private
645 */
646 function throttleHit( $limit ) {
647 global $wgOut;
648
649 $wgOut->addWikiText( wfMsg( 'acct_creation_throttle_hit', $limit ) );
650 }
651
652 /**
653 * Produce a bar of links which allow the user to select another language
654 * during login/registration but retain "returnto"
655 *
656 * @return string
657 */
658 function makeLanguageSelector() {
659 $msg = wfMsgForContent( 'loginlanguagelinks' );
660 if( $msg != '' && $msg != '&lt;loginlanguagelinks&gt;' ) {
661 $langs = explode( "\n", $msg );
662 $links = array();
663 foreach( $langs as $lang ) {
664 $lang = trim( $lang, '* ' );
665 $parts = explode( '|', $lang );
666 $links[] = $this->makeLanguageSelectorLink( $parts[0], $parts[1] );
667 }
668 return count( $links ) > 0 ? wfMsgHtml( 'loginlanguagelabel', implode( ' | ', $links ) ) : '';
669 } else {
670 return '';
671 }
672 }
673
674 /**
675 * Create a language selector link for a particular language
676 * Links back to this page preserving type and returnto
677 *
678 * @param $text Link text
679 * @param $lang Language code
680 */
681 function makeLanguageSelectorLink( $text, $lang ) {
682 global $wgUser;
683 $self = Title::makeTitle( NS_SPECIAL, 'Userlogin' );
684 $attr[] = 'uselang=' . $lang;
685 if( $this->mType == 'signup' )
686 $attr[] = 'type=signup';
687 if( $this->mReturnTo )
688 $attr[] = 'returnto=' . $this->mReturnTo;
689 $skin =& $wgUser->getSkin();
690 return $skin->makeKnownLinkObj( $self, htmlspecialchars( $text ), implode( '&', $attr ) );
691 }
692
693 }
694 ?>