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