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