PageRenderTime 79ms CodeModel.GetById 9ms RepoModel.GetById 1ms app.codeStats 1ms

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

https://bitbucket.org/linxpinx/mercurial
PHP | 8293 lines | 6508 code | 514 blank | 1271 comment | 691 complexity | 41346c6ea0247517b44398a615973399 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0, Unlicense, LGPL-2.1, Apache-2.0

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

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