00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
00087 class SC_index {
00088
00089
00090 var $redirect_url;
00091 var $GPinterface;
00092 var $u;
00093 var $p;
00094 var $L;
00095 var $loginRefresh;
00096 var $commandLI;
00097
00098
00099 var $redirectToURL;
00100 var $L_vars;
00101
00102
00103 var $content;
00104
00105 var $interfaceSelector;
00106 var $interfaceSelector_jump;
00107 var $interfaceSelector_hidden;
00108
00109
00110
00111
00112
00113
00119 function init() {
00120 global $BE_USER,$TYPO3_CONF_VARS;
00121
00122
00123 $this->redirect_url = t3lib_div::_GP('redirect_url');
00124 $this->GPinterface = t3lib_div::_GP('interface');
00125 $this->u = t3lib_div::_GP('u');
00126 $this->p = t3lib_div::_GP('p');
00127 $this->L = t3lib_div::_GP('L');
00128 $this->loginRefresh = t3lib_div::_GP('loginRefresh');
00129 $this->commandLI = t3lib_div::_GP('commandLI');
00130
00131
00132 $this->L_vars = explode('|',$TYPO3_CONF_VARS['BE']['loginLabels']);
00133
00134
00135 $this->redirectToURL = $this->redirect_url ? $this->redirect_url : 'alt_main.php';
00136
00137
00138 if ($this->L=='OUT' && is_object($BE_USER)) {
00139 $BE_USER->logoff();
00140 if ($this->redirect_url) header('Location: '.t3lib_div::locationHeaderUrl($this->redirect_url));
00141 exit;
00142 }
00143 }
00144
00150 function main() {
00151 global $TBE_TEMPLATE, $TYPO3_CONF_VARS, $BE_USER;
00152
00153
00154 $TBE_TEMPLATE->docType='xhtml_trans';
00155
00156
00157 $TBE_TEMPLATE->JScode.='
00158 <script type="text/javascript" src="md5.js"></script>
00159 '.$TBE_TEMPLATE->wrapScriptTags('
00160 function doChallengeResponse() {
00161 password = document.loginform.p_field.value;
00162 if (password) {
00163 password = MD5(password);
00164 str = document.loginform.username.value+":"+password+":"+document.loginform.challenge.value;
00165 document.loginform.userident.value = MD5(str);
00166 document.loginform.p_field.value = "";
00167 return true;
00168 }
00169 }
00170 ');
00171
00172
00173
00174
00175 $this->checkRedirect();
00176
00177
00178 $this->makeInterfaceSelectorBox();
00179
00180
00181 $this->L_vars[6] = str_replace("###SITENAME###",$TYPO3_CONF_VARS['SYS']['sitename'],$this->L_vars[6]);
00182
00183
00184 if (!$BE_USER->user['uid']) {
00185 $TBE_TEMPLATE->form = '
00186 <form action="index.php" method="post" name="loginform" onsubmit="doChallengeResponse();">
00187 <input type="hidden" name="login_status" value="login" />
00188 ';
00189 $loginForm = $this->makeLoginForm();
00190 } else {
00191 $TBE_TEMPLATE->form = '
00192 <form action="index.php" method="post" name="loginform">
00193 <input type="hidden" name="login_status" value="logout" />
00194 ';
00195 $loginForm = $this->makeLogoutForm();
00196 }
00197
00198
00199
00200 $this->content.=$TBE_TEMPLATE->startPage('TYPO3 Login: '.$TYPO3_CONF_VARS['SYS']['sitename']);
00201
00202
00203 $this->content.=$this->wrapLoginForm($loginForm);
00204
00205
00206 $this->content.= '
00207 <input type="hidden" name="userident" value="" />
00208 <input type="hidden" name="challenge" value="'.md5(uniqid('')).'" />
00209 <input type="hidden" name="redirect_url" value="'.htmlspecialchars($this->redirectToURL).'" />
00210 <input type="hidden" name="loginRefresh" value="'.htmlspecialchars($this->loginRefresh).'" />
00211 '.$this->interfaceSelector_hidden.'
00212 ';
00213
00214
00215 $this->content.=$TBE_TEMPLATE->wrapScriptTags('
00216
00217
00218 if (parent.opener && parent.opener.TS && parent.opener.TS.username && document.loginform && document.loginform.username) {
00219 document.loginform.username.value = parent.opener.TS.username;
00220 }
00221
00222
00223 if (document.loginform.username && document.loginform.username.value == "") {
00224 document.loginform.username.focus();
00225 } else if (document.loginform.p_field && document.loginform.p_field.type!="hidden") {
00226 document.loginform.p_field.focus();
00227 }
00228 ');
00229
00230
00231 $this->content.=$TBE_TEMPLATE->endPage();
00232 }
00233
00239 function printContent() {
00240
00241 echo $this->content;
00242 }
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00263 function makeLoginForm() {
00264
00265 $content.='
00266
00267 <!--
00268 Login form:
00269 -->
00270 <table cellspacing="0" cellpadding="0" border="0" id="logintable">
00271 <tr>
00272 <td colspan="2"><h2>'.htmlspecialchars($this->L_vars[6]).'</h2></td>
00273 </tr>'.($this->commandLI ? '
00274 <tr class="c-wrong">
00275 <td colspan="2"><p class="c-wrong">'.htmlspecialchars($this->L_vars[9]).'</p></td>
00276 </tr>' : '').'
00277 <tr class="c-username">
00278 <td><p class="c-username">'.htmlspecialchars($this->L_vars[0]).':</p></td>
00279 <td><input type="text" name="username" value="'.htmlspecialchars($this->u).'" class="c-username" /></td>
00280 </tr>
00281 <tr class="c-password">
00282 <td><p class="c-password">'.htmlspecialchars($this->L_vars[1]).':</p></td>
00283 <td><input type="password" name="p_field" value="'.htmlspecialchars($this->p).'" class="c-password" /></td>
00284 </tr>'.($this->interfaceSelector && !$this->loginRefresh ? '
00285 <tr class="c-interfaceselector">
00286 <td><p class="c-interfaceselector">'.htmlspecialchars($this->L_vars[2]).':</p></td>
00287 <td>'.$this->interfaceSelector.'</td>
00288 </tr>' : '' ).'
00289 <tr class="c-submit">
00290 <td></td>
00291 <td><input type="submit" name="commandLI" value="'.htmlspecialchars($this->L_vars[3]).'" class="c-submit" /></td>
00292 </tr>
00293 <tr class="c-info">
00294 <td></td>
00295 <td><p class="c-info">'.htmlspecialchars($this->L_vars[7]).'</p></td>
00296 </tr>
00297 </table>';
00298
00299
00300 return $content;
00301 }
00302
00309 function makeLogoutForm() {
00310 global $BE_USER;
00311
00312
00313 $content.='
00314
00315 <!--
00316 Login form:
00317 -->
00318 <table cellspacing="0" cellpadding="0" border="0" id="logintable">
00319 <tr>
00320 <td></td>
00321 <td><h2>'.htmlspecialchars($this->L_vars[6]).'</h2></td>
00322 </tr>
00323 <tr class="c-username">
00324 <td><p class="c-username">'.htmlspecialchars($this->L_vars[0]).':</p></td>
00325 <td><p class="c-username-current">'.htmlspecialchars($BE_USER->user['username']).'</p></td>
00326 </tr>'.($this->interfaceSelector_jump ? '
00327 <tr class="c-interfaceselector">
00328 <td><p class="c-interfaceselector">'.htmlspecialchars($this->L_vars[2]).':</p></td>
00329 <td>'.$this->interfaceSelector_jump.'</td>
00330 </tr>' : '' ).'
00331 <tr class="c-submit">
00332 <td><input type="hidden" name="p_field" value="" /></td>
00333 <td><input type="submit" name="commandLO" value="'.htmlspecialchars($this->L_vars[4]).'" class="c-submit" /></td>
00334 </tr>
00335 <tr class="c-info">
00336 <td></td>
00337 <td><p class="c-info">'.htmlspecialchars($this->L_vars[7]).'</p></td>
00338 </tr>
00339 </table>';
00340
00341
00342 return $content;
00343 }
00344
00351 function wrapLoginForm($content) {
00352
00353
00354 $logo = $GLOBALS['TBE_STYLES']['logo_login'] ?
00355 '<img src="'.htmlspecialchars($GLOBALS['BACK_PATH'].$GLOBALS['TBE_STYLES']['logo_login']).'" alt="" />' :
00356 '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/typo3logo.gif','width="333" height="43"').' alt="" />';
00357
00358
00359 $loginboxImage = $this->makeLoginBoxImage();
00360
00361
00362 $content='
00363
00364 <!--
00365 Wrapper table for the login form:
00366 -->
00367 <table cellspacing="0" cellpadding="0" border="0" id="wrapper">
00368 <tr>
00369 <td class="c-wrappercell" align="center">
00370
00371 <!--
00372 Login form image:
00373 -->
00374 <div id="loginimage">
00375 '.$logo.'
00376 </div>
00377
00378 <!--
00379 Login form wrapper:
00380 -->
00381 <table cellspacing="0" cellpadding="0" border="0" id="loginwrapper">
00382 <tr>
00383 <td>'.$loginboxImage.'</td>
00384 <td>
00385 '.$content.'
00386 </td>
00387 </tr>
00388 </table>
00389
00390 <!--
00391 Copy right notice:
00392 -->
00393 <div id="copyrightnotice">
00394 '.$this->makeCopyrightNotice().'
00395 </div>
00396
00397 '.$this->makeLoginNews().'
00398 </td>
00399 </tr>
00400 </table>';
00401
00402
00403 return $content;
00404 }
00405
00411 function checkRedirect() {
00412 global $BE_USER,$TBE_TEMPLATE;
00413
00414
00415
00416 if ($BE_USER->user['uid'] && ($this->commandLI || $this->loginRefresh || !$this->interfaceSelector)) {
00417
00418
00419 if (!$_COOKIE[$BE_USER->name]) {
00420 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);
00421 exit;
00422 }
00423
00424
00425 switch ($this->GPinterface) {
00426 case 'backend':
00427 $this->redirectToURL = 'alt_main.php';
00428 break;
00429 case 'frontend':
00430 $this->redirectToURL = '../';
00431 break;
00432 }
00433
00434
00435 if (!$this->loginRefresh) {
00436 header('Location: '.t3lib_div::locationHeaderUrl($this->redirectToURL));
00437 exit;
00438 } else {
00439 $TBE_TEMPLATE->JScode.=$TBE_TEMPLATE->wrapScriptTags('
00440 if (parent.opener && parent.opener.busy) {
00441 parent.opener.busy.loginRefreshed();
00442 parent.close();
00443 }
00444 ');
00445 }
00446 } elseif(!$BE_USER->user['uid'] && $this->commandLI) {
00447 sleep(5);
00448 }
00449 }
00450
00456 function makeInterfaceSelectorBox() {
00457 global $TYPO3_CONF_VARS;
00458
00459
00460 $this->interfaceSelector = '';
00461 $this->interfaceSelector_hidden='';
00462 $this->interfaceSelector_jump = '';
00463 #debug($this->redirect_url);
00464
00465 if ($TYPO3_CONF_VARS['BE']['interfaces'] && !$this->redirect_url) {
00466 $parts = t3lib_div::trimExplode(',',$TYPO3_CONF_VARS['BE']['interfaces']);
00467 if (count($parts)>1) {
00468
00469
00470 $tempLabels=explode(',',$this->L_vars[5]);
00471 $labels=array();
00472 $labels['backend']=$tempLabels[0];
00473 $labels['frontend']=$tempLabels[1];
00474
00475 $jumpScript=array();
00476 $jumpScript['backend']='alt_main.php';
00477 $jumpScript['frontend']='../';
00478
00479
00480 foreach($parts as $valueStr) {
00481 $this->interfaceSelector.='
00482 <option value="'.htmlspecialchars($valueStr).'">'.htmlspecialchars($labels[$valueStr]).'</option>';
00483 $this->interfaceSelector_jump.='
00484 <option value="'.htmlspecialchars($jumpScript[$valueStr]).'">'.htmlspecialchars($labels[$valueStr]).'</option>';
00485 }
00486 $this->interfaceSelector='
00487 <select name="interface" class="c-interfaceselector">'.$this->interfaceSelector.'
00488 </select>';
00489 $this->interfaceSelector_jump='
00490 <select name="interface" class="c-interfaceselector" onchange="document.location=this.options[this.selectedIndex].value;">'.$this->interfaceSelector_jump.'
00491 </select>';
00492
00493 } else {
00494
00495 $this->interfaceSelector_hidden='<input type="hidden" name="interface" value="'.trim($TYPO3_CONF_VARS['BE']['interfaces']).'" />';
00496 }
00497 }
00498 }
00499
00510 function makeCopyrightNotice() {
00511
00512
00513 $loginCopyrightWarrantyProvider = strip_tags(trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightWarrantyProvider']));
00514 $loginCopyrightWarrantyURL = strip_tags(trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightWarrantyURL']));
00515
00516
00517 if (strlen($loginCopyrightWarrantyProvider)>=2 && strlen($loginCopyrightWarrantyURL)>=10) {
00518 $warrantyNote='Warranty is supplied by '.htmlspecialchars($loginCopyrightWarrantyProvider).'; <a href="'.htmlspecialchars($loginCopyrightWarrantyURL).'" target="_blank">click for details.</a>';
00519 } else {
00520 $warrantyNote='TYPO3 comes with ABSOLUTELY NO WARRANTY; <a href="http://typo3.com/1316.0.html" target="_blank">click for details.</a>';
00521 }
00522
00523
00524 $copyrightNotice = '<a href="http://typo3.com/" target="_blank">'.
00525 '<img src="gfx/loginlogo_transp.gif" width="75" height="19" alt="TYPO3 logo" align="left" />'.
00526 'TYPO3 CMS'.($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightShowVersion']?' ver. '.htmlspecialchars($GLOBALS['TYPO_VERSION']):'').
00527 '</a>. '.
00528 'Copyright © 1998-2004 Kasper Skårhøj. Extensions are copyright of their respective owners. '.
00529 'Go to <a href="http://typo3.com/" target="_blank">http:
00530 $warrantyNote.' '.
00531 'This is free software, and you are welcome to redistribute it under certain conditions; <a href="http://typo3.com/1316.0.html" target="_blank">click for details</a>. '.
00532 'Obstructing the appearance of this notice is prohibited by law.';
00533
00534
00535 return $copyrightNotice;
00536 }
00537
00543 function makeLoginBoxImage() {
00544 $loginboxImage = '';
00545 if ($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']) {
00546 $absPath = t3lib_div::resolveBackPath(PATH_typo3.$GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']);
00547
00548
00549 $dir = t3lib_div::getFileAbsFileName($absPath);
00550 if ($dir && @is_dir($dir)) {
00551
00552
00553 $files = t3lib_div::getFilesInDir($dir,'png,jpg,gif');
00554
00555
00556 srand((float) microtime() * 10000000);
00557 $randImg = array_rand($files, 1);
00558
00559
00560 $imgSize = @getimagesize($dir.$files[$randImg]);
00561
00562
00563 if (is_array($imgSize)) {
00564 $loginboxImage = '<img src="'.htmlspecialchars($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder'].$files[$randImg]).'" '.$imgSize[3].' id="loginbox-image" alt="" />';
00565 }
00566 }
00567 } else {
00568 $loginImage = 'loginbox_image_dev.png';
00569 $imagecopy = $loginImage=='loginbox_image_dev.png' ? 'You are running the CVS version of TYPO3 '.$GLOBALS['TYPO_VERSION'] : 'Photo: © 2004 Kasper Skårhøj';
00570 $loginboxImage = '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/'.$loginImage,'width="200" height="133"').' id="loginbox-image" alt="'.$imagecopy.'" title="'.$imagecopy.'" />';
00571 }
00572
00573
00574 return $loginboxImage;
00575 }
00576
00583 function makeLoginNews() {
00584
00585
00586 $newsContent= '';
00587
00588
00589 if (is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews']) && count($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'])) {
00590 foreach($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] as $newsItem) {
00591 $newsContent.='
00592 <tr>
00593 <td class="c-date">'.htmlspecialchars($newsItem['date']).'</td>
00594 <td class="c-header">'.htmlspecialchars($newsItem['header']).'</td>
00595 </tr>
00596 <tr>
00597 <td></td>
00598 <td class="c-content">'.trim($newsItem['content']).'</td>
00599 </tr>
00600 <tr class="c-spacer">
00601 <td colspan="2"></td>
00602 </tr>
00603 ';
00604 }
00605
00606
00607 $newsContent= '
00608
00609 <!--
00610 Login screen news:
00611 -->
00612 <div id="loginNews">
00613 <h2>'.htmlspecialchars($this->L_vars[8]).'</h2>
00614 <table border="0" cellpadding="0" cellspacing="0">
00615 '.$newsContent.'
00616 </table>
00617 </div>
00618 ';
00619 }
00620
00621
00622 return $newsContent;
00623 }
00624 }
00625
00626
00627 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/index.php']) {
00628 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/index.php']);
00629 }
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641 $SOBE = t3lib_div::makeInstance('SC_index');
00642 $SOBE->init();
00643 $SOBE->main();
00644 $SOBE->printContent();
00645 ?>