Added feature #11016: Implement RSA authentication for BE and FE -- part 2 (fix hard...
[Packages/TYPO3.CMS.git] / typo3 / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
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.
13 *
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.
18 *
19 *
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.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Login-screen of TYPO3.
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 December/2003 by Kasper Skaarhoj
32 * XHTML compliant
33 *
34 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 *
40 *
41 * 87: class SC_index
42 * 120: function init()
43 * 159: function main()
44 * 268: function printContent()
45 *
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()
55 *
56 * TOTAL FUNCTIONS: 11
57 * (This index is automatically created/updated by the extension "extdeveval")
58 *
59 */
60
61
62 define('TYPO3_PROCEED_IF_NO_USER', 1);
63 require ('init.php');
64 require ('template.php');
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 /**
81 * Script Class for rendering the login form
82 *
83 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
84 * @package TYPO3
85 * @subpackage core
86 */
87 class SC_index {
88
89 // Internal, GPvars:
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.
97
98 // Internal, static:
99 var $redirectToURL; // Set to the redirect URL of the form (may be redirect_url or "backend.php")
100 var $L_vars; // Set to the labels used for the login screen.
101
102 // Internal, dynamic:
103 var $content; // Content accumulation
104
105 var $interfaceSelector; // A selector box for selecting value for "interface" may be rendered into this variable
106 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
107 var $interfaceSelector_hidden; // A hidden field, if the interface is not set.
108 var $addFields_hidden = ''; // Additional hidden fields to be placed at the login form
109
110 // sets the level of security. *'normal' = clear-text. 'challenged' = hashed password/username from form in $formfield_uident. 'superchallenged' = hashed password hashed again with username.
111 var $loginSecurityLevel = 'superchallenged';
112
113
114
115
116 /**
117 * Initialize the login box. Will also react on a &L=OUT flag and exit.
118 *
119 * @return void
120 */
121 function init() {
122 // We need a PHP session session for most login levels
123 session_start();
124
125 $this->redirect_url = t3lib_div::_GP('redirect_url');
126 $this->GPinterface = t3lib_div::_GP('interface');
127
128 // Grabbing preset username and password, for security reasons this feature only works if SSL is used
129 if (t3lib_div::getIndpEnv('TYPO3_SSL')) {
130 $this->u = t3lib_div::_GP('u');
131 $this->p = t3lib_div::_GP('p');
132 }
133
134 // If "L" is "OUT", then any logged in is logged out. If redirect_url is given, we redirect to it
135 $this->L = t3lib_div::_GP('L');
136
137 // Login
138 $this->loginRefresh = t3lib_div::_GP('loginRefresh');
139
140 // Value of "Login" button. If set, the login button was pressed.
141 $this->commandLI = t3lib_div::_GP('commandLI');
142
143 // sets the level of security from conf vars
144 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) {
145 $this->loginSecurityLevel = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'];
146 }
147
148 // Getting login labels
149 $this->L_vars = explode('|', $GLOBALS['TYPO3_CONF_VARS']['BE']['loginLabels']);
150
151 // Setting the redirect URL to "backend.php" if no alternative input is given
152 $this->redirectToURL = $this->redirect_url ? $this->redirect_url : 'backend.php';
153
154 // Do a logout if the command is set
155 if ($this->L == 'OUT' && is_object($GLOBALS['BE_USER'])) {
156 $GLOBALS['BE_USER']->logoff();
157 if ($this->redirect_url) {
158 header('Location: '.t3lib_div::locationHeaderUrl($this->redirect_url));
159 }
160 exit;
161 }
162 }
163
164
165 /**
166 * Main function - creating the login/logout form
167 *
168 * @return void
169 */
170 function main() {
171 global $TBE_TEMPLATE, $TYPO3_CONF_VARS, $BE_USER;
172
173 // Initialize template object:
174 $TBE_TEMPLATE->bodyTagAdditions = ' onload="startUp();"';
175 $TBE_TEMPLATE->moduleTemplate = $TBE_TEMPLATE->getHtmlTemplate('templates/login.html');
176
177 // Set JavaScript for creating a MD5 hash of the password:
178 $TBE_TEMPLATE->JScode.= $this->getJScode();
179
180 // Checking, if we should make a redirect.
181 // Might set JavaScript in the header to close window.
182 $this->checkRedirect();
183
184 // Initialize interface selectors:
185 $this->makeInterfaceSelectorBox();
186
187 // Replace an optional marker in the "Administration Login" label
188 $this->L_vars[6] = str_replace("###SITENAME###", $TYPO3_CONF_VARS['SYS']['sitename'], $this->L_vars[6]);
189
190 // Creating form based on whether there is a login or not:
191 if (!$BE_USER->user['uid']) {
192 $TBE_TEMPLATE->form = $this->startForm();
193 $loginForm = $this->makeLoginForm();
194 } else {
195 $TBE_TEMPLATE->form = '
196 <form action="index.php" method="post" name="loginform">
197 <input type="hidden" name="login_status" value="logout" />
198 ';
199 $loginForm = $this->makeLogoutForm();
200 }
201
202 // Starting page:
203 $this->content.=$TBE_TEMPLATE->startPage('TYPO3 Login: '.$TYPO3_CONF_VARS['SYS']['sitename']);
204
205 // Add login form:
206 $this->content.=$this->wrapLoginForm($loginForm);
207
208 // Add hidden fields and end the page
209 $this->content .= $this->getHiddenFields();
210
211 $this->content.= $TBE_TEMPLATE->endPage();
212 }
213
214 /**
215 * Outputting the accumulated content to screen
216 *
217 * @return void
218 */
219 function printContent() {
220 echo $this->content;
221 }
222
223 /*****************************
224 *
225 * Various functions
226 *
227 ******************************/
228
229 /**
230 * Creates the login form
231 * This is drawn when NO login exists.
232 *
233 * @return string HTML output
234 */
235 function makeLoginForm() {
236 $content = t3lib_parsehtml::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###LOGIN_FORM###');
237 $markers = array(
238 'HEADLINE' => $this->L_vars[6],
239 'LABEL_USERNAME' => $this->L_vars[0],
240 'LABEL_PASSWORD' => $this->L_vars[1],
241 'VALUE_USERNAME' => $this->u,
242 'VALUE_PASSWORD' => $this->p,
243 'VALUE_SUBMIT' => $this->L_vars[3],
244 'INFO' => $this->L_vars[7],
245 );
246
247 // show an error message if the login command was successful already
248 if (!$this->commandLI) {
249 $content = t3lib_parsehtml::substituteSubpart($content, '###LOGIN_ERROR###', '');
250 } else {
251 $markers['ERROR_MESSAGE'] = $this->L_vars[9];
252 }
253
254 // HSC all output
255 foreach ($markers as &$marker) {
256 $marker = htmlspecialchars($marker);
257 }
258
259
260 // remove the interface selector markers if it's not available
261 if (!($this->interfaceSelector && !$this->loginRefresh)) {
262 $content = t3lib_parsehtml::substituteSubpart($content, '###INTERFACE_SELECTOR###', '');
263 } else {
264 $markers['LABEL_INTERFACE'] = htmlspecialchars($this->L_vars[2]);
265 $markers['VALUE_INTERFACE'] = $this->interfaceSelector_jump;
266 }
267
268 return t3lib_parsehtml::substituteMarkerArray($content, $markers, '###|###');
269 }
270
271
272 /**
273 * Creates the logout form
274 * This is drawn if a user login already exists.
275 *
276 * @return string HTML output
277 */
278 function makeLogoutForm() {
279 $content = t3lib_parsehtml::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###LOGOUT_FORM###');
280 $markers = array(
281 'HEADLINE' => $this->L_vars[6],
282 'LABEL_USERNAME' => $this->L_vars[0],
283 'VALUE_USERNAME' => $GLOBALS['BE_USER']->user['username'],
284 'VALUE_SUBMIT' => $this->L_vars[4],
285 'INFO' => $this->L_vars[7],
286 );
287
288 // HSC all output
289 foreach ($markers as &$marker) {
290 $marker = htmlspecialchars($marker);
291 }
292
293 // remove the interface selector markers if it's not available
294 if (!$this->interfaceSelector_jump) {
295 $content = t3lib_parsehtml::substituteSubpart($content, '###INTERFACE_SELECTOR###', '');
296 } else {
297 $markers['LABEL_INTERFACE'] = htmlspecialchars($this->L_vars[2]);
298 $markers['VALUE_INTERFACE'] = $this->interfaceSelector_jump;
299 }
300
301 return t3lib_parsehtml::substituteMarkerArray($content, $markers, '###|###');
302 }
303
304
305 /**
306 * Wrapping the login form table in another set of tables etc:
307 *
308 * @param string HTML content for the login form
309 * @return string The HTML for the page.
310 */
311 function wrapLoginForm($content) {
312 $mainContent = t3lib_parsehtml::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###PAGE###');
313
314 if ($GLOBALS['TBE_STYLES']['logo_login']) {
315 $logo = '<img src="'.htmlspecialchars($GLOBALS['BACK_PATH'] . $GLOBALS['TBE_STYLES']['logo_login']) . '" alt="" />';
316 } else {
317 $logo = '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/typo3logo.gif','width="123" height="34"').' alt="" />';
318 }
319
320 $markers = array(
321 'LOGO' => $logo,
322 'LOGINBOX_IMAGE' => $this->makeLoginBoxImage(),
323 'FORM' => $content,
324 'NEWS' => $this->makeLoginNews(),
325 'COPYRIGHT' => $this->makeCopyrightNotice(),
326 'CSS_ERRORCLASS' => ($this->commandLI ? ' class="error"' : ''),
327 );
328 return t3lib_parsehtml::substituteMarkerArray($mainContent, $markers, '###|###');
329 }
330
331
332 /**
333 * Checking, if we should perform some sort of redirection OR closing of windows.
334 *
335 * @return void
336 */
337 function checkRedirect() {
338 global $BE_USER,$TBE_TEMPLATE;
339
340 // Do redirect:
341 // 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...)
342 if ($BE_USER->user['uid'] && ($this->commandLI || $this->loginRefresh || !$this->interfaceSelector)) {
343
344 // 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.
345 if (!$_COOKIE[$BE_USER->name]) {
346 if ($this->commandLI=='setCookie') {
347 // we tried it a second time but still no cookie
348 // 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.
349 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);
350 exit;
351 } else {
352 // try it once again - that might be needed for auto login
353 $this->redirectToURL = 'index.php?commandLI=setCookie';
354 }
355 }
356
357 if (($redirectToURL = (string)$BE_USER->getTSConfigVal('auth.BE.redirectToURL'))) {
358 $this->redirectToURL = $redirectToURL;
359 $this->GPinterface = '';
360 }
361
362 // store interface
363 $BE_USER->uc['interfaceSetup'] = $this->GPinterface;
364 $BE_USER->writeUC();
365
366 // Based on specific setting of interface we set the redirect script:
367 switch ($this->GPinterface) {
368 case 'backend':
369 $this->redirectToURL = 'backend.php';
370 break;
371 case 'backend_old':
372 $this->redirectToURL = 'alt_main.php';
373 break;
374 case 'frontend':
375 $this->redirectToURL = '../';
376 break;
377 }
378
379 // If there is a redirect URL AND if loginRefresh is not set...
380 if (!$this->loginRefresh) {
381 header('Location: '.t3lib_div::locationHeaderUrl($this->redirectToURL));
382 exit;
383 } else {
384 $TBE_TEMPLATE->JScode.=$TBE_TEMPLATE->wrapScriptTags('
385 if (parent.opener && parent.opener.busy) {
386 parent.opener.busy.loginRefreshed();
387 parent.close();
388 }
389 ');
390 }
391
392 } elseif (!$BE_USER->user['uid'] && $this->commandLI) {
393 sleep(5); // Wrong password, wait for 5 seconds
394 }
395 }
396
397 /**
398 * Making interface selector:
399 *
400 * @return void
401 */
402 function makeInterfaceSelectorBox() {
403 global $TYPO3_CONF_VARS;
404
405 // Reset variables:
406 $this->interfaceSelector = '';
407 $this->interfaceSelector_hidden='';
408 $this->interfaceSelector_jump = '';
409
410 // If interfaces are defined AND no input redirect URL in GET vars:
411 if ($TYPO3_CONF_VARS['BE']['interfaces'] && ($this->commandLI || !$this->redirect_url)) {
412 $parts = t3lib_div::trimExplode(',',$TYPO3_CONF_VARS['BE']['interfaces']);
413 if (count($parts)>1) { // Only if more than one interface is defined will we show the selector:
414
415 // Initialize:
416 $tempLabels=explode(',', $this->L_vars[5]);
417 $labels=array();
418
419 $labels['backend'] = $tempLabels[0];
420 $labels['backend_old'] = $tempLabels[2];
421 $labels['frontend'] = $tempLabels[1];
422
423 $jumpScript=array();
424 $jumpScript['backend'] = 'backend.php';
425 $jumpScript['backend_old'] = 'alt_main.php';
426 $jumpScript['frontend'] = '../';
427
428 // Traverse the interface keys:
429 foreach($parts as $valueStr) {
430 $this->interfaceSelector.='
431 <option value="'.htmlspecialchars($valueStr).'"'.(t3lib_div::_GP('interface')==htmlspecialchars($valueStr) ? ' selected="selected"' : '').'>'.htmlspecialchars($labels[$valueStr]).'</option>';
432 $this->interfaceSelector_jump.='
433 <option value="'.htmlspecialchars($jumpScript[$valueStr]).'">'.htmlspecialchars($labels[$valueStr]).'</option>';
434 }
435 $this->interfaceSelector='
436 <select id="interfaceselector" name="interface" class="c-interfaceselector">'.$this->interfaceSelector.'
437 </select>';
438 $this->interfaceSelector_jump='
439 <select id="interfaceselector" name="interface" class="c-interfaceselector" onchange="window.location.href=this.options[this.selectedIndex].value;">'.$this->interfaceSelector_jump.'
440 </select>';
441
442 } else { // If there is only ONE interface value set:
443
444 $this->interfaceSelector_hidden='<input type="hidden" name="interface" value="'.trim($TYPO3_CONF_VARS['BE']['interfaces']).'" />';
445 }
446 }
447 }
448
449 /**
450 * COPYRIGHT notice
451 *
452 * Warning:
453 * DO NOT prevent this notice from being shown in ANY WAY.
454 * 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)
455 * 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.
456 *
457 * @return string Text/Image (HTML) for copyright notice.
458 */
459 function makeCopyrightNotice() {
460
461 // Get values from TYPO3_CONF_VARS:
462 $loginCopyrightWarrantyProvider = strip_tags(trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightWarrantyProvider']));
463 $loginCopyrightWarrantyURL = strip_tags(trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightWarrantyURL']));
464 $loginImageSmall = (trim($GLOBALS['TBE_STYLES']['loginBoxImageSmall'])) ? trim($GLOBALS['TBE_STYLES']['loginBoxImageSmall']) : 'gfx/loginlogo_transp.gif';
465
466 // Make warranty note:
467 if (strlen($loginCopyrightWarrantyProvider)>=2 && strlen($loginCopyrightWarrantyURL)>=10) {
468 $warrantyNote='Warranty is supplied by '.htmlspecialchars($loginCopyrightWarrantyProvider).'; <a href="'.htmlspecialchars($loginCopyrightWarrantyURL).'" target="_blank">click for details.</a>';
469 } else {
470 $warrantyNote='TYPO3 comes with ABSOLUTELY NO WARRANTY; <a href="http://typo3.com/1316.0.html" target="_blank">click for details.</a>';
471 }
472
473 // Compile full copyright notice:
474 $copyrightNotice = '<a href="http://typo3.com/" target="_blank">'.
475 '<img src="'.$loginImageSmall.'" alt="TYPO3 logo" align="left" />'.
476 'TYPO3 CMS'.($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightShowVersion']?' ver. '.htmlspecialchars($GLOBALS['TYPO_VERSION']):'').
477 '</a>. '.
478 'Copyright &copy; '.TYPO3_copyright_year.' Kasper Sk&#229;rh&#248;j. Extensions are copyright of their respective owners. '.
479 'Go to <a href="http://typo3.com/" target="_blank">http://typo3.com/</a> for details. '.
480 $warrantyNote.' '.
481 'This is free software, and you are welcome to redistribute it under certain conditions; <a href="http://typo3.com/1316.0.html" target="_blank">click for details</a>. '.
482 'Obstructing the appearance of this notice is prohibited by law.';
483
484 // Return notice:
485 return $copyrightNotice;
486 }
487
488 /**
489 * Returns the login box image, whether the default or an image from the rotation folder.
490 *
491 * @return string HTML image tag.
492 */
493 function makeLoginBoxImage() {
494 $loginboxImage = '';
495 if ($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']) { // Look for rotation image folder:
496 $absPath = t3lib_div::resolveBackPath(PATH_typo3.$GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']);
497
498 // Get rotation folder:
499 $dir = t3lib_div::getFileAbsFileName($absPath);
500 if ($dir && @is_dir($dir)) {
501
502 // Get files for rotation into array:
503 $files = t3lib_div::getFilesInDir($dir,'png,jpg,gif');
504
505 // Pick random file:
506 srand((float) microtime() * 10000000);
507 $randImg = array_rand($files, 1);
508
509 // Get size of random file:
510 $imgSize = @getimagesize($dir.$files[$randImg]);
511
512 $imgAuthor = is_array($GLOBALS['TBE_STYLES']['loginBoxImage_author'])&&$GLOBALS['TBE_STYLES']['loginBoxImage_author'][$files[$randImg]] ? htmlspecialchars($GLOBALS['TBE_STYLES']['loginBoxImage_author'][$files[$randImg]]) : '';
513
514 // Create image tag:
515 if (is_array($imgSize)) {
516 $loginboxImage = '<img src="'.htmlspecialchars($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder'].$files[$randImg]).'" '.$imgSize[3].' id="loginbox-image" alt="'.$imgAuthor.'" title="'.$imgAuthor.'" />';
517 }
518 }
519 } else { // If no rotation folder configured, print default image:
520
521 if (strstr(TYPO3_version,'-dev')) { // development version
522 $loginImage = 'loginbox_image_dev.png';
523 $imagecopy = 'You are running a development version of TYPO3 '.TYPO3_branch;
524 } else {
525 $loginImage = 'loginbox_image.jpg';
526 $imagecopy = 'Photo by J.C. Franca (www.digitalphoto.com.br)';
527 }
528 $loginboxImage = '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/'.$loginImage,'width="200" height="133"').' id="loginbox-image" alt="'.$imagecopy.'" title="'.$imagecopy.'" />';
529 }
530
531 // Return image tag:
532 return $loginboxImage;
533 }
534
535 /**
536 * Make login news - renders the HTML content for a list of news shown under the login form. News data is added through $TYPO3_CONF_VARS
537 *
538 * @return string HTML content
539 * @credits Idea by Jan-Hendrik Heuing
540 */
541 function makeLoginNews() {
542
543 // Reset output variable:
544 $newsContent= '';
545
546 // Traverse news array IF there are records in it:
547 if (is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews']) && count($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'])) {
548 foreach($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] as $newsItem) {
549 $newsContent .= '<dt>'.htmlspecialchars($newsItem['header']).' <span>'.htmlspecialchars($newsItem['date']).'</span></dt>';
550 $newsContent .= '<dd>'.trim($newsItem['content']).'</dd>';
551 }
552
553 $title = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] ? htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle']) : htmlspecialchars($this->L_vars[8]);
554 // Wrap
555 $newsContent = '
556
557 <!--
558 Login screen news:
559 -->
560 <h2 id="loginNewsTitle">'.$title.'</h2>
561 <dl id="loginNews">
562 '.$newsContent.'
563 </dl>
564 ';
565 }
566
567 // Return content:
568 return $newsContent;
569 }
570
571 /**
572 * Returns the form tag
573 *
574 * @return string Opening form tag string
575 */
576 function startForm() {
577 $output = '';
578
579 // The form defaults to 'no login'. This prevents plain
580 // text logins to the Backend. The 'sv' extension changes the form to
581 // use superchallenged method and rsaauth extension makes rsa authetication.
582 $form = '<form action="index.php" method="post" name="loginform" ' .
583 'onsubmit="alert(\'No authentication methods available. Please, ' .
584 'contact your TYPO3 administrator.\');return false">';
585
586 // Call hooks. If they do not return anything, we fail to login
587 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginFormHook'])) {
588 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginFormHook'] as $function) {
589 $params = array();
590 $formCode = t3lib_div::callUserFunction($function, $params, $this);
591 if ($formCode) {
592 $form = $formCode;
593 break;
594 }
595 }
596 }
597
598 $output .= $form .
599 '<input type="hidden" name="login_status" value="login" />' .
600 '<input type="hidden" name="userident" value="" />' .
601 '<input type="hidden" name="redirect_url" value="'.htmlspecialchars($this->redirectToURL).'" />' .
602 '<input type="hidden" name="loginRefresh" value="'.htmlspecialchars($this->loginRefresh).'" />' .
603 $this->interfaceSelector_hidden . $this->addFields_hidden;
604
605 return $output;
606 }
607
608 /**
609 * Outputs an empty string. This function is obsolete and kept for the
610 * compatibility only.
611 *
612 * @param string $unused Unused
613 * @return string HTML output
614 */
615 function getHiddenFields($unused = '') {
616 return '';
617 }
618
619 /**
620 * Creates JavaScript for the login form
621 *
622 * @return string JavaScript code
623 */
624 function getJScode() {
625 $JSCode = '';
626 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginScriptHook'])) {
627 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginScriptHook'] as $function) {
628 $params = array();
629 $JSCode = t3lib_div::callUserFunction($function, $params, $this);
630 if ($JSCode) {
631 break;
632 }
633 }
634 }
635 $JSCode .= $GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
636 function startUp() {
637 // 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:
638 if (parent.opener && parent.opener.TS && parent.opener.TS.username && document.loginform && document.loginform.username) {
639 document.loginform.username.value = parent.opener.TS.username;
640 }
641
642 // Wait a few millisecons before calling checkFocus(). This might be necessary because some browsers need some time to auto-fill in the form fields
643 window.setTimeout("checkFocus()", 50);
644 }
645
646 // This moves focus to the right input field:
647 function checkFocus() {
648 // If for some reason there already is a username in the username form field, move focus to the password field:
649 if (document.loginform.username && document.loginform.username.value == "") {
650 document.loginform.username.focus();
651 } else if (document.loginform.p_field && document.loginform.p_field.type!="hidden") {
652 document.loginform.p_field.focus();
653 }
654 }
655 ');
656
657 return $JSCode;
658 }
659 }
660
661
662 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/index.php']) {
663 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/index.php']);
664 }
665
666
667
668 // Make instance:
669 $SOBE = t3lib_div::makeInstance('SC_index');
670 $SOBE->init();
671 $SOBE->main();
672 $SOBE->printContent();
673
674 ?>