|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2011 Kasper Skårhøj (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 10568 2011-02-22 22:52:34Z steffenk $ 00031 * Revised for TYPO3 3.6 December/2003 by Kasper Skårhøj 00032 * XHTML compliant 00033 * 00034 * @author Kasper Skårhøj <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 Skårhøj <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::sanitizeLocalUrl(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: ' . htmlspecialchars($TYPO3_CONF_VARS['SYS']['sitename']), FALSE); 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' => htmlspecialchars($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 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.'); 00370 } else { 00371 // try it once again - that might be needed for auto login 00372 $this->redirectToURL = 'index.php?commandLI=setCookie'; 00373 } 00374 } 00375 00376 if (($redirectToURL = (string)$BE_USER->getTSConfigVal('auth.BE.redirectToURL'))) { 00377 $this->redirectToURL = $redirectToURL; 00378 $this->GPinterface = ''; 00379 } 00380 00381 // store interface 00382 $BE_USER->uc['interfaceSetup'] = $this->GPinterface; 00383 $BE_USER->writeUC(); 00384 00385 // Based on specific setting of interface we set the redirect script: 00386 switch ($this->GPinterface) { 00387 case 'backend': 00388 case 'backend_old': 00389 $this->redirectToURL = 'backend.php'; 00390 break; 00391 case 'frontend': 00392 $this->redirectToURL = '../'; 00393 break; 00394 } 00395 00396 // If there is a redirect URL AND if loginRefresh is not set... 00397 if (!$this->loginRefresh) { 00398 t3lib_utility_Http::redirect($this->redirectToURL); 00399 } else { 00400 $formprotection = t3lib_formprotection_Factory::get(); 00401 $accessToken = $formprotection->generateToken('refreshTokens'); 00402 $formprotection->persistTokens(); 00403 $TBE_TEMPLATE->JScode.=$TBE_TEMPLATE->wrapScriptTags(' 00404 if (parent.opener && (parent.opener.busy || parent.opener.TYPO3.loginRefresh)) { 00405 if (parent.opener.TYPO3.loginRefresh) { 00406 parent.opener.TYPO3.loginRefresh.startTimer(); 00407 } else { 00408 parent.opener.busy.loginRefreshed(); 00409 } 00410 parent.opener.TYPO3.loginRefresh.refreshTokens("' . $accessToken . '"); 00411 parent.close(); 00412 } 00413 '); 00414 } 00415 } elseif (!$BE_USER->user['uid'] && $this->commandLI) { 00416 sleep(5); // Wrong password, wait for 5 seconds 00417 } 00418 } 00419 00420 /** 00421 * Making interface selector: 00422 * 00423 * @return void 00424 */ 00425 function makeInterfaceSelectorBox() { 00426 global $TYPO3_CONF_VARS; 00427 00428 // Reset variables: 00429 $this->interfaceSelector = ''; 00430 $this->interfaceSelector_hidden=''; 00431 $this->interfaceSelector_jump = ''; 00432 00433 // If interfaces are defined AND no input redirect URL in GET vars: 00434 if ($TYPO3_CONF_VARS['BE']['interfaces'] && ($this->commandLI || !$this->redirect_url)) { 00435 $parts = t3lib_div::trimExplode(',',$TYPO3_CONF_VARS['BE']['interfaces']); 00436 if (count($parts)>1) { // Only if more than one interface is defined will we show the selector: 00437 00438 // Initialize: 00439 $labels=array(); 00440 00441 $labels['backend'] = $GLOBALS['LANG']->getLL('interface.backend'); 00442 $labels['backend_old'] = $GLOBALS['LANG']->getLL('interface.backend_old'); 00443 $labels['frontend'] = $GLOBALS['LANG']->getLL('interface.frontend'); 00444 00445 $jumpScript=array(); 00446 $jumpScript['backend'] = 'backend.php'; 00447 $jumpScript['backend_old'] = 'backend.php'; 00448 $jumpScript['frontend'] = '../'; 00449 00450 // Traverse the interface keys: 00451 foreach($parts as $valueStr) { 00452 $this->interfaceSelector.=' 00453 <option value="'.htmlspecialchars($valueStr).'"'.(t3lib_div::_GP('interface')==htmlspecialchars($valueStr) ? ' selected="selected"' : '').'>'.htmlspecialchars($labels[$valueStr]).'</option>'; 00454 $this->interfaceSelector_jump.=' 00455 <option value="'.htmlspecialchars($jumpScript[$valueStr]).'">'.htmlspecialchars($labels[$valueStr]).'</option>'; 00456 } 00457 $this->interfaceSelector=' 00458 <select id="t3-interfaceselector" name="interface" class="c-interfaceselector" tabindex="3">'.$this->interfaceSelector.' 00459 </select>'; 00460 $this->interfaceSelector_jump=' 00461 <select id="t3-interfaceselector" name="interface" class="c-interfaceselector" tabindex="3" onchange="window.location.href=this.options[this.selectedIndex].value;">'.$this->interfaceSelector_jump.' 00462 </select>'; 00463 00464 } elseif (!$this->redirect_url) { 00465 // If there is only ONE interface value set and no redirect_url is present: 00466 $this->interfaceSelector_hidden='<input type="hidden" name="interface" value="'.trim($TYPO3_CONF_VARS['BE']['interfaces']).'" />'; 00467 } 00468 } 00469 } 00470 00471 /** 00472 * COPYRIGHT notice 00473 * 00474 * Warning: 00475 * DO NOT prevent this notice from being shown in ANY WAY. 00476 * 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) 00477 * 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. 00478 * 00479 * @return string Text/Image (HTML) for copyright notice. 00480 */ 00481 function makeCopyrightNotice() { 00482 00483 // Get values from TYPO3_CONF_VARS: 00484 $loginCopyrightWarrantyProvider = strip_tags(trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightWarrantyProvider'])); 00485 $loginCopyrightWarrantyURL = strip_tags(trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightWarrantyURL'])); 00486 $loginImageSmall = (trim($GLOBALS['TBE_STYLES']['loginBoxImageSmall'])) ? trim($GLOBALS['TBE_STYLES']['loginBoxImageSmall']) : 'gfx/loginlogo_transp.gif'; 00487 00488 // Make warranty note: 00489 if (strlen($loginCopyrightWarrantyProvider)>=2 && strlen($loginCopyrightWarrantyURL)>=10) { 00490 $warrantyNote = sprintf($GLOBALS['LANG']->getLL('warranty.by'), htmlspecialchars($loginCopyrightWarrantyProvider), '<a href="' . htmlspecialchars($loginCopyrightWarrantyURL) . '" target="_blank">', '</a>'); 00491 } else { 00492 $warrantyNote = sprintf($GLOBALS['LANG']->getLL('no.warranty'), '<a href="' . TYPO3_URL_LICENSE . '" target="_blank">', '</a>'); 00493 } 00494 00495 // Compile full copyright notice: 00496 $copyrightNotice = '<a href="' . TYPO3_URL_GENERAL . '" target="_blank">'. 00497 '<img src="' . $loginImageSmall . '" alt="' . $GLOBALS['LANG']->getLL('typo3.logo') . '" align="left" />' . 00498 $GLOBALS['LANG']->getLL('typo3.cms') . ($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightShowVersion']?' ' . $GLOBALS['LANG']->getLL('version.short') . ' ' . htmlspecialchars($GLOBALS['TYPO_VERSION']):'') . 00499 '</a>. ' . 00500 $GLOBALS['LANG']->getLL('copyright') . ' © ' . TYPO3_copyright_year . ' Kasper Skårhøj. ' . $GLOBALS['LANG']->getLL('extension.copyright') . ' ' . 00501 sprintf($GLOBALS['LANG']->getLL('details.link'), '<a href="' . TYPO3_URL_GENERAL . '" target="_blank">' . TYPO3_URL_GENERAL . '</a>') . '<br /> ' . 00502 $warrantyNote . ' ' . 00503 sprintf($GLOBALS['LANG']->getLL('free.software'), '<a href="' . TYPO3_URL_LICENSE . '" target="_blank">', '</a> ') . 00504 $GLOBALS['LANG']->getLL('keep.notice'); 00505 00506 // Return notice: 00507 return $copyrightNotice; 00508 } 00509 00510 /** 00511 * Returns the login box image, whether the default or an image from the rotation folder. 00512 * 00513 * @return string HTML image tag. 00514 */ 00515 function makeLoginBoxImage() { 00516 $loginboxImage = ''; 00517 if ($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']) { // Look for rotation image folder: 00518 $absPath = t3lib_div::resolveBackPath(PATH_typo3.$GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']); 00519 00520 // Get rotation folder: 00521 $dir = t3lib_div::getFileAbsFileName($absPath); 00522 if ($dir && @is_dir($dir)) { 00523 00524 // Get files for rotation into array: 00525 $files = t3lib_div::getFilesInDir($dir,'png,jpg,gif'); 00526 00527 // Pick random file: 00528 $randImg = array_rand($files, 1); 00529 00530 // Get size of random file: 00531 $imgSize = @getimagesize($dir.$files[$randImg]); 00532 00533 $imgAuthor = is_array($GLOBALS['TBE_STYLES']['loginBoxImage_author'])&&$GLOBALS['TBE_STYLES']['loginBoxImage_author'][$files[$randImg]] ? htmlspecialchars($GLOBALS['TBE_STYLES']['loginBoxImage_author'][$files[$randImg]]) : ''; 00534 00535 // Create image tag: 00536 if (is_array($imgSize)) { 00537 $loginboxImage = '<img src="'.htmlspecialchars($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder'].$files[$randImg]).'" '.$imgSize[3].' id="loginbox-image" alt="'.$imgAuthor.'" title="'.$imgAuthor.'" />'; 00538 } 00539 } 00540 } else { // If no rotation folder configured, print default image: 00541 00542 if (strstr(TYPO3_version,'-dev')) { // development version 00543 $loginImage = 'loginbox_image_dev.png'; 00544 $imagecopy = 'You are running a development version of TYPO3 '.TYPO3_branch; 00545 } else { 00546 $loginImage = 'loginbox_image.jpg'; 00547 $imagecopy = 'Photo by J.C. Franca (www.digitalphoto.com.br)'; 00548 } 00549 $loginboxImage = '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/'.$loginImage,'width="200" height="133"').' id="loginbox-image" alt="'.$imagecopy.'" title="'.$imagecopy.'" />'; 00550 } 00551 00552 // Return image tag: 00553 return $loginboxImage; 00554 } 00555 00556 /** 00557 * Make login news - renders the HTML content for a list of news shown under 00558 * the login form. News data is added through $TYPO3_CONF_VARS 00559 * 00560 * @return string HTML content 00561 * @credits Idea by Jan-Hendrik Heuing 00562 * @deprecated $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] is deprecated since 4.5. Use system news records instead. 00563 */ 00564 function makeLoginNews() { 00565 $newsContent = ''; 00566 00567 $systemNews = $this->getSystemNews(); 00568 if (count($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'])) { 00569 t3lib_div::logDeprecatedFunction(); 00570 00571 $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] = array_merge( 00572 $systemNews, 00573 $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] 00574 ); 00575 } else { 00576 $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] = $systemNews; 00577 } 00578 00579 // Traverse news array IF there are records in it: 00580 if (is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews']) && count($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews']) && !t3lib_div::_GP('loginRefresh')) { 00581 $htmlParser = t3lib_div::makeInstance('t3lib_parsehtml_proc'); 00582 // get the main news template, and replace the subpart after looped through 00583 $newsContent = t3lib_parsehtml::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###LOGIN_NEWS###'); 00584 $newsItemTemplate = t3lib_parsehtml::getSubpart($newsContent, '###NEWS_ITEM###'); 00585 00586 $newsItem = ''; 00587 $count = 1; 00588 foreach ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] as $newsItemData) { 00589 $additionalClass = ''; 00590 if ($count == 1) { 00591 $additionalClass = ' first-item'; 00592 } elseif($count == count($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'])) { 00593 $additionalClass = ' last-item'; 00594 } 00595 00596 $newsItemContent = $htmlParser->TS_transform_rte($htmlParser->TS_links_rte($newsItemData['content'])); 00597 $newsItemMarker = array( 00598 '###HEADER###' => htmlspecialchars($newsItemData['header']), 00599 '###DATE###' => htmlspecialchars($newsItemData['date']), 00600 '###CONTENT###' => $newsItemContent, 00601 '###CLASS###' => $additionalClass 00602 ); 00603 00604 $count++; 00605 $newsItem .= t3lib_parsehtml::substituteMarkerArray($newsItemTemplate, $newsItemMarker); 00606 } 00607 00608 $title = ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] : $GLOBALS['LANG']->getLL('newsheadline')); 00609 00610 $newsContent = t3lib_parsehtml::substituteMarker($newsContent, '###NEWS_HEADLINE###', htmlspecialchars($title)); 00611 $newsContent = t3lib_parsehtml::substituteSubpart($newsContent, '###NEWS_ITEM###', $newsItem); 00612 } 00613 00614 return $newsContent; 00615 } 00616 00617 /** 00618 * Gets news from sys_news and converts them into a format suitable for 00619 * showing them at the login screen. 00620 * 00621 * @return array An array of login news. 00622 */ 00623 protected function getSystemNews() { 00624 $systemNewsTable = 'sys_news'; 00625 $systemNews = array(); 00626 00627 $systemNewsRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 00628 'title, content, crdate', 00629 $systemNewsTable, 00630 '1=1' . 00631 t3lib_BEfunc::BEenableFields($systemNewsTable) . 00632 t3lib_BEfunc::deleteClause($systemNewsTable), 00633 '', 00634 'crdate DESC' 00635 ); 00636 00637 foreach ($systemNewsRecords as $systemNewsRecord) { 00638 $systemNews[] = array( 00639 'date' => date( 00640 $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], 00641 $systemNewsRecord['crdate'] 00642 ), 00643 'header' => $systemNewsRecord['title'], 00644 'content' => $systemNewsRecord['content'] 00645 ); 00646 } 00647 00648 return $systemNews; 00649 } 00650 00651 /** 00652 * Returns the form tag 00653 * 00654 * @return string Opening form tag string 00655 */ 00656 function startForm() { 00657 $output = ''; 00658 00659 // The form defaults to 'no login'. This prevents plain 00660 // text logins to the Backend. The 'sv' extension changes the form to 00661 // use superchallenged method and rsaauth extension makes rsa authetication. 00662 $form = '<form action="index.php" method="post" name="loginform" ' . 00663 'onsubmit="alert(\'No authentication methods available. Please, ' . 00664 'contact your TYPO3 administrator.\');return false">'; 00665 00666 // Call hooks. If they do not return anything, we fail to login 00667 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginFormHook'])) { 00668 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginFormHook'] as $function) { 00669 $params = array(); 00670 $formCode = t3lib_div::callUserFunction($function, $params, $this); 00671 if ($formCode) { 00672 $form = $formCode; 00673 break; 00674 } 00675 } 00676 } 00677 00678 $output .= $form . 00679 '<input type="hidden" name="login_status" value="login" />' . 00680 '<input type="hidden" name="userident" value="" />' . 00681 '<input type="hidden" name="redirect_url" value="'.htmlspecialchars($this->redirectToURL).'" />' . 00682 '<input type="hidden" name="loginRefresh" value="'.htmlspecialchars($this->loginRefresh).'" />' . 00683 $this->interfaceSelector_hidden . $this->addFields_hidden; 00684 00685 return $output; 00686 } 00687 00688 /** 00689 * Creates JavaScript for the login form 00690 * 00691 * @return string JavaScript code 00692 */ 00693 function getJScode() { 00694 $JSCode = ''; 00695 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginScriptHook'])) { 00696 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginScriptHook'] as $function) { 00697 $params = array(); 00698 $JSCode = t3lib_div::callUserFunction($function, $params, $this); 00699 if ($JSCode) { 00700 break; 00701 } 00702 } 00703 } 00704 $JSCode .= $GLOBALS['TBE_TEMPLATE']->wrapScriptTags(' 00705 function startUp() { 00706 // 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: 00707 try { 00708 if (parent.opener && parent.opener.TS && parent.opener.TS.username && document.loginform && document.loginform.username) { 00709 document.loginform.username.value = parent.opener.TS.username; 00710 } 00711 } 00712 catch(error) { 00713 //continue 00714 } 00715 00716 // Wait a few millisecons before calling checkFocus(). This might be necessary because some browsers need some time to auto-fill in the form fields 00717 window.setTimeout("checkFocus()", 50); 00718 } 00719 00720 // This moves focus to the right input field: 00721 function checkFocus() { 00722 // If for some reason there already is a username in the username form field, move focus to the password field: 00723 if (document.loginform.username && document.loginform.username.value == "") { 00724 document.loginform.username.focus(); 00725 } else if (document.loginform.p_field && document.loginform.p_field.type!="hidden") { 00726 document.loginform.p_field.focus(); 00727 } 00728 } 00729 00730 // This function shows a warning, if user has capslock enabled 00731 // parameter showWarning: shows warning if true and capslock active, otherwise only hides warning, if capslock gets inactive 00732 function checkCapslock(e, showWarning) { 00733 if (!isCapslock(e)) { 00734 document.getElementById(\'t3-capslock\').style.display = \'none\'; 00735 } else if (showWarning) { 00736 document.getElementById(\'t3-capslock\').style.display = \'block\'; 00737 } 00738 } 00739 00740 // Checks weather capslock is enabled (returns true if enabled, false otherwise) 00741 // thanks to http://24ways.org/2007/capturing-caps-lock 00742 00743 function isCapslock(e) { 00744 var ev = e ? e : window.event; 00745 if (!ev) { 00746 return; 00747 } 00748 var targ = ev.target ? ev.target : ev.srcElement; 00749 // get key pressed 00750 var which = -1; 00751 if (ev.which) { 00752 which = ev.which; 00753 } else if (ev.keyCode) { 00754 which = ev.keyCode; 00755 } 00756 // get shift status 00757 var shift_status = false; 00758 if (ev.shiftKey) { 00759 shift_status = ev.shiftKey; 00760 } else if (ev.modifiers) { 00761 shift_status = !!(ev.modifiers & 4); 00762 } 00763 return (((which >= 65 && which <= 90) && !shift_status) || 00764 ((which >= 97 && which <= 122) && shift_status)); 00765 } 00766 00767 // prevent opening the login form in the backend frameset 00768 if (top.location.href != self.location.href) { 00769 top.location.href = self.location.href; 00770 } 00771 00772 '); 00773 00774 return $JSCode; 00775 } 00776 00777 00778 /** 00779 * Checks if labels from $GLOBALS['TYPO3_CONF_VARS']['BE']['loginLabels'] were changed, and merge them to $GLOBALS['LOCAL_LANG'] if needed 00780 * 00781 * This method keeps backwards compatibility, if you modified your 00782 * labels with the install tool, we recommend to transfer this labels to a locallang.xml file 00783 * using the llxml extension 00784 * 00785 * @return void 00786 */ 00787 protected function mergeOldLoginLabels() { 00788 // Getting login labels 00789 $oldLoginLabels = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['loginLabels']); 00790 if ($oldLoginLabels != '') { 00791 // md5 hash of the default loginLabels string 00792 $defaultOldLoginLabelsHash = 'bcf0d32e58c6454ea50c6c956f1f18f0'; 00793 // compare loginLabels from TYPO3_CONF_VARS to default value 00794 if (md5($oldLoginLabels) != $defaultOldLoginLabelsHash) { 00795 $lang = $GLOBALS['LANG']->lang; 00796 $oldLoginLabelArray = explode('|',$oldLoginLabels); 00797 $overrideLabelKeys = array( 00798 'labels.username' => $oldLoginLabelArray[0], 00799 'labels.password' => $oldLoginLabelArray[1], 00800 'labels.interface' => $oldLoginLabelArray[2], 00801 'labels.submitLogin' => $oldLoginLabelArray[3], 00802 'labels.submitLogout' => $oldLoginLabelArray[4], 00803 'availableInterfaces' => $oldLoginLabelArray[5], 00804 'headline' => $oldLoginLabelArray[6], 00805 'info.jscookies' => $oldLoginLabelArray[7], 00806 'newsheadline' => $oldLoginLabelArray[8], 00807 'error.login' => $oldLoginLabelArray[9], 00808 ); 00809 if (!is_array($GLOBALS['LOCAL_LANG'][$lang])) { 00810 $GLOBALS['LOCAL_LANG'][$lang] = array(); 00811 } 00812 // now override the labels from the LOCAL_LANG with the TYPO3_CONF_VARS 00813 foreach ($overrideLabelKeys as $labelKey => $label) { 00814 $GLOBALS['LOCAL_LANG'][$lang][$labelKey] = $GLOBALS['LOCAL_LANG']['default'][$labelKey] = $label; 00815 } 00816 } 00817 } 00818 } 00819 } 00820 00821 00822 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/index.php'])) { 00823 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/index.php']); 00824 } 00825 00826 00827 00828 // Make instance: 00829 $SOBE = t3lib_div::makeInstance('SC_index'); 00830 $SOBE->init(); 00831 $SOBE->main(); 00832 $SOBE->printContent(); 00833 00834 ?>
1.8.0