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