PageRenderTime 97ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/typo3/sysext/install/mod/class.tx_install.php

https://bitbucket.org/tritum_sw/typo3v4-core
PHP | 8476 lines | 6717 code | 543 blank | 1216 comment | 728 complexity | 476370d9fe6f6190da6e2ab928087c75 MD5 | raw file
Possible License(s): GPL-2.0, Apache-2.0, BSD-3-Clause, BSD-2-Clause, AGPL-1.0, LGPL-3.0, GPL-3.0, MIT, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /***************************************************************
  3. * Copyright notice
  4. *
  5. * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
  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. * Contains the class for the Install Tool
  29. *
  30. * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  31. * @author Ingmar Schlecht <ingmar@typo3.org>
  32. */
  33. // include requirements definition:
  34. require_once(t3lib_extMgm::extPath('install') . 'requirements.php');
  35. // include session handling
  36. require_once(t3lib_extMgm::extPath('install') . 'mod/class.tx_install_session.php');
  37. // include update classes
  38. require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_charsetdefaults.php');
  39. require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_compatversion.php');
  40. require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_cscsplit.php');
  41. require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_notinmenu.php');
  42. require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_mergeadvanced.php');
  43. require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_installsysexts.php');
  44. require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_imagescols.php');
  45. require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_installnewsysexts.php');
  46. require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_statictemplates.php');
  47. require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_t3skin.php');
  48. require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_compressionlevel.php');
  49. require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_migrateworkspaces.php');
  50. require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_flagsfromsprite.php');
  51. require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_addflexformstoacl.php');
  52. require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_imagelink.php');
  53. /**
  54. * Install Tool module
  55. *
  56. * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  57. * @author Ingmar Schlecht <ingmar@typo3.org>
  58. * @package TYPO3
  59. * @subpackage tx_install
  60. */
  61. class tx_install extends t3lib_install {
  62. var $templateFilePath = 'typo3/sysext/install/Resources/Private/Templates/';
  63. var $template;
  64. var $javascript;
  65. var $stylesheets;
  66. var $markers = array();
  67. var $messages = array();
  68. var $errorMessages = array();
  69. var $mailMessage = '';
  70. var $action = ''; // The url that calls this script
  71. var $scriptSelf = 'index.php'; // The url that calls this script
  72. var $updateIdentity = 'TYPO3 Install Tool';
  73. var $headerStyle ='';
  74. var $setAllCheckBoxesByDefault=0;
  75. var $allowFileEditOutsite_typo3conf_dir=0;
  76. var $INSTALL =array(); // In constructor: is set to global GET/POST var TYPO3_INSTALL
  77. var $checkIMlzw = 0; // If set, lzw capabilities of the available ImageMagick installs are check by actually writing a gif-file and comparing size
  78. var $checkIM = 0; // If set, ImageMagick is checked.
  79. var $dumpImCommands=1; // If set, the image Magick commands are always outputted in the image processing checker
  80. var $mode = ''; // If set to "123" then only most vital information is displayed.
  81. var $step = 0; // If set to 1,2,3 or GO it signifies various functions.
  82. var $totalSteps = 4; // Can be changed by hook to define the total steps in 123 mode
  83. // internal
  84. var $passwordOK=0; // This is set, if the password check was ok. The function init() will exit if this is not set
  85. var $silent=1; // If set, the check routines don't add to the message-array
  86. var $sections=array(); // Used to gather the message information.
  87. var $fatalError=0; // This is set if some error occured that will definitely prevent TYpo3 from running.
  88. var $sendNoCacheHeaders=1;
  89. var $config_array = array( // Flags are set in this array if the options are available and checked ok.
  90. 'gd'=>0,
  91. 'gd_gif'=>0,
  92. 'gd_png'=>0,
  93. 'gd_jpg'=>0,
  94. 'freetype' => 0,
  95. 'safemode' => 0,
  96. 'dir_typo3temp' => 0,
  97. 'dir_temp' => 0,
  98. 'im_versions' => array(),
  99. 'im' => 0,
  100. 'sql.safe_mode_user' => '',
  101. 'mysqlConnect' => 0,
  102. 'no_database' => 0
  103. );
  104. var $typo3temp_path='';
  105. /**
  106. * the session handling object
  107. *
  108. * @var tx_install_session
  109. */
  110. protected $session = NULL;
  111. /**
  112. * the form protection instance used for creating and verifying form tokens
  113. *
  114. * @var t3lib_formprotection_InstallToolFormProtection
  115. */
  116. protected $formProtection = NULL;
  117. var $menuitems = array(
  118. 'config' => 'Basic Configuration',
  119. 'database' => 'Database Analyser',
  120. 'update' => 'Upgrade Wizard',
  121. 'images' => 'Image Processing',
  122. 'extConfig' => 'All Configuration',
  123. 'cleanup' => 'Clean up',
  124. 'phpinfo' => 'phpinfo()',
  125. 'typo3conf_edit' => 'Edit files in typo3conf/',
  126. 'about' => 'About',
  127. 'logout' => 'Logout from Install Tool',
  128. );
  129. // PHP modules which are required. Can be changed by hook in getMissingPhpModules()
  130. protected $requiredPhpModules = array(
  131. 'fileinfo',
  132. 'filter',
  133. 'gd',
  134. 'json',
  135. 'mysql',
  136. 'pcre',
  137. 'session',
  138. 'SPL',
  139. 'standard',
  140. 'openssl',
  141. 'xml',
  142. 'zlib'
  143. );
  144. /**
  145. * Constructor
  146. *
  147. * @return void
  148. */
  149. function __construct() {
  150. parent::__construct();
  151. if (!$GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword']) {
  152. $this->outputErrorAndExit('Install Tool deactivated.<br />You must enable it by setting a password in typo3conf/localconf.php. If you insert the line below, the password will be \'joh316\':<br /><br />$TYPO3_CONF_VARS[\'BE\'][\'installToolPassword\'] = \'bacb98acf97e0b6112b1d1b650b84971\';', 'Fatal error');
  153. }
  154. if ($this->sendNoCacheHeaders) {
  155. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
  156. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  157. header('Expires: 0');
  158. header('Cache-Control: no-cache, must-revalidate');
  159. header('Pragma: no-cache');
  160. }
  161. // ****************************
  162. // Initializing incoming vars.
  163. // ****************************
  164. $this->INSTALL = t3lib_div::_GP('TYPO3_INSTALL');
  165. $this->mode = t3lib_div::_GP('mode');
  166. if ($this->mode !== '123') {
  167. $this->mode = '';
  168. }
  169. if (t3lib_div::_GP('step') === 'go') {
  170. $this->step = 'go';
  171. } else {
  172. $this->step = intval(t3lib_div::_GP('step'));
  173. }
  174. // Let DBAL decide whether to load itself
  175. $dbalLoaderFile = $this->backPath . 'sysext/dbal/class.tx_dbal_autoloader.php';
  176. if (@is_file($dbalLoaderFile)) {
  177. include($dbalLoaderFile);
  178. }
  179. if ($this->mode === '123') {
  180. // Check for mandatory PHP modules
  181. $missingPhpModules = $this->getMissingPhpModules();
  182. if (count($missingPhpModules) > 0) {
  183. throw new RuntimeException('TYPO3 Installation Error: The following PHP module(s) is/are missing: <em>' .
  184. implode(', ', $missingPhpModules) .
  185. '</em><br /><br />You need to install and enable these modules first to be able to install TYPO3.',
  186. 1294587482
  187. );
  188. }
  189. // Load saltedpasswords if possible
  190. $saltedpasswordsLoaderFile = $this->backPath . 'sysext/saltedpasswords/classes/class.tx_saltedpasswords_autoloader.php';
  191. if (@is_file($saltedpasswordsLoaderFile)) {
  192. include($saltedpasswordsLoaderFile);
  193. }
  194. }
  195. $this->redirect_url = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('redirect_url'));
  196. $this->INSTALL['type'] = '';
  197. if ($_GET['TYPO3_INSTALL']['type']) {
  198. $allowedTypes = array(
  199. 'config', 'database', 'update', 'images', 'extConfig',
  200. 'cleanup', 'phpinfo', 'typo3conf_edit', 'about', 'logout'
  201. );
  202. if (in_array($_GET['TYPO3_INSTALL']['type'], $allowedTypes)) {
  203. $this->INSTALL['type'] = $_GET['TYPO3_INSTALL']['type'];
  204. }
  205. }
  206. if ($this->step == 4) {
  207. $this->INSTALL['type'] = 'database';
  208. }
  209. // Hook to raise the counter for the total steps in the 1-2-3 installer
  210. if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['additionalSteps'])) {
  211. foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['additionalSteps'] as $classData) {
  212. $hookObject = t3lib_div::getUserObj($classData);
  213. $this->totalSteps += (integer) $hookObject->executeAdditionalSteps($this);
  214. }
  215. }
  216. if ($this->mode=='123') {
  217. $tempItems = $this->menuitems;
  218. $this->menuitems = array(
  219. 'config' => $tempItems['config'],
  220. 'database' => $tempItems['database']
  221. );
  222. if (!$this->INSTALL['type'] || !isset($this->menuitems[$this->INSTALL['type']])) {
  223. $this->INSTALL['type'] = 'config';
  224. }
  225. } else {
  226. if (!$this->INSTALL['type'] || !isset($this->menuitems[$this->INSTALL['type']])) {
  227. $this->INSTALL['type'] = 'about';
  228. }
  229. }
  230. $this->action = $this->scriptSelf .
  231. '?TYPO3_INSTALL[type]=' . $this->INSTALL['type'] .
  232. ($this->mode? '&mode=' . $this->mode : '') .
  233. ($this->step? '&step=' . $this->step : '');
  234. $this->typo3temp_path = PATH_site.'typo3temp/';
  235. if (!is_dir($this->typo3temp_path) || !is_writeable($this->typo3temp_path)) {
  236. $this->outputErrorAndExit('Install Tool needs to write to typo3temp/. Make sure this directory is writeable by your webserver: ' . htmlspecialchars($this->typo3temp_path), 'Fatal error');
  237. }
  238. try {
  239. $this->session = t3lib_div::makeInstance('tx_install_session');
  240. } catch (Exception $exception) {
  241. $this->outputErrorAndExit($exception->getMessage());
  242. }
  243. // *******************
  244. // Check authorization
  245. // *******************
  246. if (!$this->session->hasSession()) {
  247. $this->session->startSession();
  248. }
  249. if ($this->session->isAuthorized() || $this->checkPassword()) {
  250. $this->passwordOK=1;
  251. $this->session->refreshSession();
  252. $enableInstallToolFile = PATH_typo3conf . 'ENABLE_INSTALL_TOOL';
  253. if (is_file ($enableInstallToolFile)) {
  254. // Extend the age of the ENABLE_INSTALL_TOOL file by one hour
  255. @touch($enableInstallToolFile);
  256. }
  257. if($this->redirect_url) {
  258. t3lib_utility_Http::redirect($this->redirect_url);
  259. }
  260. $this->formProtection = t3lib_formProtection_Factory::get(
  261. 't3lib_formprotection_InstallToolFormProtection'
  262. );
  263. $this->formProtection->injectInstallTool($this);
  264. } else {
  265. $this->loginForm();
  266. }
  267. }
  268. /**
  269. * Returns TRUE if submitted password is ok.
  270. *
  271. * If password is ok, set session as "authorized".
  272. *
  273. * @return boolean TRUE if the submitted password was ok and session was
  274. * authorized, FALSE otherwise
  275. */
  276. function checkPassword() {
  277. $p = t3lib_div::_GP('password');
  278. if ($p && md5($p) === $GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword']) {
  279. $this->session->setAuthorized();
  280. // Sending warning email
  281. $wEmail = $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'];
  282. if ($wEmail) {
  283. $subject = 'Install Tool Login at "' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '"';
  284. $email_body = 'There has been an Install Tool login at TYPO3 site "' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '" (' . t3lib_div::getIndpEnv('HTTP_HOST') . ') from remote address "' . t3lib_div::getIndpEnv('REMOTE_ADDR') . '" (' . t3lib_div::getIndpEnv('REMOTE_HOST') . ')';
  285. mail($wEmail,
  286. $subject,
  287. $email_body,
  288. 'From: TYPO3 Install Tool WARNING <>'
  289. );
  290. }
  291. return TRUE;
  292. } else {
  293. // Bad password, send warning:
  294. if ($p) {
  295. $wEmail = $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'];
  296. if ($wEmail) {
  297. $subject="Install Tool Login ATTEMPT at '".$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']."'";
  298. $email_body="There has been an Install Tool login attempt at TYPO3 site '".$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']."' (".t3lib_div::getIndpEnv('HTTP_HOST').").
  299. The MD5 hash of the last 5 characters of the password tried was '".substr(md5($p), -5)."'
  300. REMOTE_ADDR was '".t3lib_div::getIndpEnv('REMOTE_ADDR')."' (".t3lib_div::getIndpEnv('REMOTE_HOST').')';
  301. mail($wEmail,
  302. $subject,
  303. $email_body,
  304. 'From: TYPO3 Install Tool WARNING <>'
  305. );
  306. }
  307. }
  308. return FALSE;
  309. }
  310. }
  311. /**
  312. * Create the HTML for the login form
  313. *
  314. * Reads and fills the template.
  315. * Substitutes subparts when wrong password has been given
  316. * or the session has expired
  317. *
  318. * @return void
  319. */
  320. function loginForm() {
  321. $password = t3lib_div::_GP('password');
  322. $redirect_url = $this->redirect_url ? $this->redirect_url : $this->action;
  323. // Get the template file
  324. $templateFile = @file_get_contents(
  325. PATH_site . $this->templateFilePath . 'LoginForm.html'
  326. );
  327. // Get the template part from the file
  328. $template = t3lib_parsehtml::getSubpart(
  329. $templateFile, '###TEMPLATE###'
  330. );
  331. // Password has been given, but this form is rendered again.
  332. // This means the given password was wrong
  333. if (!empty($password)) {
  334. // Get the subpart for the wrong password
  335. $wrongPasswordSubPart = t3lib_parsehtml::getSubpart(
  336. $template, '###WRONGPASSWORD###'
  337. );
  338. // Define the markers content
  339. $wrongPasswordMarkers = array(
  340. 'passwordMessage' => 'The password you just tried has this md5-value:',
  341. 'password' => md5($password)
  342. );
  343. // Fill the markers in the subpart
  344. $wrongPasswordSubPart = t3lib_parsehtml::substituteMarkerArray(
  345. $wrongPasswordSubPart,
  346. $wrongPasswordMarkers,
  347. '###|###',
  348. TRUE,
  349. TRUE
  350. );
  351. }
  352. // Session has expired
  353. if (!$this->session->isAuthorized() && $this->session->isExpired()) {
  354. // Get the subpart for the expired session message
  355. $sessionExpiredSubPart = t3lib_parsehtml::getSubpart(
  356. $template, '###SESSIONEXPIRED###'
  357. );
  358. // Define the markers content
  359. $sessionExpiredMarkers = array(
  360. 'message' => 'Your Install Tool session has expired'
  361. );
  362. // Fill the markers in the subpart
  363. $sessionExpiredSubPart = t3lib_parsehtml::substituteMarkerArray(
  364. $sessionExpiredSubPart,
  365. $sessionExpiredMarkers,
  366. '###|###',
  367. TRUE,
  368. TRUE
  369. );
  370. }
  371. // Substitute the subpart for the expired session in the template
  372. $template = t3lib_parsehtml::substituteSubpart(
  373. $template,
  374. '###SESSIONEXPIRED###',
  375. $sessionExpiredSubPart
  376. );
  377. // Substitute the subpart for the wrong password in the template
  378. $template = t3lib_parsehtml::substituteSubpart(
  379. $template,
  380. '###WRONGPASSWORD###',
  381. $wrongPasswordSubPart
  382. );
  383. // Define the markers content
  384. $markers = array(
  385. 'siteName' => 'Site: ' .
  386. htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']),
  387. 'headTitle' => 'Login to TYPO3 ' . TYPO3_version . ' Install Tool',
  388. 'redirectUrl' => htmlspecialchars($redirect_url),
  389. 'enterPassword' => 'Password',
  390. 'login' => 'Login',
  391. 'message' => '
  392. <p class="typo3-message message-information">
  393. The Install Tool Password is <em>not</em> the admin password
  394. of TYPO3.
  395. <br />
  396. The default password is <em>joh316</em>. Be sure to change it!
  397. <br /><br />
  398. If you don\'t know the current password, you can set a new
  399. one by setting the value of
  400. $TYPO3_CONF_VARS[\'BE\'][\'installToolPassword\'] in
  401. typo3conf/localconf.php to the md5() hash value of the
  402. password you desire.
  403. </p>
  404. '
  405. );
  406. // Fill the markers in the template
  407. $content = t3lib_parsehtml::substituteMarkerArray(
  408. $template,
  409. $markers,
  410. '###|###',
  411. TRUE,
  412. TRUE
  413. );
  414. // Send content to the page wrapper function
  415. $this->output($this->outputWrapper($content));
  416. }
  417. /**
  418. * Calling function that checks system, IM, GD, dirs, database
  419. * and lets you alter localconf.php
  420. *
  421. * This method is called from init.php to start the Install Tool.
  422. *
  423. * @return void
  424. */
  425. function init() {
  426. // Must be called after inclusion of init.php (or from init.php)
  427. if (!defined('PATH_typo3')) exit;
  428. if (!$this->passwordOK) exit;
  429. // Setting stuff...
  430. $this->check_mail();
  431. $this->setupGeneral();
  432. $this->generateConfigForm();
  433. if (count($this->messages)) {
  434. t3lib_utility_Debug::debug($this->messages);
  435. }
  436. if ($this->step) {
  437. $this->output($this->outputWrapper($this->stepOutput()));
  438. } else {
  439. // Menu...
  440. switch($this->INSTALL['type']) {
  441. case 'images':
  442. $this->checkIM=1;
  443. $this->checkTheConfig();
  444. $this->silent=0;
  445. $this->checkTheImageProcessing();
  446. break;
  447. case 'database':
  448. $this->checkTheConfig();
  449. $this->silent=0;
  450. $this->checkTheDatabase();
  451. break;
  452. case 'update':
  453. $this->checkDatabase();
  454. $this->silent=0;
  455. $this->updateWizard();
  456. break;
  457. case 'config':
  458. $this->silent=0;
  459. $this->checkIM=1;
  460. $this->message(
  461. 'About configuration',
  462. 'How to configure TYPO3',
  463. $this->generallyAboutConfiguration()
  464. );
  465. $isPhpCgi = (PHP_SAPI == 'fpm-fcgi' || PHP_SAPI == 'cgi' || PHP_SAPI == 'isapi' || PHP_SAPI == 'cgi-fcgi');
  466. $this->message(
  467. 'System Information',
  468. 'Your system has the following configuration',
  469. '
  470. <dl id="systemInformation">
  471. <dt>OS detected:</dt>
  472. <dd>' . (TYPO3_OS == 'WIN' ? 'WIN' : 'UNIX') .'</dd>
  473. <dt>CGI detected:</dt>
  474. <dd>' . ($isPhpCgi ? 'YES' : 'NO') . '</dd>
  475. <dt>PATH_thisScript:</dt>
  476. <dd>' . PATH_thisScript . '</dd>
  477. </dl>
  478. '
  479. );
  480. $this->checkTheConfig();
  481. $ext = 'Write config to localconf.php';
  482. if ($this->fatalError) {
  483. if (
  484. $this->config_array['no_database'] ||
  485. !$this->config_array['mysqlConnect']
  486. ) {
  487. $this->message($ext, 'Database not configured yet!', '
  488. <p>
  489. You need to specify database username,
  490. password and host as one of the first things.
  491. <br />
  492. Next you\'ll have to select a database to
  493. use with TYPO3.
  494. </p>
  495. <p>
  496. Use the form below.
  497. </p>
  498. ', 2);
  499. } else {
  500. $this->message($ext, 'Fatal error encountered!', '
  501. <p>
  502. Somewhere above a fatal configuration
  503. problem is encountered.
  504. Please make sure that you\'ve fixed this
  505. error before you submit the configuration.
  506. TYPO3 will not run if this problem is not
  507. fixed!
  508. <br />
  509. You should also check all warnings that may
  510. appear.
  511. </p>
  512. ', 2);
  513. }
  514. } elseif ($this->mode=='123') {
  515. if (!$this->fatalError) {
  516. $this->message($ext, 'Basic configuration completed', '
  517. <p>
  518. You have no fatal errors in your basic
  519. configuration.
  520. You may have warnings though. Please pay
  521. attention to them!
  522. However you may continue and install the
  523. database.
  524. </p>
  525. <p>
  526. <strong>
  527. <span style="color:#f00;">Step 2: </span>
  528. </strong>
  529. <a href="' . $this->scriptSelf .
  530. '?TYPO3_INSTALL[type]=database' .
  531. ($this->mode ? '&mode=' . rawurlencode($this->mode) : '') .
  532. '">Click here to install the database.</a>
  533. </p>
  534. ', -1, 1);
  535. }
  536. }
  537. $this->message($ext, 'Very Important: Changing Image Processing settings', '
  538. <p>
  539. When you change the settings for Image Processing
  540. you <em>must</em> take into account
  541. that <em>old images</em> may still be in typo3temp/
  542. folder and prevent new files from being generated!
  543. <br />
  544. This is especially important to know, if you\'re
  545. trying to set up image processing for the very first
  546. time.
  547. <br />
  548. The problem is solved by <a href="' .
  549. htmlspecialchars($this->setScriptName('cleanup')) .
  550. '">clearing the typo3temp/ folder</a>.
  551. Also make sure to clear the cache_pages table.
  552. </p>
  553. ', 1, 1);
  554. $this->message($ext, 'Very Important: Changing Encryption Key setting', '
  555. <p>
  556. When you change the setting for the Encryption Key
  557. you <em>must</em> take into account that a change to
  558. this value might invalidate temporary information,
  559. URLs etc.
  560. <br />
  561. The problem is solved by <a href="' .
  562. htmlspecialchars($this->setScriptName('cleanup')) .
  563. '">clearing the typo3temp/ folder</a>.
  564. Also make sure to clear the cache_pages table.
  565. </p>
  566. ', 1, 1);
  567. $this->message($ext, 'Update localconf.php', '
  568. <p>
  569. This form updates the localconf.php file with the
  570. suggested values you see below. The values are based
  571. on the analysis above.
  572. <br />
  573. You can change the values in case you have
  574. alternatives to the suggested defaults.
  575. <br />
  576. By this final step you will configure TYPO3 for
  577. immediate use provided that you have no fatal errors
  578. left above.
  579. </p>' . $this->setupGeneral('get_form') . '
  580. ', 0, 1);
  581. $this->output($this->outputWrapper($this->printAll()));
  582. break;
  583. case 'extConfig':
  584. $this->silent=0;
  585. $this->generateConfigForm('get_form');
  586. // Get the template file
  587. $templateFile = @file_get_contents(
  588. PATH_site . $this->templateFilePath . 'InitExtConfig.html'
  589. );
  590. // Get the template part from the file
  591. $template = t3lib_parsehtml::getSubpart(
  592. $templateFile, '###TEMPLATE###'
  593. );
  594. // Define the markers content
  595. $markers = array(
  596. 'action' => $this->action,
  597. 'content' => $this->printAll(),
  598. 'write' => 'Write to localconf.php',
  599. 'notice' => 'NOTICE:',
  600. 'explanation' => '
  601. By clicking this button, localconf.php is updated
  602. with new values for the parameters listed above!
  603. '
  604. );
  605. // Fill the markers in the template
  606. $content = t3lib_parsehtml::substituteMarkerArray(
  607. $template,
  608. $markers,
  609. '###|###',
  610. TRUE,
  611. FALSE
  612. );
  613. // Send content to the page wrapper function
  614. $this->output($this->outputWrapper($content));
  615. break;
  616. case 'cleanup':
  617. $this->checkTheConfig();
  618. $this->silent=0;
  619. $this->cleanupManager();
  620. break;
  621. case 'phpinfo':
  622. $this->silent=0;
  623. $this->phpinformation();
  624. break;
  625. case 'typo3conf_edit':
  626. $this->silent=0;
  627. $this->typo3conf_edit();
  628. break;
  629. case 'logout':
  630. $enableInstallToolFile = PATH_site . 'typo3conf/ENABLE_INSTALL_TOOL';
  631. if (is_file($enableInstallToolFile) && trim(file_get_contents($enableInstallToolFile)) !== 'KEEP_FILE') {
  632. unlink(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
  633. }
  634. $this->formProtection->clean();
  635. $this->session->destroySession();
  636. t3lib_utility_Http::redirect($this->scriptSelf);
  637. break;
  638. case 'about':
  639. default:
  640. $this->silent=0;
  641. $this->message('About', 'Warning - very important!', $this->securityRisk().$this->alterPasswordForm(), 2);
  642. $this->message('About', 'Using this script', '
  643. <p>
  644. Installing TYPO3 has always been a hot topic on the
  645. mailing list and forums. Therefore we\'ve developed
  646. this tool which will help you through configuration
  647. and testing.
  648. <br />
  649. There are three primary steps for you to take:
  650. </p>
  651. <p>
  652. <strong>1: Basic Configuration</strong>
  653. <br />
  654. In this step your PHP-configuration is checked. If
  655. there are any settings that will prevent TYPO3 from
  656. running correctly you\'ll get warnings and errors
  657. with a description of the problem.
  658. <br />
  659. You\'ll have to enter a database username, password
  660. and hostname. Then you can choose to create a new
  661. database or select an existing one.
  662. <br />
  663. Finally the image processing settings are entered
  664. and verified and you can choose to let the script
  665. update the configuration file,
  666. typo3conf/localconf.php with the suggested settings.
  667. </p>
  668. <p>
  669. <strong>2: Database Analyser</strong>
  670. <br />
  671. In this step you can either install a new database
  672. or update the database from any previous TYPO3
  673. version.
  674. <br />
  675. You can also get an overview of extra/missing
  676. fields/tables in the database compared to a raw
  677. sql-file.
  678. <br />
  679. The database is also verified against your
  680. \'tables.php\' configuration ($TCA) and you can
  681. even see suggestions to entries in $TCA or new
  682. fields in the database.
  683. </p>
  684. <p>
  685. <strong>3: Upgrade Wizard</strong>
  686. <br />
  687. Here you will find update methods taking care of
  688. changes to the TYPO3 core which are not backwards
  689. compatible.
  690. <br />
  691. It is recommended to run this wizard after every
  692. update to make sure everything will still work
  693. flawlessly.
  694. </p>
  695. <p>
  696. <strong>4: Image Processing</strong>
  697. <br />
  698. This step is a visual guide to verify your
  699. configuration of the image processing software.
  700. <br />
  701. You\'ll be presented to a list of images that should
  702. all match in pairs. If some irregularity appears,
  703. you\'ll get a warning. Thus you\'re able to track an
  704. error before you\'ll discover it on your website.
  705. </p>
  706. <p>
  707. <strong>5: All Configuration</strong>
  708. <br />
  709. This gives you access to any of the configuration
  710. options in the TYPO3_CONF_VARS array. Every option
  711. is also presented with a comment explaining what it
  712. does.
  713. </p>
  714. <p>
  715. <strong>6: Cleanup</strong>
  716. <br />
  717. Here you can clean up the temporary files in typo3temp/
  718. folder and the tables used for caching of data in
  719. your database.
  720. </p>
  721. ');
  722. $this->message('About', 'Why is this script stand-alone?', '
  723. <p>
  724. You would think that this script should rather be a
  725. module in the backend and access-controlled to only
  726. admin-users from the database. But that\'s not how
  727. it works.
  728. <br />
  729. The reason is, that this script must not be
  730. depending on the success of the configuration of
  731. TYPO3 and whether or not there is a working database
  732. behind. Therefore the script is invoked from the
  733. backend init.php file, which allows access if the
  734. constant \'TYPO3_enterInstallScript\' has been
  735. defined and is not FALSE. That is and should be the
  736. case <em>only</em> when calling the script
  737. \'typo3/install/index.php\' - this script!
  738. </p>
  739. ');
  740. $headCode='Header legend';
  741. $this->message($headCode, 'Notice!', '
  742. <p>
  743. Indicates that something is important to be aware
  744. of.
  745. <br />
  746. This does <em>not</em> indicate an error.
  747. </p>
  748. ', 1);
  749. $this->message($headCode, 'Just information', '
  750. <p>
  751. This is a simple message with some information about
  752. something.
  753. </p>
  754. ');
  755. $this->message($headCode, 'Check was successful', '
  756. <p>
  757. Indicates that something was checked and returned an
  758. expected result.
  759. </p>
  760. ', -1);
  761. $this->message($headCode, 'Warning!', '
  762. <p>
  763. Indicates that something may very well cause trouble
  764. and you should definitely look into it before
  765. proceeding.
  766. <br />
  767. This indicates a <em>potential</em> error.
  768. </p>
  769. ', 2);
  770. $this->message($headCode, 'Error!', '
  771. <p>
  772. Indicates that something is definitely wrong and
  773. that TYPO3 will most likely not perform as expected
  774. if this problem is not solved.
  775. <br />
  776. This indicates an actual error.
  777. </p>
  778. ', 3);
  779. $this->output($this->outputWrapper($this->printAll()));
  780. break;
  781. }
  782. }
  783. }
  784. /**
  785. * Controls the step 1-2-3-go process
  786. *
  787. * @return string The content to output to the screen
  788. */
  789. function stepOutput() {
  790. // Get the template file
  791. $templateFile = @file_get_contents(
  792. PATH_site . $this->templateFilePath . 'StepOutput.html'
  793. );
  794. // Get the template part from the file
  795. $template = t3lib_parsehtml::getSubpart(
  796. $templateFile, '###TEMPLATE###'
  797. );
  798. // Define the markers content
  799. $markers = array(
  800. 'stepHeader' => $this->stepHeader(),
  801. 'notice' => 'Skip this wizard (for power users only)',
  802. 'skip123' => $this->scriptSelf
  803. );
  804. $this->checkTheConfig();
  805. $error_missingConnect = '
  806. <p class="typo3-message message-error">
  807. <strong>
  808. There is no connection to the database!
  809. </strong>
  810. <br />
  811. (Username: <em>' . htmlspecialchars(TYPO3_db_username) . '</em>,
  812. Host: <em>' . htmlspecialchars(TYPO3_db_host) . '</em>,
  813. Using Password: YES)
  814. <br />
  815. Go to Step 1 and enter a valid username and password!
  816. </p>
  817. ';
  818. $error_missingDB = '
  819. <p class="typo3-message message-error">
  820. <strong>
  821. There is no access to the database (<em>' . htmlspecialchars(TYPO3_db) . '</em>)!
  822. </strong>
  823. <br />
  824. Go to Step 2 and select a valid database!
  825. </p>
  826. ';
  827. // only get the number of tables if it is not the first two steps in the 123-installer
  828. // (= no DB connection yet)
  829. $whichTables = ($this->step != 1 && $this->step != 2 ? $this->sqlHandler->getListOfTables() : array());
  830. $error_emptyDB = '
  831. <p class="typo3-message message-error">
  832. <strong>
  833. The database is still empty. There are no tables!
  834. </strong>
  835. <br />
  836. Go to Step 3 and import a database!
  837. </p>
  838. ';
  839. // Hook to override and add steps to the 1-2-3 installer
  840. if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['stepOutput'])) {
  841. foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['stepOutput'] as $classData) {
  842. $hookObject = t3lib_div::getUserObj($classData);
  843. $hookObject->executeStepOutput($markers, $this->step, $this);
  844. }
  845. }
  846. // Use the default steps when there is no override
  847. if (!$markers['header'] && !$markers['step']) {
  848. switch(strtolower($this->step)) {
  849. case 1:
  850. // Get the subpart for the first step
  851. $step1SubPart = t3lib_parsehtml::getSubpart(
  852. $templateFile, '###STEP1###'
  853. );
  854. // Add header marker for main template
  855. $markers['header'] = 'Welcome to the TYPO3 Install Tool';
  856. // Define the markers content for the subpart
  857. $step1SubPartMarkers = array(
  858. 'llIntroduction' => '
  859. <p>
  860. TYPO3 is an enterprise content management system
  861. that is powerful, yet easy to install.
  862. </p>
  863. <p>
  864. In three simple steps you\'ll be ready to add content to your website.
  865. </p>
  866. ',
  867. 'step' => $this->step + 1,
  868. 'action' => htmlspecialchars($this->action),
  869. 'continue' => 'Continue'
  870. );
  871. // Add step marker for main template
  872. $markers['step'] = t3lib_parsehtml::substituteMarkerArray(
  873. $step1SubPart,
  874. $step1SubPartMarkers,
  875. '###|###',
  876. TRUE,
  877. FALSE
  878. );
  879. break;
  880. case 2:
  881. // Get the subpart for the second step
  882. $step2SubPart = t3lib_parsehtml::getSubpart(
  883. $templateFile, '###STEP2###'
  884. );
  885. // Add header marker for main template
  886. $markers['header'] = 'Connect to your database host';
  887. // Define the markers content for the subpart
  888. $step2SubPartMarkers = array(
  889. 'step' => $this->step + 1,
  890. 'action' => htmlspecialchars($this->action),
  891. 'encryptionKey' => $this->createEncryptionKey(),
  892. 'branch' => TYPO3_branch,
  893. 'labelUsername' => 'Username',
  894. 'username' => htmlspecialchars(TYPO3_db_username),
  895. 'labelPassword' => 'Password',
  896. 'password' => htmlspecialchars(TYPO3_db_password),
  897. 'labelHost' => 'Host',
  898. 'host' => TYPO3_db_host ? htmlspecialchars(TYPO3_db_host) : 'localhost',
  899. 'continue' => 'Continue',
  900. 'llDescription' => 'If you have not already created a username and password to access the database, please do so now. This can be done using tools provided by your host.'
  901. );
  902. // Add step marker for main template
  903. $markers['step'] = t3lib_parsehtml::substituteMarkerArray(
  904. $step2SubPart,
  905. $step2SubPartMarkers,
  906. '###|###',
  907. TRUE,
  908. FALSE
  909. );
  910. break;
  911. case 3:
  912. // Add header marker for main template
  913. $markers['header'] = 'Select database';
  914. // There should be a database host connection at this point
  915. if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(
  916. TYPO3_db_host, TYPO3_db_username, TYPO3_db_password
  917. )) {
  918. // Get the subpart for the third step
  919. $step3SubPart = t3lib_parsehtml::getSubpart(
  920. $templateFile, '###STEP3###'
  921. );
  922. // Get the subpart for the database options
  923. $step3DatabaseOptionsSubPart = t3lib_parsehtml::getSubpart(
  924. $step3SubPart, '###DATABASEOPTIONS###'
  925. );
  926. $dbArr = $this->getDatabaseList();
  927. $dbIncluded = 0;
  928. $step3DatabaseOptions = array();
  929. foreach ($dbArr as $dbname) {
  930. // Define the markers content for database options
  931. $step3DatabaseOptionMarkers = array(
  932. 'databaseValue' => htmlspecialchars($dbname),
  933. 'databaseSelected' => $dbname == TYPO3_db ? 'selected="selected"' : '',
  934. 'databaseName' => htmlspecialchars($dbname)
  935. );
  936. // Add the option HTML to an array
  937. $step3DatabaseOptions[] = t3lib_parsehtml::substituteMarkerArray(
  938. $step3DatabaseOptionsSubPart,
  939. $step3DatabaseOptionMarkers,
  940. '###|###',
  941. TRUE,
  942. TRUE
  943. );
  944. if ($dbname==TYPO3_db) $dbIncluded=1;
  945. }
  946. if (!$dbIncluded && TYPO3_db) {
  947. // // Define the markers content when no access
  948. $step3DatabaseOptionMarkers = array(
  949. 'databaseValue' => htmlspecialchars(TYPO3_db),
  950. 'databaseSelected' => 'selected="selected"',
  951. 'databaseName' => htmlspecialchars(TYPO3_db) . ' (NO ACCESS!)'
  952. );
  953. // Add the option HTML to an array
  954. $step3DatabaseOptions[] = t3lib_parsehtml::substituteMarkerArray(
  955. $step3DatabaseOptionsSubPart,
  956. $step3DatabaseOptionMarkers,
  957. '###|###',
  958. TRUE,
  959. TRUE
  960. );
  961. }
  962. $usePatternList = FALSE;
  963. $createDatabaseAllowed = $this->checkCreateDatabasePrivileges();
  964. if ($createDatabaseAllowed === TRUE) {
  965. $formFieldAttributesNew = 'checked="checked"';
  966. $llRemark1 = 'Enter a name for your TYPO3 database.';
  967. } elseif (is_array($createDatabaseAllowed)) {
  968. $llRemark1 = 'Enter a name for your TYPO3 database.';
  969. $llDbPatternRemark = 'The name has to match one of these names/patterns (% is a wild card):';
  970. $llDbPatternList = '<li>' . implode('</li><li>', $createDatabaseAllowed) . '</li>';
  971. $usePatternList = TRUE;
  972. } else {
  973. $formFieldAttributesNew = 'disabled="disabled"';
  974. $formFieldAttributesSelect = 'checked="checked"';
  975. $llRemark1 = 'You have no permissions to create new databases.';
  976. }
  977. // Substitute the subpart for the database options
  978. $content = t3lib_parsehtml::substituteSubpart(
  979. $step3SubPart,
  980. '###DATABASEOPTIONS###',
  981. implode(LF, $step3DatabaseOptions)
  982. );
  983. if ($usePatternList === FALSE) {
  984. $content = t3lib_parsehtml::substituteSubpart(
  985. $content,
  986. '###DATABASE_NAME_PATTERNS###',
  987. ''
  988. );
  989. }
  990. // Define the markers content
  991. $step3SubPartMarkers = array(
  992. 'step' => $this->step + 1,
  993. 'llOptions' => 'You have two options:',
  994. 'action' => htmlspecialchars($this->action),
  995. 'llOption1' => 'Create a new database (recommended):',
  996. 'llRemark1' => $llRemark1,
  997. 'll_Db_Pattern_Remark' => $llDbPatternRemark,
  998. 'll_Db_Pattern_List' => $llDbPatternList,
  999. 'formFieldAttributesNew' => $formFieldAttributesNew,
  1000. 'formFieldAttributesSelect' => $formFieldAttributesSelect,
  1001. 'llOption2' => 'Select an EMPTY existing database:',
  1002. 'llRemark2' => 'Any tables used by TYPO3 will be overwritten.',
  1003. 'continue' => 'Continue'
  1004. );
  1005. // Add step marker for main template
  1006. $markers['step'] = t3lib_parsehtml::substituteMarkerArray(
  1007. $content,
  1008. $step3SubPartMarkers,
  1009. '###|###',
  1010. TRUE,
  1011. TRUE
  1012. );
  1013. } else {
  1014. // Add step marker for main template when no connection
  1015. $markers['step'] = $error_missingConnect;
  1016. }
  1017. break;
  1018. case 4:
  1019. // Add header marker for main template
  1020. $markers['header'] = 'Import the Database Tables';
  1021. // There should be a database host connection at this point
  1022. if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(
  1023. TYPO3_db_host, TYPO3_db_username, TYPO3_db_password
  1024. )) {
  1025. // The selected database should be accessible
  1026. if ($GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) {
  1027. // Get the subpart for the fourth step
  1028. $step4SubPart = t3lib_parsehtml::getSubpart(
  1029. $templateFile, '###STEP4###'
  1030. );
  1031. // Get the subpart for the database type options
  1032. $step4DatabaseTypeOptionsSubPart = t3lib_parsehtml::getSubpart(
  1033. $step4SubPart, '###DATABASETYPEOPTIONS###'
  1034. );
  1035. $sFiles = t3lib_div::getFilesInDir(PATH_typo3conf, 'sql', 1, 1);
  1036. // Check if default database scheme "database.sql" already exists, otherwise create it
  1037. if (!strstr(implode(',', $sFiles).',', '/database.sql,')) {
  1038. array_unshift($sFiles, 'Default TYPO3 Tables');
  1039. }
  1040. $step4DatabaseTypeOptions = array();
  1041. foreach ($sFiles as $f) {
  1042. if ($f=='Default TYPO3 Tables') $key='CURRENT_TABLES+STATIC';
  1043. else $key=htmlspecialchars($f);
  1044. // Define the markers content for database type subpart
  1045. $step4DatabaseTypeOptionMarkers = array(
  1046. 'databaseTypeValue' => 'import|' . $key,
  1047. 'databaseName' => htmlspecialchars(basename($f))
  1048. );
  1049. // Add the option HTML to an array
  1050. $step4DatabaseTypeOptions[] = t3lib_parsehtml::substituteMarkerArray(
  1051. $step4DatabaseTypeOptionsSubPart,
  1052. $step4DatabaseTypeOptionMarkers,
  1053. '###|###',
  1054. TRUE,
  1055. FALSE
  1056. );
  1057. }
  1058. // Substitute the subpart for the database type options
  1059. $content = t3lib_parsehtml::substituteSubpart(
  1060. $step4SubPart,
  1061. '###DATABASETYPEOPTIONS###',
  1062. implode(LF, $step4DatabaseTypeOptions)
  1063. );
  1064. // Define the markers content
  1065. $step4SubPartMarkers = array(
  1066. 'llSummary' => 'Database summary:',
  1067. 'llUsername' => 'Username:',
  1068. 'username' => htmlspecialchars(TYPO3_db_username),
  1069. 'llHost' => 'Host:',
  1070. 'host' => htmlspecialchars(TYPO3_db_host),
  1071. 'llDatabase' => 'Database:',
  1072. 'database' => htmlspecialchars(TYPO3_db),
  1073. 'llNumberTables' => 'Number of tables:',
  1074. 'numberTables' => count($whichTables),
  1075. 'action' => htmlspecialchars($this->action),
  1076. 'llDatabaseType' => 'Select database contents:',
  1077. 'label' => 'Import database'
  1078. );
  1079. // Add step marker for main template
  1080. $markers['step'] = t3lib_parsehtml::substituteMarkerArray(
  1081. $content,
  1082. $step4SubPartMarkers,
  1083. '###|###',
  1084. TRUE,
  1085. TRUE
  1086. );
  1087. } else {
  1088. // Add step marker for main template when no database
  1089. $markers['step'] = $error_missingDB;
  1090. }
  1091. } else {
  1092. // Add step marker for main template when no connection
  1093. $markers['step'] = $error_missingConnect;
  1094. }
  1095. break;
  1096. case 'go':
  1097. // Add header marker for main template
  1098. $markers['header'] = 'Congratulations!';
  1099. // There should be a database host connection at this point
  1100. if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(
  1101. TYPO3_db_host, TYPO3_db_username, TYPO3_db_password
  1102. )) {
  1103. // The selected database should be accessible
  1104. if ($GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) {
  1105. // The database should contain tables
  1106. if (count($whichTables)) {
  1107. // Get the subpart for the go step
  1108. $stepGoSubPart = t3lib_parsehtml::getSubpart(
  1109. $templateFile, '###STEPGO###'
  1110. );
  1111. // Define the markers content
  1112. $stepGoSubPartMarkers = array(
  1113. 'messageBasicFinished' => $this->messageBasicFinished(),
  1114. 'llImportant' => 'Important Security Warning',
  1115. 'securityRisk' => $this->securityRisk(),
  1116. 'llSwitchMode' => '
  1117. <a href="' . $this->scriptSelf . '">
  1118. Change the Install Tool password here
  1119. </a>
  1120. '
  1121. );
  1122. // Add step marker for main template
  1123. $markers['step'] = t3lib_parsehtml::substituteMarkerArray(
  1124. $stepGoSubPart,
  1125. $stepGoSubPartMarkers,
  1126. '###|###',
  1127. TRUE,
  1128. TRUE
  1129. );
  1130. } else {
  1131. // Add step marker for main template when empty database
  1132. $markers['step'] = $error_emptyDB;
  1133. }
  1134. } else {
  1135. // Add step marker for main template when no database
  1136. $markers['step'] = $error_missingDB;
  1137. }
  1138. } else {
  1139. // Add step marker for main template when no connection
  1140. $markers['step'] = $error_missingConnect;
  1141. }
  1142. break;
  1143. }
  1144. }
  1145. // Fill the markers in the template
  1146. $content = t3lib_parsehtml::substituteMarkerArray(
  1147. $template,
  1148. $markers,
  1149. '###|###',
  1150. TRUE,
  1151. FALSE
  1152. );
  1153. return $content;
  1154. }
  1155. /**
  1156. * Calling the functions that checks the system
  1157. *
  1158. * @return void
  1159. */
  1160. function checkTheConfig() {
  1161. // Order important:
  1162. $this->checkDirs();
  1163. $this->checkConfiguration();
  1164. $this->checkExtensions();
  1165. if (TYPO3_OS=='WIN') {
  1166. $paths=array($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'], $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'], 'c:\\php\\imagemagick\\', 'c:\\php\\GraphicsMagick\\', 'c:\\apache\\ImageMagick\\', 'c:\\apache\\GraphicsMagick\\');
  1167. if (!isset($_SERVER['PATH'])) {
  1168. $serverPath = array_change_key_case($_SERVER, CASE_UPPER);
  1169. $paths = array_merge($paths, explode(';', $serverPath['PATH']));
  1170. } else {
  1171. $paths = array_merge($paths, explode(';', $_SERVER['PATH']));
  1172. }
  1173. } else {
  1174. $paths=array($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'], $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'], '/usr/local/bin/', '/usr/bin/', '/usr/X11R6/bin/', '/opt/local/bin/');
  1175. $paths = array_merge($paths, explode(':', $_SERVER['PATH']));
  1176. }
  1177. $paths = array_unique($paths);
  1178. asort($paths);
  1179. if (t3lib_utility_PhpOptions::isSafeModeEnabled()) {
  1180. $paths=array(ini_get('safe_mode_exec_dir'), '/usr/local/php/bin/');
  1181. }
  1182. if ($this->INSTALL['checkIM']['lzw']) {
  1183. $this->checkIMlzw=1;
  1184. }
  1185. if ($this->INSTALL['checkIM']['path']) {
  1186. $paths[]=trim($this->INSTALL['checkIM']['path']);
  1187. }
  1188. if ($this->checkIM) $this->checkImageMagick($paths);
  1189. $this->checkDatabase();
  1190. }
  1191. /**
  1192. * Editing files in typo3conf directory (or elsewhere if enabled)
  1193. *
  1194. * @return void
  1195. */
  1196. function typo3conf_edit() {
  1197. // default:
  1198. $EDIT_path = PATH_typo3conf;
  1199. if ($this->allowFileEditOutsite_typo3conf_dir && $this->INSTALL['FILE']['EDIT_path']) {
  1200. if (t3lib_div::validPathStr($this->INSTALL['FILE']['EDIT_path']) && substr($this->INSTALL['FILE']['EDIT_path'], -1)=='/') {
  1201. $tmp_path = PATH_site.$this->INSTALL['FILE']['EDIT_path'];
  1202. if (is_dir($tmp_path)) {
  1203. $EDIT_path=$tmp_path;
  1204. } else {
  1205. $this->errorMessages[] = '
  1206. \'' . $tmp_path . '\' was not directory
  1207. ';
  1208. }
  1209. } else {
  1210. $this->errorMessages[] = '
  1211. Bad directory name (must be like t3lib/ or media/script/)
  1212. ';
  1213. }
  1214. }
  1215. $headCode = 'Edit files in '.basename($EDIT_path).'/';
  1216. $messages = '';
  1217. if ($this->INSTALL['SAVE_FILE']) {
  1218. $save_to_file = $this->INSTALL['FILE']['name'];
  1219. if (@is_file($save_to_file)) {
  1220. $save_to_file_md5 = md5($save_to_file);
  1221. if (isset($this->INSTALL['FILE'][$save_to_file_md5]) && t3lib_div::isFirstPartOfStr($save_to_file, $EDIT_path.'') && substr($save_to_file, -1)!='~' && !strstr($save_to_file, '_bak')) {
  1222. $this->INSTALL['typo3conf_files'] = $save_to_file;
  1223. $save_fileContent = $this->INSTALL['FILE'][$save_to_file_md5];
  1224. if ($this->INSTALL['FILE']['win_to_unix_br']) {
  1225. $save_fileContent = str_replace(CRLF, LF, $save_fileContent);
  1226. }
  1227. $backupFile = $this->getBackupFilename($save_to_file);
  1228. if ($this->INSTALL['FILE']['backup']) {
  1229. if (@is_file($backupFile)) { unlink($backupFile); }
  1230. rename($save_to_file, $backupFile);
  1231. $messages .= '
  1232. Backup written to <strong>' . $backupFile . '</strong>
  1233. <br />
  1234. ';
  1235. }
  1236. t3lib_div::writeFile($save_to_file, $save_fileContent);
  1237. $messages .= '
  1238. File saved: <strong>' . $save_to_file . '</strong>
  1239. <br />
  1240. MD5-sum: ' . $this->INSTALL['FILE']['prevMD5'] . ' (prev)
  1241. <br />
  1242. MD5-sum: ' . md5($save_fileContent) . ' (new)
  1243. <br />
  1244. ';
  1245. }
  1246. }
  1247. }
  1248. // Filelist:
  1249. // Get the template file
  1250. $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'Typo3ConfEdit.html');
  1251. // Get the template part from the file
  1252. $template = t3lib_parsehtml::getSubpart($templateFile, '###TEMPLATE###');
  1253. // Get the subpart for the files
  1254. $filesSubpart = t3lib_parsehtml::getSubpart($template, '###FILES###');
  1255. $files = array();
  1256. $typo3conf_files = t3lib_div::getFilesInDir($EDIT_path, '', 1, 1);
  1257. $fileFound = 0;
  1258. foreach ($typo3conf_files as $k => $file) {
  1259. // Delete temp_CACHED files if option is set
  1260. if ( $this->INSTALL['delTempCached'] && preg_match('|/temp_CACHED_[a-z0-9_]+\.php|', $file)) {
  1261. unlink($file);
  1262. continue;
  1263. }
  1264. if ($this->INSTALL['typo3conf_files'] && !strcmp($this->INSTALL['typo3conf_files'], $file)) {
  1265. $fileFound = 1;
  1266. }
  1267. // Define the markers content for the files subpart
  1268. $filesMarkers = array(
  1269. 'editUrl' => $this->action . '&amp;TYPO3_INSTALL[typo3conf_files]=' . rawurlencode($file) . ($this->allowFileEditOutsite_typo3conf_dir ? '&amp;TYPO3_INSTALL[FILE][EDIT_path]=' . rawurlencode($this->INSTALL['FILE']['EDIT_path']) : '') . '#confEditFileList',
  1270. 'fileName' => basename($file),
  1271. 'fileSize' => t3lib_div::formatSize(filesize($file)),
  1272. 'class' => $this->INSTALL['typo3conf_files'] && !strcmp($this->INSTALL['typo3conf_files'], $file) ? 'class="act"' : ''
  1273. );
  1274. // Fill the markers in the subpart
  1275. $files[] = t3lib_parsehtml::substituteMarkerArray(
  1276. $filesSubpart,
  1277. $filesMarkers,
  1278. '###|###',
  1279. TRUE,
  1280. FALSE
  1281. );
  1282. }
  1283. if ($fileFound && @is_file($this->INSTALL['typo3conf_files'])) {
  1284. $backupFile = $this->getBackupFilename($this->INSTALL['typo3conf_files']);
  1285. $fileContent = t3lib_div::getUrl($this->INSTALL['typo3conf_files']);
  1286. // Get the subpart to edit the files
  1287. $fileEditTemplate = t3lib_parsehtml::getSubpart($template, '###FILEEDIT###');
  1288. $allowFileEditOutsideTypo3ConfDirSubPart = '';
  1289. if (substr($this->INSTALL['typo3conf_files'], -1) != '~' && !strstr($this->INSTALL['typo3conf_files'], '_bak')) {
  1290. // Get the subpart to show the save button
  1291. $showSaveButtonSubPart = t3lib_parsehtml::getSubpart($fileEditTemplate, '###SHOWSAVEBUTTON###');
  1292. }
  1293. if ($this->allowFileEditOutsite_typo3conf_dir) {
  1294. // Get the subpart to show if files are allowed outside the directory typo3conf
  1295. $allowFileEditOutsideTypo3ConfDirSubPart = t3lib_parsehtml::getSubpart($fileEditTemplate, '###ALLOWFILEEDITOUTSIDETYPO3CONFDIR###');
  1296. }
  1297. // Substitute the subpart for the save button
  1298. $fileEditContent = t3lib_parsehtml::substituteSubpart(
  1299. $fileEditTemplate,
  1300. '###SHOWSAVEBUTTON###',
  1301. $showSaveButtonSubPart
  1302. );
  1303. // Substitute the subpart to show if files are allowed outside the directory typo3conf
  1304. $fileEditContent = t3lib_parsehtml::substituteSubpart(
  1305. $fileEditContent,
  1306. '###ALLOWFILEEDITOUTSIDETYPO3CONFDIR###',
  1307. $allowFileEditOutsideTypo3ConfDirSubPart
  1308. );
  1309. // Define the markers content for subpart to edit the files
  1310. $fileEditMarkers = array(
  1311. 'messages' => !empty($messages) ? '<p class="typo3-message message-warning">' . $messages . '</p>' : '',
  1312. 'action' => $this->action . '#fileEditHeader',
  1313. 'saveFile' => 'Save file',
  1314. 'close' => 'Close',
  1315. 'llEditing' => 'Editing file:',
  1316. 'file' => $this->INSTALL['typo3conf_files'],
  1317. 'md5Sum' => 'MD5-sum: ' . md5($fileContent),
  1318. 'fileName' => $this->INSTALL['typo3conf_files'],
  1319. 'fileEditPath' => $this->INSTALL['FILE']['EDIT_path'],
  1320. 'filePreviousMd5' => md5($fileContent),
  1321. 'fileMd5' => md5($this->INSTALL['typo3conf_files']),
  1322. 'fileContent' => t3lib_div::formatForTextarea($fileContent),
  1323. 'winToUnixBrChecked' => TYPO3_OS == 'WIN' ? '' : 'checked="checked"',
  1324. 'winToUnixBr' => 'Convert Windows linebreaks (13-10) to Unix (10)',
  1325. 'backupChecked' => @is_file($backupFile) ? 'checked="checked"' : '',
  1326. 'backup' => 'Make backup copy (rename to ' . basename($backupFile) . ')'
  1327. );
  1328. // Fill the markers in the subpart to edit the files
  1329. $fileEditContent = t3lib_parsehtml::substituteMarkerArray(
  1330. $fileEditContent,
  1331. $fileEditMarkers,
  1332. '###|###',
  1333. TRUE,
  1334. FALSE
  1335. );
  1336. }
  1337. if ($this->allowFileEditOutsite_typo3conf_dir) {
  1338. // Get the subpart to show if files are allowed outside the directory typo3conf
  1339. $allowFileEditOutsideTypo3ConfDirSubPart = t3lib_parsehtml::getSubpart($template, '###ALLOWFILEEDITOUTSIDETYPO3CONFDIR###');
  1340. // Define the markers content
  1341. $allowFileEditOutsideTypo3ConfDirMarkers = array(
  1342. 'action' => $this->acti

Large files files are truncated, but you can click here to view the full file