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