2 /***************************************************************
5 * (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Login-screen of TYPO3.
31 * Revised for TYPO3 3.6 December/2003 by Kasper Skaarhoj
34 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
37 * [CLASS/FUNCTION INDEX of SCRIPT]
42 * 120: function init()
43 * 159: function main()
44 * 268: function printContent()
46 * SECTION: Various functions
47 * 292: function makeLoginForm()
48 * 337: function makeLogoutForm()
49 * 379: function wrapLoginForm($content)
50 * 438: function checkRedirect()
51 * 495: function makeInterfaceSelectorBox()
52 * 549: function makeCopyrightNotice()
53 * 582: function makeLoginBoxImage()
54 * 622: function makeLoginNews()
57 * (This index is automatically created/updated by the extension "extdeveval")
62 define('TYPO3_PROCEED_IF_NO_USER', 1);
64 require('template.php');
81 * Script Class for rendering the login form
83 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
90 var $redirect_url; // GPvar: redirect_url; The URL to redirect to after login.
91 var $GPinterface; // GPvar: Defines which interface to load (from interface selector)
92 var $u; // GPvar: preset username
93 var $p; // GPvar: preset password
94 var $L; // GPvar: If "L" is "OUT", then any logged in used is logged out. If redirect_url is given, we redirect to it
95 var $loginRefresh; // Login-refresh boolean; The backend will call this script with this value set when the login is close to being expired and the form needs to be redrawn.
96 var $commandLI; // Value of forms submit button for login.
99 var $redirectToURL; // Set to the redirect URL of the form (may be redirect_url or "backend.php")
101 // Internal, dynamic:
102 var $content; // Content accumulation
104 var $interfaceSelector; // A selector box for selecting value for "interface" may be rendered into this variable
105 var $interfaceSelector_jump; // A selector box for selecting value for "interface" may be rendered into this variable - this will have an onchange action which will redirect the user to the selected interface right away
106 var $interfaceSelector_hidden; // A hidden field, if the interface is not set.
107 var $addFields_hidden = ''; // Additional hidden fields to be placed at the login form
109 // sets the level of security. *'normal' = clear-text. 'challenged' = hashed password/username from form in $formfield_uident. 'superchallenged' = hashed password hashed again with username.
110 var $loginSecurityLevel = 'superchallenged';
116 * Initialize the login box. Will also react on a &L=OUT flag and exit.
121 // We need a PHP session session for most login levels
124 $this->redirect_url
= t3lib_div
::_GP('redirect_url');
125 $this->GPinterface
= t3lib_div
::_GP('interface');
127 // Grabbing preset username and password, for security reasons this feature only works if SSL is used
128 if (t3lib_div
::getIndpEnv('TYPO3_SSL')) {
129 $this->u
= t3lib_div
::_GP('u');
130 $this->p
= t3lib_div
::_GP('p');
133 // If "L" is "OUT", then any logged in is logged out. If redirect_url is given, we redirect to it
134 $this->L
= t3lib_div
::_GP('L');
137 $this->loginRefresh
= t3lib_div
::_GP('loginRefresh');
139 // Value of "Login" button. If set, the login button was pressed.
140 $this->commandLI
= t3lib_div
::_GP('commandLI');
142 // sets the level of security from conf vars
143 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) {
144 $this->loginSecurityLevel
= $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'];
147 // try to get the preferred browser language
148 $preferredBrowserLanguage = $GLOBALS['LANG']->csConvObj
->getPreferredClientLanguage(t3lib_div
::getIndpEnv('HTTP_ACCEPT_LANGUAGE'));
149 // if we found a $preferredBrowserLanguage and it is not the default language and no be_user is logged in
150 // initialize $GLOBALS['LANG'] again with $preferredBrowserLanguage
151 if ($preferredBrowserLanguage != 'default' && !$GLOBALS['BE_USER']->user
['uid']) {
152 $GLOBALS['LANG']->init($preferredBrowserLanguage);
154 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_login.xml');
156 // check if labels from $GLOBALS['TYPO3_CONF_VARS']['BE']['loginLabels'] were changed,
157 // and merge them to $GLOBALS['LOCAL_LANG'] if needed
158 $this->mergeOldLoginLabels();
160 // Setting the redirect URL to "backend.php" if no alternative input is given
161 $this->redirectToURL
= ($this->redirect_url ?
$this->redirect_url
: 'backend.php');
164 // Do a logout if the command is set
165 if ($this->L
== 'OUT' && is_object($GLOBALS['BE_USER'])) {
166 $GLOBALS['BE_USER']->logoff();
167 if ($this->redirect_url
) {
168 t3lib_div
::redirect($this->redirect_url
);
176 * Main function - creating the login/logout form
181 global $TBE_TEMPLATE, $TYPO3_CONF_VARS, $BE_USER;
183 // Initialize template object:
184 $TBE_TEMPLATE->bodyTagAdditions
= ' onload="startUp();"';
185 $TBE_TEMPLATE->moduleTemplate
= $TBE_TEMPLATE->getHtmlTemplate('templates/login.html');
187 // Set JavaScript for creating a MD5 hash of the password:
188 $TBE_TEMPLATE->JScode
.= $this->getJScode();
190 // Checking, if we should make a redirect.
191 // Might set JavaScript in the header to close window.
192 $this->checkRedirect();
194 // Initialize interface selectors:
195 $this->makeInterfaceSelectorBox();
197 // Creating form based on whether there is a login or not:
198 if (!$BE_USER->user
['uid']) {
199 $TBE_TEMPLATE->form
= $this->startForm();
200 $loginForm = $this->makeLoginForm();
202 $TBE_TEMPLATE->form
= '
203 <form action="index.php" method="post" name="loginform">
204 <input type="hidden" name="login_status" value="logout" />
206 $loginForm = $this->makeLogoutForm();
210 $this->content
.=$TBE_TEMPLATE->startPage('TYPO3 Login: '.$TYPO3_CONF_VARS['SYS']['sitename']);
213 $this->content
.=$this->wrapLoginForm($loginForm);
215 $this->content
.= $TBE_TEMPLATE->endPage();
219 * Outputting the accumulated content to screen
223 function printContent() {
227 /*****************************
231 ******************************/
234 * Creates the login form
235 * This is drawn when NO login exists.
237 * @return string HTML output
239 function makeLoginForm() {
240 $content = t3lib_parsehtml
::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate
, '###LOGIN_FORM###');
242 'VALUE_USERNAME' => htmlspecialchars($this->u
),
243 'VALUE_PASSWORD' => htmlspecialchars($this->p
),
244 'VALUE_SUBMIT' => $GLOBALS['LANG']->getLL('labels.submitLogin', true),
247 // show an error message if the login command was successful already, otherwise remove the subpart
248 if (!$this->commandLI
) {
249 $content = t3lib_parsehtml
::substituteSubpart($content, '###LOGIN_ERROR###', '');
251 $markers['ERROR_MESSAGE'] = $GLOBALS['LANG']->getLL('error.login', true);
255 // remove the interface selector markers if it's not available
256 if (!($this->interfaceSelector
&& !$this->loginRefresh
)) {
257 $content = t3lib_parsehtml
::substituteSubpart($content, '###INTERFACE_SELECTOR###', '');
259 $markers['LABEL_INTERFACE'] = $GLOBALS['LANG']->getLL('labels.interface', true);
260 $markers['VALUE_INTERFACE'] = $this->interfaceSelector
;
263 return t3lib_parsehtml
::substituteMarkerArray($content, $markers, '###|###');
268 * Creates the logout form
269 * This is drawn if a user login already exists.
271 * @return string HTML output
273 function makeLogoutForm() {
274 $content = t3lib_parsehtml
::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate
, '###LOGOUT_FORM###');
276 'LABEL_USERNAME' => $GLOBALS['LANG']->getLL('labels.username', true),
277 'VALUE_USERNAME' => htmlspecialchars($GLOBALS['BE_USER']->user
['username']),
278 'VALUE_SUBMIT' => $GLOBALS['LANG']->getLL('labels.submitLogout', true),
281 // remove the interface selector markers if it's not available
282 if (!$this->interfaceSelector_jump
) {
283 $content = t3lib_parsehtml
::substituteSubpart($content, '###INTERFACE_SELECTOR###', '');
285 $markers['LABEL_INTERFACE'] = $GLOBALS['LANG']->getLL('labels.interface', true);
286 $markers['VALUE_INTERFACE'] = $this->interfaceSelector_jump
;
289 return t3lib_parsehtml
::substituteMarkerArray($content, $markers, '###|###');
294 * Wrapping the login form table in another set of tables etc:
296 * @param string HTML content for the login form
297 * @return string The HTML for the page.
299 function wrapLoginForm($content) {
300 $mainContent = t3lib_parsehtml
::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate
, '###PAGE###');
302 if ($GLOBALS['TBE_STYLES']['logo_login']) {
303 $logo = '<img src="'.htmlspecialchars($GLOBALS['BACK_PATH'] . $GLOBALS['TBE_STYLES']['logo_login']) . '" alt="" />';
305 $logo = '<img'.t3lib_iconWorks
::skinImg($GLOBALS['BACK_PATH'],'gfx/typo3logo.gif','width="123" height="34"').' alt="" />';
310 'LOGINBOX_IMAGE' => $this->makeLoginBoxImage(),
312 'NEWS' => $this->makeLoginNews(),
313 'COPYRIGHT' => $this->makeCopyrightNotice(),
314 'CSS_ERRORCLASS' => ($this->commandLI ?
' class="error"' : ''),
316 // the labels will be replaced later on, thus the other parts above
317 // can use these markers as well and it will be replaced
318 'HEADLINE' => $GLOBALS['LANG']->getLL('headline', true),
319 'INFO_ABOUT' => $GLOBALS['LANG']->getLL('info.about', true),
320 'INFO_RELOAD' => $GLOBALS['LANG']->getLL('info.reset', true),
321 'ERROR_JAVASCRIPT' => $GLOBALS['LANG']->getLL('error.javascript', true),
322 'ERROR_COOKIES' => $GLOBALS['LANG']->getLL('error.cookies', true),
323 'ERROR_COOKIES_IGNORE' => $GLOBALS['LANG']->getLL('error.cookies_ignore', true),
324 'ERROR_CAPSLOCK' => $GLOBALS['LANG']->getLL('error.capslock', true),
325 'LABEL_DONATELINK' => $GLOBALS['LANG']->getLL('labels.donate', true),
326 'LABEL_USERNAME' => $GLOBALS['LANG']->getLL('labels.username', true),
327 'LABEL_PASSWORD' => $GLOBALS['LANG']->getLL('labels.password', true),
328 'CLEAR' => $GLOBALS['LANG']->getLL('clear', true),
329 'SITELINK' => '<a href="/">###SITENAME###</a>',
331 // global variables will now be replaced (at last)
332 'SITENAME' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']
334 return t3lib_parsehtml
::substituteMarkerArray($mainContent, $markers, '###|###');
339 * Checking, if we should perform some sort of redirection OR closing of windows.
343 function checkRedirect() {
344 global $BE_USER,$TBE_TEMPLATE;
347 // If a user is logged in AND a) if either the login is just done (commandLI) or b) a loginRefresh is done or c) the interface-selector is NOT enabled (If it is on the other hand, it should not just load an interface, because people has to choose then...)
348 if ($BE_USER->user
['uid'] && ($this->commandLI ||
$this->loginRefresh ||
!$this->interfaceSelector
)) {
350 // If no cookie has been set previously we tell people that this is a problem. This assumes that a cookie-setting script (like this one) has been hit at least once prior to this instance.
351 if (!$_COOKIE[$BE_USER->name
]) {
352 if ($this->commandLI
=='setCookie') {
353 // we tried it a second time but still no cookie
354 // 26/4 2005: This does not work anymore, because the saving of challenge values in $_SESSION means the system will act as if the password was wrong.
355 t3lib_BEfunc
::typo3PrintError ('Login-error',"Yeah, that's a classic. No cookies, no TYPO3.<br /><br />Please accept cookies from TYPO3 - otherwise you'll not be able to use the system.",0);
358 // try it once again - that might be needed for auto login
359 $this->redirectToURL
= 'index.php?commandLI=setCookie';
363 if (($redirectToURL = (string)$BE_USER->getTSConfigVal('auth.BE.redirectToURL'))) {
364 $this->redirectToURL
= $redirectToURL;
365 $this->GPinterface
= '';
369 $BE_USER->uc
['interfaceSetup'] = $this->GPinterface
;
372 // Based on specific setting of interface we set the redirect script:
373 switch ($this->GPinterface
) {
375 $this->redirectToURL
= 'backend.php';
378 $this->redirectToURL
= 'alt_main.php';
381 $this->redirectToURL
= '../';
385 // If there is a redirect URL AND if loginRefresh is not set...
386 if (!$this->loginRefresh
) {
387 t3lib_div
::redirect($this->redirectToURL
);
389 $TBE_TEMPLATE->JScode
.=$TBE_TEMPLATE->wrapScriptTags('
390 if (parent.opener && (parent.opener.busy || parent.opener.TYPO3.loginRefresh)) {
391 if (parent.opener.TYPO3.loginRefresh) {
392 parent.opener.TYPO3.loginRefresh.startTimer();
394 parent.opener.busy.loginRefreshed();
400 } elseif (!$BE_USER->user
['uid'] && $this->commandLI
) {
401 sleep(5); // Wrong password, wait for 5 seconds
406 * Making interface selector:
410 function makeInterfaceSelectorBox() {
411 global $TYPO3_CONF_VARS;
414 $this->interfaceSelector
= '';
415 $this->interfaceSelector_hidden
='';
416 $this->interfaceSelector_jump
= '';
418 // If interfaces are defined AND no input redirect URL in GET vars:
419 if ($TYPO3_CONF_VARS['BE']['interfaces'] && ($this->commandLI ||
!$this->redirect_url
)) {
420 $parts = t3lib_div
::trimExplode(',',$TYPO3_CONF_VARS['BE']['interfaces']);
421 if (count($parts)>1) { // Only if more than one interface is defined will we show the selector:
424 $tempLabels = t3lib_div
::trimExplode(',', $GLOBALS['LANG']->getLL('availableInterfaces'));
427 $labels['backend'] = $tempLabels[0];
428 $labels['backend_old'] = $tempLabels[2];
429 $labels['frontend'] = $tempLabels[1];
432 $jumpScript['backend'] = 'backend.php';
433 $jumpScript['backend_old'] = 'alt_main.php';
434 $jumpScript['frontend'] = '../';
436 // Traverse the interface keys:
437 foreach($parts as $valueStr) {
438 $this->interfaceSelector
.='
439 <option value="'.htmlspecialchars($valueStr).'"'.(t3lib_div
::_GP('interface')==htmlspecialchars($valueStr) ?
' selected="selected"' : '').'>'.htmlspecialchars($labels[$valueStr]).'</option>';
440 $this->interfaceSelector_jump
.='
441 <option value="'.htmlspecialchars($jumpScript[$valueStr]).'">'.htmlspecialchars($labels[$valueStr]).'</option>';
443 $this->interfaceSelector
='
444 <select id="t3-interfaceselector" name="interface" class="c-interfaceselector" tabindex="3">'.$this->interfaceSelector
.'
446 $this->interfaceSelector_jump
='
447 <select id="t3-interfaceselector" name="interface" class="c-interfaceselector" tabindex="3" onchange="window.location.href=this.options[this.selectedIndex].value;">'.$this->interfaceSelector_jump
.'
450 } else { // If there is only ONE interface value set:
452 $this->interfaceSelector_hidden
='<input type="hidden" name="interface" value="'.trim($TYPO3_CONF_VARS['BE']['interfaces']).'" />';
461 * DO NOT prevent this notice from being shown in ANY WAY.
462 * According to the GPL license an interactive application must show such a notice on start-up ('If the program is interactive, make it output a short notice... ' - see GPL.txt)
463 * Therefore preventing this notice from being properly shown is a violation of the license, regardless of whether you remove it or use a stylesheet to obstruct the display.
465 * @return string Text/Image (HTML) for copyright notice.
467 function makeCopyrightNotice() {
469 // Get values from TYPO3_CONF_VARS:
470 $loginCopyrightWarrantyProvider = strip_tags(trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightWarrantyProvider']));
471 $loginCopyrightWarrantyURL = strip_tags(trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightWarrantyURL']));
472 $loginImageSmall = (trim($GLOBALS['TBE_STYLES']['loginBoxImageSmall'])) ?
trim($GLOBALS['TBE_STYLES']['loginBoxImageSmall']) : 'gfx/loginlogo_transp.gif';
474 // Make warranty note:
475 if (strlen($loginCopyrightWarrantyProvider)>=2 && strlen($loginCopyrightWarrantyURL)>=10) {
476 $warrantyNote = sprintf($GLOBALS['LANG']->getLL('warranty.by'), htmlspecialchars($loginCopyrightWarrantyProvider), '<a href="' . htmlspecialchars($loginCopyrightWarrantyURL) . '" target="_blank">', '</a>');
478 $warrantyNote = sprintf($GLOBALS['LANG']->getLL('no.warranty'), '<a href="http://typo3.com/1316.0.html" target="_blank">', '</a>');
481 // Compile full copyright notice:
482 $copyrightNotice = '<a href="http://typo3.com/" target="_blank">'.
483 '<img src="' . $loginImageSmall . '" alt="' . $GLOBALS['LANG']->getLL('typo3.logo') . '" align="left" />' .
484 $GLOBALS['LANG']->getLL('typo3.cms') . ($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightShowVersion']?
' ' . $GLOBALS['LANG']->getLL('version.short') . ' ' . htmlspecialchars($GLOBALS['TYPO_VERSION']):'') .
486 $GLOBALS['LANG']->getLL('copyright') . ' © ' . TYPO3_copyright_year
. ' Kasper Skårhøj. ' . $GLOBALS['LANG']->getLL('extension.copyright') . ' ' .
487 sprintf($GLOBALS['LANG']->getLL('details.link'), '<a href="http://typo3.com/" target="_blank">http://typo3.com/</a>') . '<br /> ' .
488 $warrantyNote . ' ' .
489 sprintf($GLOBALS['LANG']->getLL('free.software'), '<a href="http://typo3.com/1316.0.html" target="_blank">', '</a> ') .
490 $GLOBALS['LANG']->getLL('keep.notice');
493 return $copyrightNotice;
497 * Returns the login box image, whether the default or an image from the rotation folder.
499 * @return string HTML image tag.
501 function makeLoginBoxImage() {
503 if ($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']) { // Look for rotation image folder:
504 $absPath = t3lib_div
::resolveBackPath(PATH_typo3
.$GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']);
506 // Get rotation folder:
507 $dir = t3lib_div
::getFileAbsFileName($absPath);
508 if ($dir && @is_dir
($dir)) {
510 // Get files for rotation into array:
511 $files = t3lib_div
::getFilesInDir($dir,'png,jpg,gif');
514 $randImg = array_rand($files, 1);
516 // Get size of random file:
517 $imgSize = @getimagesize
($dir.$files[$randImg]);
519 $imgAuthor = is_array($GLOBALS['TBE_STYLES']['loginBoxImage_author'])&&$GLOBALS['TBE_STYLES']['loginBoxImage_author'][$files[$randImg]] ?
htmlspecialchars($GLOBALS['TBE_STYLES']['loginBoxImage_author'][$files[$randImg]]) : '';
522 if (is_array($imgSize)) {
523 $loginboxImage = '<img src="'.htmlspecialchars($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder'].$files[$randImg]).'" '.$imgSize[3].' id="loginbox-image" alt="'.$imgAuthor.'" title="'.$imgAuthor.'" />';
526 } else { // If no rotation folder configured, print default image:
528 if (strstr(TYPO3_version
,'-dev')) { // development version
529 $loginImage = 'loginbox_image_dev.png';
530 $imagecopy = 'You are running a development version of TYPO3 '.TYPO3_branch
;
532 $loginImage = 'loginbox_image.jpg';
533 $imagecopy = 'Photo by J.C. Franca (www.digitalphoto.com.br)';
535 $loginboxImage = '<img'.t3lib_iconWorks
::skinImg($GLOBALS['BACK_PATH'],'gfx/'.$loginImage,'width="200" height="133"').' id="loginbox-image" alt="'.$imagecopy.'" title="'.$imagecopy.'" />';
539 return $loginboxImage;
543 * Make login news - renders the HTML content for a list of news shown under
544 * the login form. News data is added through $TYPO3_CONF_VARS
546 * @return string HTML content
547 * @credits Idea by Jan-Hendrik Heuing
549 function makeLoginNews() {
552 // Traverse news array IF there are records in it:
553 if (is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews']) && count($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'])) {
555 // get the main news template, and replace the subpart after looped through
556 $newsContent = t3lib_parsehtml
::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate
, '###LOGIN_NEWS###');
557 $newsItemTemplate = t3lib_parsehtml
::getSubpart($newsContent, '###NEWS_ITEM###');
559 $newsItemContent = '';
560 foreach ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] as $newsItem) {
561 $newsItemMarker = array(
562 '###HEADER###' => htmlspecialchars($newsItem['header']),
563 '###DATE###' => htmlspecialchars($newsItem['date']),
564 '###CONTENT###' => trim($newsItem['content'])
566 $newsItemContent .= t3lib_parsehtml
::substituteMarkerArray($newsItemTemplate, $newsItemMarker);
569 $title = ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] ?
$GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] : $GLOBALS['LANG']->getLL('newsheadline'));
571 $newsContent = t3lib_parsehtml
::substituteMarker($newsContent, '###NEWS_HEADLINE###', htmlspecialchars($title));
572 $newsContent = t3lib_parsehtml
::substituteSubpart($newsContent, '###NEWS_ITEM###', $newsItemContent);
579 * Returns the form tag
581 * @return string Opening form tag string
583 function startForm() {
586 // The form defaults to 'no login'. This prevents plain
587 // text logins to the Backend. The 'sv' extension changes the form to
588 // use superchallenged method and rsaauth extension makes rsa authetication.
589 $form = '<form action="index.php" method="post" name="loginform" ' .
590 'onsubmit="alert(\'No authentication methods available. Please, ' .
591 'contact your TYPO3 administrator.\');return false">';
593 // Call hooks. If they do not return anything, we fail to login
594 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginFormHook'])) {
595 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginFormHook'] as $function) {
597 $formCode = t3lib_div
::callUserFunction($function, $params, $this);
606 '<input type="hidden" name="login_status" value="login" />' .
607 '<input type="hidden" name="userident" value="" />' .
608 '<input type="hidden" name="redirect_url" value="'.htmlspecialchars($this->redirectToURL
).'" />' .
609 '<input type="hidden" name="loginRefresh" value="'.htmlspecialchars($this->loginRefresh
).'" />' .
610 $this->interfaceSelector_hidden
. $this->addFields_hidden
;
616 * Outputs an empty string. This function is obsolete and kept for the
617 * compatibility only.
619 * @param string $unused Unused
620 * @return string HTML output
621 * @deprecated since TYPO3 4.3, all the functionality was put in $this->startForm() and $this->addFields_hidden
623 function getHiddenFields($unused = '') {
624 t3lib_div
::logDeprecatedFunction();
629 * Creates JavaScript for the login form
631 * @return string JavaScript code
633 function getJScode() {
635 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginScriptHook'])) {
636 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginScriptHook'] as $function) {
638 $JSCode = t3lib_div
::callUserFunction($function, $params, $this);
644 $JSCode .= $GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
646 // If the login screen is shown in the login_frameset window for re-login, then try to get the username of the current/former login from opening windows main frame:
647 if (parent.opener && parent.opener.TS && parent.opener.TS.username && document.loginform && document.loginform.username) {
648 document.loginform.username.value = parent.opener.TS.username;
651 // Wait a few millisecons before calling checkFocus(). This might be necessary because some browsers need some time to auto-fill in the form fields
652 window.setTimeout("checkFocus()", 50);
655 // This moves focus to the right input field:
656 function checkFocus() {
657 // If for some reason there already is a username in the username form field, move focus to the password field:
658 if (document.loginform.username && document.loginform.username.value == "") {
659 document.loginform.username.focus();
660 } else if (document.loginform.p_field && document.loginform.p_field.type!="hidden") {
661 document.loginform.p_field.focus();
665 // This function shows a warning, if user has capslock enabled
666 // parameter showWarning: shows warning if true and capslock active, otherwise only hides warning, if capslock gets inactive
667 function checkCapslock(e, showWarning) {
668 if (!isCapslock(e)) {
669 document.getElementById(\'t3-capslock\').style.display = \'none\';
670 } else if (showWarning) {
671 document.getElementById(\'t3-capslock\').style.display = \'block\';
675 // Checks weather capslock is enabled (returns true if enabled, false otherwise)
676 // thanks to http://24ways.org/2007/capturing-caps-lock
678 function isCapslock(e) {
679 var ev = e ? e : window.event;
683 var targ = ev.target ? ev.target : ev.srcElement;
688 } else if (ev.keyCode) {
692 var shift_status = false;
694 shift_status = ev.shiftKey;
695 } else if (ev.modifiers) {
696 shift_status = !!(ev.modifiers & 4);
698 return (((which >= 65 && which <= 90) && !shift_status) ||
699 ((which >= 97 && which <= 122) && shift_status));
702 // prevent opening the login form in the backend frameset
703 if (top.location.href != self.location.href) {
704 top.location.href = self.location.href;
714 * Checks if labels from $GLOBALS['TYPO3_CONF_VARS']['BE']['loginLabels'] were changed, and merge them to $GLOBALS['LOCAL_LANG'] if needed
716 * This method keeps backwards compatibility, if you modified your
717 * labels with the install tool, we recommend to transfer this labels to a locallang.xml file
718 * using the llxml extension
722 protected function mergeOldLoginLabels() {
723 // Getting login labels
724 $oldLoginLabels = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['loginLabels']);
725 if ($oldLoginLabels != '') {
726 // md5 hash of the default loginLabels string
727 $defaultOldLoginLabelsHash = 'bcf0d32e58c6454ea50c6c956f1f18f0';
728 // compare loginLabels from TYPO3_CONF_VARS to default value
729 if (md5($oldLoginLabels) != $defaultOldLoginLabelsHash) {
730 $lang = $GLOBALS['LANG']->lang
;
731 $oldLoginLabelArray = explode('|',$oldLoginLabels);
732 $overrideLabelKeys = array(
733 'labels.username' => $oldLoginLabelArray[0],
734 'labels.password' => $oldLoginLabelArray[1],
735 'labels.interface' => $oldLoginLabelArray[2],
736 'labels.submitLogin' => $oldLoginLabelArray[3],
737 'labels.submitLogout' => $oldLoginLabelArray[4],
738 'availableInterfaces' => $oldLoginLabelArray[5],
739 'headline' => $oldLoginLabelArray[6],
740 'info.jscookies' => $oldLoginLabelArray[7],
741 'newsheadline' => $oldLoginLabelArray[8],
742 'error.login' => $oldLoginLabelArray[9],
744 if (!is_array($GLOBALS['LOCAL_LANG'][$lang])) {
745 $GLOBALS['LOCAL_LANG'][$lang] = array();
747 // now override the labels from the LOCAL_LANG with the TYPO3_CONF_VARS
748 foreach ($overrideLabelKeys as $labelKey => $label) {
749 $GLOBALS['LOCAL_LANG'][$lang][$labelKey] = $GLOBALS['LOCAL_LANG']['default'][$labelKey] = $label;
757 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/index.php']) {
758 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/index.php']);
764 $SOBE = t3lib_div
::makeInstance('SC_index');
767 $SOBE->printContent();