Fixed Bug #10212: Missing files in sysext install
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / mod / class.tx_install_ajax.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Marcus Krause, Helmut Hummel (security@typo3.org)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28
29
30 // *******************************
31 // Set error reporting
32 // *******************************
33 error_reporting (E_ALL ^ E_NOTICE);
34
35
36 // ***********************
37 // Paths are setup
38 // ***********************
39 define('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
40 define('TYPO3_MODE','FE');
41 if (!defined('PATH_thisScript')) define('PATH_thisScript',str_replace('//','/', str_replace('\\','/', (php_sapi_name()=='cgi'||php_sapi_name()=='isapi' ||php_sapi_name()=='cgi-fcgi')&&($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED'])? ($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED']):($_SERVER['ORIG_SCRIPT_FILENAME']?$_SERVER['ORIG_SCRIPT_FILENAME']:$_SERVER['SCRIPT_FILENAME']))));
42
43 if (!defined('PATH_site')) define('PATH_site', dirname(PATH_thisScript).'/');
44 if (!defined('PATH_t3lib')) define('PATH_t3lib', PATH_site.'t3lib/');
45 define('PATH_tslib', PATH_site.'tslib/');
46 define('PATH_typo3conf', PATH_site.'typo3conf/');
47 define('TYPO3_mainDir', 'typo3/'); // This is the directory of the backend administration for the sites of this TYPO3 installation.
48
49 if (!@is_dir(PATH_typo3conf)) die('Cannot find configuration. This file is probably executed from the wrong location.');
50
51
52 require_once(PATH_t3lib.'class.t3lib_div.php');
53
54 /**
55 * This is the eID handler for install tool AJAX calls.
56 *
57 * @author Marcus Krause <security@typo3.org>
58 */
59 class tx_install_ajax {
60
61
62 /**
63 * Keeps content to be printed.
64 *
65 * @var string
66 */
67 var $content;
68
69 /**
70 * Keeps command to process.
71 *
72 * @var string
73 */
74 var $cmd = '';
75
76
77 /**
78 * Init function, setting the input vars in the class scope.
79 *
80 * @return void
81 */
82 function init() {
83 $this->cmd = t3lib_div::_GP('cmd');
84 }
85
86 /**
87 * Main function which creates the AJAX call return string.
88 * It is stored in $this->content.
89 *
90 * @return void
91 */
92 function main() {
93 // Create output:
94 switch ($this->cmd) {
95 case 'encryptionKey':
96 default:
97 $this->content = $this->createEncryptionKey();
98 break;
99 }
100 }
101
102 /**
103 * Outputs the content from $this->content
104 *
105 * @return void
106 */
107 function printContent() {
108 echo $this->content;
109 }
110
111 /**
112 * Returns a newly created TYPO3 encryption key with a given length.
113 *
114 * @param integer $keyLength desired key length
115 * @return string
116 */
117 function createEncryptionKey($keyLength = 96) {
118
119 $bytes = t3lib_div::generateRandomBytes($keyLength);
120 return substr(bin2hex($bytes), -96);
121 }
122 }
123
124 // Make instance:
125 $SOBE = t3lib_div::makeInstance('tx_install_ajax');
126 $SOBE->init();
127 $SOBE->main();
128 $SOBE->printContent();
129
130 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/sysext/install/mod/class.tx_install_ajax.php']) {
131 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/sysext/install/mod/class.tx_install_ajax.php']);
132 }
133 ?>