|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009-2011 Marcus Krause, Helmut Hummel (security@typo3.org) 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 00029 00030 // ******************************* 00031 // Set error reporting 00032 // ******************************* 00033 if (defined('E_DEPRECATED')) { 00034 error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED); 00035 } else { 00036 error_reporting(E_ALL ^ E_NOTICE); 00037 } 00038 00039 00040 // *********************** 00041 // Paths are setup 00042 // *********************** 00043 define('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':''); 00044 define('TYPO3_MODE','FE'); 00045 00046 if(!defined('PATH_thisScript')) { 00047 define('PATH_thisScript', str_replace('//', '/', str_replace('\\', '/', 00048 (PHP_SAPI == 'fpm-fcgi' || PHP_SAPI == 'cgi' || PHP_SAPI == 'isapi' || PHP_SAPI == 'cgi-fcgi') && 00049 ($_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED']) ? 00050 ($_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED']) : 00051 ($_SERVER['ORIG_SCRIPT_FILENAME'] ? $_SERVER['ORIG_SCRIPT_FILENAME'] : $_SERVER['SCRIPT_FILENAME'])))); 00052 } 00053 00054 if (!defined('PATH_site')) define('PATH_site', dirname(PATH_thisScript).'/'); 00055 if (!defined('PATH_t3lib')) define('PATH_t3lib', PATH_site.'t3lib/'); 00056 define('PATH_tslib', PATH_site.'tslib/'); 00057 define('PATH_typo3conf', PATH_site.'typo3conf/'); 00058 define('TYPO3_mainDir', 'typo3/'); // This is the directory of the backend administration for the sites of this TYPO3 installation. 00059 00060 if (!@is_dir(PATH_typo3conf)) die('Cannot find configuration. This file is probably executed from the wrong location.'); 00061 00062 00063 require_once(PATH_t3lib.'class.t3lib_div.php'); 00064 00065 /** 00066 * This is the eID handler for install tool AJAX calls. 00067 * 00068 * @author Marcus Krause <security@typo3.org> 00069 */ 00070 class tx_install_ajax { 00071 00072 00073 /** 00074 * Keeps content to be printed. 00075 * 00076 * @var string 00077 */ 00078 var $content; 00079 00080 /** 00081 * Keeps command to process. 00082 * 00083 * @var string 00084 */ 00085 var $cmd = ''; 00086 00087 00088 /** 00089 * Init function, setting the input vars in the class scope. 00090 * 00091 * @return void 00092 */ 00093 function init() { 00094 $this->cmd = t3lib_div::_GP('cmd'); 00095 } 00096 00097 /** 00098 * Main function which creates the AJAX call return string. 00099 * It is stored in $this->content. 00100 * 00101 * @return void 00102 */ 00103 function main() { 00104 // Create output: 00105 switch ($this->cmd) { 00106 case 'encryptionKey': 00107 default: 00108 $this->content = $this->createEncryptionKey(); 00109 $this->addTempContentHttpHeaders(); 00110 break; 00111 } 00112 } 00113 00114 /** 00115 * Outputs the content from $this->content 00116 * 00117 * @return void 00118 */ 00119 function printContent() { 00120 if (!headers_sent()) { 00121 header('Content-Length: ' . strlen($this->content)); 00122 } 00123 echo $this->content; 00124 } 00125 00126 /** 00127 * Returns a newly created TYPO3 encryption key with a given length. 00128 * 00129 * @param integer $keyLength desired key length 00130 * @return string 00131 */ 00132 function createEncryptionKey($keyLength = 96) { 00133 if (!headers_sent()) { 00134 header("Content-type: text/plain"); 00135 } 00136 00137 return t3lib_div::getRandomHexString($keyLength); 00138 } 00139 00140 /** 00141 * Sends cache control headers that prevent caching in user agents. 00142 * 00143 */ 00144 function addTempContentHttpHeaders() { 00145 if (!headers_sent()) { 00146 // see RFC 2616 00147 // see Microsoft Knowledge Base #234067 00148 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 00149 header('Cache-Control: no-cache, must-revalidate'); 00150 header('Pragma: no-cache'); 00151 header('Expires: -1'); 00152 } 00153 } 00154 } 00155 00156 // Make instance: 00157 $SOBE = t3lib_div::makeInstance('tx_install_ajax'); 00158 $SOBE->init(); 00159 $SOBE->main(); 00160 $SOBE->printContent(); 00161 00162 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/install/mod/class.tx_install_ajax.php'])) { 00163 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/install/mod/class.tx_install_ajax.php']); 00164 } 00165 ?>
1.8.0