index.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2010 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Login-screen of TYPO3.
00029  *
00030  * $Id: index.php 7905 2010-06-13 14:42:33Z ohader $
00031  * Revised for TYPO3 3.6 December/2003 by Kasper Skaarhoj
00032  * XHTML compliant
00033  *
00034  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00035  */
00036 /**
00037  * [CLASS/FUNCTION INDEX of SCRIPT]
00038  *
00039  *
00040  *
00041  *   87: class SC_index
00042  *  120:     function init()
00043  *  159:     function main()
00044  *  268:     function printContent()
00045  *
00046  *              SECTION: Various functions
00047  *  292:     function makeLoginForm()
00048  *  337:     function makeLogoutForm()
00049  *  379:     function wrapLoginForm($content)
00050  *  438:     function checkRedirect()
00051  *  495:     function makeInterfaceSelectorBox()
00052  *  549:     function makeCopyrightNotice()
00053  *  582:     function makeLoginBoxImage()
00054  *  622:     function makeLoginNews()
00055  *
00056  * TOTAL FUNCTIONS: 11
00057  * (This index is automatically created/updated by the extension "extdeveval")
00058  *
00059  */
00060 
00061 
00062 define('TYPO3_PROCEED_IF_NO_USER', 1);
00063 require('init.php');
00064 require('template.php');
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 /**
00081  * Script Class for rendering the login form
00082  *
00083  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00084  * @package TYPO3
00085  * @subpackage core
00086  */
00087 class SC_index {
00088 
00089         // Internal, GPvars:
00090     var $redirect_url;          // GPvar: redirect_url; The URL to redirect to after login.
00091     var $GPinterface;           // GPvar: Defines which interface to load (from interface selector)
00092     var $u;                 // GPvar: preset username
00093     var $p;                 // GPvar: preset password
00094     var $L;                 // GPvar: If "L" is "OUT", then any logged in used is logged out. If redirect_url is given, we redirect to it
00095     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.
00096     var $commandLI;             // Value of forms submit button for login.
00097 
00098         // Internal, static:
00099     var $redirectToURL;         // Set to the redirect URL of the form (may be redirect_url or "backend.php")
00100 
00101         // Internal, dynamic:
00102     var $content;               // Content accumulation
00103 
00104     var $interfaceSelector;         // A selector box for selecting value for "interface" may be rendered into this variable
00105     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
00106     var $interfaceSelector_hidden;  // A hidden field, if the interface is not set.
00107     var $addFields_hidden = '';     // Additional hidden fields to be placed at the login form
00108 
00109         // sets the level of security. *'normal' = clear-text. 'challenged' = hashed password/username from form in $formfield_uident. 'superchallenged' = hashed password hashed again with username.
00110     var $loginSecurityLevel = 'superchallenged';
00111 
00112 
00113 
00114 
00115     /**
00116      * Initialize the login box. Will also react on a &L=OUT flag and exit.
00117      *
00118      * @return  void
00119      */
00120     function init() {
00121             // We need a PHP session session for most login levels
00122         session_start();
00123 
00124         $this->redirect_url = t3lib_div::_GP('redirect_url');
00125         $this->GPinterface = t3lib_div::_GP('interface');
00126 
00127             // Grabbing preset username and password, for security reasons this feature only works if SSL is used
00128         if (t3lib_div::getIndpEnv('TYPO3_SSL')) {
00129             $this->u = t3lib_div::_GP('u');
00130             $this->p = t3lib_div::_GP('p');
00131         }
00132 
00133             // If "L" is "OUT", then any logged in is logged out. If redirect_url is given, we redirect to it
00134         $this->L = t3lib_div::_GP('L');
00135 
00136             // Login
00137         $this->loginRefresh = t3lib_div::_GP('loginRefresh');
00138 
00139             // Value of "Login" button. If set, the login button was pressed.
00140         $this->commandLI = t3lib_div::_GP('commandLI');
00141 
00142             // sets the level of security from conf vars
00143         if ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) {
00144             $this->loginSecurityLevel = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'];
00145         }
00146 
00147             // try to get the preferred browser language
00148         $preferredBrowserLanguage = $GLOBALS['LANG']->csConvObj->getPreferredClientLanguage(t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE'));
00149             // if we found a $preferredBrowserLanguage and it is not the default language and no be_user is logged in
00150             // initialize $GLOBALS['LANG'] again with $preferredBrowserLanguage
00151         if ($preferredBrowserLanguage != 'default' && !$GLOBALS['BE_USER']->user['uid']) {
00152             $GLOBALS['LANG']->init($preferredBrowserLanguage);
00153         }
00154         $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_login.xml');
00155 
00156             // check if labels from $GLOBALS['TYPO3_CONF_VARS']['BE']['loginLabels'] were changed,
00157             // and merge them to $GLOBALS['LOCAL_LANG'] if needed
00158         $this->mergeOldLoginLabels();
00159 
00160             // Setting the redirect URL to "backend.php" if no alternative input is given
00161         $this->redirectToURL = ($this->redirect_url ? $this->redirect_url : 'backend.php');
00162 
00163 
00164             // Do a logout if the command is set
00165         if ($this->L == 'OUT' && is_object($GLOBALS['BE_USER'])) {
00166             $GLOBALS['BE_USER']->logoff();
00167             if ($this->redirect_url) {
00168                 t3lib_utility_Http::redirect($this->redirect_url);
00169             }
00170             exit;
00171         }
00172     }
00173 
00174 
00175     /**
00176      * Main function - creating the login/logout form
00177      *
00178      * @return  void
00179      */
00180     function main() {
00181         global $TBE_TEMPLATE, $TYPO3_CONF_VARS, $BE_USER;
00182 
00183             // Initialize template object:
00184         $TBE_TEMPLATE->bodyTagAdditions = ' onload="startUp();"';
00185         $TBE_TEMPLATE->moduleTemplate = $TBE_TEMPLATE->getHtmlTemplate('templates/login.html');
00186 
00187         $TBE_TEMPLATE->getPageRenderer()->loadExtJS();
00188         $TBE_TEMPLATE->getPageRenderer()->loadPrototype();
00189         $TBE_TEMPLATE->getPageRenderer()->loadScriptaculous();
00190 
00191             // Set JavaScript for creating a MD5 hash of the password:
00192         $TBE_TEMPLATE->JScode.= $this->getJScode();
00193 
00194             // Checking, if we should make a redirect.
00195             // Might set JavaScript in the header to close window.
00196         $this->checkRedirect();
00197 
00198             // Initialize interface selectors:
00199         $this->makeInterfaceSelectorBox();
00200 
00201             // Creating form based on whether there is a login or not:
00202         if (!$BE_USER->user['uid']) {
00203             $TBE_TEMPLATE->form = $this->startForm();
00204             $loginForm = $this->makeLoginForm();
00205         } else {
00206             $TBE_TEMPLATE->form = '
00207                 <form action="index.php" method="post" name="loginform">
00208                 <input type="hidden" name="login_status" value="logout" />
00209                 ';
00210             $loginForm = $this->makeLogoutForm();
00211         }
00212 
00213             // Starting page:
00214         $this->content.=$TBE_TEMPLATE->startPage('TYPO3 Login: '.$TYPO3_CONF_VARS['SYS']['sitename']);
00215 
00216             // Add login form:
00217         $this->content.=$this->wrapLoginForm($loginForm);
00218 
00219         $this->content.= $TBE_TEMPLATE->endPage();
00220     }
00221 
00222     /**
00223      * Outputting the accumulated content to screen
00224      *
00225      * @return  void
00226      */
00227     function printContent() {
00228         echo $this->content;
00229     }
00230 
00231     /*****************************
00232      *
00233      * Various functions
00234      *
00235      ******************************/
00236 
00237     /**
00238      * Creates the login form
00239      * This is drawn when NO login exists.
00240      *
00241      * @return  string      HTML output
00242      */
00243     function makeLoginForm()    {
00244         $content = t3lib_parsehtml::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###LOGIN_FORM###');
00245         $markers = array(
00246             'VALUE_USERNAME' => htmlspecialchars($this->u),
00247             'VALUE_PASSWORD' => htmlspecialchars($this->p),
00248             'VALUE_SUBMIT'   => $GLOBALS['LANG']->getLL('labels.submitLogin', true),
00249         );
00250 
00251             // show an error message if the login command was successful already, otherwise remove the subpart
00252         if (!$this->commandLI) {
00253             $content = t3lib_parsehtml::substituteSubpart($content, '###LOGIN_ERROR###', '');
00254         } else {
00255             $markers['ERROR_MESSAGE'] = $GLOBALS['LANG']->getLL('error.login', true);
00256             $markers['ERROR_LOGIN_TITLE'] = $GLOBALS['LANG']->getLL('error.login.title', true);
00257             $markers['ERROR_LOGIN_DESCRIPTION'] = $GLOBALS['LANG']->getLL('error.login.description', true);
00258         }
00259 
00260 
00261             // remove the interface selector markers if it's not available
00262         if (!($this->interfaceSelector && !$this->loginRefresh)) {
00263             $content = t3lib_parsehtml::substituteSubpart($content, '###INTERFACE_SELECTOR###', '');
00264         } else {
00265             $markers['LABEL_INTERFACE'] = $GLOBALS['LANG']->getLL('labels.interface', true);
00266             $markers['VALUE_INTERFACE'] = $this->interfaceSelector;
00267         }
00268 
00269         return t3lib_parsehtml::substituteMarkerArray($content, $markers, '###|###');
00270     }
00271 
00272 
00273     /**
00274      * Creates the logout form
00275      * This is drawn if a user login already exists.
00276      *
00277      * @return  string      HTML output
00278      */
00279     function makeLogoutForm() {
00280         $content = t3lib_parsehtml::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###LOGOUT_FORM###');
00281         $markers = array(
00282             'LABEL_USERNAME' => $GLOBALS['LANG']->getLL('labels.username', true),
00283             'VALUE_USERNAME' => htmlspecialchars($GLOBALS['BE_USER']->user['username']),
00284             'VALUE_SUBMIT'   => $GLOBALS['LANG']->getLL('labels.submitLogout', true),
00285         );
00286 
00287             // remove the interface selector markers if it's not available
00288         if (!$this->interfaceSelector_jump) {
00289             $content = t3lib_parsehtml::substituteSubpart($content, '###INTERFACE_SELECTOR###', '');
00290         } else {
00291             $markers['LABEL_INTERFACE'] = $GLOBALS['LANG']->getLL('labels.interface', true);
00292             $markers['VALUE_INTERFACE'] = $this->interfaceSelector_jump;
00293         }
00294 
00295         return t3lib_parsehtml::substituteMarkerArray($content, $markers, '###|###');
00296     }
00297 
00298 
00299     /**
00300      * Wrapping the login form table in another set of tables etc:
00301      *
00302      * @param   string      HTML content for the login form
00303      * @return  string      The HTML for the page.
00304      */
00305     function wrapLoginForm($content) {
00306         $mainContent = t3lib_parsehtml::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###PAGE###');
00307 
00308         if ($GLOBALS['TBE_STYLES']['logo_login']) {
00309             $logo = '<img src="'.htmlspecialchars($GLOBALS['BACK_PATH'] . $GLOBALS['TBE_STYLES']['logo_login']) . '" alt="" />';
00310         } else {
00311             $logo = '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/typo3logo.gif','width="123" height="34"').' alt="" />';
00312         }
00313 
00314         $markers = array(
00315             'LOGO'             => $logo,
00316             'LOGINBOX_IMAGE'   => $this->makeLoginBoxImage(),
00317             'FORM'             => $content,
00318             'NEWS'             => $this->makeLoginNews(),
00319             'COPYRIGHT'        => $this->makeCopyrightNotice(),
00320             'CSS_ERRORCLASS'   => ($this->commandLI ? ' class="error"' : ''),
00321             'CSS_OPENIDCLASS'  => 't3-login-openid-' . (t3lib_extMgm::isLoaded('openid') ? 'enabled' : 'disabled'),
00322 
00323                 // the labels will be replaced later on, thus the other parts above
00324                 // can use these markers as well and it will be replaced
00325             'HEADLINE'         => $GLOBALS['LANG']->getLL('headline', true),
00326             'INFO_ABOUT'       => $GLOBALS['LANG']->getLL('info.about', true),
00327             'INFO_RELOAD'      => $GLOBALS['LANG']->getLL('info.reset', true),
00328             'INFO'             => $GLOBALS['LANG']->getLL('info.cookies_and_js', true),
00329             'ERROR_JAVASCRIPT' => $GLOBALS['LANG']->getLL('error.javascript', true),
00330             'ERROR_COOKIES'    => $GLOBALS['LANG']->getLL('error.cookies', true),
00331             'ERROR_COOKIES_IGNORE' => $GLOBALS['LANG']->getLL('error.cookies_ignore', true),
00332             'ERROR_CAPSLOCK'   => $GLOBALS['LANG']->getLL('error.capslock', true),
00333             'ERROR_FURTHERHELP' => $GLOBALS['LANG']->getLL('error.furtherInformation', true),
00334             'LABEL_DONATELINK' => $GLOBALS['LANG']->getLL('labels.donate', true),
00335             'LABEL_USERNAME'   => $GLOBALS['LANG']->getLL('labels.username', true),
00336             'LABEL_OPENID'     => $GLOBALS['LANG']->getLL('labels.openId', true),
00337             'LABEL_PASSWORD'   => $GLOBALS['LANG']->getLL('labels.password', true),
00338             'LABEL_WHATISOPENID' => $GLOBALS['LANG']->getLL('labels.whatIsOpenId', true),
00339             'LABEL_SWITCHOPENID' => $GLOBALS['LANG']->getLL('labels.switchToOpenId', true),
00340             'LABEL_SWITCHDEFAULT' => $GLOBALS['LANG']->getLL('labels.switchToDefault', true),
00341             'CLEAR'            => $GLOBALS['LANG']->getLL('clear', true),
00342             'LOGIN_PROCESS'    => $GLOBALS['LANG']->getLL('login_process', true),
00343             'SITELINK'         => '<a href="/">###SITENAME###</a>',
00344 
00345                 // global variables will now be replaced (at last)
00346             'SITENAME'         => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']
00347         );
00348         return t3lib_parsehtml::substituteMarkerArray($mainContent, $markers, '###|###');
00349     }
00350 
00351 
00352     /**
00353      * Checking, if we should perform some sort of redirection OR closing of windows.
00354      *
00355      * @return  void
00356      */
00357     function checkRedirect()    {
00358         global $BE_USER,$TBE_TEMPLATE;
00359 
00360             // Do redirect:
00361             // 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...)
00362         if ($BE_USER->user['uid'] && ($this->commandLI || $this->loginRefresh || !$this->interfaceSelector))    {
00363 
00364                 // 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.
00365             if (!$_COOKIE[$BE_USER->name]) {
00366                 if ($this->commandLI=='setCookie') {
00367                         // we tried it a second time but still no cookie
00368                         // 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.
00369                     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);
00370                     exit;
00371                 } else {
00372                         // try it once again - that might be needed for auto login
00373                     $this->redirectToURL = 'index.php?commandLI=setCookie';
00374                 }
00375             }
00376 
00377             if (($redirectToURL = (string)$BE_USER->getTSConfigVal('auth.BE.redirectToURL'))) {
00378                 $this->redirectToURL = $redirectToURL;
00379                 $this->GPinterface = '';
00380             }
00381 
00382                 // store interface
00383             $BE_USER->uc['interfaceSetup'] = $this->GPinterface;
00384             $BE_USER->writeUC();
00385 
00386                 // Based on specific setting of interface we set the redirect script:
00387             switch ($this->GPinterface) {
00388                 case 'backend':
00389                 case 'backend_old':
00390                     $this->redirectToURL = 'backend.php';
00391                 break;
00392                 case 'frontend':
00393                     $this->redirectToURL = '../';
00394                 break;
00395             }
00396 
00397                 // If there is a redirect URL AND if loginRefresh is not set...
00398             if (!$this->loginRefresh)   {
00399                 t3lib_utility_Http::redirect($this->redirectToURL);
00400             } else {
00401                 $TBE_TEMPLATE->JScode.=$TBE_TEMPLATE->wrapScriptTags('
00402                     if (parent.opener && (parent.opener.busy || parent.opener.TYPO3.loginRefresh)) {
00403                         if (parent.opener.TYPO3.loginRefresh) {
00404                             parent.opener.TYPO3.loginRefresh.startTimer();
00405                         } else {
00406                             parent.opener.busy.loginRefreshed();
00407                         }
00408                         parent.close();
00409                     }
00410                 ');
00411             }
00412         } elseif (!$BE_USER->user['uid'] && $this->commandLI) {
00413             sleep(5);   // Wrong password, wait for 5 seconds
00414         }
00415     }
00416 
00417     /**
00418      * Making interface selector:
00419      *
00420      * @return  void
00421      */
00422     function makeInterfaceSelectorBox() {
00423         global $TYPO3_CONF_VARS;
00424 
00425             // Reset variables:
00426         $this->interfaceSelector = '';
00427         $this->interfaceSelector_hidden='';
00428         $this->interfaceSelector_jump = '';
00429 
00430             // If interfaces are defined AND no input redirect URL in GET vars:
00431         if ($TYPO3_CONF_VARS['BE']['interfaces'] && ($this->commandLI || !$this->redirect_url)) {
00432             $parts = t3lib_div::trimExplode(',',$TYPO3_CONF_VARS['BE']['interfaces']);
00433             if (count($parts)>1)    {   // Only if more than one interface is defined will we show the selector:
00434 
00435                     // Initialize:
00436                 $labels=array();
00437 
00438                 $labels['backend']     = $GLOBALS['LANG']->getLL('interface.backend');
00439                 $labels['backend_old'] = $GLOBALS['LANG']->getLL('interface.backend_old');
00440                 $labels['frontend']    = $GLOBALS['LANG']->getLL('interface.frontend');
00441 
00442                 $jumpScript=array();
00443                 $jumpScript['backend']     = 'backend.php';
00444                 $jumpScript['backend_old'] = 'backend.php';
00445                 $jumpScript['frontend']    = '../';
00446 
00447                     // Traverse the interface keys:
00448                 foreach($parts as $valueStr)    {
00449                     $this->interfaceSelector.='
00450                             <option value="'.htmlspecialchars($valueStr).'"'.(t3lib_div::_GP('interface')==htmlspecialchars($valueStr) ? ' selected="selected"' : '').'>'.htmlspecialchars($labels[$valueStr]).'</option>';
00451                     $this->interfaceSelector_jump.='
00452                             <option value="'.htmlspecialchars($jumpScript[$valueStr]).'">'.htmlspecialchars($labels[$valueStr]).'</option>';
00453                 }
00454                 $this->interfaceSelector='
00455                         <select id="t3-interfaceselector" name="interface" class="c-interfaceselector" tabindex="3">'.$this->interfaceSelector.'
00456                         </select>';
00457                 $this->interfaceSelector_jump='
00458                         <select id="t3-interfaceselector" name="interface" class="c-interfaceselector" tabindex="3" onchange="window.location.href=this.options[this.selectedIndex].value;">'.$this->interfaceSelector_jump.'
00459                         </select>';
00460 
00461             } else {    // If there is only ONE interface value set:
00462 
00463                 $this->interfaceSelector_hidden='<input type="hidden" name="interface" value="'.trim($TYPO3_CONF_VARS['BE']['interfaces']).'" />';
00464             }
00465         }
00466     }
00467 
00468     /**
00469      * COPYRIGHT notice
00470      *
00471      * Warning:
00472      * DO NOT prevent this notice from being shown in ANY WAY.
00473      * 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)
00474      * 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.
00475      *
00476      * @return  string      Text/Image (HTML) for copyright notice.
00477      */
00478     function makeCopyrightNotice()  {
00479 
00480             // Get values from TYPO3_CONF_VARS:
00481         $loginCopyrightWarrantyProvider = strip_tags(trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightWarrantyProvider']));
00482         $loginCopyrightWarrantyURL = strip_tags(trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightWarrantyURL']));
00483         $loginImageSmall = (trim($GLOBALS['TBE_STYLES']['loginBoxImageSmall'])) ? trim($GLOBALS['TBE_STYLES']['loginBoxImageSmall']) : 'gfx/loginlogo_transp.gif';
00484 
00485             // Make warranty note:
00486         if (strlen($loginCopyrightWarrantyProvider)>=2 && strlen($loginCopyrightWarrantyURL)>=10)   {
00487             $warrantyNote = sprintf($GLOBALS['LANG']->getLL('warranty.by'), htmlspecialchars($loginCopyrightWarrantyProvider), '<a href="' . htmlspecialchars($loginCopyrightWarrantyURL) . '" target="_blank">', '</a>');
00488         } else {
00489             $warrantyNote = sprintf($GLOBALS['LANG']->getLL('no.warranty'), '<a href="http://typo3.com/1316.0.html" target="_blank">', '</a>');
00490         }
00491 
00492             // Compile full copyright notice:
00493         $copyrightNotice = '<a href="http://typo3.com/" target="_blank">'.
00494                     '<img src="' . $loginImageSmall . '" alt="' . $GLOBALS['LANG']->getLL('typo3.logo') . '" align="left" />' .
00495                     $GLOBALS['LANG']->getLL('typo3.cms') . ($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightShowVersion']?' ' . $GLOBALS['LANG']->getLL('version.short') . ' ' . htmlspecialchars($GLOBALS['TYPO_VERSION']):'') .
00496                     '</a>. ' .
00497                     $GLOBALS['LANG']->getLL('copyright') . ' &copy; ' . TYPO3_copyright_year . ' Kasper Sk&#229;rh&#248;j. ' . $GLOBALS['LANG']->getLL('extension.copyright') . ' ' .
00498                     sprintf($GLOBALS['LANG']->getLL('details.link'), '<a href="http://typo3.com/" target="_blank">http://typo3.com/</a>') . '<br /> ' .
00499                     $warrantyNote . ' ' .
00500                     sprintf($GLOBALS['LANG']->getLL('free.software'), '<a href="http://typo3.com/1316.0.html" target="_blank">', '</a> ') .
00501                     $GLOBALS['LANG']->getLL('keep.notice');
00502 
00503             // Return notice:
00504         return $copyrightNotice;
00505     }
00506 
00507     /**
00508      * Returns the login box image, whether the default or an image from the rotation folder.
00509      *
00510      * @return  string      HTML image tag.
00511      */
00512     function makeLoginBoxImage()    {
00513         $loginboxImage = '';
00514         if ($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']) {       // Look for rotation image folder:
00515             $absPath = t3lib_div::resolveBackPath(PATH_typo3.$GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']);
00516 
00517                 // Get rotation folder:
00518             $dir = t3lib_div::getFileAbsFileName($absPath);
00519             if ($dir && @is_dir($dir))  {
00520 
00521                     // Get files for rotation into array:
00522                 $files = t3lib_div::getFilesInDir($dir,'png,jpg,gif');
00523 
00524                     // Pick random file:
00525                 $randImg = array_rand($files, 1);
00526 
00527                     // Get size of random file:
00528                 $imgSize = @getimagesize($dir.$files[$randImg]);
00529 
00530                 $imgAuthor = is_array($GLOBALS['TBE_STYLES']['loginBoxImage_author'])&&$GLOBALS['TBE_STYLES']['loginBoxImage_author'][$files[$randImg]] ? htmlspecialchars($GLOBALS['TBE_STYLES']['loginBoxImage_author'][$files[$randImg]]) : '';
00531 
00532                     // Create image tag:
00533                 if (is_array($imgSize)) {
00534                     $loginboxImage = '<img src="'.htmlspecialchars($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder'].$files[$randImg]).'" '.$imgSize[3].' id="loginbox-image" alt="'.$imgAuthor.'" title="'.$imgAuthor.'" />';
00535                 }
00536             }
00537         } else {    // If no rotation folder configured, print default image:
00538 
00539             if (strstr(TYPO3_version,'-dev'))   {   // development version
00540                 $loginImage = 'loginbox_image_dev.png';
00541                 $imagecopy = 'You are running a development version of TYPO3 '.TYPO3_branch;
00542             } else {
00543                 $loginImage = 'loginbox_image.jpg';
00544                 $imagecopy = 'Photo by J.C. Franca (www.digitalphoto.com.br)';
00545             }
00546             $loginboxImage = '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/'.$loginImage,'width="200" height="133"').' id="loginbox-image" alt="'.$imagecopy.'" title="'.$imagecopy.'" />';
00547         }
00548 
00549             // Return image tag:
00550         return $loginboxImage;
00551     }
00552 
00553     /**
00554      * Make login news - renders the HTML content for a list of news shown under
00555      * the login form. News data is added through $TYPO3_CONF_VARS
00556      *
00557      * @return  string      HTML content
00558      * @credits         Idea by Jan-Hendrik Heuing
00559      */
00560     function makeLoginNews() {
00561         $newsContent = '';
00562 
00563             // Traverse news array IF there are records in it:
00564         if (is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews']) && count($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews']) && !t3lib_div::_GP('loginRefresh')) {
00565 
00566                 // get the main news template, and replace the subpart after looped through
00567             $newsContent      = t3lib_parsehtml::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###LOGIN_NEWS###');
00568             $newsItemTemplate = t3lib_parsehtml::getSubpart($newsContent, '###NEWS_ITEM###');
00569 
00570             $newsItemContent = '';
00571             $count = 1;
00572             foreach ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] as $newsItem) {
00573                 $additionalClass = '';
00574                 if ($count == 1) {
00575                     $additionalClass = ' first-item';
00576                 } elseif($count == count($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'])) {
00577                     $additionalClass = ' last-item';
00578                 }
00579                 $newsItemMarker = array(
00580                     '###HEADER###'  => htmlspecialchars($newsItem['header']),
00581                     '###DATE###'    => htmlspecialchars($newsItem['date']),
00582                     '###CONTENT###' => trim($newsItem['content']),
00583                     '###CLASS###'   => $additionalClass
00584                 );
00585 
00586                 $count++;
00587                 $newsItemContent .= t3lib_parsehtml::substituteMarkerArray($newsItemTemplate, $newsItemMarker);
00588             }
00589 
00590             $title = ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] : $GLOBALS['LANG']->getLL('newsheadline'));
00591 
00592             $newsContent = t3lib_parsehtml::substituteMarker($newsContent,  '###NEWS_HEADLINE###', htmlspecialchars($title));
00593             $newsContent = t3lib_parsehtml::substituteSubpart($newsContent, '###NEWS_ITEM###', $newsItemContent);
00594         }
00595 
00596         return $newsContent;
00597     }
00598 
00599     /**
00600      * Returns the form tag
00601      *
00602      * @return  string      Opening form tag string
00603      */
00604     function startForm()    {
00605         $output = '';
00606 
00607         // The form defaults to 'no login'. This prevents plain
00608         // text logins to the Backend. The 'sv' extension changes the form to
00609         // use superchallenged method and rsaauth extension makes rsa authetication.
00610         $form = '<form action="index.php" method="post" name="loginform" ' .
00611                 'onsubmit="alert(\'No authentication methods available. Please, ' .
00612                 'contact your TYPO3 administrator.\');return false">';
00613 
00614         // Call hooks. If they do not return anything, we fail to login
00615         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginFormHook'])) {
00616             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginFormHook'] as $function) {
00617                 $params = array();
00618                 $formCode = t3lib_div::callUserFunction($function, $params, $this);
00619                 if ($formCode) {
00620                     $form = $formCode;
00621                     break;
00622                 }
00623             }
00624         }
00625 
00626         $output .= $form .
00627             '<input type="hidden" name="login_status" value="login" />' .
00628             '<input type="hidden" name="userident" value="" />' .
00629             '<input type="hidden" name="redirect_url" value="'.htmlspecialchars($this->redirectToURL).'" />' .
00630             '<input type="hidden" name="loginRefresh" value="'.htmlspecialchars($this->loginRefresh).'" />' .
00631             $this->interfaceSelector_hidden . $this->addFields_hidden;
00632 
00633         return $output;
00634     }
00635 
00636     /**
00637      * Outputs an empty string. This function is obsolete and kept for the
00638      * compatibility only.
00639      *
00640      * @param   string  $unused Unused
00641      * @return  string      HTML output
00642      * @deprecated since TYPO3 4.3, all the functionality was put in $this->startForm() and $this->addFields_hidden
00643      */
00644     function getHiddenFields($unused = '') {
00645         t3lib_div::logDeprecatedFunction();
00646         return '';
00647     }
00648 
00649     /**
00650      * Creates JavaScript for the login form
00651      *
00652      * @return  string      JavaScript code
00653      */
00654     function getJScode()    {
00655         $JSCode = '';
00656         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginScriptHook'])) {
00657             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginScriptHook'] as $function) {
00658                 $params = array();
00659                 $JSCode = t3lib_div::callUserFunction($function, $params, $this);
00660                 if ($JSCode) {
00661                     break;
00662                 }
00663             }
00664         }
00665         $JSCode .= $GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
00666             function startUp() {
00667                     // 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:
00668                 try {
00669                     if (parent.opener && parent.opener.TS && parent.opener.TS.username && document.loginform && document.loginform.username)    {
00670                         document.loginform.username.value = parent.opener.TS.username;
00671                     }
00672                 }
00673                 catch(error) {
00674                     //continue
00675                 }
00676 
00677                     // Wait a few millisecons before calling checkFocus(). This might be necessary because some browsers need some time to auto-fill in the form fields
00678                 window.setTimeout("checkFocus()", 50);
00679             }
00680 
00681                 // This moves focus to the right input field:
00682             function checkFocus() {
00683                     // If for some reason there already is a username in the username form field, move focus to the password field:
00684                 if (document.loginform.username && document.loginform.username.value == "") {
00685                     document.loginform.username.focus();
00686                 } else if (document.loginform.p_field && document.loginform.p_field.type!="hidden") {
00687                     document.loginform.p_field.focus();
00688                 }
00689             }
00690 
00691                 // This function shows a warning, if user has capslock enabled
00692                 // parameter showWarning: shows warning if true and capslock active, otherwise only hides warning, if capslock gets inactive
00693             function checkCapslock(e, showWarning) {
00694                 if (!isCapslock(e)) {
00695                     document.getElementById(\'t3-capslock\').style.display = \'none\';
00696                 } else if (showWarning) {
00697                     document.getElementById(\'t3-capslock\').style.display = \'block\';
00698                 }
00699             }
00700 
00701                 // Checks weather capslock is enabled (returns true if enabled, false otherwise)
00702                 // thanks to http://24ways.org/2007/capturing-caps-lock
00703 
00704             function isCapslock(e) {
00705                 var ev = e ? e : window.event;
00706                 if (!ev) {
00707                     return;
00708                 }
00709                 var targ = ev.target ? ev.target : ev.srcElement;
00710                 // get key pressed
00711                 var which = -1;
00712                 if (ev.which) {
00713                     which = ev.which;
00714                 } else if (ev.keyCode) {
00715                     which = ev.keyCode;
00716                 }
00717                 // get shift status
00718                 var shift_status = false;
00719                 if (ev.shiftKey) {
00720                     shift_status = ev.shiftKey;
00721                 } else if (ev.modifiers) {
00722                     shift_status = !!(ev.modifiers & 4);
00723                 }
00724                 return (((which >= 65 && which <= 90) && !shift_status) ||
00725                     ((which >= 97 && which <= 122) && shift_status));
00726             }
00727 
00728                 // prevent opening the login form in the backend frameset
00729             if (top.location.href != self.location.href) {
00730                 top.location.href = self.location.href;
00731             }
00732 
00733             ');
00734 
00735         return $JSCode;
00736     }
00737 
00738 
00739     /**
00740      * Checks if labels from $GLOBALS['TYPO3_CONF_VARS']['BE']['loginLabels'] were changed, and merge them to $GLOBALS['LOCAL_LANG'] if needed
00741      *
00742      * This method keeps backwards compatibility, if you modified your
00743      * labels with the install tool, we recommend to transfer this labels to a locallang.xml file
00744      * using the llxml extension
00745      *
00746      * @return  void
00747      */
00748     protected function mergeOldLoginLabels() {
00749             // Getting login labels
00750         $oldLoginLabels = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['loginLabels']);
00751         if ($oldLoginLabels != '') {
00752                 // md5 hash of the default loginLabels string
00753             $defaultOldLoginLabelsHash = 'bcf0d32e58c6454ea50c6c956f1f18f0';
00754                 // compare loginLabels from TYPO3_CONF_VARS to default value
00755             if (md5($oldLoginLabels) != $defaultOldLoginLabelsHash) {
00756                 $lang = $GLOBALS['LANG']->lang;
00757                 $oldLoginLabelArray = explode('|',$oldLoginLabels);
00758                 $overrideLabelKeys = array(
00759                     'labels.username'     => $oldLoginLabelArray[0],
00760                     'labels.password'     => $oldLoginLabelArray[1],
00761                     'labels.interface'    => $oldLoginLabelArray[2],
00762                     'labels.submitLogin'  => $oldLoginLabelArray[3],
00763                     'labels.submitLogout' => $oldLoginLabelArray[4],
00764                     'availableInterfaces' => $oldLoginLabelArray[5],
00765                     'headline'            => $oldLoginLabelArray[6],
00766                     'info.jscookies'      => $oldLoginLabelArray[7],
00767                     'newsheadline'        => $oldLoginLabelArray[8],
00768                     'error.login'         => $oldLoginLabelArray[9],
00769                 );
00770                 if (!is_array($GLOBALS['LOCAL_LANG'][$lang])) {
00771                     $GLOBALS['LOCAL_LANG'][$lang] = array();
00772                 }
00773                     // now override the labels from the LOCAL_LANG with the TYPO3_CONF_VARS
00774                 foreach ($overrideLabelKeys as $labelKey => $label) {
00775                     $GLOBALS['LOCAL_LANG'][$lang][$labelKey] = $GLOBALS['LOCAL_LANG']['default'][$labelKey] = $label;
00776                 }
00777             }
00778         }
00779     }
00780 }
00781 
00782 
00783 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/index.php']) {
00784     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/index.php']);
00785 }
00786 
00787 
00788 
00789 // Make instance:
00790 $SOBE = t3lib_div::makeInstance('SC_index');
00791 $SOBE->init();
00792 $SOBE->main();
00793 $SOBE->printContent();
00794 
00795 ?>

Generated on Sat Jul 24 04:17:15 2010 for TYPO3 API by  doxygen 1.4.7