Example #1
0
    /**
     * Create the HTML for the login form
     *
     * Reads and fills the template.
     * Substitutes subparts when wrong password has been given
     * or the session has expired
     *
     * @return void
     * @todo Define visibility
     */
    public function loginForm()
    {
        $password = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('password');
        $redirect_url = $this->redirect_url ? $this->redirect_url : $this->action;
        // Get the template file
        $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'LoginForm.html');
        // Get the template part from the file
        $template = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($templateFile, '###TEMPLATE###');
        // Password has been given, but this form is rendered again.
        // This means the given password was wrong
        if (!empty($password)) {
            // Get the subpart for the wrong password
            $wrongPasswordSubPart = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($template, '###WRONGPASSWORD###');
            // Define the markers content
            $wrongPasswordMarkers = array('passwordMessage' => 'The password you just tried has this md5-value:', 'password' => md5($password));
            // Fill the markers in the subpart
            $wrongPasswordSubPart = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($wrongPasswordSubPart, $wrongPasswordMarkers, '###|###', TRUE, TRUE);
        }
        // Session has expired
        if (!$this->session->isAuthorized() && $this->session->isExpired()) {
            // Get the subpart for the expired session message
            $sessionExpiredSubPart = \TYPO3\CMS\Core\Html\HtmlParser::getSubpart($template, '###SESSIONEXPIRED###');
            // Define the markers content
            $sessionExpiredMarkers = array('message' => 'Your Install Tool session has expired');
            // Fill the markers in the subpart
            $sessionExpiredSubPart = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($sessionExpiredSubPart, $sessionExpiredMarkers, '###|###', TRUE, TRUE);
        }
        // Substitute the subpart for the expired session in the template
        $template = \TYPO3\CMS\Core\Html\HtmlParser::substituteSubpart($template, '###SESSIONEXPIRED###', $sessionExpiredSubPart);
        // Substitute the subpart for the wrong password in the template
        $template = \TYPO3\CMS\Core\Html\HtmlParser::substituteSubpart($template, '###WRONGPASSWORD###', $wrongPasswordSubPart);
        // Define the markers content
        $markers = array('siteName' => 'Site: ' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']), 'headTitle' => 'Login to TYPO3 ' . TYPO3_version . ' Install Tool', 'redirectUrl' => htmlspecialchars($redirect_url), 'enterPassword' => 'Password', 'login' => 'Login', 'message' => '
				<p class="typo3-message message-information">
					The Install Tool Password is <em>not</em> the admin password
					of TYPO3.
					<br />
					The default password is <em>joh316</em>. Be sure to change it!
					<br /><br />
					If you don\'t know the current password, you can set a new
					one by setting the value of
					$TYPO3_CONF_VARS[\'BE\'][\'installToolPassword\'] in
					typo3conf/localconf.php to the md5() hash value of the
					password you desire.
				</p>
			');
        // Fill the markers in the template
        $content = \TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray($template, $markers, '###|###', TRUE, TRUE);
        // Send content to the page wrapper function
        $this->output($this->outputWrapper($content));
    }