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