[TASK] Cleanup of includes
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / mod / class.tx_install.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Contains the class for the Install Tool
29 *
30 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
31 * @author Ingmar Schlecht <ingmar@typo3.org>
32 */
33 /**
34 * [CLASS/FUNCTION INDEX of SCRIPT]
35 *
36 *
37 *
38 * 162: class tx_install extends t3lib_install
39 * 234: function tx_install()
40 * 318: function checkPassword()
41 * 362: function loginForm()
42 * 396: function init()
43 * 574: function stepOutput()
44 * 836: function checkTheConfig()
45 * 867: function typo3conf_edit()
46 * 976: function phpinformation()
47 *
48 * SECTION: typo3temp/ manager
49 * 1079: function typo3TempManager()
50 * 1199: function getSelectorOptions($deleteType,$tt='')
51 *
52 * SECTION: cleanup manager
53 * 1231: function cleanupManager()
54 *
55 * SECTION: CONFIGURATION FORM
56 * 1299: function generateConfigForm($type='')
57 * 1367: function getDefaultConfigArrayComments($string,$mainArray=array(),$commentArray=array())
58 *
59 * SECTION: CHECK CONFIGURATION FUNCTIONS
60 * 1419: function checkConfiguration()
61 * 1572: function check_mail($cmd='')
62 * 1611: function checkExtensions()
63 * 1673: function checkDirs()
64 * 1762: function checkImageMagick($paths)
65 * 1837: function _checkImageMagickGifCapability($path)
66 * 1880: function _checkImageMagick_getVersion($file, $path)
67 * 1915: function checkDatabase()
68 * 1977: function setupGeneral($cmd='')
69 * 2166: function writeToLocalconf_control($lines="", $showOutput=1)
70 * 2190: function outputExitBasedOnStep($content)
71 * 2206: function setLabelValueArray($arr,$type)
72 * 2246: function getFormElement($labels,$values,$fieldName,$default,$msg='')
73 * 2266: function getDatabaseList()
74 * 2290: function setupGeneralCalculate()
75 * 2387: function isTTF()
76 *
77 * SECTION: ABOUT the isXXX functions.
78 * 2436: function isGD()
79 * 2447: function isGIF()
80 * 2459: function isJPG()
81 * 2470: function isPNG()
82 * 2482: function ImageTypes()
83 * 2493: function getGDSoftwareInfo()
84 * 2505: function generallyAboutConfiguration()
85 *
86 * SECTION: IMAGE processing
87 * 2565: function checkTheImageProcessing()
88 * 3046: function isExtensionEnabled($ext, $headCode, $short)
89 * 3062: function displayTwinImage ($imageFile, $IMcommands=array(), $note='')
90 * 3130: function getTwinImageMessage($message, $label_1="", $label_2='')
91 * 3146: function formatImCmds($arr)
92 * 3167: function imagemenu()
93 *
94 * SECTION: DATABASE analysing
95 * 3209: function checkTheDatabase()
96 * 3849: function updateWizard()
97 * 3873: function updateWizard_parts($action)
98 * 3987: function getUpgradeObjInstance($className, $identifier)
99 * 4000: function isBackendAdminUser()
100 * 4023: function isBasicComplete($tLabel)
101 * 4063: function generateUpdateDatabaseForm($type, $arr_update, $arr_remove, $action_type)
102 * 4094: function getUpdateDbFormWrap($action_type, $content, $label='Write to database')
103 * 4107: function displayFields($arr, $pre=0, $label='')
104 * 4132: function displayFieldComp($arr, $arr_db)
105 * 4174: function displaySuggestions($arr, $excludeList='')
106 * 4204: function compareDatabaseAndTCA($FDsrc, $TCA, $onlyFields=0)
107 * 4262: function compareTCAandDatabase($TCA, $FDcomp)
108 * 4296: function suggestFieldDefinition($fieldInfo)
109 * 4373: function getItemArrayType($arr)
110 * 4401: function getItemBlobSize($len)
111 * 4412: function suggestTCAFieldDefinition($fieldName,$fieldInfo)
112 * 4555: function includeTCA()
113 *
114 * SECTION: GENERAL FUNCTIONS
115 * 4597: function linkIt($url,$link='')
116 * 4611: function message($head, $short_string='', $long_string='', $type=0, $force=0)
117 * 4632: function printSection($head, $short_string, $long_string, $type)
118 * 4673: function fw($str,$size=1)
119 * 4696: function fwheader($str)
120 * 4707: function wrapInCells($label,$content)
121 * 4716: function printAll()
122 * 4735: function outputWrapper($content)
123 * 4801: function menu()
124 * 4823: function stepHeader()
125 * 4865: function note123()
126 * 4879: function endNotes()
127 * 4912: function securityRisk()
128 * 4930: function alterPasswordForm()
129 * 4946: function messageBasicFinished()
130 * 4968: function setScriptName($type)
131 * 4981: function formWidth($size=48,$textarea=0,$styleOverride='')
132 * 5002: function formWidthText($size=48,$styleOverride='',$wrap='')
133 * 5018: function getBackupFilename($filename)
134 *
135 * TOTAL FUNCTIONS: 82
136 * (This index is automatically created/updated by the extension "extdeveval")
137 *
138 */
139
140 // include requirements definition:
141 require_once(t3lib_extMgm::extPath('install') . 'requirements.php');
142
143 // include session handling
144 require_once(t3lib_extMgm::extPath('install') . 'mod/class.tx_install_session.php');
145
146 // include update classes
147 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_charsetdefaults.php');
148 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_compatversion.php');
149 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_cscsplit.php');
150 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_notinmenu.php');
151 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_mergeadvanced.php');
152 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_installsysexts.php');
153 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_imagescols.php');
154 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_installnewsysexts.php');
155 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_statictemplates.php');
156 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_t3skin.php');
157 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_compressionlevel.php');
158 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_migrateworkspaces.php');
159 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_flagsfromsprite.php');
160 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_addflexformstoacl.php');
161 require_once(t3lib_extMgm::extPath('install') . 'updates/class.tx_coreupdates_imagelink.php');
162
163 /**
164 * Install Tool module
165 *
166 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
167 * @author Ingmar Schlecht <ingmar@typo3.org>
168 * @package TYPO3
169 * @subpackage tx_install
170 */
171 class tx_install extends t3lib_install {
172 var $templateFilePath = 'typo3/sysext/install/Resources/Private/Templates/';
173 var $template;
174 var $javascript;
175 var $stylesheets;
176 var $markers = array();
177 var $messages = array();
178 var $errorMessages = array();
179 var $mailMessage = '';
180 var $action = ''; // The url that calls this script
181 var $scriptSelf = 'index.php'; // The url that calls this script
182 var $updateIdentity = 'TYPO3 Install Tool';
183 var $headerStyle ='';
184 var $setAllCheckBoxesByDefault=0;
185
186 var $allowFileEditOutsite_typo3conf_dir=0;
187
188 var $INSTALL =array(); // In constructor: is set to global GET/POST var TYPO3_INSTALL
189 var $checkIMlzw = 0; // If set, lzw capabilities of the available ImageMagick installs are check by actually writing a gif-file and comparing size
190 var $checkIM = 0; // If set, ImageMagick is checked.
191 var $dumpImCommands=1; // If set, the image Magick commands are always outputted in the image processing checker
192 var $mode = ''; // If set to "123" then only most vital information is displayed.
193 var $step = 0; // If set to 1,2,3 or GO it signifies various functions.
194 var $totalSteps = 4; // Can be changed by hook to define the total steps in 123 mode
195
196 // internal
197 var $passwordOK=0; // This is set, if the password check was ok. The function init() will exit if this is not set
198 var $silent=1; // If set, the check routines don't add to the message-array
199 var $sections=array(); // Used to gather the message information.
200 var $fatalError=0; // This is set if some error occured that will definitely prevent TYpo3 from running.
201 var $sendNoCacheHeaders=1;
202 var $config_array = array( // Flags are set in this array if the options are available and checked ok.
203 'gd'=>0,
204 'gd_gif'=>0,
205 'gd_png'=>0,
206 'gd_jpg'=>0,
207 'freetype' => 0,
208 'safemode' => 0,
209 'dir_typo3temp' => 0,
210 'dir_temp' => 0,
211 'im_versions' => array(),
212 'im' => 0,
213 'sql.safe_mode_user' => '',
214 'mysqlConnect' => 0,
215 'no_database' => 0
216 );
217 var $typo3temp_path='';
218 /**
219 * the session handling object
220 *
221 * @var tx_install_session
222 */
223 protected $session = NULL;
224
225 /**
226 * the form protection instance used for creating and verifying form tokens
227 *
228 * @var t3lib_formprotection_InstallToolFormProtection
229 */
230 protected $formProtection = NULL;
231
232 var $menuitems = array(
233 'config' => 'Basic Configuration',
234 'database' => 'Database Analyser',
235 'update' => 'Upgrade Wizard',
236 'images' => 'Image Processing',
237 'extConfig' => 'All Configuration',
238 'cleanup' => 'Clean up',
239 'phpinfo' => 'phpinfo()',
240 'typo3conf_edit' => 'Edit files in typo3conf/',
241 'about' => 'About',
242 'logout' => 'Logout from Install Tool',
243 );
244
245 // PHP modules which are required. Can be changed by hook in getMissingPhpModules()
246 protected $requiredPhpModules = array(
247 'filter',
248 'gd',
249 'json',
250 'mysql',
251 'pcre',
252 'session',
253 'SPL',
254 'standard',
255 'xml',
256 'zlib'
257 );
258
259
260
261
262
263 /**
264 * Constructor
265 *
266 * @return void
267 */
268 function __construct() {
269 parent::__construct();
270
271 if (!$GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword']) {
272 $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');
273 }
274
275 if ($this->sendNoCacheHeaders) {
276 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
277 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
278 header('Expires: 0');
279 header('Cache-Control: no-cache, must-revalidate');
280 header('Pragma: no-cache');
281 }
282
283 // ****************************
284 // Initializing incoming vars.
285 // ****************************
286 $this->INSTALL = t3lib_div::_GP('TYPO3_INSTALL');
287 $this->mode = t3lib_div::_GP('mode');
288 if ($this->mode !== '123') {
289 $this->mode = '';
290 }
291 if (t3lib_div::_GP('step') === 'go') {
292 $this->step = 'go';
293 } else {
294 $this->step = intval(t3lib_div::_GP('step'));
295 }
296
297 // Let DBAL decide whether to load itself
298 $dbalLoaderFile = $this->backPath . 'sysext/dbal/class.tx_dbal_autoloader.php';
299 if (@is_file($dbalLoaderFile)) {
300 include($dbalLoaderFile);
301 }
302
303 if ($this->mode === '123') {
304 // Check for mandatory PHP modules
305 $missingPhpModules = $this->getMissingPhpModules();
306 if (count($missingPhpModules) > 0) {
307 throw new RuntimeException('TYPO3 Installation Error: The following PHP module(s) is/are missing: <em>' .
308 implode(', ', $missingPhpModules) .
309 '</em><br /><br />You need to install and enable these modules first to be able to install TYPO3.',
310 1294587482
311 );
312 }
313 }
314 $this->redirect_url = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('redirect_url'));
315
316 $this->INSTALL['type'] = '';
317 if ($_GET['TYPO3_INSTALL']['type']) {
318 $allowedTypes = array(
319 'config', 'database', 'update', 'images', 'extConfig',
320 'cleanup', 'phpinfo', 'typo3conf_edit', 'about', 'logout'
321 );
322
323 if (in_array($_GET['TYPO3_INSTALL']['type'], $allowedTypes)) {
324 $this->INSTALL['type'] = $_GET['TYPO3_INSTALL']['type'];
325 }
326 }
327
328 if ($this->step == 4) {
329 $this->INSTALL['type'] = 'database';
330 }
331
332 // Hook to raise the counter for the total steps in the 1-2-3 installer
333 if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['additionalSteps'])) {
334 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['additionalSteps'] as $classData) {
335 $hookObject = t3lib_div::getUserObj($classData);
336 $this->totalSteps += (integer) $hookObject->executeAdditionalSteps($this);
337 }
338 }
339
340 if ($this->mode=='123') {
341 $tempItems = $this->menuitems;
342 $this->menuitems = array(
343 'config' => $tempItems['config'],
344 'database' => $tempItems['database']
345 );
346 if (!$this->INSTALL['type'] || !isset($this->menuitems[$this->INSTALL['type']])) {
347 $this->INSTALL['type'] = 'config';
348 }
349 } else {
350 if (!$this->INSTALL['type'] || !isset($this->menuitems[$this->INSTALL['type']])) {
351 $this->INSTALL['type'] = 'about';
352 }
353 }
354
355 $this->action = $this->scriptSelf .
356 '?TYPO3_INSTALL[type]=' . $this->INSTALL['type'] .
357 ($this->mode? '&mode=' . $this->mode : '') .
358 ($this->step? '&step=' . $this->step : '');
359 $this->typo3temp_path = PATH_site.'typo3temp/';
360 if (!is_dir($this->typo3temp_path) || !is_writeable($this->typo3temp_path)) {
361 $this->outputErrorAndExit('Install Tool needs to write to typo3temp/. Make sure this directory is writeable by your webserver: ' . htmlspecialchars($this->typo3temp_path), 'Fatal error');
362 }
363
364 try {
365 $this->session = t3lib_div::makeInstance('tx_install_session');
366 } catch (Exception $exception) {
367 $this->outputErrorAndExit($exception->getMessage());
368 }
369
370 // *******************
371 // Check authorization
372 // *******************
373 if (!$this->session->hasSession()) {
374 $this->session->startSession();
375 }
376
377 if ($this->session->isAuthorized() || $this->checkPassword()) {
378 $this->passwordOK=1;
379 $this->session->refreshSession();
380
381 $enableInstallToolFile = PATH_typo3conf . 'ENABLE_INSTALL_TOOL';
382 if (is_file ($enableInstallToolFile)) {
383 // Extend the age of the ENABLE_INSTALL_TOOL file by one hour
384 @touch($enableInstallToolFile);
385 }
386
387 if($this->redirect_url) {
388 t3lib_utility_Http::redirect($this->redirect_url);
389 }
390
391 $this->formProtection = t3lib_formProtection_Factory::get(
392 't3lib_formprotection_InstallToolFormProtection'
393 );
394 $this->formProtection->injectInstallTool($this);
395 } else {
396 $this->loginForm();
397 }
398 }
399
400 /**
401 * Returns TRUE if submitted password is ok.
402 *
403 * If password is ok, set session as "authorized".
404 *
405 * @return boolean TRUE if the submitted password was ok and session was
406 * authorized, FALSE otherwise
407 */
408 function checkPassword() {
409 $p = t3lib_div::_GP('password');
410
411 if ($p && md5($p)==$GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword']) {
412 $this->session->setAuthorized();
413
414 // Sending warning email
415 $wEmail = $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'];
416 if ($wEmail) {
417 $subject="Install Tool Login at '".$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']."'";
418 $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').')';
419 mail($wEmail,
420 $subject,
421 $email_body,
422 'From: TYPO3 Install Tool WARNING <>'
423 );
424 }
425 return TRUE;
426 } else {
427 // Bad password, send warning:
428 if ($p) {
429 $wEmail = $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'];
430 if ($wEmail) {
431 $subject="Install Tool Login ATTEMPT at '".$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']."'";
432 $email_body="There has been an Install Tool login attempt at TYPO3 site '".$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']."' (".t3lib_div::getIndpEnv('HTTP_HOST').").
433 The MD5 hash of the last 5 characters of the password tried was '".substr(md5($p), -5)."'
434 REMOTE_ADDR was '".t3lib_div::getIndpEnv('REMOTE_ADDR')."' (".t3lib_div::getIndpEnv('REMOTE_HOST').')';
435 mail($wEmail,
436 $subject,
437 $email_body,
438 'From: TYPO3 Install Tool WARNING <>'
439 );
440 }
441 }
442 return FALSE;
443 }
444 }
445
446 /**
447 * Create the HTML for the login form
448 *
449 * Reads and fills the template.
450 * Substitutes subparts when wrong password has been given
451 * or the session has expired
452 *
453 * @return void
454 */
455 function loginForm() {
456 $password = t3lib_div::_GP('password');
457 $redirect_url = $this->redirect_url ? $this->redirect_url : $this->action;
458 // Get the template file
459 $templateFile = @file_get_contents(
460 PATH_site . $this->templateFilePath . 'LoginForm.html'
461 );
462 // Get the template part from the file
463 $template = t3lib_parsehtml::getSubpart(
464 $templateFile, '###TEMPLATE###'
465 );
466 // Password has been given, but this form is rendered again.
467 // This means the given password was wrong
468 if (!empty($password)) {
469 // Get the subpart for the wrong password
470 $wrongPasswordSubPart = t3lib_parsehtml::getSubpart(
471 $template, '###WRONGPASSWORD###'
472 );
473 // Define the markers content
474 $wrongPasswordMarkers = array(
475 'passwordMessage' => 'The password you just tried has this md5-value:',
476 'password' => md5($password)
477 );
478 // Fill the markers in the subpart
479 $wrongPasswordSubPart = t3lib_parsehtml::substituteMarkerArray(
480 $wrongPasswordSubPart,
481 $wrongPasswordMarkers,
482 '###|###',
483 TRUE,
484 TRUE
485 );
486 }
487 // Session has expired
488 if (!$this->session->isAuthorized() && $this->session->isExpired()) {
489 // Get the subpart for the expired session message
490 $sessionExpiredSubPart = t3lib_parsehtml::getSubpart(
491 $template, '###SESSIONEXPIRED###'
492 );
493 // Define the markers content
494 $sessionExpiredMarkers = array(
495 'message' => 'Your Install Tool session has expired'
496 );
497 // Fill the markers in the subpart
498 $sessionExpiredSubPart = t3lib_parsehtml::substituteMarkerArray(
499 $sessionExpiredSubPart,
500 $sessionExpiredMarkers,
501 '###|###',
502 TRUE,
503 TRUE
504 );
505 }
506 // Substitute the subpart for the expired session in the template
507 $template = t3lib_parsehtml::substituteSubpart(
508 $template,
509 '###SESSIONEXPIRED###',
510 $sessionExpiredSubPart
511 );
512 // Substitute the subpart for the wrong password in the template
513 $template = t3lib_parsehtml::substituteSubpart(
514 $template,
515 '###WRONGPASSWORD###',
516 $wrongPasswordSubPart
517 );
518 // Define the markers content
519 $markers = array(
520 'siteName' => 'Site: ' .
521 htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']),
522 'headTitle' => 'Login to TYPO3 ' . TYPO3_version . ' Install Tool',
523 'redirectUrl' => htmlspecialchars($redirect_url),
524 'enterPassword' => 'Password',
525 'login' => 'Login',
526 'message' => '
527 <p class="typo3-message message-information">
528 The Install Tool Password is <em>not</em> the admin password
529 of TYPO3.
530 <br />
531 The default password is <em>joh316</em>. Be sure to change it!
532 <br /><br />
533 If you don\'t know the current password, you can set a new
534 one by setting the value of
535 $TYPO3_CONF_VARS[\'BE\'][\'installToolPassword\'] in
536 typo3conf/localconf.php to the md5() hash value of the
537 password you desire.
538 </p>
539 '
540 );
541 // Fill the markers in the template
542 $content = t3lib_parsehtml::substituteMarkerArray(
543 $template,
544 $markers,
545 '###|###',
546 TRUE,
547 TRUE
548 );
549
550 // Send content to the page wrapper function
551 $this->output($this->outputWrapper($content));
552 }
553
554 /**
555 * Calling function that checks system, IM, GD, dirs, database
556 * and lets you alter localconf.php
557 *
558 * This method is called from init.php to start the Install Tool.
559 *
560 * @return void
561 */
562 function init() {
563 // Must be called after inclusion of init.php (or from init.php)
564 if (!defined('PATH_typo3')) exit;
565 if (!$this->passwordOK) exit;
566
567 // Setting stuff...
568 $this->check_mail();
569 $this->setupGeneral();
570 $this->generateConfigForm();
571 if (count($this->messages)) {
572 t3lib_div::debug($this->messages);
573 }
574
575 if ($this->step) {
576 $this->output($this->outputWrapper($this->stepOutput()));
577 } else {
578
579 // Menu...
580 switch($this->INSTALL['type']) {
581 case 'images':
582 $this->checkIM=1;
583 $this->checkTheConfig();
584 $this->silent=0;
585 $this->checkTheImageProcessing();
586 break;
587 case 'database':
588 $this->checkTheConfig();
589 $this->silent=0;
590 $this->checkTheDatabase();
591 break;
592 case 'update':
593 $this->checkDatabase();
594 $this->silent=0;
595 $this->updateWizard();
596 break;
597 case 'config':
598 $this->silent=0;
599 $this->checkIM=1;
600 $this->message(
601 'About configuration',
602 'How to configure TYPO3',
603 $this->generallyAboutConfiguration()
604 );
605 $this->message(
606 'System Information',
607 'Your system has the following configuration',
608 '
609 <dl id="systemInformation">
610 <dt>OS detected:</dt>
611 <dd>' . (TYPO3_OS == 'WIN' ? 'WIN' : 'UNIX') .'</dd>
612 <dt>UNIX/CGI detected:</dt>
613 <dd>' . (PHP_SAPI == 'cgi' ? 'YES' : 'NO') . '</dd>
614 <dt>PATH_thisScript:</dt>
615 <dd>' . PATH_thisScript . '</dd>
616 </dl>
617 '
618 );
619 $this->checkTheConfig();
620
621 $ext = 'Write config to localconf.php';
622 if ($this->fatalError) {
623 if (
624 $this->config_array['no_database'] ||
625 !$this->config_array['mysqlConnect']
626 ) {
627 $this->message($ext, 'Database not configured yet!', '
628 <p>
629 You need to specify database username,
630 password and host as one of the first things.
631 <br />
632 Next you\'ll have to select a database to
633 use with TYPO3.
634 </p>
635 <p>
636 Use the form below.
637 </p>
638 ', 2);
639 } else {
640 $this->message($ext, 'Fatal error encountered!', '
641 <p>
642 Somewhere above a fatal configuration
643 problem is encountered.
644 Please make sure that you\'ve fixed this
645 error before you submit the configuration.
646 TYPO3 will not run if this problem is not
647 fixed!
648 <br />
649 You should also check all warnings that may
650 appear.
651 </p>
652 ', 2);
653 }
654 } elseif ($this->mode=='123') {
655 if (!$this->fatalError) {
656 $this->message($ext, 'Basic configuration completed', '
657 <p>
658 You have no fatal errors in your basic
659 configuration.
660 You may have warnings though. Please pay
661 attention to them!
662 However you may continue and install the
663 database.
664 </p>
665 <p>
666 <strong>
667 <span style="color:#f00;">Step 2: </span>
668 </strong>
669 <a href="' . $this->scriptSelf .
670 '?TYPO3_INSTALL[type]=database' .
671 ($this->mode ? '&mode=' . rawurlencode($this->mode) : '') .
672 '">Click here to install the database.</a>
673 </p>
674 ', -1, 1);
675 }
676 }
677 $this->message($ext, 'Very Important: Changing Image Processing settings', '
678 <p>
679 When you change the settings for Image Processing
680 you <em>must</em> take into account
681 that <em>old images</em> may still be in typo3temp/
682 folder and prevent new files from being generated!
683 <br />
684 This is especially important to know, if you\'re
685 trying to set up image processing for the very first
686 time.
687 <br />
688 The problem is solved by <a href="' .
689 htmlspecialchars($this->setScriptName('cleanup')) .
690 '">clearing the typo3temp/ folder</a>.
691 Also make sure to clear the cache_pages table.
692 </p>
693 ', 1, 1);
694 $this->message($ext, 'Very Important: Changing Encryption Key setting', '
695 <p>
696 When you change the setting for the Encryption Key
697 you <em>must</em> take into account that a change to
698 this value might invalidate temporary information,
699 URLs etc.
700 <br />
701 The problem is solved by <a href="' .
702 htmlspecialchars($this->setScriptName('cleanup')) .
703 '">clearing the typo3temp/ folder</a>.
704 Also make sure to clear the cache_pages table.
705 </p>
706 ', 1, 1);
707 $this->message($ext, 'Update localconf.php', '
708 <p>
709 This form updates the localconf.php file with the
710 suggested values you see below. The values are based
711 on the analysis above.
712 <br />
713 You can change the values in case you have
714 alternatives to the suggested defaults.
715 <br />
716 By this final step you will configure TYPO3 for
717 immediate use provided that you have no fatal errors
718 left above.
719 </p>' . $this->setupGeneral('get_form') . '
720 ', 0, 1);
721
722 $this->output($this->outputWrapper($this->printAll()));
723
724 break;
725 case 'extConfig':
726 $this->silent=0;
727 $this->generateConfigForm('get_form');
728 // Get the template file
729 $templateFile = @file_get_contents(
730 PATH_site . $this->templateFilePath . 'InitExtConfig.html'
731 );
732 // Get the template part from the file
733 $template = t3lib_parsehtml::getSubpart(
734 $templateFile, '###TEMPLATE###'
735 );
736 // Define the markers content
737 $markers = array(
738 'action' => $this->action,
739 'content' => $this->printAll(),
740 'write' => 'Write to localconf.php',
741 'notice' => 'NOTICE:',
742 'explanation' => '
743 By clicking this button, localconf.php is updated
744 with new values for the parameters listed above!
745 '
746 );
747 // Fill the markers in the template
748 $content = t3lib_parsehtml::substituteMarkerArray(
749 $template,
750 $markers,
751 '###|###',
752 TRUE,
753 FALSE
754 );
755 // Send content to the page wrapper function
756 $this->output($this->outputWrapper($content));
757 break;
758 case 'cleanup':
759 $this->checkTheConfig();
760 $this->silent=0;
761 $this->cleanupManager();
762 break;
763 case 'phpinfo':
764 $this->silent=0;
765 $this->phpinformation();
766 break;
767 case 'typo3conf_edit':
768 $this->silent=0;
769 $this->typo3conf_edit();
770 break;
771 case 'logout':
772 $enableInstallToolFile = PATH_site . 'typo3conf/ENABLE_INSTALL_TOOL';
773 if (is_file($enableInstallToolFile) && trim(file_get_contents($enableInstallToolFile)) !== 'KEEP_FILE') {
774 unlink(PATH_typo3conf . 'ENABLE_INSTALL_TOOL');
775 }
776 $this->formProtection->clean();
777 $this->session->destroySession();
778 t3lib_utility_Http::redirect($this->scriptSelf);
779 break;
780 case 'about':
781 default:
782 $this->silent=0;
783 $this->message('About', 'Warning - very important!', $this->securityRisk().$this->alterPasswordForm(),2);
784
785 $this->message('About', 'Using this script', '
786 <p>
787 Installing TYPO3 has always been a hot topic on the
788 mailing list and forums. Therefore we\'ve developed
789 this tool which will help you through configuration
790 and testing.
791 <br />
792 There are three primary steps for you to take:
793 </p>
794 <p>
795 <strong>1: Basic Configuration</strong>
796 <br />
797 In this step your PHP-configuration is checked. If
798 there are any settings that will prevent TYPO3 from
799 running correctly you\'ll get warnings and errors
800 with a description of the problem.
801 <br />
802 You\'ll have to enter a database username, password
803 and hostname. Then you can choose to create a new
804 database or select an existing one.
805 <br />
806 Finally the image processing settings are entered
807 and verified and you can choose to let the script
808 update the configuration file,
809 typo3conf/localconf.php with the suggested settings.
810 </p>
811 <p>
812 <strong>2: Database Analyser</strong>
813 <br />
814 In this step you can either install a new database
815 or update the database from any previous TYPO3
816 version.
817 <br />
818 You can also get an overview of extra/missing
819 fields/tables in the database compared to a raw
820 sql-file.
821 <br />
822 The database is also verified against your
823 \'tables.php\' configuration ($TCA) and you can
824 even see suggestions to entries in $TCA or new
825 fields in the database.
826 </p>
827 <p>
828 <strong>3: Upgrade Wizard</strong>
829 <br />
830 Here you will find update methods taking care of
831 changes to the TYPO3 core which are not backwards
832 compatible.
833 <br />
834 It is recommended to run this wizard after every
835 update to make sure everything will still work
836 flawlessly.
837 </p>
838 <p>
839 <strong>4: Image Processing</strong>
840 <br />
841 This step is a visual guide to verify your
842 configuration of the image processing software.
843 <br />
844 You\'ll be presented to a list of images that should
845 all match in pairs. If some irregularity appears,
846 you\'ll get a warning. Thus you\'re able to track an
847 error before you\'ll discover it on your website.
848 </p>
849 <p>
850 <strong>5: All Configuration</strong>
851 <br />
852 This gives you access to any of the configuration
853 options in the TYPO3_CONF_VARS array. Every option
854 is also presented with a comment explaining what it
855 does.
856 </p>
857 <p>
858 <strong>6: Cleanup</strong>
859 <br />
860 Here you can clean up the temporary files in typo3temp/
861 folder and the tables used for caching of data in
862 your database.
863 </p>
864 ');
865
866 $this->message('About', 'Why is this script stand-alone?', '
867 <p>
868 You would think that this script should rather be a
869 module in the backend and access-controlled to only
870 admin-users from the database. But that\'s not how
871 it works.
872 <br />
873 The reason is, that this script must not be
874 depending on the success of the configuration of
875 TYPO3 and whether or not there is a working database
876 behind. Therefore the script is invoked from the
877 backend init.php file, which allows access if the
878 constant \'TYPO3_enterInstallScript\' has been
879 defined and is not FALSE. That is and should be the
880 case <em>only</em> when calling the script
881 \'typo3/install/index.php\' - this script!
882 </p>
883 ');
884
885
886 $headCode='Header legend';
887 $this->message($headCode, 'Notice!', '
888 <p>
889 Indicates that something is important to be aware
890 of.
891 <br />
892 This does <em>not</em> indicate an error.
893 </p>
894 ', 1);
895 $this->message($headCode, 'Just information', '
896 <p>
897 This is a simple message with some information about
898 something.
899 </p>
900 ');
901 $this->message($headCode, 'Check was successful', '
902 <p>
903 Indicates that something was checked and returned an
904 expected result.
905 </p>
906 ', -1);
907 $this->message($headCode, 'Warning!', '
908 <p>
909 Indicates that something may very well cause trouble
910 and you should definitely look into it before
911 proceeding.
912 <br />
913 This indicates a <em>potential</em> error.
914 </p>
915 ', 2);
916 $this->message($headCode, 'Error!', '
917 <p>
918 Indicates that something is definitely wrong and
919 that TYPO3 will most likely not perform as expected
920 if this problem is not solved.
921 <br />
922 This indicates an actual error.
923 </p>
924 ', 3);
925
926 $this->output($this->outputWrapper($this->printAll()));
927 break;
928 }
929 }
930 }
931
932 /**
933 * Controls the step 1-2-3-go process
934 *
935 * @return string The content to output to the screen
936 */
937 function stepOutput() {
938 // Get the template file
939 $templateFile = @file_get_contents(
940 PATH_site . $this->templateFilePath . 'StepOutput.html'
941 );
942 // Get the template part from the file
943 $template = t3lib_parsehtml::getSubpart(
944 $templateFile, '###TEMPLATE###'
945 );
946 // Define the markers content
947 $markers = array(
948 'stepHeader' => $this->stepHeader(),
949 'notice' => 'Skip this wizard (for power users only)',
950 'skip123' => $this->scriptSelf
951 );
952
953 $this->checkTheConfig();
954 $error_missingConnect = '
955 <p class="typo3-message message-error">
956 <strong>
957 There is no connection to the database!
958 </strong>
959 <br />
960 (Username: <em>' . htmlspecialchars(TYPO3_db_username) . '</em>,
961 Host: <em>' . htmlspecialchars(TYPO3_db_host) . '</em>,
962 Using Password: YES)
963 <br />
964 Go to Step 1 and enter a valid username and password!
965 </p>
966 ';
967 $error_missingDB = '
968 <p class="typo3-message message-error">
969 <strong>
970 There is no access to the database (<em>' . htmlspecialchars(TYPO3_db) . '</em>)!
971 </strong>
972 <br />
973 Go to Step 2 and select a valid database!
974 </p>
975 ';
976
977 // only get the number of tables if it is not the first two steps in the 123-installer
978 // (= no DB connection yet)
979 $whichTables = ($this->step != 1 && $this->step != 2 ? $this->getListOfTables() : array());
980
981 $error_emptyDB = '
982 <p class="typo3-message message-error">
983 <strong>
984 The database is still empty. There are no tables!
985 </strong>
986 <br />
987 Go to Step 3 and import a database!
988 </p>
989 ';
990
991 // Hook to override and add steps to the 1-2-3 installer
992 if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['stepOutput'])) {
993 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['stepOutput'] as $classData) {
994 $hookObject = t3lib_div::getUserObj($classData);
995 $hookObject->executeStepOutput($markers, $this->step, $this);
996 }
997 }
998 // Use the default steps when there is no override
999 if (!$markers['header'] && !$markers['step']) {
1000 switch(strtolower($this->step)) {
1001 case 1:
1002 // Get the subpart for the first step
1003 $step1SubPart = t3lib_parsehtml::getSubpart(
1004 $templateFile, '###STEP1###'
1005 );
1006 // Add header marker for main template
1007 $markers['header'] = 'Welcome to the TYPO3 Install Tool';
1008 // Define the markers content for the subpart
1009 $step1SubPartMarkers = array(
1010 'llIntroduction' => '
1011 <p>
1012 TYPO3 is an enterprise content management system
1013 that is powerful, yet easy to install.
1014 </p>
1015 <p>
1016 In three simple steps you\'ll be ready to add content to your website.
1017 </p>
1018 ',
1019 'step' => $this->step + 1,
1020 'action' => htmlspecialchars($this->action),
1021 'continue' => 'Continue'
1022 );
1023 // Add step marker for main template
1024 $markers['step'] = t3lib_parsehtml::substituteMarkerArray(
1025 $step1SubPart,
1026 $step1SubPartMarkers,
1027 '###|###',
1028 TRUE,
1029 FALSE
1030 );
1031 break;
1032 case 2:
1033 // Get the subpart for the second step
1034 $step2SubPart = t3lib_parsehtml::getSubpart(
1035 $templateFile, '###STEP2###'
1036 );
1037 // Add header marker for main template
1038 $markers['header'] = 'Connect to your database host';
1039 // Define the markers content for the subpart
1040 $step2SubPartMarkers = array(
1041 'step' => $this->step + 1,
1042 'action' => htmlspecialchars($this->action),
1043 'encryptionKey' => $this->createEncryptionKey(),
1044 'branch' => TYPO3_branch,
1045 'labelUsername' => 'Username',
1046 'username' => htmlspecialchars(TYPO3_db_username),
1047 'labelPassword' => 'Password',
1048 'password' => htmlspecialchars(TYPO3_db_password),
1049 'labelHost' => 'Host',
1050 'host' => TYPO3_db_host ? htmlspecialchars(TYPO3_db_host) : 'localhost',
1051 'continue' => 'Continue',
1052 '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.'
1053 );
1054 // Add step marker for main template
1055 $markers['step'] = t3lib_parsehtml::substituteMarkerArray(
1056 $step2SubPart,
1057 $step2SubPartMarkers,
1058 '###|###',
1059 TRUE,
1060 FALSE
1061 );
1062 break;
1063 case 3:
1064 // Add header marker for main template
1065 $markers['header'] = 'Select database';
1066 // There should be a database host connection at this point
1067 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(
1068 TYPO3_db_host, TYPO3_db_username, TYPO3_db_password
1069 )) {
1070 // Get the subpart for the third step
1071 $step3SubPart = t3lib_parsehtml::getSubpart(
1072 $templateFile, '###STEP3###'
1073 );
1074 // Get the subpart for the database options
1075 $step3DatabaseOptionsSubPart = t3lib_parsehtml::getSubpart(
1076 $step3SubPart, '###DATABASEOPTIONS###'
1077 );
1078
1079 $dbArr = $this->getDatabaseList();
1080 $dbIncluded = 0;
1081 $step3DatabaseOptions = array();
1082 foreach ($dbArr as $dbname) {
1083 // Define the markers content for database options
1084 $step3DatabaseOptionMarkers = array(
1085 'databaseValue' => htmlspecialchars($dbname),
1086 'databaseSelected' => $dbname == TYPO3_db ? 'selected="selected"' : '',
1087 'databaseName' => htmlspecialchars($dbname)
1088 );
1089 // Add the option HTML to an array
1090 $step3DatabaseOptions[] = t3lib_parsehtml::substituteMarkerArray(
1091 $step3DatabaseOptionsSubPart,
1092 $step3DatabaseOptionMarkers,
1093 '###|###',
1094 TRUE,
1095 TRUE
1096 );
1097 if ($dbname==TYPO3_db) $dbIncluded=1;
1098 }
1099 if (!$dbIncluded && TYPO3_db) {
1100 // // Define the markers content when no access
1101 $step3DatabaseOptionMarkers = array(
1102 'databaseValue' => htmlspecialchars(TYPO3_db),
1103 'databaseSelected' => 'selected="selected"',
1104 'databaseName' => htmlspecialchars(TYPO3_db) . ' (NO ACCESS!)'
1105 );
1106 // Add the option HTML to an array
1107 $step3DatabaseOptions[] = t3lib_parsehtml::substituteMarkerArray(
1108 $step3DatabaseOptionsSubPart,
1109 $step3DatabaseOptionMarkers,
1110 '###|###',
1111 TRUE,
1112 TRUE
1113 );
1114 }
1115 // Substitute the subpart for the database options
1116 $content = t3lib_parsehtml::substituteSubpart(
1117 $step3SubPart,
1118 '###DATABASEOPTIONS###',
1119 implode(LF, $step3DatabaseOptions)
1120 );
1121 // Define the markers content
1122 $step3SubPartMarkers = array(
1123 'step' => $this->step + 1,
1124 'llOptions' => 'You have two options:',
1125 'action' => htmlspecialchars($this->action),
1126 'llOption1' => 'Create a new database (recommended):',
1127 'llRemark1' => 'Enter a name for your TYPO3 database.',
1128 'llOption2' => 'Select an EMPTY existing database:',
1129 'llRemark2' => 'Any tables used by TYPO3 will be overwritten.',
1130 'continue' => 'Continue'
1131 );
1132 // Add step marker for main template
1133 $markers['step'] = t3lib_parsehtml::substituteMarkerArray(
1134 $content,
1135 $step3SubPartMarkers,
1136 '###|###',
1137 TRUE,
1138 TRUE
1139 );
1140 } else {
1141 // Add step marker for main template when no connection
1142 $markers['step'] = $error_missingConnect;
1143 }
1144 break;
1145 case 4:
1146 // Add header marker for main template
1147 $markers['header'] = 'Import the Database Tables';
1148 // There should be a database host connection at this point
1149 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(
1150 TYPO3_db_host, TYPO3_db_username, TYPO3_db_password
1151 )) {
1152 // The selected database should be accessible
1153 if ($GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) {
1154 // Get the subpart for the fourth step
1155 $step4SubPart = t3lib_parsehtml::getSubpart(
1156 $templateFile, '###STEP4###'
1157 );
1158 // Get the subpart for the database type options
1159 $step4DatabaseTypeOptionsSubPart = t3lib_parsehtml::getSubpart(
1160 $step4SubPart, '###DATABASETYPEOPTIONS###'
1161 );
1162
1163 $sFiles = t3lib_div::getFilesInDir(PATH_typo3conf,'sql',1,1);
1164
1165 // Check if default database scheme "database.sql" already exists, otherwise create it
1166 if (!strstr(implode(',',$sFiles).',', '/database.sql,')) {
1167 array_unshift($sFiles,'Default TYPO3 Tables');
1168 }
1169
1170 $step4DatabaseTypeOptions = array();
1171 foreach ($sFiles as $f) {
1172 if ($f=='Default TYPO3 Tables') $key='CURRENT_TABLES+STATIC';
1173 else $key=htmlspecialchars($f);
1174 // Define the markers content for database type subpart
1175 $step4DatabaseTypeOptionMarkers = array(
1176 'databaseTypeValue' => 'import|' . $key,
1177 'databaseName' => htmlspecialchars(basename($f))
1178 );
1179 // Add the option HTML to an array
1180 $step4DatabaseTypeOptions[] = t3lib_parsehtml::substituteMarkerArray(
1181 $step4DatabaseTypeOptionsSubPart,
1182 $step4DatabaseTypeOptionMarkers,
1183 '###|###',
1184 TRUE,
1185 FALSE
1186 );
1187 }
1188 // Substitute the subpart for the database type options
1189 $content = t3lib_parsehtml::substituteSubpart(
1190 $step4SubPart,
1191 '###DATABASETYPEOPTIONS###',
1192 implode(LF, $step4DatabaseTypeOptions)
1193 );
1194 // Define the markers content
1195 $step4SubPartMarkers = array(
1196 'llSummary' => 'Database summary:',
1197 'llUsername' => 'Username:',
1198 'username' => htmlspecialchars(TYPO3_db_username),
1199 'llHost' => 'Host:',
1200 'host' => htmlspecialchars(TYPO3_db_host),
1201 'llDatabase' => 'Database:',
1202 'database' => htmlspecialchars(TYPO3_db),
1203 'llNumberTables' => 'Number of tables:',
1204 'numberTables' => count($whichTables),
1205 'action' => htmlspecialchars($this->action),
1206 'llDatabaseType' => 'Select database contents:',
1207 'label' => 'Import database'
1208 );
1209 // Add step marker for main template
1210 $markers['step'] = t3lib_parsehtml::substituteMarkerArray(
1211 $content,
1212 $step4SubPartMarkers,
1213 '###|###',
1214 TRUE,
1215 TRUE
1216 );
1217 } else {
1218 // Add step marker for main template when no database
1219 $markers['step'] = $error_missingDB;
1220 }
1221 } else {
1222 // Add step marker for main template when no connection
1223 $markers['step'] = $error_missingConnect;
1224 }
1225 break;
1226 case 'go':
1227 // Add header marker for main template
1228 $markers['header'] = 'Congratulations!';
1229 // There should be a database host connection at this point
1230 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(
1231 TYPO3_db_host, TYPO3_db_username, TYPO3_db_password
1232 )) {
1233 // The selected database should be accessible
1234 if ($GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) {
1235 // The database should contain tables
1236 if (count($whichTables)) {
1237 // Get the subpart for the go step
1238 $stepGoSubPart = t3lib_parsehtml::getSubpart(
1239 $templateFile, '###STEPGO###'
1240 );
1241 // Define the markers content
1242 $stepGoSubPartMarkers = array(
1243 'messageBasicFinished' => $this->messageBasicFinished(),
1244 'llImportant' => 'Important Security Warning',
1245 'securityRisk' => $this->securityRisk(),
1246 'llSwitchMode' => '
1247 <a href="' . $this->scriptSelf . '">
1248 Change the Install Tool password here
1249 </a>
1250 '
1251 );
1252 // Add step marker for main template
1253 $markers['step'] = t3lib_parsehtml::substituteMarkerArray(
1254 $stepGoSubPart,
1255 $stepGoSubPartMarkers,
1256 '###|###',
1257 TRUE,
1258 TRUE
1259 );
1260 } else {
1261 // Add step marker for main template when empty database
1262 $markers['step'] = $error_emptyDB;
1263 }
1264 } else {
1265 // Add step marker for main template when no database
1266 $markers['step'] = $error_missingDB;
1267 }
1268 } else {
1269 // Add step marker for main template when no connection
1270 $markers['step'] = $error_missingConnect;
1271 }
1272 break;
1273 }
1274 }
1275 // Fill the markers in the template
1276 $content = t3lib_parsehtml::substituteMarkerArray(
1277 $template,
1278 $markers,
1279 '###|###',
1280 TRUE,
1281 FALSE
1282 );
1283
1284 return $content;
1285 }
1286
1287 /**
1288 * Calling the functions that checks the system
1289 *
1290 * @return void
1291 */
1292 function checkTheConfig() {
1293 // Order important:
1294 $this->checkDirs();
1295 $this->checkConfiguration();
1296 $this->checkExtensions();
1297
1298 if (TYPO3_OS=='WIN') {
1299 $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\\');
1300 if (!isset($_SERVER['PATH'])) {
1301 $serverPath = array_change_key_case($_SERVER, CASE_UPPER);
1302 $paths = array_merge($paths, explode(';', $serverPath['PATH']));
1303 } else {
1304 $paths = array_merge($paths, explode(';', $_SERVER['PATH']));
1305 }
1306 } else {
1307 $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/');
1308 $paths = array_merge($paths, explode(':', $_SERVER['PATH']));
1309 }
1310 $paths = array_unique($paths);
1311
1312 asort($paths);
1313 if (t3lib_utility_PhpOptions::isSafeModeEnabled()) {
1314 $paths=array(ini_get('safe_mode_exec_dir'),'/usr/local/php/bin/');
1315 }
1316 if ($this->INSTALL['checkIM']['lzw']) {
1317 $this->checkIMlzw=1;
1318 }
1319 if ($this->INSTALL['checkIM']['path']) {
1320 $paths[]=trim($this->INSTALL['checkIM']['path']);
1321 }
1322 if ($this->checkIM) $this->checkImageMagick($paths);
1323 $this->checkDatabase();
1324 }
1325
1326 /**
1327 * Editing files in typo3conf directory (or elsewhere if enabled)
1328 *
1329 * @return void
1330 */
1331 function typo3conf_edit() {
1332 // default:
1333 $EDIT_path = PATH_typo3conf;
1334 if ($this->allowFileEditOutsite_typo3conf_dir && $this->INSTALL['FILE']['EDIT_path']) {
1335 if (t3lib_div::validPathStr($this->INSTALL['FILE']['EDIT_path']) && substr($this->INSTALL['FILE']['EDIT_path'],-1)=='/') {
1336 $tmp_path = PATH_site.$this->INSTALL['FILE']['EDIT_path'];
1337 if (is_dir($tmp_path)) {
1338 $EDIT_path=$tmp_path;
1339 } else {
1340 $this->errorMessages[] = '
1341 \'' . $tmp_path . '\' was not directory
1342 ';
1343 }
1344 } else {
1345 $this->errorMessages[] = '
1346 Bad directory name (must be like t3lib/ or media/script/)
1347 ';
1348 }
1349 }
1350
1351 $headCode = 'Edit files in '.basename($EDIT_path).'/';
1352 $messages = '';
1353
1354 if ($this->INSTALL['SAVE_FILE']) {
1355 $save_to_file = $this->INSTALL['FILE']['name'];
1356 if (@is_file($save_to_file)) {
1357 $save_to_file_md5 = md5($save_to_file);
1358 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')) {
1359 $this->INSTALL['typo3conf_files'] = $save_to_file;
1360 $save_fileContent = $this->INSTALL['FILE'][$save_to_file_md5];
1361
1362 if ($this->INSTALL['FILE']['win_to_unix_br']) {
1363 $save_fileContent = str_replace(CRLF, LF, $save_fileContent);
1364 }
1365
1366 $backupFile = $this->getBackupFilename($save_to_file);
1367 if ($this->INSTALL['FILE']['backup']) {
1368 if (@is_file($backupFile)) { unlink($backupFile); }
1369 rename($save_to_file,$backupFile);
1370 $messages .= '
1371 Backup written to <strong>' . $backupFile . '</strong>
1372 <br />
1373 ';
1374 }
1375
1376 t3lib_div::writeFile($save_to_file,$save_fileContent);
1377 $messages .= '
1378 File saved: <strong>' . $save_to_file . '</strong>
1379 <br />
1380 MD5-sum: ' . $this->INSTALL['FILE']['prevMD5'] . ' (prev)
1381 <br />
1382 MD5-sum: ' . md5($save_fileContent) . ' (new)
1383 <br />
1384 ';
1385 }
1386 }
1387 }
1388
1389 // Filelist:
1390 // Get the template file
1391 $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'Typo3ConfEdit.html');
1392 // Get the template part from the file
1393 $template = t3lib_parsehtml::getSubpart($templateFile, '###TEMPLATE###');
1394 // Get the subpart for the files
1395 $filesSubpart = t3lib_parsehtml::getSubpart($template, '###FILES###');
1396 $files = array();
1397
1398 $typo3conf_files = t3lib_div::getFilesInDir($EDIT_path,'',1,1);
1399 $fileFound = 0;
1400
1401
1402 foreach ($typo3conf_files as $k => $file) {
1403 // Delete temp_CACHED files if option is set
1404 if ( $this->INSTALL['delTempCached'] && preg_match('|/temp_CACHED_[a-z0-9_]+\.php|', $file)) {
1405 unlink($file);
1406 continue;
1407 }
1408 if ($this->INSTALL['typo3conf_files'] && !strcmp($this->INSTALL['typo3conf_files'],$file)) {
1409 $fileFound = 1;
1410 }
1411 // Define the markers content for the files subpart
1412 $filesMarkers = array(
1413 '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',
1414 'fileName' => basename($file),
1415 'fileSize' => t3lib_div::formatSize(filesize($file)),
1416 'class' => $this->INSTALL['typo3conf_files'] && !strcmp($this->INSTALL['typo3conf_files'], $file) ? 'class="act"' : ''
1417 );
1418 // Fill the markers in the subpart
1419 $files[] = t3lib_parsehtml::substituteMarkerArray(
1420 $filesSubpart,
1421 $filesMarkers,
1422 '###|###',
1423 TRUE,
1424 FALSE
1425 );
1426 }
1427
1428 if ($fileFound && @is_file($this->INSTALL['typo3conf_files'])) {
1429
1430 $backupFile = $this->getBackupFilename($this->INSTALL['typo3conf_files']);
1431 $fileContent = t3lib_div::getUrl($this->INSTALL['typo3conf_files']);
1432 // Get the subpart to edit the files
1433 $fileEditTemplate = t3lib_parsehtml::getSubpart($template, '###FILEEDIT###');
1434 $allowFileEditOutsideTypo3ConfDirSubPart = '';
1435
1436 if (substr($this->INSTALL['typo3conf_files'], -1) != '~' && !strstr($this->INSTALL['typo3conf_files'], '_bak')) {
1437 // Get the subpart to show the save button
1438 $showSaveButtonSubPart = t3lib_parsehtml::getSubpart($fileEditTemplate, '###SHOWSAVEBUTTON###');
1439 }
1440
1441 if ($this->allowFileEditOutsite_typo3conf_dir) {
1442 // Get the subpart to show if files are allowed outside the directory typo3conf
1443 $allowFileEditOutsideTypo3ConfDirSubPart = t3lib_parsehtml::getSubpart($fileEditTemplate, '###ALLOWFILEEDITOUTSIDETYPO3CONFDIR###');
1444 }
1445 // Substitute the subpart for the save button
1446 $fileEditContent = t3lib_parsehtml::substituteSubpart(
1447 $fileEditTemplate,
1448 '###SHOWSAVEBUTTON###',
1449 $showSaveButtonSubPart
1450 );
1451 // Substitute the subpart to show if files are allowed outside the directory typo3conf
1452 $fileEditContent = t3lib_parsehtml::substituteSubpart(
1453 $fileEditContent,
1454 '###ALLOWFILEEDITOUTSIDETYPO3CONFDIR###',
1455 $allowFileEditOutsideTypo3ConfDirSubPart
1456 );
1457 // Define the markers content for subpart to edit the files
1458 $fileEditMarkers = array(
1459 'messages' => !empty($messages) ? '<p class="typo3-message message-warning">' . $messages . '</p>' : '',
1460 'action' => $this->action . '#fileEditHeader',
1461 'saveFile' => 'Save file',
1462 'close' => 'Close',
1463 'llEditing' => 'Editing file:',
1464 'file' => $this->INSTALL['typo3conf_files'],
1465 'md5Sum' => 'MD5-sum: ' . md5($fileContent),
1466 'fileName' => $this->INSTALL['typo3conf_files'],
1467 'fileEditPath' => $this->INSTALL['FILE']['EDIT_path'],
1468 'filePreviousMd5' => md5($fileContent),
1469 'fileMd5' => md5($this->INSTALL['typo3conf_files']),
1470 'fileContent' => t3lib_div::formatForTextarea($fileContent),
1471 'winToUnixBrChecked' => TYPO3_OS == 'WIN' ? '' : 'checked="checked"',
1472 'winToUnixBr' => 'Convert Windows linebreaks (13-10) to Unix (10)',
1473 'backupChecked' => @is_file($backupFile) ? 'checked="checked"' : '',
1474 'backup' => 'Make backup copy (rename to ' . basename($backupFile) . ')'
1475 );
1476 // Fill the markers in the subpart to edit the files
1477 $fileEditContent = t3lib_parsehtml::substituteMarkerArray(
1478 $fileEditContent,
1479 $fileEditMarkers,
1480 '###|###',
1481 TRUE,
1482 FALSE
1483 );
1484 }
1485
1486 if ($this->allowFileEditOutsite_typo3conf_dir) {
1487 // Get the subpart to show if files are allowed outside the directory typo3conf
1488 $allowFileEditOutsideTypo3ConfDirSubPart = t3lib_parsehtml::getSubpart($template, '###ALLOWFILEEDITOUTSIDETYPO3CONFDIR###');
1489 // Define the markers content
1490 $allowFileEditOutsideTypo3ConfDirMarkers = array(
1491 'action' => $this->action,
1492 'pathSite' => PATH_site,
1493 'editPath' => $this->INSTALL['FILE']['EDIT_path'],
1494 'set' => 'Set'
1495 );
1496 // Fill the markers in the subpart
1497 $allowFileEditOutsideTypo3ConfDirSubPart = t3lib_parsehtml::substituteMarkerArray(
1498 $allowFileEditOutsideTypo3ConfDirSubPart,
1499 $allowFileEditOutsideTypo3ConfDirMarkers,
1500 '###|###',
1501 TRUE,
1502 FALSE
1503 );
1504 }
1505 // Substitute the subpart to edit the file
1506 $fileListContent = t3lib_parsehtml::substituteSubpart(
1507 $template,
1508 '###FILEEDIT###',
1509 $fileEditContent
1510 );
1511 // Substitute the subpart when files can be edited outside typo3conf directory
1512 $fileListContent = t3lib_parsehtml::substituteSubpart(
1513 $fileListContent,
1514 '###ALLOWFILEEDITOUTSIDETYPO3CONFDIR###',
1515 $allowFileEditOutsideTypo3ConfDirSubPart
1516 );
1517 // Substitute the subpart for the files
1518 $fileListContent = t3lib_parsehtml::substituteSubpart(
1519 $fileListContent,
1520 '###FILES###',
1521 implode(LF, $files)
1522 );
1523 // Define the markers content
1524 $fileListMarkers = array(
1525 'editPath' => '(' . $EDIT_path . ')',
1526 'deleteTempCachedUrl' => $this->action . '&amp;TYPO3_INSTALL[delTempCached]=1',
1527 'deleteTempCached' => 'Delete temp_CACHED* files'
1528 );
1529 // Fill the markers
1530 $fileListContent = t3lib_parsehtml::substituteMarkerArray(
1531 $fileListContent,
1532 $fileListMarkers,
1533 '###|###',
1534 TRUE,
1535 FALSE
1536 );
1537 // Add the content to the message array
1538 $this->message($headCode, 'Files in folder', $fileListContent);
1539 // Output the page
1540 $this->output($this->outputWrapper($this->printAll()));
1541 }
1542
1543 /**
1544 * Outputs system information
1545 *
1546 * @return void
1547 */
1548 function phpinformation() {
1549 $headCode = 'PHP information';
1550
1551 $sVar = t3lib_div::getIndpEnv('_ARRAY');
1552 $sVar['CONST: PHP_OS']=PHP_OS;
1553 $sVar['CONST: TYPO3_OS']=TYPO3_OS;
1554 $sVar['CONST: PATH_thisScript']=PATH_thisScript;
1555 $sVar['CONST: php_sapi_name()']=PHP_SAPI;
1556 $sVar['OTHER: TYPO3_VERSION']=TYPO3_version;
1557 $sVar['OTHER: PHP_VERSION']=phpversion();
1558 $sVar['imagecreatefromgif()']=function_exists('imagecreatefromgif');
1559 $sVar['imagecreatefrompng()']=function_exists('imagecreatefrompng');
1560 $sVar['imagecreatefromjpeg()']=function_exists('imagecreatefromjpeg');
1561 $sVar['imagegif()']=function_exists('imagegif');
1562 $sVar['imagepng()']=function_exists('imagepng');
1563 $sVar['imagejpeg()']=function_exists('imagejpeg');
1564 $sVar['imagettftext()']=function_exists('imagettftext');
1565 $sVar['OTHER: IMAGE_TYPES']=function_exists('imagetypes') ? imagetypes() : 0;
1566 $sVar['OTHER: memory_limit']=ini_get('memory_limit');
1567
1568 $gE_keys = explode(',','SERVER_PORT,SERVER_SOFTWARE,GATEWAY_INTERFACE,SCRIPT_NAME,PATH_TRANSLATED');
1569 foreach ($gE_keys as $k) {
1570 $sVar['SERVER: '.$k]=$_SERVER[$k];
1571 }
1572
1573 $gE_keys = explode(',','image_processing,gdlib,gdlib_png,im,im_path,im_path_lzw,im_version_5,im_negate_mask,im_imvMaskState,im_combine_filename');
1574
1575 foreach ($gE_keys as $k) {
1576 $sVar['T3CV_GFX: '.$k]=$GLOBALS['TYPO3_CONF_VARS']['GFX'][$k];
1577 }
1578
1579 $debugInfo = array(
1580 '### DEBUG SYSTEM INFORMATION - START ###'
1581 );
1582 foreach ($sVar as $kkk => $vvv) {
1583 $debugInfo[]=str_pad(substr($kkk,0,20),20).': '.$vvv;
1584 }
1585 $debugInfo[]='### DEBUG SYSTEM INFORMATION - END ###';
1586 // Get the template file
1587 $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'PhpInformation.html');
1588 // Get the template part from the file
1589 $template = t3lib_parsehtml::getSubpart($templateFile, '###TEMPLATE###');
1590 // Define the markers content
1591 $markers = array(
1592 'explanation' => 'Please copy/paste the information from this text field into an email or bug-report as "Debug System Information" whenever you wish to get support or report problems. This information helps others to check if your system has some obvious misconfiguration and you\'ll get your help faster!',
1593 'debugInfo' => t3lib_div::formatForTextarea(implode(LF, $debugInfo))
1594 );
1595 // Fill the markers
1596 $content = t3lib_parsehtml::substituteMarkerArray(
1597 $template,
1598 $markers,
1599 '###|###',
1600 TRUE,
1601 FALSE
1602 );
1603 // Add the content to the message array
1604 $this->message($headCode, 'DEBUG information', $content);
1605 // Start with various server information
1606 $getEnvArray = array();
1607 $gE_keys = explode(',','QUERY_STRING,HTTP_ACCEPT,HTTP_ACCEPT_ENCODING,HTTP_ACCEPT_LANGUAGE,HTTP_CONNECTION,HTTP_COOKIE,HTTP_HOST,HTTP_USER_AGENT,REMOTE_ADDR,REMOTE_HOST,REMOTE_PORT,SERVER_ADDR,SERVER_ADMIN,SERVER_NAME,SERVER_PORT,SERVER_SIGNATURE,SERVER_SOFTWARE,GATEWAY_INTERFACE,SERVER_PROTOCOL,REQUEST_METHOD,SCRIPT_NAME,PATH_TRANSLATED,HTTP_REFERER,PATH_INFO');
1608 foreach ($gE_keys as $k) {
1609 $getEnvArray[$k] = getenv($k);
1610 }
1611 $this->message($headCode, 't3lib_div::getIndpEnv()', $this->viewArray(t3lib_div::getIndpEnv('_ARRAY')));
1612 $this->message($headCode, 'getenv()', $this->viewArray($getEnvArray));
1613 $this->message($headCode, '_ENV', $this->viewArray($_ENV));
1614 $this->message($headCode, '_SERVER', $this->viewArray($_SERVER));
1615 $this->message($headCode, '_COOKIE', $this->viewArray($_COOKIE));
1616 $this->message($headCode, '_GET', $this->viewArray($_GET));
1617 // Start with the phpinfo() part
1618 ob_start();
1619 phpinfo();
1620 $contents = explode('<body>',ob_get_contents());
1621 ob_end_clean();
1622 $contents = explode('</body>',$contents[1]);
1623 // Do code cleaning: phpinfo() is not XHTML1.1 compliant
1624 $phpinfo = str_replace('<font', '<span', $contents[0]);
1625 $phpinfo = str_replace('</font', '</span', $phpinfo);
1626 $phpinfo = str_replace('<img border="0"', '<img', $phpinfo);
1627 $phpinfo = str_replace('<a name=', '<a id=', $phpinfo);
1628 // Add phpinfo() to the message array
1629 $this->message($headCode, 'phpinfo()', '
1630 <div class="phpinfo">
1631 ' . $phpinfo . '
1632 </div>
1633 ');
1634 // Output the page
1635 $this->output($this->outputWrapper($this->printAll()));
1636 }
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647 /*******************************
1648 *
1649 * cleanup manager
1650 *
1651 *******************************/
1652
1653 /**
1654 * Provides a tool cleaning up various tables in the database
1655 *
1656 * @return void
1657 * @author Robert Lemke <rl@robertlemke.de>
1658 * @todo Add more functionality ...
1659 */
1660 function cleanupManager() {
1661 $headCode = 'Clean up your TYPO3 installation';
1662 $this->message($headCode, 'Database cache tables', '
1663 <p>
1664 <strong>Clear cached image sizes</strong>
1665 <br />
1666 Clears the cache used for memorizing sizes of all images used in
1667 your website. This information is cached in order to gain
1668 performance and will be stored each time a new image is being
1669 displayed in the frontend.
1670 </p>
1671 <p>
1672 You should <em>Clear All Cache</em> in the backend after
1673 clearing this cache.
1674 </p>
1675 ');
1676
1677 $tables = $this->getListOfTables();
1678 $action = $this->INSTALL['cleanup_type'];
1679
1680 if (($action == 'cache_imagesizes' || $action == 'all') && isset ($tables['cache_imagesizes'])) {
1681 $GLOBALS['TYPO3_DB']->exec_TRUNCATEquery('cache_imagesizes');
1682 }
1683
1684 $cleanupType = array (
1685 'all' => 'Clean up everything',
1686 );
1687
1688 // Get cache_imagesizes info
1689 if (isset ($tables['cache_imagesizes'])) {
1690 $cleanupType['cache_imagesizes'] = 'Clear cached image sizes only';
1691 $cachedImageSizesCounter = intval($GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'cache_imagesizes'));
1692 } else {
1693 $this->message($headCode, 'Table cache_imagesizes does not exist!', '
1694 <p>
1695 The table cache_imagesizes was not found. Please check your
1696 database settings in Basic Configuration and compare your
1697 table definition with the Database Analyzer.
1698 </p>
1699 ', 2);
1700 $cachedImageSizesCounter = 'unknown';
1701 }
1702 // Get the template file
1703 $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'CleanUpManager.html');
1704 // Get the template part from the file
1705 $template = t3lib_parsehtml::getSubpart($templateFile, '###TEMPLATE###');
1706 // Get the subpart for the 'Clean up' dropdown
1707 $cleanUpOptionsSubpart = t3lib_parsehtml::getSubpart($template, '###CLEANUPOPTIONS###');
1708 $cleanUpOptions = array();
1709
1710 foreach ($cleanupType as $cleanUpKey => $cleanUpValue) {
1711 // Define the markers content
1712 $cleanUpMarkers = array(
1713 'value' => htmlspecialchars($cleanUpKey),
1714 'data' => htmlspecialchars($cleanUpValue)
1715 );
1716 // Fill the markers in the subpart
1717 $cleanUpOptions[] = t3lib_parsehtml::substituteMarkerArray(
1718 $cleanUpOptionsSubpart,
1719 $cleanUpMarkers,
1720 '###|###',
1721 TRUE,
1722 FALSE
1723 );
1724 }
1725 // Substitute the subpart for the 'Clean up' dropdown
1726 $content = t3lib_parsehtml::substituteSubpart(
1727 $template,
1728 '###CLEANUPOPTIONS###',
1729 implode(LF, $cleanUpOptions)
1730 );
1731 // Define the markers content
1732 $markers = array(
1733 'numberCached' => 'Number cached image sizes:',
1734 'number' => $cachedImageSizesCounter,
1735 'action' => $this->action,
1736 'cleanUp' => 'Clean up',
1737 'execute' => 'Execute'
1738 );
1739 // Fill the markers
1740 $content = t3lib_parsehtml::substituteMarkerArray(
1741 $content,
1742 $markers,
1743 '###|###',
1744 TRUE,
1745 FALSE
1746 );
1747 // Add the content to the message array
1748 $this->message($headCode, 'Statistics', $content, 1);
1749
1750
1751
1752
1753
1754
1755
1756 $this->message($headCode, 'typo3temp/ folder', '
1757 <p>
1758 TYPO3 uses this directory for temporary files, mainly processed
1759 and cached images.
1760 <br />
1761 The filenames are very cryptic; They are unique representations
1762 of the file properties made by md5-hashing a serialized array
1763 with information.
1764 <br />
1765 Anyway this directory may contain many thousand files and a lot
1766 of them may be of no use anymore.
1767 </p>
1768 <p>
1769 With this test you can delete the files in this folder. When you
1770 do that, you should also clear the cache database tables
1771 afterwards.
1772 </p>
1773 ');
1774
1775 if (!$this->config_array['dir_typo3temp']) {
1776 $this->message('typo3temp/ directory', 'typo3temp/ not writable!', '
1777 <p>
1778 You must make typo3temp/ write enabled before you can
1779 proceed with this test.
1780 </p>
1781 ', 2);
1782 $this->output($this->outputWrapper($this->printAll()));
1783 return;
1784 }
1785
1786 // Run through files
1787 $fileCounter = 0;
1788 $deleteCounter = 0;
1789 $criteriaMatch = 0;
1790 $tmap=array('day'=>1, 'week'=>7, 'month'=>30);
1791 $tt = $this->INSTALL['typo3temp_delete'];
1792 $subdir = $this->INSTALL['typo3temp_subdir'];
1793 if (strlen($subdir) && !preg_match('/^[[:alnum:]_]+\/$/',$subdir)) die('subdir "'.$subdir.'" was not allowed!');
1794 $action = $this->INSTALL['typo3temp_action'];
1795 $d = @dir($this->typo3temp_path.$subdir);
1796 if (is_object($d)) {
1797 while($entry=$d->read()) {
1798 $theFile = $this->typo3temp_path.$subdir.$entry;
1799 if (@is_file($theFile)) {
1800 $ok = 0;
1801 $fileCounter++;
1802 if ($tt) {
1803 if (t3lib_div::testInt($tt)) {
1804 if (filesize($theFile) > $tt*1024) $ok=1;
1805 } else {
1806 if (fileatime($theFile) < $GLOBALS['EXEC_TIME'] - (intval($tmap[$tt]) * 60 * 60 * 24)) {
1807 $ok = 1;
1808 }
1809 }
1810 } else {
1811 $ok = 1;
1812 }
1813 if ($ok) {
1814 $hashPart=substr(basename($theFile),-14,10);
1815 // This is a kind of check that the file being deleted has a 10 char hash in it
1816 if (!preg_match('/[^a-f0-9]/',$hashPart) || substr($theFile,-6)==='.cache' || substr($theFile,-4)==='.tbl' || substr(basename($theFile),0,8)==='install_') {
1817 if ($action && $deleteCounter<$action) {
1818 $deleteCounter++;
1819 unlink($theFile);
1820 } else {
1821 $criteriaMatch++;
1822 }
1823 }
1824 }
1825 }
1826 }
1827 $d->close();
1828 }
1829
1830 // Find sub-dirs:
1831 $subdirRegistry = array(''=>'');
1832 $d = @dir($this->typo3temp_path);
1833 if (is_object($d)) {
1834 while($entry=$d->read()) {
1835 $theFile = $entry;
1836 if (@is_dir($this->typo3temp_path.$theFile) && $theFile!='..' && $theFile!='.') {
1837 $subdirRegistry[$theFile.'/'] = $theFile.'/ (Files: '.count(t3lib_div::getFilesInDir($this->typo3temp_path.$theFile)).')';
1838 }
1839 }
1840 }
1841
1842 $deleteType=array(
1843 '0' => 'All',
1844 'day' => 'Last access more than a day ago',
1845 'week' => 'Last access more than a week ago',
1846 'month' => 'Last access more than a month ago',
1847 '10' => 'Filesize greater than 10KB',
1848 '50' => 'Filesize greater than 50KB',
1849 '100' => 'Filesize greater than 100KB'
1850 );
1851
1852 $actionType=array(
1853 '0' => "Don't delete, just display statistics",
1854 '100' => 'Delete 100',
1855 '500' => 'Delete 500',
1856 '1000' => 'Delete 1000'
1857 );
1858 // Get the template file
1859 $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'Typo3TempManager.html');
1860 // Get the template part from the file
1861 $template = t3lib_parsehtml::getSubpart($templateFile, '###TEMPLATE###');
1862 // Get the subpart for 'Delete files by condition' dropdown
1863 $deleteOptionsSubpart = t3lib_parsehtml::getSubpart($template, '###DELETEOPTIONS###');
1864 $deleteOptions = array();
1865
1866 foreach ($deleteType as $deleteKey => $deleteValue) {
1867 // Define the markers content
1868 $deleteMarkers = array(
1869 'value' => htmlspecialchars($deleteKey),
1870 'selected' => !strcmp($deleteKey, $tt) ? 'selected="selected"' : '',
1871 'data' => htmlspecialchars($deleteValue)
1872 );
1873 // Fill the markers in the subpart
1874 $deleteOptions[] = t3lib_parsehtml::substituteMarkerArray(
1875 $deleteOptionsSubpart,
1876 $deleteMarkers,
1877 '###|###',
1878 TRUE,
1879 FALSE
1880 );
1881 }
1882 // Substitute the subpart for 'Delete files by condition' dropdown
1883 $content = t3lib_parsehtml::substituteSubpart(
1884 $template,
1885 '###DELETEOPTIONS###',
1886 implode(LF, $deleteOptions)
1887 );
1888 // Get the subpart for 'Number of files at a time' dropdown
1889 $actionOptionsSubpart = t3lib_parsehtml::getSubpart($template, '###ACTIONOPTIONS###');
1890 $actionOptions = array();
1891
1892 foreach ($actionType as $actionKey => $actionValue) {
1893 // Define the markers content
1894 $actionMarkers = array(
1895 'value' => htmlspecialchars($actionKey),
1896 'data' => htmlspecialchars($actionValue)
1897 );
1898 // Fill the markers in the subpart
1899 $actionOptions[] = t3lib_parsehtml::substituteMarkerArray(
1900 $actionOptionsSubpart,
1901 $actionMarkers,
1902 '###|###',
1903 TRUE,
1904 FALSE
1905 );
1906 }
1907 // Substitute the subpart for 'Number of files at a time' dropdown
1908 $content = t3lib_parsehtml::substituteSubpart(
1909 $content,
1910 '###ACTIONOPTIONS###',
1911 implode(LF, $actionOptions)
1912 );
1913 // Get the subpart for 'From sub-directory' dropdown
1914 $subDirectoryOptionsSubpart = t3lib_parsehtml::getSubpart($template, '###SUBDIRECTORYOPTIONS###');
1915 $subDirectoryOptions = array();
1916
1917 foreach ($subdirRegistry as $subDirectoryKey => $subDirectoryValue) {
1918 // Define the markers content
1919 $subDirectoryMarkers = array(
1920 'value' => htmlspecialchars($subDirectoryKey),
1921 'selected' => !strcmp($subDirectoryKey, $this->INSTALL['typo3temp_subdir']) ? 'selected="selected"' : '',
1922 'data' => htmlspecialchars($subDirectoryValue)
1923 );
1924 // Fill the markers in the subpart
1925 $subDirectoryOptions[] = t3lib_parsehtml::substituteMarkerArray(
1926 $subDirectoryOptionsSubpart,
1927 $subDirectoryMarkers,
1928 '###|###',
1929 TRUE,
1930 FALSE
1931 );
1932 }
1933 // Substitute the subpart for 'From sub-directory' dropdown
1934 $content = t3lib_parsehtml::substituteSubpart(
1935 $content,
1936 '###SUBDIRECTORYOPTIONS###',
1937 implode(LF, $subDirectoryOptions)
1938 );
1939 // Define the markers content
1940 $markers = array(
1941 'numberTemporary' => 'Number of temporary files:',
1942 'numberMatching' => 'Number matching:',
1943 'numberDeleted' => 'Number deleted:',
1944 'temporary' => ($fileCounter - $deleteCounter),
1945 'matching' => $criteriaMatch,
1946 'deleteType' => '<span>' . htmlspecialchars($deleteType[$tt]) . '</span>',
1947 'deleted' => $deleteCounter,
1948 'deleteCondition' => 'Delete files by condition',
1949 'numberFiles' => 'Number of files at a time:',
1950 'fromSubdirectory' => 'From sub-directory:',
1951 'execute' => 'Execute',
1952 'explanation' => '
1953 <p>
1954 This tool will delete files only if the last 10 characters
1955 before the extension (3 chars+\'.\') are hexadecimal valid
1956 ciphers, which are lowercase a-f and 0-9.
1957 </p>
1958 '
1959 );
1960 // Fill the markers
1961 $content = t3lib_parsehtml::substituteMarkerArray(
1962 $content,
1963 $markers,
1964 '###|###',
1965 TRUE,
1966 FALSE
1967 );
1968 // Add the content to the message array
1969 $this->message($headCode, 'Statistics', $content, 1);
1970
1971
1972 // Output the page
1973 $this->output($this->outputWrapper($this->printAll()));
1974 }
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988 /*******************************
1989 *
1990 * CONFIGURATION FORM
1991 *
1992 ********************************/
1993
1994 /**
1995 * Creating the form for editing the TYPO3_CONF_VARS options.
1996 *
1997 * @param string $type If get_form, display form, otherwise checks and store in localconf.php
1998 * @return void
1999 */
2000 function generateConfigForm($type='') {
2001 $default_config_content = t3lib_div::getUrl(PATH_t3lib.'config_default.php');
2002 $commentArr = $this->getDefaultConfigArrayComments($default_config_content);
2003
2004 switch($type) {
2005 case 'get_form':
2006 // Get the template file
2007 $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'GenerateConfigForm.html');
2008 // Get the template part from the file
2009 $template = t3lib_parsehtml::getSubpart($templateFile, '###TEMPLATE###');
2010
2011 foreach ($GLOBALS['TYPO3_CONF_VARS'] as $k => $va) {
2012 $ext='['.$k.']';
2013 $this->message($ext, '$TYPO3_CONF_VARS[\''.$k.'\']',$commentArr[0][$k],1);
2014
2015 foreach ($va as $vk => $value) {
2016 $textAreaSubpart = '';
2017 $booleanSubpart = '';
2018 $textLineSubpart = '';
2019
2020 $description = trim($commentArr[1][$k][$vk]);
2021 $isTextarea = preg_match('/^(<.*?>)?string \(textarea\)/i', $description) ? TRUE : FALSE;
2022 $doNotRender = preg_match('/^(<.*?>)?string \(exclude\)/i', $description) ? TRUE : FALSE;
2023
2024 if (!is_array($value) && !$doNotRender && ($this->checkForBadString($value) || $isTextarea)) {
2025 $k2 = '['.$vk.']';
2026
2027 if ($isTextarea) {
2028 // Get the subpart for a textarea
2029 $textAreaSubpart = t3lib_parsehtml::getSubpart($template, '###TEXTAREA###');
2030 // Define the markers content
2031 $textAreaMarkers = array(
2032 'id' => $k . '-' . $vk,
2033 'name' => 'TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']',
2034 'value' => str_replace(array("'.chr(10).'", "' . LF . '"), array(LF, LF), $value)
2035 );
2036 $value = str_replace(array("'.chr(10).'", "' . LF . '"), array(' | ', ' | '), $value);
2037 // Fill the markers in the subpart
2038 $textAreaSubpart = t3lib_parsehtml::substituteMarkerArray(
2039 $textAreaSubpart,
2040 $textAreaMarkers,
2041 '###|###',
2042 TRUE,
2043 FALSE
2044 );
2045 } elseif (preg_match('/^(<.*?>)?boolean/i', $description)) {
2046 // Get the subpart for a checkbox
2047 $booleanSubpart = t3lib_parsehtml::getSubpart($template, '###BOOLEAN###');
2048 // Define the markers content
2049 $booleanMarkers = array(
2050 'id' => $k . '-' . $vk,
2051 'name' => 'TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']',
2052 'value' => $value && strcmp($value, '0') ? $value : 1,
2053 'checked' => $value ? 'checked="checked"' : ''
2054 );
2055 // Fill the markers in the subpart
2056 $booleanSubpart = t3lib_parsehtml::substituteMarkerArray(
2057 $booleanSubpart,
2058 $booleanMarkers,
2059 '###|###',
2060 TRUE,
2061 FALSE
2062 );
2063 } else {
2064 // Get the subpart for an input text field
2065 $textLineSubpart = t3lib_parsehtml::getSubpart($template, '###TEXTLINE###');
2066 // Define the markers content
2067 $textLineMarkers = array(
2068 'id' => $k . '-' . $vk,
2069 'name' => 'TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']',
2070 'value' => $value
2071 );
2072 // Fill the markers in the subpart
2073 $textLineSubpart = t3lib_parsehtml::substituteMarkerArray(
2074 $textLineSubpart,
2075 $textLineMarkers,
2076 '###|###',
2077 TRUE,
2078 FALSE
2079 );
2080 }
2081 // Substitute the subpart for a textarea
2082 $content = t3lib_parsehtml::substituteSubpart(
2083 $template,
2084 '###TEXTAREA###',
2085 $textAreaSubpart
2086 );
2087 // Substitute the subpart for a checkbox
2088 $content = t3lib_parsehtml::substituteSubpart(
2089 $content,
2090 '###BOOLEAN###',
2091 $booleanSubpart
2092 );
2093 // Substitute the subpart for an input text field
2094 $content = t3lib_parsehtml::substituteSubpart(
2095 $content,
2096 '###TEXTLINE###',
2097 $textLineSubpart
2098 );
2099 // Define the markers content
2100 $markers = array(
2101 'description' => $description,
2102 'key' => '[' . $k . '][' . $vk . ']',
2103 'label' => htmlspecialchars(t3lib_div::fixed_lgd_cs($value, 40))
2104 );
2105 // Fill the markers
2106 $content = t3lib_parsehtml::substituteMarkerArray(
2107 $content,
2108 $markers,
2109 '###|###',
2110 TRUE,
2111 FALSE
2112 );
2113 // Add the content to the message array
2114 $this->message($ext, $k2, $content);
2115 }
2116 }
2117 }
2118 break;
2119 default:
2120 if (is_array($this->INSTALL['extConfig'])) {
2121 $lines = $this->writeToLocalconf_control();
2122 foreach ($this->INSTALL['extConfig'] as $k => $va) {
2123 if (is_array($GLOBALS['TYPO3_CONF_VARS'][$k])) {
2124 foreach ($va as $vk => $value) {
2125 if (isset($GLOBALS['TYPO3_CONF_VARS'][$k][$vk])) {
2126 $doit=1;
2127 if ($k=='BE' && $vk=='installToolPassword') {
2128 if ($value) {
2129 if (isset($_POST['installToolPassword_check'])) {
2130 if (!$this->formProtection->validateToken(
2131 (string) $_POST['formToken'],
2132 'installToolPassword',
2133 'change'
2134 )) {
2135 $doit = FALSE;
2136 break;
2137 }
2138
2139 if (!t3lib_div::_GP('installToolPassword_check')
2140 || strcmp(t3lib_div::_GP('installToolPassword_check'), $value)
2141 ) {
2142 $doit = FALSE;
2143 $this->errorMessages[]
2144 = 'The two passwords did not ' .
2145 'match! The password was not changed.';
2146 }
2147 }
2148 if (t3lib_div::_GP('installToolPassword_md5')) $value =md5($value);
2149 } else $doit=0;
2150 }
2151
2152 $description = trim($commentArr[1][$k][$vk]);
2153 if (preg_match('/^string \(textarea\)/i', $description)) {
2154 // Force Unix linebreaks in textareas
2155 $value = str_replace(CR, '', $value);
2156 // Preserve linebreaks
2157 $value = str_replace(LF, "' . LF . '", $value);
2158 }
2159 if (preg_match('/^boolean/i', $description)) {
2160 // When submitting settings in the Install Tool, values that default to "FALSE" or "true"
2161 // in config_default.php will be sent as "0" resp. "1". Therefore, reset the values
2162 // to their boolean equivalent.
2163 if ($GLOBALS['TYPO3_CONF_VARS'][$k][$vk] === FALSE && $value === '0') {
2164 $value = FALSE;
2165 } elseif ($GLOBALS['TYPO3_CONF_VARS'][$k][$vk] === TRUE && $value === '1') {
2166 $value = TRUE;
2167 }
2168 }
2169
2170 if ($doit && strcmp($GLOBALS['TYPO3_CONF_VARS'][$k][$vk],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\''.$k.'\'][\''.$vk.'\']', $value);
2171 }
2172 }
2173 }
2174 }
2175 $this->writeToLocalconf_control($lines);
2176 }
2177 break;
2178 }
2179 }
2180
2181 /**
2182 * Make an array of the comments in the t3lib/config_default.php file
2183 *
2184 * @param string $string The contents of the config_default.php file
2185 * @param array $mainArray
2186 * @param array $commentArray
2187 * @return array
2188 */
2189 function getDefaultConfigArrayComments($string,$mainArray=array(),$commentArray=array()) {
2190 $lines = explode(LF, $string);
2191 $in=0;
2192 $mainKey='';
2193 foreach ($lines as $lc) {
2194 $lc = trim($lc);
2195 if ($in) {
2196 if (!strcmp($lc,');')) {
2197 $in=0;
2198 } else {
2199 if (preg_match('/["\']([[:alnum:]_-]*)["\'][[:space:]]*=>(.*)/i',$lc,$reg)) {
2200 preg_match('/,[\t\s]*\/\/(.*)/i',$reg[2],$creg);
2201 $theComment = trim($creg[1]);
2202 if (substr(strtolower(trim($reg[2])),0,5)=='array' && !strcmp($reg[1],strtoupper($reg[1]))) {
2203 $mainKey=trim($reg[1]);
2204 $mainArray[$mainKey]=$theComment;
2205 } elseif ($mainKey) {
2206 $commentArray[$mainKey][$reg[1]]=$theComment;
2207 }
2208 }
2209 }
2210 }
2211 if (!strcmp($lc, '$TYPO3_CONF_VARS = array(')) {
2212 $in=1;
2213 }
2214 }
2215 return array($mainArray,$commentArray);
2216 }
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230 /*******************************
2231 *
2232 * CHECK CONFIGURATION FUNCTIONS
2233 *
2234 *******************************/
2235
2236 /**
2237 * Checking php.ini configuration and set appropriate messages and flags.
2238 *
2239 * @return void
2240 */
2241 function checkConfiguration() {
2242 $ext='php.ini configuration checked';
2243 $this->message($ext);
2244
2245 // *****************
2246 // Incoming values:
2247 // *****************
2248
2249 // Includepath
2250 $incPaths = t3lib_div::trimExplode(TYPO3_OS=='WIN'?';':':', ini_get('include_path'));
2251 if (!in_array('.',$incPaths)) {
2252 $this->message($ext, 'Current directory (./) is not in include path!', '
2253 <p>
2254 <em>include_path=' . ini_get('include_path') . '</em>
2255 <br />
2256 Normally the current path, \'.\', is included in the
2257 include_path of PHP. Although TYPO3 does not rely on this,
2258 it is an unusual setting that may introduce problems for
2259 some extensions.
2260 </p>
2261 ', 1);
2262 } else $this->message($ext, 'Current directory in include path',"",-1);
2263
2264 // *****************
2265 // File uploads
2266 // *****************
2267 if (!ini_get('file_uploads')) {
2268 $this->message($ext, 'File uploads not allowed', '
2269 <p>
2270 <em>file_uploads=' . ini_get('file_uploads') . '</em>
2271 <br />
2272 TYPO3 uses the ability to upload files from the browser in
2273 various cases.
2274 <br />
2275 As long as this flag is disabled, you\'ll not be able to
2276 upload files.
2277 <br />
2278 But it doesn\'t end here, because not only are files not
2279 accepted by the server - ALL content in the forms are
2280 discarded and therefore nothing at all will be editable
2281 if you don\'t set this flag!
2282 <br />
2283 However if you cannot enable fileupload for some reason
2284 alternatively you change the default form encoding value
2285 with \$TYPO3_CONF_VARS[SYS][form_enctype].
2286 </p>
2287 ', 3);
2288 } else $this->message($ext, 'File uploads allowed',"",-1);
2289
2290 $upload_max_filesize = t3lib_div::getBytesFromSizeMeasurement(ini_get('upload_max_filesize'));
2291 $post_max_size = t3lib_div::getBytesFromSizeMeasurement(ini_get('post_max_size'));
2292 if ($upload_max_filesize<1024*1024*10) {
2293 $this->message($ext, 'Maximum upload filesize too small?', '
2294 <p>
2295 <em>upload_max_filesize=' . ini_get('upload_max_filesize') . '</em>
2296 <br />
2297 By default TYPO3 supports uploading, copying and moving
2298 files of sizes up to 10MB (You can alter the TYPO3 defaults
2299 by the config option TYPO3_CONF_VARS[BE][maxFileSize]).
2300 <br />
2301 Your current value is below this, so at this point, PHP sets
2302 the limits for uploaded filesizes and not TYPO3.
2303 <br />
2304 <strong>Notice:</strong> The limits for filesizes attached
2305 to database records are set in the tables.php configuration
2306 files (\$TCA) for each group/file field. You may override
2307 these values in localconf.php or by page TSconfig settings.
2308 </p>
2309 ', 1);
2310 }
2311 if ($upload_max_filesize > $post_max_size) {
2312 $this->message($ext, 'Maximum size for POST requests is smaller than max. upload filesize', '
2313 <p>
2314 <em>upload_max_filesize=' . ini_get('upload_max_filesize') . '
2315 , post_max_size=' . ini_get('post_max_size') . '</em>
2316 <br />
2317 You have defined a maximum size for file uploads which
2318 exceeds the allowed size for POST requests. Therefore the
2319 file uploads can not be larger than ' . ini_get('post_max_size') . '
2320 </p>
2321 ', 1);
2322 }
2323
2324 // *****************
2325 // Memory and functions
2326 // *****************
2327 $memory_limit_value = t3lib_div::getBytesFromSizeMeasurement(ini_get('memory_limit'));
2328
2329 if ($memory_limit_value && $memory_limit_value < t3lib_div::getBytesFromSizeMeasurement(TYPO3_REQUIREMENTS_MINIMUM_PHP_MEMORY_LIMIT)) {
2330 $this->message($ext, 'Memory limit below ' . TYPO3_REQUIREMENTS_MINIMUM_PHP_MEMORY_LIMIT, '
2331 <p>
2332 <em>memory_limit=' . ini_get('memory_limit') . '</em>
2333 <br />
2334 Your system is configured to enforce a memory limit of PHP
2335 scripts lower than ' . TYPO3_REQUIREMENTS_MINIMUM_PHP_MEMORY_LIMIT . '.
2336 The Extension Manager needs to include more PHP-classes than
2337 will fit into this memory space. There is nothing else to do
2338 than raise the limit. To be safe, ask the system
2339 administrator of the webserver to raise the limit to over
2340 ' . TYPO3_REQUIREMENTS_MINIMUM_PHP_MEMORY_LIMIT . '.
2341 </p>
2342 ', 3);
2343 } elseif(!$memory_limit_value) {
2344 $this->message($ext, 'Memory limit', '
2345 <p>
2346 <em>No memory limit in effect.</em>
2347 </p>
2348 ', -1);
2349 } else {
2350 $this->message($ext, 'Memory limit: ' . ini_get('memory_limit'), '', -1);
2351 }
2352 if (ini_get('max_execution_time')<30) {
2353 $this->message($ext, 'Maximum execution time below 30 seconds', '
2354 <p>
2355 <em>max_execution_time=' . ini_get('max_execution_time') . '</em>
2356 <br />
2357 May impose problems if too low.
2358 </p>
2359 ', 1);
2360 } else {
2361 $this->message($ext, 'Maximum execution time: ' . ini_get('max_execution_time') . ' seconds', '', -1);
2362 }
2363 if (ini_get('disable_functions')) {
2364 $this->message($ext, 'Functions disabled!', '
2365 <p>
2366 <em>disable_functions=' . ini_get('disable_functions') . '</em>
2367 <br />
2368 The above list of functions are disabled. If TYPO3 use any
2369 of these there might be trouble.
2370 <br />
2371 TYPO3 is designed to use the default set of PHP4.3.0+
2372 functions plus the functions of GDLib.
2373 <br />
2374 Possibly these functions are disabled due to security risks
2375 and most likely the list would include a function like
2376 <em>exec()</em> which is use by TYPO3 to access ImageMagick.
2377 </p>
2378 ', 2);
2379 } else {
2380 $this->message($ext, 'Functions disabled: none', '', -1);
2381 }
2382 // Mail tests
2383 if (TYPO3_OS == 'WIN') {
2384 $smtp = ini_get('SMTP');
2385 $bad_smtp = FALSE;
2386 if (!t3lib_div::validIP($smtp)) {
2387 $smtp_addr = @gethostbyname($smtp);
2388 $bad_smtp = ($smtp_addr == $smtp);
2389 }
2390 else {
2391 $smtp_addr = $smtp;
2392 }
2393 if (!$smtp || $bad_smtp || !t3lib_div::testInt(ini_get('smtp_port'))) {
2394 $this->message($ext, 'Mail configuration is not set correctly', '
2395 <p>
2396 Mail configuration is not set
2397 <br />
2398 PHP mail() function requires SMTP and smtp_port to have
2399 correct values on Windows.
2400 </p>
2401 ', 2);
2402 } else {
2403 if (($smtp_addr == '127.0.0.1' || $smtp_addr == '::1') && ($_SERVER['SERVER_ADDR'] == '127.0.0.1' || $_SERVER['SERVER_ADDR'] == '::1')) {
2404 $this->message($ext, 'Mail is configured (potential problem exists!)', '
2405 <p>
2406 <em>SMTP=' . $smtp . '</em> - <strong>Note:</strong>
2407 this server! Are you sure it runs SMTP server?
2408 <br />
2409 <em>smtp_port=' . ini_get('smtp_port') . '</em>
2410 </p>' . $this->check_mail('get_form') . '
2411 ', 1);
2412 } else {
2413 $this->message($ext, 'Mail is configured', '
2414 <p>
2415 <em>SMTP=' . $smtp . '</em>
2416 <br />
2417 <em>smtp_port=' . ini_get('smtp_port') . '</em>
2418 </p>' . $this->check_mail('get_form') .'
2419 ', -1);
2420 }
2421 }
2422 } elseif (!ini_get('sendmail_path')) {
2423 $this->message($ext, 'Sendmail path not defined!', '
2424 <p>
2425 This may be critical to TYPO3\'s use of the mail() function.
2426 Please be sure that the mail() function in your
2427 php-installation works!
2428 </p>' . $this->check_mail('get_form') . '
2429 ', 1);
2430 } else {
2431 list($prg) = explode(' ', ini_get('sendmail_path'));
2432 if (!@is_executable($prg)) {
2433 $this->message($ext, 'Sendmail program not found or not executable?', '
2434 <p>
2435 <em>sendmail_path=' . ini_get('sendmail_path') . '</em>
2436 <br />
2437 This may be critical to TYPO3\'s use of the mail()
2438 function. Please be sure that the mail() function in
2439 your php-installation works!
2440 </p>' . $this->check_mail('get_form') .'
2441 ', 1);
2442 } else {
2443 $this->message($ext, 'Sendmail OK', '
2444 <p>
2445 <em>sendmail_path=' . ini_get('sendmail_path') . '</em>
2446 </p>' . $this->check_mail('get_form') . '
2447 ', -1);
2448 }
2449 }
2450
2451 // *****************
2452 // Safe mode related
2453 // *****************
2454 if (t3lib_utility_PhpOptions::isSafeModeEnabled()) {
2455 $this->message($ext, 'Safe mode turned on', '
2456 <p>
2457 <em>safe_mode=' . ini_get('safe_mode') . '</em>
2458 <br />
2459 In safe_mode PHP is restricted in several ways. This is a
2460 good thing because it adds protection to your (and others)
2461 scripts. But it may also introduce problems. In TYPO3 this
2462 <em>may be</em> a problem in two areas: File administration
2463 and execution of external programs, in particular
2464 ImageMagick.
2465 <br />
2466 If you just ignore this warning, you\'ll most likely find,
2467 that TYPO3 seems to work except from the image-generation.
2468 The problem in that case is that the external ImageMagick
2469 programs are not allowed to be executed from the regular
2470 paths like "/usr/bin/" or "/usr/X11R6/bin/".
2471 <br />
2472 If you use safe_mode with TYPO3, you should disable use of
2473 external programs ([BE][disable_exec_function]=1).
2474 <br />
2475 In safe mode you must ensure that all the php-scripts and
2476 upload folders are owned by the same user.
2477 </p>
2478 <p>
2479 <em>safe_mode_exec_dir=' . ini_get('safe_mode_exec_dir') . '</em>
2480 <br />
2481 If the ImageMagick utilities are located in this directory,
2482 everything is fine. Below on this page, you can see if
2483 ImageMagick is found here. If not, ask you ISP to put the
2484 three ImageMagick programs, \'convert\',
2485 \'combine\'/\'composite\' and \'identify\' there (eg. with
2486 symlinks if Unix server)
2487 </p>
2488 <p>
2489 <strong>Example of safe_mode settings:</strong>
2490 <br />
2491 Set this in the php.ini file:
2492 </p>
2493 <p>
2494 ; Safe Mode
2495 <br />
2496 safe_mode = On
2497 <br />
2498 safe_mode_exec_dir = /usr/bin/
2499 </p>
2500 <p>
2501 ...and the ImageMagick \'/usr/bin/convert\' will be
2502 executable.
2503 <br />
2504 The last slash is important (..../) and you can only specify
2505 one directory.
2506 </p>
2507 <p>
2508 <strong>Notice: </strong>
2509 <br />
2510 ImageMagick 6 or GraphicsMagick is recommended and the binaries are
2511 normally installed in /usr/bin.
2512 <br />
2513 Paths to ImageMagick are defined in localconf.php and may be
2514 something else than /usr/bin/, but this is default for
2515 ImageMagick 6+
2516 </p>
2517 ', 2);
2518 if (ini_get('doc_root')) {
2519 $this->message($ext, 'doc_root set', '
2520 <p>
2521 <em>doc_root=' . ini_get('doc_root') . '</em>
2522 <br />
2523 PHP cannot execute scripts outside this directory. If
2524 that is a problem is please correct it.
2525 </p>
2526 ', 1);
2527 }
2528 $this->config_array['safemode']=1;
2529 } else {
2530 $this->message($ext, 'safe_mode: off',"",-1);
2531 }
2532 if (t3lib_utility_PhpOptions::isSqlSafeModeEnabled()) {
2533 $this->message($ext, 'sql.safe_mode is enabled', '
2534 <p>
2535 <em>sql.safe_mode=' . ini_get('sql.safe_mode') . '</em>
2536 <br />
2537 This means that you can only connect to the database with a
2538 username corresponding to the user of the webserver process
2539 or fileowner. Consult your ISP for information about this.
2540 Also see <a href="http://www.wrox.com/Consumer/Store/Books/2963/29632002.htm">
2541 http://www.wrox.com/Consumer/Store/Books/2963/29632002.htm</a>
2542 <br />
2543 The owner of the current file is:
2544 <strong>' . get_current_user () . '</strong>
2545 </p>
2546 ', 1);
2547 $this->config_array['sql.safe_mode_user'] = get_current_user();
2548 } else {
2549 $this->message($ext, 'sql.safe_mode: off',"",-1);
2550 }
2551 if (ini_get('open_basedir')) {
2552 $this->message($ext, 'open_basedir set', '
2553 <p>
2554 <em>open_basedir=' . ini_get('open_basedir') . '</em>
2555 <br />
2556 This restricts TYPO3 to open and include files only in this
2557 path. Please make sure that this does not prevent TYPO3 from
2558 running.
2559 <br />
2560 <strong>Notice (UNIX):</strong> Before checking a path
2561 according to open_basedir, PHP resolves all symbolic links.
2562 </p>
2563 ', 1);
2564 // ???? If this option was set falsely you probably didn't see this page in the
2565 // first place, but this option <strong>may spoil this configuration test</strong>
2566 // when checking for such as ImageMagick executables.
2567 } else {
2568 $this->message($ext, 'open_basedir: off',"",-1);
2569 }
2570
2571 // Check availability of PHP session support
2572 if (extension_loaded('session')) {
2573 $this->message($ext, 'PHP sessions available', '
2574 <p>
2575 <em>PHP Sessions available</em>
2576 <br />
2577 PHP is compiled with session support and session support is
2578 available.
2579 </p>
2580 ', -1);
2581 } else {
2582 $this->message($ext, 'PHP Sessions not available', '
2583 <p>
2584 PHP is not compiled with session support, or session support
2585 is disabled in php.ini.
2586 <br />
2587 TYPO3 needs session support.
2588 </p>
2589 ', 3);
2590 }
2591
2592 // Suhosin/Hardened PHP:
2593 $suhosinDescription = '
2594 <p>
2595 Suhosin limits the number of elements that can be submitted in
2596 forms to the server. This will affect for example the
2597 "All configuration" section in the Install Tool or Inline
2598 Relational Record Editing (IRRE) with many child records.
2599 </p>';
2600 if (extension_loaded('suhosin')) {
2601 $suhosinSuggestion = '
2602 <p>
2603 At least a value of 400 is suggested.
2604 </p>
2605 ';
2606
2607 $suhosinRequestMaxVars = ini_get('suhosin.request.max_vars');
2608 $suhosinPostMaxVars = ini_get('suhosin.post.max_vars');
2609 $suhosinRequestMaxVarsType = ($suhosinRequestMaxVars < 400 ? 2 : -1);
2610 $suhosinPostMaxVarsType = ($suhosinPostMaxVars < 400 ? 2 : -1);
2611 $suhosinType = ($suhosinRequestMaxVars < 400 || $suhosinPostMaxVars < 400 ? 2 : -1);
2612
2613 $this->message($ext, 'Suhosin/Hardened PHP is loaded', $suhosinDescription, $suhosinType);
2614 $this->message($ext, 'suhosin.request.max_vars: ' . $suhosinRequestMaxVars, $suhosinSuggestion, $suhosinRequestMaxVarsType);
2615 $this->message($ext, 'suhosin.post.max_vars: ' . $suhosinPostMaxVars, $suhosinSuggestion, $suhosinPostMaxVarsType);
2616 } else {
2617 $this->message($ext, 'Suhosin/Hardened PHP is not loaded', $suhosinDescription, 0);
2618 }
2619
2620 // Check for stripped PHPdoc comments that are required to evaluate annotations:
2621 $method = new ReflectionMethod('tx_install', 'check_mail');
2622 if (strlen($method->getDocComment()) === 0) {
2623 $description = '
2624 <p>
2625 The system extension Extbase evaluates annotations in PHPdoc
2626 comments and thus requires eAccelerator not to strip away
2627 these parts. However, this is currently the only part in the
2628 TYPO3 Core (beside deprecation log and unit tests). If
2629 Extbase is not used, recompiling eAccelerator is not
2630 required at all.
2631 <br/>
2632 <br/>
2633 If you do not want comments to be stripped by eAccelerator,
2634 please recompile with the following configuration setting
2635 (<a href="http://eaccelerator.net/ticket/229" target="_blank">
2636 more details</a>):
2637 <br />
2638 <em>--with-eaccelerator-doc-comment-inclusion</em>
2639 </p>
2640 ';
2641 $this->message($ext, 'PHPdoc comments are stripped', $description, 2);
2642 }
2643 }
2644
2645 /**
2646 * Check if PHP function mail() works
2647 *
2648 * @param string $cmd If "get_form" then a formfield for the mail-address is shown. If not, it's checked if "check_mail" was in the INSTALL array and if so a test mail is sent to the recipient given.
2649 * @return string The mail form if it is requested with get_form
2650 */
2651 function check_mail($cmd='') {
2652 switch($cmd) {
2653 case 'get_form':
2654 $out = '
2655 <p id="checkMailForm">
2656 You can check the t3lib_mail functionality by entering your email
2657 address here and press the button. You should then
2658 receive a testmail from "typo3installtool@example.org".
2659 </p>
2660 ';
2661 // Get the template file
2662 $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'CheckMail.html');
2663 // Get the template part from the file
2664 $template = t3lib_parsehtml::getSubpart($templateFile, '###TEMPLATE###');
2665
2666 if (!empty($this->mailMessage)) {
2667 // Get the subpart for the mail is sent message
2668 $mailSentSubpart = t3lib_parsehtml::getSubpart($template, '###MAILSENT###');
2669 }
2670 // Substitute the subpart for the mail is sent message
2671 $template = t3lib_parsehtml::substituteSubpart(
2672 $template,
2673 '###MAILSENT###',
2674 $mailSentSubpart
2675 );
2676 // Define the markers content
2677 $markers = array(
2678 'message' => $this->mailMessage,
2679 'enterEmail' => 'Enter the email address',
2680 'actionUrl' => $this->action . '#checkMailForm',
2681 'submit' => 'Send test mail'
2682 );
2683 // Fill the markers
2684 $out .= t3lib_parsehtml::substituteMarkerArray(
2685 $template,
2686 $markers,
2687 '###|###',
2688 TRUE,
2689 TRUE
2690 );
2691 break;
2692 default:
2693 if (trim($this->INSTALL['check_mail'])) {
2694 $subject = 'TEST SUBJECT';
2695 $email = trim($this->INSTALL['check_mail']);
2696
2697 /** @var $mailMessage t3lib_mail_Message */
2698 $mailMessage = t3lib_div::makeInstance('t3lib_mail_Message');
2699 $mailMessage->addTo($email)
2700 ->addFrom('typo3installtool@example.org', 'TYPO3 Install Tool')
2701 ->setSubject($subject)
2702 ->setBody('<html><body>HTML TEST CONTENT</body></html>');
2703 $mailMessage->addPart('TEST CONTENT');
2704 $mailMessage->send();
2705 $this->mailMessage= 'Mail was sent to: ' . $email;
2706 }
2707 break;
2708 }
2709 return $out;
2710 }
2711
2712 /**
2713 * Checking php extensions, specifically GDLib and Freetype
2714 *
2715 * @return void
2716 */
2717 function checkExtensions() {
2718 $ext = 'GDLib';
2719 $this->message($ext);
2720
2721 $software_info=1;
2722 if (extension_loaded('gd') && $this->isGD()) {
2723 $this->config_array['gd']=1;
2724 $this->message($ext, 'GDLib found',"",-1);
2725 if ($this->isPNG()) {
2726 $this->config_array['gd_png']=1;
2727 $this->message($ext, 'PNG supported',"",-1);
2728 }
2729 if ($this->isGIF()) {
2730 $this->config_array['gd_gif']=1;
2731 $this->message($ext, 'GIF supported',"",-1);
2732 }
2733 if ($this->isJPG()) {
2734 $this->config_array['gd_jpg']=1;
2735 $this->message($ext, 'JPG supported (not used by TYPO3)','');
2736 }
2737 if (!$this->config_array['gd_gif'] && !$this->config_array['gd_png']) {
2738 $this->message($ext, 'PNG or GIF not supported', '
2739 <p>
2740 Your GDLib supports either GIF nor PNG. It must support
2741 either one of them.
2742 </p>
2743 ', 2);
2744 } else {
2745 $msg=array();
2746 if ($this->config_array['gd_gif'] && $this->config_array['gd_png']) {
2747 $msg[] = '
2748 <p>
2749 You can choose between generating GIF or PNG files,
2750 as your GDLib supports both.
2751 </p>
2752 ';
2753 }
2754 if ($this->config_array['gd_gif']) {
2755 $msg[] = '
2756 <p>
2757 You should watch out for the generated size of the
2758 GIF-files because some versions of the GD library do
2759 not compress them with LZW, but RLE and ImageMagick
2760 is subsequently used to compress with LZW. But in
2761 the case of ImageMagick failing this task (eg. not
2762 being compiled with LZW which is the case with some
2763 versions) you\'ll end up with GIF-filesizes all too
2764 big!
2765 <br />
2766 This Install Tool tests what kinds of GIF
2767 compression are available in the ImageMagick
2768 installations by a physical test. You can also check
2769 it manually by opening a TYPO3 generated gif-file
2770 with Photoshop and save it in a new file. If the
2771 file sizes of the original and the new file are
2772 almost the same, you\'re having LZW compression and
2773 everything is fine.
2774 </p>
2775 ';
2776 }
2777 if ($this->config_array['gd_png']) {
2778 $msg[] = '
2779 <p>
2780 TYPO3 prefers the use of GIF-files and most likely
2781 your visitors on your website does too as not all
2782 browsers support PNG yet.
2783 </p>
2784 ';
2785 }
2786 $this->message($ext, 'GIF / PNG issues', implode(LF, $msg), 1);
2787 }
2788 if (!$this->isTTF()) {
2789 $this->message($ext, 'FreeType is apparently not installed', '
2790 <p>
2791 It looks like the FreeType library is not compiled into
2792 GDLib. This is required when TYPO3 uses GDLib and
2793 you\'ll most likely get errors like \'ImageTTFBBox is
2794 not a function\' or \'ImageTTFText is not a function\'.
2795 </p>
2796 ', 2);
2797 } else {
2798 $this->message($ext, 'FreeType quick-test (' . ($this->isGIF() ? 'as GIF' : 'as PNG') . ')', '
2799 <p>
2800 <img src="' . htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI') . '&testingTrueTypeSupport=1') . '" alt="" />
2801 <br />
2802 (If the text is exceeding the image borders you are
2803 using Freetype 2 and need to set
2804 TYPO3_CONF_VARS[GFX][TTFdpi]=96.
2805 <br />
2806 If there is no image at all Freetype is most likely NOT
2807 available and you can just as well disable GDlib for
2808 TYPO3...)
2809 </p>
2810 ', -1);
2811 $this->config_array['freetype']=1;
2812 }
2813 } else {
2814 $this->message($ext, 'GDLib2 not found', '
2815 <p>
2816 GDLib2 is required if you want to use the GIFBUILDER object
2817 in TypoScript. GIFBUILDER is in charge of all advanced image
2818 generation in TypoScript, including graphical menuitems.
2819 <br />
2820 GDLib2 is also used in the TYPO3 Backend (TBE) to generate
2821 record icons and new module tabs.
2822 <br />
2823 It\'s highly recommended to install this library. Remember
2824 to compile GD with FreeType which is also required.
2825 <br />
2826 If you choose not to install GDLib, you can disable it in
2827 the configuration with [GFX][gdlib]=0;.
2828 </p>
2829 ', 2);
2830 }
2831 $this->message($ext, 'GDLib software information', $this->getGDSoftwareInfo());
2832 }
2833
2834 /**
2835 * Checking and testing that the required writable directories are writable.
2836 *
2837 * @return void
2838 */
2839 function checkDirs() {
2840 // Check typo3/temp/
2841 $ext='Directories';
2842 $this->message($ext);
2843
2844 $uniqueName = md5(uniqid(microtime()));
2845
2846 // The requirement level (the integer value, ie. the second value of the value array) has the following meanings:
2847 // -1 = not required, but if it exists may be writable or not
2848 // 0 = not required, if it exists the dir should be writable
2849 // 1 = required, don't has to be writable
2850 // 2 = required, has to be writable
2851
2852 $checkWrite=array(
2853 'typo3temp/' => array('This folder is used by both the frontend (FE) and backend (BE) interface for all kind of temporary and cached files.',2,'dir_typo3temp'),
2854 'typo3temp/pics/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'),
2855 'typo3temp/temp/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'),
2856 'typo3temp/llxml/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'),
2857 'typo3temp/cs/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'),
2858 'typo3temp/GB/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'),
2859 'typo3temp/locks/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'),
2860 'typo3conf/' => array('This directory contains the local configuration files of your website. TYPO3 must be able to write to these configuration files during setup and when the Extension Manager (EM) installs extensions.',2),
2861 'typo3conf/ext/' => array('Location for local extensions. Must be writable if the Extension Manager is supposed to install extensions for this website.',0),
2862 'typo3conf/l10n/' => array('Location for translations. Must be writable if the Extension Manager is supposed to install translations for extensions.',0),
2863 TYPO3_mainDir.'ext/' => array('Location for global extensions. Must be writable if the Extension Manager is supposed to install extensions globally in the source.',-1),
2864 'uploads/' => array('Location for uploaded files from RTE, in the subdirectories for uploaded files of content elements.',2),
2865 'uploads/pics/' => array('Typical location for uploaded files (images especially).',0),
2866 'uploads/media/' => array('Typical location for uploaded files (non-images especially).',0),
2867 'uploads/tf/' => array('Typical location for uploaded files (TS template resources).',0),
2868 $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] => array('Location for local files such as templates, independent uploads etc.',-1),
2869 $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/' => array('Typical temporary location for default upload of files by administrators.',0),
2870 );
2871
2872 foreach ($checkWrite as $relpath => $descr) {
2873
2874 // Check typo3temp/
2875 $general_message = $descr[0];
2876
2877 // If the directory is missing, try to create it
2878 if (!@is_dir(PATH_site.$relpath)) {
2879 t3lib_div::mkdir(PATH_site.$relpath);
2880 }
2881
2882 if (!@is_dir(PATH_site.$relpath)) {
2883 if ($descr[1]) { // required...
2884 $this->message($ext, $relpath.' directory does not exist and could not be created', '
2885 <p>
2886 <em>Full path: ' . PATH_site . $relpath . '</em>
2887 <br />
2888 ' . $general_message . '
2889 </p>
2890 <p>
2891 This error should not occur as ' . $relpath . ' must
2892 always be accessible in the root of a TYPO3 website.
2893 </p>
2894 ', 3);
2895 } else {
2896 if ($descr[1] == 0) {
2897 $msg = 'This directory does not necessarily have to exist but if it does it must be writable.';
2898 } else {
2899 $msg = 'This directory does not necessarily have to exist and if it does it can be writable or not.';
2900 }
2901 $this->message($ext, $relpath.' directory does not exist', '
2902 <p>
2903 <em>Full path: ' . PATH_site . $relpath . '</em>
2904 <br />
2905 ' . $general_message . '
2906 </p>
2907 <p>
2908 ' . $msg . '
2909 </p>
2910 ', 2);
2911 }
2912 } else {
2913 $file = PATH_site.$relpath.$uniqueName;
2914 @touch($file);
2915 if (@is_file($file)) {
2916 unlink($file);
2917 if ($descr[2]) { $this->config_array[$descr[2]]=1; }
2918 $this->message($ext, $relpath.' writable','',-1);
2919 } else {
2920 $severity = ($descr[1]==2 || $descr[1]==0) ? 3 : 2;
2921 if ($descr[1] == 0 || $descr[1] == 2) {
2922 $msg = 'The directory '.$relpath.' must be writable!';
2923 } elseif ($descr[1] == -1 || $descr[1] == 1) {
2924 $msg = 'The directory '.$relpath.' does not neccesarily have to be writable.';
2925 }
2926 $this->message($ext, $relpath .' directory not writable', '
2927 <p>
2928 <em>Full path: ' . $file . '</em>
2929 <br />
2930 ' . $general_message . '
2931 </p>
2932 <p>
2933 Tried to write this file (with touch()) but didn\'t
2934 succeed.
2935 <br />
2936 ' . $msg . '
2937 </p>
2938 ', $severity);
2939 }
2940 }
2941 }
2942 }
2943
2944 /**
2945 * Checking for existing ImageMagick installs.
2946 *
2947 * This tries to find available ImageMagick installations and tries to find the version numbers by executing "convert" without parameters. If the ->checkIMlzw is set, LZW capabilities of the IM installs are check also.
2948 *
2949 * @param array $paths Possible ImageMagick paths
2950 * @return void
2951 */
2952 function checkImageMagick($paths) {
2953 $ext='Check Image Magick';
2954 $this->message($ext);
2955 // Get the template file
2956 $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'CheckImageMagick.html');
2957
2958 $p