TYPO3 CMS  TYPO3_6-2
LoginController.php
Go to the documentation of this file.
1 <?php
3 
23 
30 
31  const SIGNAL_RenderLoginForm = 'renderLoginForm';
32 
33  // Internal, GPvars:
34  // GPvar: redirect_url; The URL to redirect to after login.
38  public $redirect_url;
39 
40  // GPvar: Defines which interface to load (from interface selector)
44  public $GPinterface;
45 
46  // GPvar: preset username
50  public $u;
51 
52  // GPvar: preset password
56  public $p;
57 
61  protected $openIdUrl;
62 
63  // GPvar: If "L" is "OUT", then any logged in used is logged out. If redirect_url is given, we redirect to it
67  public $L;
68 
69  // 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.
73  public $loginRefresh;
74 
75  // Value of forms submit button for login.
79  public $commandLI;
80 
81  // Internal, static:
82  // Set to the redirect URL of the form (may be redirect_url or "backend.php")
87 
88  // Internal, dynamic:
89  // Content accumulation
93  public $content;
94 
95  // A selector box for selecting value for "interface" may be rendered into this variable
100 
101  // A selector box for selecting value for "interface" may be rendered into this variable
102  // this will have an onchange action which will redirect the user to the selected interface right away
107 
108  // A hidden field, if the interface is not set.
113 
114  // Additional hidden fields to be placed at the login form
118  public $addFields_hidden = '';
119 
120  // sets the level of security. *'normal' = clear-text. 'challenged' = hashed
121  // password/username from form in $formfield_uident. 'superchallenged' = hashed password hashed again with username.
125  public $loginSecurityLevel = 'superchallenged';
126 
131 
135  public function __construct() {
136  $this->init();
137  }
138 
145  public function init() {
146  // We need a PHP session session for most login levels
147  session_start();
148  $this->redirect_url = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('redirect_url'));
149  $this->GPinterface = GeneralUtility::_GP('interface');
150  // Grabbing preset username and password, for security reasons this feature only works if SSL is used
151  if (GeneralUtility::getIndpEnv('TYPO3_SSL')) {
152  $this->u = GeneralUtility::_GP('u');
153  $this->p = GeneralUtility::_GP('p');
154  $this->openIdUrl = GeneralUtility::_GP('openid_url');
155  }
156  // If "L" is "OUT", then any logged in is logged out. If redirect_url is given, we redirect to it
157  $this->L = GeneralUtility::_GP('L');
158  // Login
159  $this->loginRefresh = GeneralUtility::_GP('loginRefresh');
160  // Value of "Login" button. If set, the login button was pressed.
161  $this->commandLI = GeneralUtility::_GP('commandLI');
162  // Sets the level of security from conf vars
163  if ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) {
164  $this->loginSecurityLevel = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'];
165  }
166  // Try to get the preferred browser language
167  $preferredBrowserLanguage = $GLOBALS['LANG']->csConvObj->getPreferredClientLanguage(GeneralUtility::getIndpEnv('HTTP_ACCEPT_LANGUAGE'));
168  // If we found a $preferredBrowserLanguage and it is not the default language and no be_user is logged in
169  // initialize $GLOBALS['LANG'] again with $preferredBrowserLanguage
170  if ($preferredBrowserLanguage !== 'default' && empty($GLOBALS['BE_USER']->user['uid'])) {
171  $GLOBALS['LANG']->init($preferredBrowserLanguage);
172  }
173  $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_login.xlf');
174  // Setting the redirect URL to "backend.php" if no alternative input is given
175  $this->redirectToURL = $this->redirect_url ?: 'backend.php';
176  // Do a logout if the command is set
177  if ($this->L == 'OUT' && is_object($GLOBALS['BE_USER'])) {
178  $GLOBALS['BE_USER']->logoff();
179  if ($this->redirect_url) {
180  HttpUtility::redirect($this->redirect_url);
181  }
182  die;
183  }
184  }
185 
192  public function main() {
193  // Initialize template object:
194  $GLOBALS['TBE_TEMPLATE']->bodyTagAdditions = ' onload="startUp();"';
195  $GLOBALS['TBE_TEMPLATE']->moduleTemplate = $GLOBALS['TBE_TEMPLATE']->getHtmlTemplate('EXT:backend/Resources/Private/Templates/login.html');
197  $pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
198  $pageRenderer->loadExtJS();
199  $pageRenderer->loadPrototype();
200  $pageRenderer->loadScriptaculous();
201  // Set JavaScript for creating a MD5 hash of the password:
202  $GLOBALS['TBE_TEMPLATE']->JScode .= $this->getJScode();
203  // Checking, if we should make a redirect.
204  // Might set JavaScript in the header to close window.
205  $this->checkRedirect();
206  // Initialize interface selectors:
207  $this->makeInterfaceSelectorBox();
208  // Creating form based on whether there is a login or not:
209  if (empty($GLOBALS['BE_USER']->user['uid'])) {
210  $GLOBALS['TBE_TEMPLATE']->form = $this->startForm();
211  $loginForm = $this->makeLoginForm();
212  } else {
213  $GLOBALS['TBE_TEMPLATE']->form = '
214  <form action="index.php" method="post" name="loginform">
215  <input type="hidden" name="login_status" value="logout" />
216  ';
217  $loginForm = $this->makeLogoutForm();
218  }
219  // Starting page:
220  $this->content .= $GLOBALS['TBE_TEMPLATE']->startPage('TYPO3 CMS Login: ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], FALSE);
221  // Add login form:
222  $this->content .= $this->wrapLoginForm($loginForm);
223  $this->content .= $GLOBALS['TBE_TEMPLATE']->endPage();
224  }
225 
232  public function printContent() {
233  echo $this->content;
234  }
235 
236  /*****************************
237  *
238  * Various functions
239  *
240  ******************************/
248  public function makeLoginForm() {
249  $content = HtmlParser::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###LOGIN_FORM###');
250  $markers = array(
251  'VALUE_USERNAME' => htmlspecialchars($this->u),
252  'VALUE_PASSWORD' => htmlspecialchars($this->p),
253  'VALUE_OPENID_URL' => htmlspecialchars($this->openIdUrl),
254  'VALUE_SUBMIT' => $GLOBALS['LANG']->getLL('labels.submitLogin', TRUE)
255  );
256  // Show an error message if the login command was successful already, otherwise remove the subpart
257  if (!$this->isLoginInProgress()) {
258  $content = HtmlParser::substituteSubpart($content, '###LOGIN_ERROR###', '');
259  } else {
260  $markers['ERROR_MESSAGE'] = $GLOBALS['LANG']->getLL('error.login', TRUE);
261  $markers['ERROR_LOGIN_TITLE'] = $GLOBALS['LANG']->getLL('error.login.title', TRUE);
262  $markers['ERROR_LOGIN_DESCRIPTION'] = $GLOBALS['LANG']->getLL('error.login.description', TRUE);
263  }
264  // Remove the interface selector markers if it's not available
265  if (!($this->interfaceSelector && !$this->loginRefresh)) {
266  $content = HtmlParser::substituteSubpart($content, '###INTERFACE_SELECTOR###', '');
267  } else {
268  $markers['LABEL_INTERFACE'] = $GLOBALS['LANG']->getLL('labels.interface', TRUE);
269  $markers['VALUE_INTERFACE'] = $this->interfaceSelector;
270  }
271  return HtmlParser::substituteMarkerArray($content, $markers, '###|###');
272  }
273 
281  public function makeLogoutForm() {
282  $content = HtmlParser::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###LOGOUT_FORM###');
283  $markers = array(
284  'LABEL_USERNAME' => $GLOBALS['LANG']->getLL('labels.username', TRUE),
285  'VALUE_USERNAME' => htmlspecialchars($GLOBALS['BE_USER']->user['username']),
286  'VALUE_SUBMIT' => $GLOBALS['LANG']->getLL('labels.submitLogout', TRUE)
287  );
288  // Remove the interface selector markers if it's not available
289  if (!$this->interfaceSelector_jump) {
290  $content = HtmlParser::substituteSubpart($content, '###INTERFACE_SELECTOR###', '');
291  } else {
292  $markers['LABEL_INTERFACE'] = $GLOBALS['LANG']->getLL('labels.interface', TRUE);
293  $markers['VALUE_INTERFACE'] = $this->interfaceSelector_jump;
294  }
295  return HtmlParser::substituteMarkerArray($content, $markers, '###|###');
296  }
297 
305  public function wrapLoginForm($content) {
306  $mainContent = HtmlParser::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###PAGE###');
307  if ($GLOBALS['TBE_STYLES']['logo_login']) {
308  $logo = '<img src="' . htmlspecialchars(($GLOBALS['BACK_PATH'] . $GLOBALS['TBE_STYLES']['logo_login'])) . '" alt="" class="t3-login-logo" />';
309  } else {
310  $logo = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/typo3logo.gif', 'width="123" height="34"') . ' alt="" class="t3-login-logo" />';
311  }
313  $browserWarning = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('warning.incompatibleBrowser') . ' ' . $GLOBALS['LANG']->getLL('warning.incompatibleBrowserInternetExplorer'), $GLOBALS['LANG']->getLL('warning.incompatibleBrowserHeadline'), FlashMessage::ERROR);
314  $browserWarning = $browserWarning->render();
315  $additionalCssClasses = array();
316  if ($this->isLoginInProgress()) {
317  $additionalCssClasses[] = 'error';
318  }
319  if ($this->loginRefresh) {
320  $additionalCssClasses[] = 'refresh';
321  }
322  $markers = array(
323  'LOGO' => $logo,
324  'LOGINBOX_IMAGE' => $this->makeLoginBoxImage(),
325  'FORM' => $content,
326  'NEWS' => $this->makeLoginNews(),
327  'COPYRIGHT' => BackendUtility::TYPO3_copyRightNotice($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightShowVersion']),
328  'CSS_CLASSES' => !empty($additionalCssClasses) ? 'class="' . implode(' ', $additionalCssClasses) . '"' : '',
329  'CSS_OPENIDCLASS' => 't3-login-openid-' . (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('openid') ? 'enabled' : 'disabled'),
330  // The labels will be replaced later on, thus the other parts above
331  // can use these markers as well and it will be replaced
332  'HEADLINE' => $GLOBALS['LANG']->getLL('headline', TRUE),
333  'INFO_ABOUT' => $GLOBALS['LANG']->getLL('info.about', TRUE),
334  'INFO_RELOAD' => $GLOBALS['LANG']->getLL('info.reset', TRUE),
335  'INFO' => $GLOBALS['LANG']->getLL('info.cookies_and_js', TRUE),
336  'WARNING_BROWSER_INCOMPATIBLE' => $browserWarning,
337  'ERROR_JAVASCRIPT' => $GLOBALS['LANG']->getLL('error.javascript', TRUE),
338  'ERROR_COOKIES' => $GLOBALS['LANG']->getLL('error.cookies', TRUE),
339  'ERROR_COOKIES_IGNORE' => $GLOBALS['LANG']->getLL('error.cookies_ignore', TRUE),
340  'ERROR_CAPSLOCK' => $GLOBALS['LANG']->getLL('error.capslock', TRUE),
341  'ERROR_FURTHERHELP' => $GLOBALS['LANG']->getLL('error.furtherInformation', TRUE),
342  'LABEL_DONATELINK' => $GLOBALS['LANG']->getLL('labels.donate', TRUE),
343  'LABEL_USERNAME' => $GLOBALS['LANG']->getLL('labels.username', TRUE),
344  'LABEL_OPENID' => $GLOBALS['LANG']->getLL('labels.openId', TRUE),
345  'LABEL_PASSWORD' => $GLOBALS['LANG']->getLL('labels.password', TRUE),
346  'LABEL_WHATISOPENID' => $GLOBALS['LANG']->getLL('labels.whatIsOpenId', TRUE),
347  'LABEL_SWITCHOPENID' => $GLOBALS['LANG']->getLL('labels.switchToOpenId', TRUE),
348  'LABEL_SWITCHDEFAULT' => $GLOBALS['LANG']->getLL('labels.switchToDefault', TRUE),
349  'CLEAR' => $GLOBALS['LANG']->getLL('clear', TRUE),
350  'LOGIN_PROCESS' => $GLOBALS['LANG']->getLL('login_process', TRUE),
351  'SITELINK' => '<a href="/">###SITENAME###</a>',
352  // Global variables will now be replaced (at last)
353  'SITENAME' => htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'])
354  );
355  $markers = $this->emitRenderLoginFormSignal($markers);
356  return HtmlParser::substituteMarkerArray($mainContent, $markers, '###|###');
357  }
358 
365  public function checkRedirect() {
366  // Do redirect:
367  // If a user is logged in AND a) if either the login is just done (isLoginInProgress) 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...)
368  if (!empty($GLOBALS['BE_USER']->user['uid']) && ($this->isLoginInProgress() || $this->loginRefresh || !$this->interfaceSelector)) {
369  // 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.
370  if (!$_COOKIE[\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::getCookieName()]) {
371  if ($this->commandLI == 'setCookie') {
372  // we tried it a second time but still no cookie
373  // 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.
374  throw new \RuntimeException('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.', 1294586846);
375  } else {
376  // try it once again - that might be needed for auto login
377  $this->redirectToURL = 'index.php?commandLI=setCookie';
378  }
379  }
380  if ($redirectToURL = (string) $GLOBALS['BE_USER']->getTSConfigVal('auth.BE.redirectToURL')) {
381  $this->redirectToURL = $redirectToURL;
382  $this->GPinterface = '';
383  }
384  // store interface
385  $GLOBALS['BE_USER']->uc['interfaceSetup'] = $this->GPinterface;
386  $GLOBALS['BE_USER']->writeUC();
387  // Based on specific setting of interface we set the redirect script:
388  switch ($this->GPinterface) {
389  case 'backend':
390 
391  case 'backend_old':
392  $this->redirectToURL = 'backend.php';
393  break;
394  case 'frontend':
395  $this->redirectToURL = '../';
396  break;
397  }
400  // If there is a redirect URL AND if loginRefresh is not set...
401  if (!$this->loginRefresh) {
402  $formProtection->storeSessionTokenInRegistry();
403  HttpUtility::redirect($this->redirectToURL);
404  } else {
405  $formProtection->setSessionTokenFromRegistry();
406  $formProtection->persistSessionToken();
407  $GLOBALS['TBE_TEMPLATE']->JScode .= $GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
408  if (parent.opener && (parent.opener.busy || parent.opener.TYPO3.loginRefresh)) {
409  if (parent.opener.TYPO3.loginRefresh) {
410  parent.opener.TYPO3.loginRefresh.startTimer();
411  } else {
412  parent.opener.busy.loginRefreshed();
413  }
414  parent.close();
415  }
416  ');
417  }
418  }
419  }
420 
427  public function makeInterfaceSelectorBox() {
428  // Reset variables:
429  $this->interfaceSelector = '';
430  $this->interfaceSelector_hidden = '';
431  $this->interfaceSelector_jump = '';
432  // If interfaces are defined AND no input redirect URL in GET vars:
433  if ($GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces'] && ($this->isLoginInProgress() || !$this->redirect_url)) {
434  $parts = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces']);
435  // Only if more than one interface is defined will we show the selector:
436  if (count($parts) > 1) {
437  // Initialize:
438  $labels = array();
439  $labels['backend'] = $GLOBALS['LANG']->getLL('interface.backend');
440  $labels['backend_old'] = $GLOBALS['LANG']->getLL('interface.backend_old');
441  $labels['frontend'] = $GLOBALS['LANG']->getLL('interface.frontend');
442  $jumpScript = array();
443  $jumpScript['backend'] = 'backend.php';
444  $jumpScript['backend_old'] = 'backend.php';
445  $jumpScript['frontend'] = '../';
446  // Traverse the interface keys:
447  foreach ($parts as $valueStr) {
448  $this->interfaceSelector .= '
449  <option value="' . htmlspecialchars($valueStr) . '"' . (GeneralUtility::_GP('interface') == htmlspecialchars($valueStr) ? ' selected="selected"' : '') . '>' . htmlspecialchars($labels[$valueStr]) . '</option>';
450  $this->interfaceSelector_jump .= '
451  <option value="' . htmlspecialchars($jumpScript[$valueStr]) . '">' . htmlspecialchars($labels[$valueStr]) . '</option>';
452  }
453  $this->interfaceSelector = '
454  <select id="t3-interfaceselector" name="interface" class="c-interfaceselector" tabindex="3">' . $this->interfaceSelector . '
455  </select>';
456  $this->interfaceSelector_jump = '
457  <select id="t3-interfaceselector" name="interface" class="c-interfaceselector" tabindex="3" onchange="window.location.href=this.options[this.selectedIndex].value;">' . $this->interfaceSelector_jump . '
458  </select>';
459  } elseif (!$this->redirect_url) {
460  // If there is only ONE interface value set and no redirect_url is present:
461  $this->interfaceSelector_hidden = '<input type="hidden" name="interface" value="' . trim($GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces']) . '" />';
462  }
463  }
464  }
465 
472  public function makeLoginBoxImage() {
473  $loginboxImage = '';
474  // Look for rotation image folder:
475  if ($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']) {
476  $absPath = GeneralUtility::resolveBackPath(PATH_typo3 . $GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']);
477  // Get rotation folder:
478  $dir = GeneralUtility::getFileAbsFileName($absPath);
479  if ($dir && @is_dir($dir)) {
480  // Get files for rotation into array:
481  $files = GeneralUtility::getFilesInDir($dir, 'png,jpg,gif');
482  // Pick random file:
483  $randImg = array_rand($files, 1);
484  // Get size of random file:
485  $imgSize = @getimagesize(($dir . $files[$randImg]));
486  $imgAuthor = is_array($GLOBALS['TBE_STYLES']['loginBoxImage_author']) && $GLOBALS['TBE_STYLES']['loginBoxImage_author'][$files[$randImg]] ? htmlspecialchars($GLOBALS['TBE_STYLES']['loginBoxImage_author'][$files[$randImg]]) : '';
487  // Create image tag:
488  if (is_array($imgSize)) {
489  $loginboxImage = '<img src="' . htmlspecialchars(($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder'] . $files[$randImg])) . '" ' . $imgSize[3] . ' id="loginbox-image" alt="' . $imgAuthor . '" title="' . $imgAuthor . '" />';
490  }
491  }
492  } else {
493  // If no rotation folder configured, print default image:
494  // Development version
495  if (strstr(TYPO3_version, '-dev')) {
496  $loginImage = 'loginbox_image_dev.png';
497  $imagecopy = 'You are running a development version of TYPO3 ' . TYPO3_branch;
498  } else {
499  $loginImage = 'loginbox_image.jpg';
500  $imagecopy = 'Photo by J.C. Franca (www.digitalphoto.com.br)';
501  }
502  $loginboxImage = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], ('gfx/' . $loginImage), 'width="200" height="133"') . ' id="loginbox-image" alt="' . $imagecopy . '" title="' . $imagecopy . '" />';
503  }
504  // Return image tag:
505  return $loginboxImage;
506  }
507 
516  public function makeLoginNews() {
517  $newsContent = '';
518  $systemNews = $this->getSystemNews();
519  // Traverse news array IF there are records in it:
520  if (is_array($systemNews) && count($systemNews) && !GeneralUtility::_GP('loginRefresh')) {
522  $htmlParser = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Html\\RteHtmlParser');
523  $htmlParser->procOptions['dontHSC_rte'] = TRUE;
524 
525  // Get the main news template, and replace the subpart after looped through
526  $newsContent = HtmlParser::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###LOGIN_NEWS###');
527  $newsItemTemplate = HtmlParser::getSubpart($newsContent, '###NEWS_ITEM###');
528  $newsItem = '';
529  $count = 1;
530  foreach ($systemNews as $newsItemData) {
531  $additionalClass = '';
532  if ($count == 1) {
533  $additionalClass = ' first-item';
534  } elseif ($count == count($systemNews)) {
535  $additionalClass = ' last-item';
536  }
537  $newsItemContent = $htmlParser->TS_transform_rte($htmlParser->TS_links_rte($newsItemData['content']));
538  $newsItemMarker = array(
539  '###HEADER###' => htmlspecialchars($newsItemData['header']),
540  '###DATE###' => htmlspecialchars($newsItemData['date']),
541  '###CONTENT###' => $newsItemContent,
542  '###CLASS###' => $additionalClass
543  );
544  $count++;
545  $newsItem .= HtmlParser::substituteMarkerArray($newsItemTemplate, $newsItemMarker);
546  }
547  $title = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] : $GLOBALS['LANG']->getLL('newsheadline');
548  $newsContent = HtmlParser::substituteMarker($newsContent, '###NEWS_HEADLINE###', htmlspecialchars($title));
549  $newsContent = HtmlParser::substituteSubpart($newsContent, '###NEWS_ITEM###', $newsItem);
550  }
551  return $newsContent;
552  }
553 
560  protected function getSystemNews() {
561  $systemNewsTable = 'sys_news';
562  $systemNews = array();
563  $systemNewsRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('title, content, crdate', $systemNewsTable, '1=1' . BackendUtility::BEenableFields($systemNewsTable) . BackendUtility::deleteClause($systemNewsTable), '', 'crdate DESC');
564  foreach ($systemNewsRecords as $systemNewsRecord) {
565  $systemNews[] = array(
566  'date' => date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $systemNewsRecord['crdate']),
567  'header' => $systemNewsRecord['title'],
568  'content' => $systemNewsRecord['content']
569  );
570  }
571  return $systemNews;
572  }
573 
580  public function startForm() {
581  $output = '';
582  // The form defaults to 'no login'. This prevents plain
583  // text logins to the Backend. The 'sv' extension changes the form to
584  // use superchallenged method and rsaauth extension makes rsa authetication.
585  $form = '<form action="index.php" method="post" name="loginform" ' . 'onsubmit="alert(\'No authentication methods available. Please, ' . 'contact your TYPO3 administrator.\');return false">';
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 = GeneralUtility::callUserFunction($function, $params, $this);
591  if ($formCode) {
592  $form = $formCode;
593  break;
594  }
595  }
596  }
597  $output .= $form . '<input type="hidden" name="login_status" value="login" />' . '<input type="hidden" name="userident" value="" />' . '<input type="hidden" name="redirect_url" value="' . htmlspecialchars($this->redirectToURL) . '" />' . '<input type="hidden" name="loginRefresh" value="' . htmlspecialchars($this->loginRefresh) . '" />' . $this->interfaceSelector_hidden . $this->addFields_hidden;
598  return $output;
599  }
600 
607  public function getJScode() {
608  $JSCode = '';
609  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginScriptHook'])) {
610  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginScriptHook'] as $function) {
611  $params = array();
612  $JSCode = GeneralUtility::callUserFunction($function, $params, $this);
613  if ($JSCode) {
614  break;
615  }
616  }
617  }
618  $JSCode .= $GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
619  function startUp() {
620  // 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:
621  try {
622  if (parent.opener && parent.opener.TS && parent.opener.TS.username && document.loginform && document.loginform.username) {
623  document.loginform.username.value = parent.opener.TS.username;
624  }
625  }
626  catch(error) {
627  //continue
628  }
629 
630  // Wait a few millisecons before calling checkFocus(). This might be necessary because some browsers need some time to auto-fill in the form fields
631  window.setTimeout("checkFocus()", 50);
632  }
633 
634  // This moves focus to the right input field:
635  function checkFocus() {
636  // If for some reason there already is a username in the username form field, move focus to the password field:
637  if (document.loginform.username && document.loginform.username.value == "") {
638  document.loginform.username.focus();
639  } else if (document.loginform.p_field && document.loginform.p_field.type!="hidden") {
640  document.loginform.p_field.focus();
641  }
642  }
643 
644  // This function shows a warning, if user has capslock enabled
645  // parameter showWarning: shows warning if TRUE and capslock active, otherwise only hides warning, if capslock gets inactive
646  function checkCapslock(e, showWarning) {
647  if (!isCapslock(e)) {
648  document.getElementById(\'t3-capslock\').style.display = \'none\';
649  } else if (showWarning) {
650  document.getElementById(\'t3-capslock\').style.display = \'block\';
651  }
652  }
653 
654  // Checks weather capslock is enabled (returns TRUE if enabled, false otherwise)
655  // thanks to http://24ways.org/2007/capturing-caps-lock
656 
657  function isCapslock(e) {
658  var ev = e ? e : window.event;
659  if (!ev) {
660  return;
661  }
662  var targ = ev.target ? ev.target : ev.srcElement;
663  // get key pressed
664  var which = -1;
665  if (ev.which) {
666  which = ev.which;
667  } else if (ev.keyCode) {
668  which = ev.keyCode;
669  }
670  // get shift status
671  var shift_status = false;
672  if (ev.shiftKey) {
673  shift_status = ev.shiftKey;
674  } else if (ev.modifiers) {
675  shift_status = !!(ev.modifiers & 4);
676  }
677  return (((which >= 65 && which <= 90) && !shift_status) ||
678  ((which >= 97 && which <= 122) && shift_status));
679  }
680 
681  // prevent opening the login form in the backend frameset
682  if (top.location.href != self.location.href) {
683  top.location.href = self.location.href;
684  }
685 
686  ');
687  return $JSCode;
688  }
689 
695  protected function isLoginInProgress() {
696  $username = GeneralUtility::_GP('username');
697  return !(empty($username) && empty($this->commandLI));
698  }
699 
706  protected function emitRenderLoginFormSignal(array $markers) {
707  $signalArguments = $this->getSignalSlotDispatcher()->dispatch('TYPO3\\CMS\\Backend\\Controller\\LoginController', self::SIGNAL_RenderLoginForm, array($this, $markers));
708  return $signalArguments[1];
709  }
710 
716  protected function getSignalSlotDispatcher() {
717  if (!isset($this->signalSlotDispatcher)) {
718  $this->signalSlotDispatcher = $this->getObjectManager()->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
719  }
721  }
722 
728  protected function getObjectManager() {
729  return GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
730  }
731 
732 }
static skinImg($backPath, $src, $wHattribs='', $outputMode=0)
die
Definition: index.php:6
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
static substituteMarker($content, $marker, $markContent)
Definition: HtmlParser.php:167
static getSubpart($content, $marker)
Definition: HtmlParser.php:39
static substituteMarkerArray($content, $markContentArray, $wrap='', $uppercase=FALSE, $deleteUnused=FALSE)
Definition: HtmlParser.php:189
static substituteSubpart($content, $marker, $subpartContent, $recursive=TRUE, $keepMarker=FALSE)
Definition: HtmlParser.php:79
static getFilesInDir($path, $extensionList='', $prependPath=FALSE, $order='', $excludePattern='')
static redirect($url, $httpStatus=self::HTTP_STATUS_303)
Definition: HttpUtility.php:76
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static getFileAbsFileName($filename, $onlyRelative=TRUE, $relToTYPO3_mainDir=FALSE)
static deleteClause($table, $tableAlias='')
static TYPO3_copyRightNotice($showVersionNumber=TRUE)