PageRenderTime 58ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 1ms

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

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

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