Fixed bug #12295: Cleaning config_default, exclude values from being listed in instal...
[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 * 4898: function convertByteSize($bytes)
132 * 4912: function securityRisk()
133 * 4930: function alterPasswordForm()
134 * 4946: function messageBasicFinished()
135 * 4968: function setScriptName($type)
136 * 4981: function formWidth($size=48,$textarea=0,$styleOverride='')
137 * 5002: function formWidthText($size=48,$styleOverride='',$wrap='')
138 * 5018: function getBackupFilename($filename)
139 *
140 * TOTAL FUNCTIONS: 82
141 * (This index is automatically created/updated by the extension "extdeveval")
142 *
143 */
144
145 // include update classes
146 require_once(t3lib_extMgm::extPath('install').'updates/class.tx_coreupdates_compatversion.php');
147 require_once(t3lib_extMgm::extPath('install').'updates/class.tx_coreupdates_cscsplit.php');
148 require_once(t3lib_extMgm::extPath('install').'updates/class.tx_coreupdates_notinmenu.php');
149 require_once(t3lib_extMgm::extPath('install').'updates/class.tx_coreupdates_mergeadvanced.php');
150 require_once(t3lib_extMgm::extPath('install').'updates/class.tx_coreupdates_installsysexts.php');
151 require_once(t3lib_extMgm::extPath('install').'updates/class.tx_coreupdates_imagescols.php');
152 require_once(t3lib_extMgm::extPath('install').'updates/class.tx_coreupdates_installversioning.php');
153 require_once(t3lib_extMgm::extPath('install').'updates/class.tx_coreupdates_installnewsysexts.php');
154 require_once(t3lib_extMgm::extPath('install') . 'mod/class.tx_install_session.php');
155
156 /**
157 * Install Tool module
158 *
159 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
160 * @author Ingmar Schlecht <ingmar@typo3.org>
161 * @package TYPO3
162 * @subpackage tx_install
163 */
164 class tx_install extends t3lib_install {
165 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()
166 var $getGD_end_string = '</table>'; // Used to identify the end of the GD section (found with getGD_start_string) in the output from phpinfo()
167 var $getTTF_string = 'with TTF library'; // Used to identify whether TTF-lib is included with GD
168 var $getTTF_string_alt = 'with freetype'; // Used to identify whether TTF-lib is included with GD
169 var $action = ''; // The url that calls this script
170 var $scriptSelf = 'index.php'; // The url that calls this script
171 var $fontTag2='<div class="bodytext">';
172 var $fontTag1='<div class="smalltext">';
173 var $updateIdentity = 'TYPO3 Install Tool';
174 var $headerStyle ='';
175 var $contentBeforeTable='';
176 var $setAllCheckBoxesByDefault=0;
177
178 var $allowFileEditOutsite_typo3conf_dir=0;
179
180 var $INSTALL =array(); // In constructor: is set to global GET/POST var TYPO3_INSTALL
181 var $checkIMlzw = 0; // If set, lzw capabilities of the available ImageMagick installs are check by actually writing a gif-file and comparing size
182 var $checkIM = 0; // If set, ImageMagick is checked.
183 var $dumpImCommands=1; // If set, the image Magick commands are always outputted in the image processing checker
184 var $mode = ''; // If set to "123" then only most vital information is displayed.
185 var $step = 0; // If set to 1,2,3 or GO it signifies various functions.
186
187 // internal
188 var $passwordOK=0; // This is set, if the password check was ok. The function init() will exit if this is not set
189 var $silent=1; // If set, the check routines don't add to the message-array
190 var $messageFunc_nl2br=1;
191 var $sections=array(); // Used to gather the message information.
192 var $fatalError=0; // This is set if some error occured that will definitely prevent TYpo3 from running.
193 var $sendNoCacheHeaders=1;
194 var $config_array = array( // Flags are set in this array if the options are available and checked ok.
195 'gd'=>0,
196 'gd_gif'=>0,
197 'gd_png'=>0,
198 'gd_jpg'=>0,
199 'freetype' => 0,
200 'safemode' => 0,
201 'dir_typo3temp' => 0,
202 'dir_temp' => 0,
203 'im_versions' => array(),
204 'im' => 0,
205 'sql.safe_mode_user' => '',
206 'mysqlConnect' => 0,
207 'no_database' => 0
208 );
209 var $typo3temp_path='';
210 /**
211 * the session handling object
212 *
213 * @var tx_install_session
214 */
215 protected $session = NULL;
216
217 var $menuitems = array(
218 'config' => 'Basic Configuration',
219 'database' => 'Database Analyser',
220 'update' => 'Update Wizard',
221 'images' => 'Image Processing',
222 'extConfig' => 'All Configuration',
223 'typo3temp' => 'typo3temp/',
224 'cleanup' => 'Clean up database',
225 'phpinfo' => 'phpinfo()',
226 'typo3conf_edit' => 'Edit files in typo3conf/',
227 'about' => 'About'
228 );
229 var $JSmessage = '';
230
231
232
233
234
235
236 /**
237 * Constructor
238 *
239 * @return [type] ...
240 */
241 function tx_install() {
242 parent::t3lib_install();
243
244 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';");
245
246 if ($this->sendNoCacheHeaders) {
247 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
248 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
249 header('Expires: 0');
250 header('Cache-Control: no-cache, must-revalidate');
251 header('Pragma: no-cache');
252 }
253
254 // ****************************
255 // Initializing incoming vars.
256 // ****************************
257 $this->INSTALL = t3lib_div::_GP('TYPO3_INSTALL');
258 $this->mode = t3lib_div::_GP('mode');
259 if ($this->mode !== '123') {
260 $this->mode = '';
261 }
262 if (t3lib_div::_GP('step') === 'go') {
263 $this->step = 'go';
264 } else {
265 $this->step = intval(t3lib_div::_GP('step'));
266 }
267 $this->redirect_url = t3lib_div::_GP('redirect_url');
268
269 $this->INSTALL['type'] = '';
270 if ($_GET['TYPO3_INSTALL']['type']) {
271 $allowedTypes = array(
272 'config', 'database', 'update', 'images', 'extConfig',
273 'typo3temp', 'cleanup', 'phpinfo', 'typo3conf_edit', 'about'
274 );
275
276 if (in_array($_GET['TYPO3_INSTALL']['type'], $allowedTypes)) {
277 $this->INSTALL['type'] = $_GET['TYPO3_INSTALL']['type'];
278 }
279 }
280
281 if ($this->step == 3) {
282 $this->INSTALL['type'] = 'database';
283 }
284
285 if ($this->mode=='123') {
286 $tempItems = $this->menuitems;
287 $this->menuitems = array(
288 'config' => $tempItems['config'],
289 'database' => $tempItems['database']
290 );
291 if (!$this->INSTALL['type'] || !isset($this->menuitems[$this->INSTALL['type']])) {
292 $this->INSTALL['type'] = 'config';
293 }
294 } else {
295 if (!$this->INSTALL['type'] || !isset($this->menuitems[$this->INSTALL['type']])) {
296 $this->INSTALL['type'] = 'about';
297 }
298 }
299
300 $this->action = $this->scriptSelf .
301 '?TYPO3_INSTALL[type]=' . $this->INSTALL['type'] .
302 ($this->mode? '&mode=' . $this->mode : '') .
303 ($this->step? '&step=' . $this->step : '');
304 $this->typo3temp_path = PATH_site.'typo3temp/';
305 if (!is_dir($this->typo3temp_path) || !is_writeable($this->typo3temp_path)) {
306 die('Install Tool needs to write to typo3temp/. Make sure this directory is writeable by your webserver: '. $this->typo3temp_path);
307 }
308
309 $this->session = t3lib_div::makeInstance('tx_install_session');
310
311 // *******************
312 // Check authorization
313 // *******************
314 if (!$this->session->hasSession()) {
315 $this->session->startSession();
316
317 $this->JSmessage='SECURITY:
318 Make sure to protect the Install Tool with another password than "joh316".
319 Better yet you can add a die() function call to typo3/install/index.php after usage.
320
321 IF THE INSTALL TOOL CRASHES...
322 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.
323 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.
324 On behalf of PHP we regret this inconvenience.
325
326 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.
327 ';
328 }
329
330 if ($this->session->isAuthorized() || $this->checkPassword()) {
331 $this->passwordOK=1;
332 $this->session->refreshSession();
333
334 $enableInstallToolFile = PATH_typo3conf . 'ENABLE_INSTALL_TOOL';
335 if (is_file ($enableInstallToolFile)) {
336 // Extend the age of the ENABLE_INSTALL_TOOL file by one hour
337 @touch($enableInstallToolFile);
338 }
339
340 if($this->redirect_url) {
341 header('Location: '.$this->redirect_url);
342 }
343 } else {
344 $this->loginForm();
345 }
346 }
347
348 /**
349 * Returns true if submitted password is ok.
350 *
351 * If password is ok, set session as "authorized".
352 *
353 * @return boolean true if the submitted password was ok and session was
354 * authorized, false otherwise
355 */
356 function checkPassword() {
357 $p = t3lib_div::_GP('password');
358
359 if ($p && md5($p)==$GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword']) {
360 $this->session->setAuthorized();
361
362 // Sending warning email
363 $wEmail = $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'];
364 if ($wEmail) {
365 $subject="Install Tool Login at '".$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']."'";
366 $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').')';
367 mail($wEmail,
368 $subject,
369 $email_body,
370 'From: TYPO3 Install Tool WARNING <>'
371 );
372 }
373 return true;
374 } else {
375 // Bad password, send warning:
376 if ($p) {
377 $wEmail = $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'];
378 if ($wEmail) {
379 $subject="Install Tool Login ATTEMPT at '".$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']."'";
380 $email_body="There has been an Install Tool login attempt at TYPO3 site '".$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']."' (".t3lib_div::getIndpEnv('HTTP_HOST').").
381 The MD5 hash of the last 5 characters of the password tried was '".substr(md5($p), -5)."'
382 REMOTE_ADDR was '".t3lib_div::getIndpEnv('REMOTE_ADDR')."' (".t3lib_div::getIndpEnv('REMOTE_HOST').')';
383 mail($wEmail,
384 $subject,
385 $email_body,
386 'From: TYPO3 Install Tool WARNING <>'
387 );
388 }
389 }
390 return false;
391 }
392 }
393
394 /**
395 * [Describe function...]
396 *
397 * @return [type] ...
398 */
399 function loginForm() {
400 $p = t3lib_div::_GP('password');
401 $redirect_url = $this->redirect_url ? $this->redirect_url : $this->action;
402
403 $this->messageFunc_nl2br=0;
404 $this->silent=0;
405
406 $content = '<form action="index.php" method="post" name="passwordForm">
407 <input type="password" name="password"><br />
408 <input type="hidden" name="redirect_url" value="'.htmlspecialchars($redirect_url).'">
409 <input type="submit" value="Log in"><br />
410 <br />
411
412 '.$this->fw('The Install Tool Password is <i>not</i> the admin password of TYPO3.<br />
413 If you don\'t know the current password, you can set a new one by setting the value of $TYPO3_CONF_VARS[\'BE\'][\'installToolPassword\'] in typo3conf/localconf.php to the md5() hash value of the password you desire.'.
414 ($p ? '<br /><br />The password you just tried has this md5-value: <br /><br />'.md5($p) : '')
415 ).'
416 </form>
417 <script type="text/javascript">
418 <!--
419 document.passwordForm.password.focus();
420 //-->
421 </script>';
422
423 if (!$this->session->isAuthorized() && $this->session->isExpired()) {
424 $this->message('Password', 'Your install tool session has expired', '', 3);
425 }
426 $this->message('Password', 'Enter the Install Tool Password', $content, 0);
427 $this->output($this->outputWrapper($this->printAll()));
428 }
429
430 /**
431 * Calling function that checks system, IM, GD, dirs, database and lets you alter localconf.php
432 * This method is called from init.php to start the install Tool.
433 *
434 * @return void
435 */
436 function init() {
437 if (!defined('PATH_typo3')) exit; // Must be called after inclusion of init.php (or from init.php)
438 if (!$this->passwordOK) exit;
439
440 // Setting stuff...
441 $this->check_mail();
442 $this->setupGeneral();
443 $this->generateConfigForm();
444 if (count($this->messages)) t3lib_div::debug($this->messages);
445
446 if ($this->step) {
447 $this->output($this->outputWrapper($this->stepOutput()));
448 } else {
449 // Menu...
450 switch($this->INSTALL['type']) {
451 case 'images':
452 $this->checkIM=1;
453 $this->checkTheConfig();
454 $this->silent=0;
455 $this->checkTheImageProcessing();
456 break;
457 case 'database':
458 $this->checkTheConfig();
459 $this->silent=0;
460 $this->checkTheDatabase();
461 break;
462 case 'update':
463 $this->checkDatabase();
464 $this->silent=0;
465 $this->updateWizard();
466 break;
467 case 'config':
468 $this->silent=0;
469 $this->checkIM=1;
470 $this->message('About configuration','How to configure TYPO3',$this->generallyAboutConfiguration());
471 $this->checkTheConfig();
472
473 $ext = 'Write config to localconf.php';
474 if ($this->fatalError) {
475 if ($this->config_array['no_database'] || !$this->config_array['mysqlConnect']) {
476 $this->message($ext, 'Database not configured yet!', '
477 You need to specify database username, password and host as one of the first things.
478 Next you\'ll have to select a database to use with TYPO3.
479 Use the form below:
480 ',2);
481 } else {
482 $this->message($ext, 'Fatal error encountered!', '
483 Somewhere above a fatal configuration problem is encountered. Please make sure that you\'ve fixed this error before you submit the configuration. TYPO3 will not run if this problem is not fixed!
484 You should also check all warnings that may appear.
485 ',2);
486 }
487 } elseif ($this->mode=='123') {
488 if (!$this->fatalError) {
489 $this->message($ext, 'Basic configuration completed', '
490 You have no fatal errors in your basic configuration. You may have warnings though. Please pay attention to them! However you may continue and install the database.
491
492 <strong><span style="color:#f00;">Step 2:</span></strong> <a href="'.$this->scriptSelf.'?TYPO3_INSTALL[type]=database'.($this->mode?'&mode='.rawurlencode($this->mode):'').'">Click here to install the database.</a>
493 ',-1,1);
494 }
495 }
496 $this->message($ext, 'Very Important: Changing Image Processing settings', "
497 When you change the settings for Image Processing you <i>must</i> take into account that <u>old images</u> may still be in typo3temp/ folder and prevent new files from being generated! This is especially important to know, if you're trying to set up image processing for the very first time.
498 The problem is solved by <a href=\"".htmlspecialchars($this->setScriptName('typo3temp'))."\">clearing the typo3temp/ folder</a>. Also make sure to clear the cache_pages table.
499 ",1,1);
500 $this->message($ext, 'Very Important: Changing Encryption Key setting', "
501 When you change the setting for the Encryption Key you <i>must</i> take into account that a change to this value might invalidate temporary information, URLs etc.
502 The problem is solved by <a href=\"".htmlspecialchars($this->setScriptName('typo3temp'))."\">clearing the typo3temp/ folder</a>. Also make sure to clear the cache_pages table.
503 ",1,1);
504 $this->message($ext, 'Update localconf.php', "
505 This form updates the localconf.php file with the suggested values you see below. The values are based on the analysis above.
506 You can change the values in case you have alternatives to the suggested defaults.
507 By this final step you will configure TYPO3 for immediate use provided that you have no fatal errors left above."
508 .$this->setupGeneral('get_form'),0,1);
509
510 $this->output($this->outputWrapper($this->printAll()));
511
512 break;
513 case 'extConfig':
514 $this->silent=0;
515
516 $this->generateConfigForm('get_form');
517
518 $content = $this->printAll();
519 $content = '<form action="'.$this->action.'" method="post">'.$content.'<input type="submit" value="Write to localconf.php"><br /><br />
520 '.$this->fw('<strong>NOTICE: </strong>By clicking this button, localconf.php is updated with new values for the parameters listed above!<br />').'
521 </form>';
522 $this->output($this->outputWrapper($content));
523 break;
524 case 'typo3temp':
525 $this->checkTheConfig();
526 $this->silent=0;
527 $this->typo3TempManager();
528 break;
529 case 'cleanup':
530 $this->checkTheConfig();
531 $this->silent=0;
532 $this->cleanupManager();
533 break;
534 case 'phpinfo':
535 $this->silent=0;
536 $this->phpinformation();
537 break;
538 case 'typo3conf_edit':
539 $this->silent=0;
540 $this->typo3conf_edit();
541 break;
542 case 'about':
543 default:
544 $this->silent=0;
545 $this->message('About', 'Warning - very important!', $this->securityRisk().$this->alterPasswordForm(),2);
546
547 $this->message('About', 'Using this script', "
548 Installing TYPO3 has always been a hot topic on the mailing list and forums. Therefore we've developed this tool which will help you through configuration and testing.
549 There are three primary steps for you to take:
550
551 <strong>1: Basic Configuration</strong>
552 In this step your PHP-configuration is checked. If there are any settings that will prevent TYPO3 from running correctly you'll get warnings and errors with a description of the problem.
553 You'll have to enter a database username, password and hostname. Then you can choose to create a new database or select an existing one.
554 Finally the image processing settings are entered and verified and you can choose to let the script update the configuration file, typo3conf/localconf.php with the suggested settings.
555
556 <strong>2: Database Analyser</strong>
557 In this step you can either install a new database or update the database from any previous TYPO3 version.
558 You can also get an overview of extra/missing fields/tables in the database compared to a raw sql-file.
559 The database is also verified agains your 'tables.php' configuration (\$TCA) and you can even see suggestions to entries in \$TCA or new fields in the database.
560
561 <strong>3: Update Wizard</strong>
562 Here you will find update methods taking care of changes to the TYPO3 core which are not backwards compatible.
563 It is recommended to run this wizard after every update to make sure everything will still work flawlessly.
564
565 <strong>4: Image Processing</strong>
566 This step is a visual guide to verify your configuration of the image processing software.
567 You'll be presented to a list of images that should all match in pairs. If some irregularity appears, you'll get a warning. Thus you're able to track an error before you'll discover it on your website.
568
569 <strong>5: All Configuration</strong>
570 This gives you access to any of the configuration options in the TYPO3_CONF_VARS array. Every option is also presented with a comment explaining what it does.
571
572 <strong>6: typo3temp/</strong>
573 Here you can manage the files in typo3temp/ folder in a simple manner. typo3temp/ contains temporary files, which may still be used by the website, but some may not. By searching for files with old access-dates, you can possibly manage to delete unused files rather than files still used. However if you delete a temporary file still in use, it's just regenerated as long as you make sure to clear the cache tables afterwards.
574 ");
575
576 $this->message('About', 'Why is this script stand-alone?', "
577 You would think that this script should rather be a module in the backend and access-controlled to only admin-users from the database. But that's not how it works.
578 The reason is, that this script must not be depending on the success of the configuration of TYPO3 and whether or not there is a working database behind. Therefore the script is invoked from the backend init.php file, which allows access if the constant 'TYPO3_enterInstallScript' has been defined and is not false. That is and should be the case <i>only</i> when calling the script 'typo3/install/index.php' - this script!
579 ");
580
581
582 $headCode='Header legend';
583 $this->message($headCode, 'Notice!', '
584 Indicates that something is important to be aware of.
585 This does <em>not</em> indicate an error.
586 ',1);
587 $this->message($headCode, 'Just information', '
588 This is a simple message with some information about something.
589 ');
590 $this->message($headCode, 'Check was successful', '
591 Indicates that something was checked and returned an expected result.
592 ',-1);
593 $this->message($headCode, 'Warning!', '
594 Indicates that something may very well cause trouble and you should definitely look into it before proceeding.
595 This indicates a <em>potential</em> error.
596 ',2);
597 $this->message($headCode, 'Error!', '
598 Indicates that something is definitely wrong and that TYPO3 will most likely not perform as expected if this problem is not solved.
599 This indicates an actual error.
600 ',3);
601
602 $this->output($this->outputWrapper($this->printAll()));
603 break;
604 }
605 }
606 }
607
608 /**
609 * Controls the step 1-2-3-go process
610 *
611 * @return string the content to output to the screen
612 */
613 function stepOutput() {
614 $this->checkTheConfig();
615 $error_missingConnect='<br />
616 '.$this->fontTag2.'<img src="'.$this->backPath.'gfx/icon_fatalerror.gif" width="18" height="16" class="absmiddle">
617 There is no connection to the database!<br />
618 (Username: <i>' . TYPO3_db_username . '</i>, Host: <i>' . TYPO3_db_host . '</i>, Using Password: YES) . <br />
619 <br />
620 <strong>Go to Step 1</strong> and enter a proper username/password!</span>
621 <br />
622 <br />
623 ';
624 $error_missingDB='<br />
625 '.$this->fontTag2.'<img src="'.$this->backPath.'gfx/icon_fatalerror.gif" width="18" height="16" class="absmiddle">
626 There is no access to the database (<i>'.TYPO3_db.'</i>)!<br />
627 <br />
628 <strong>Go to Step 2</strong> and select an accessible database!</span>
629 <br />
630 <br />
631 ';
632
633 // only get the number of tables if it is not the first step in the 123-installer
634 // (= no DB connection yet)
635 $whichTables = ($this->step != 1 ? $this->getListOfTables() : array());
636 $dbInfo='
637 <table border="0" cellpadding="1" cellspacing="0">
638 <tr>
639 <td valign="top" nowrap="nowrap" colspan="2" align="center">'.$this->fontTag2.'<strong><img src="'.$this->backPath.'gfx/icon_note.gif" hspace="5" width="18" height="16" class="absmiddle">Database summary:</strong></span></td>
640 </tr>
641 <tr>
642 <td valign="top" nowrap="nowrap">'.$this->fontTag1.'Username:</span></td>
643 <td valign="top" nowrap="nowrap"><strong>'.$this->fontTag1.''.TYPO3_db_username.'</span></strong></td>
644 </tr>
645 <tr>
646 <td valign="top" nowrap="nowrap">'.$this->fontTag1.'Host:</span></td>
647 <td valign="top" nowrap="nowrap"><strong>'.$this->fontTag1.''.TYPO3_db_host.'</span></strong></td>
648 </tr>
649 <tr>
650 <td valign="top" nowrap="nowrap">'.$this->fontTag1.'Database:</span></td>
651 <td valign="top" nowrap="nowrap"><strong>'.$this->fontTag1.''.TYPO3_db.'</span></strong></td>
652 </tr>
653 <tr>
654 <td valign="top" nowrap="nowrap">'.$this->fontTag1.'# of tables:</span></td>
655 <td valign="top" nowrap="nowrap"><strong>'.$this->fontTag1.''.(count($whichTables)?'<span style="color:#f00;">'.count($whichTables).'</span>':count($whichTables)).'</span></strong></td>
656 </tr>
657 </table>
658 ';
659 $error_emptyDB='<br />
660 '.$this->fontTag2.'<img src="'.$this->backPath.'gfx/icon_fatalerror.gif" width="18" height="16" class="absmiddle">
661 The database is still empty. There are no tables!<br />
662 <br />
663 <strong>Go to Step 3</strong> and import a database!</span>
664 <br />
665 <br />
666 ';
667
668 switch(strtolower($this->step)) {
669 case 1:
670 $msg='
671 <br />
672 <br />
673 <table border="0">
674 <form action="'.$this->action.'" method="post">
675 <tr>
676 <td valign="top" nowrap="nowrap"><strong>
677 '.$this->fontTag2.'Username:</span></strong>
678 </td>
679 <td> &nbsp;
680 </td>
681 <td valign="top">
682 '.$this->fontTag2.'
683 <input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_username]" value="'.TYPO3_db_username.'"></span><br />
684 </td>
685 </tr>
686 <tr>
687 <td valign="top" nowrap="nowrap"><strong>
688 '.$this->fontTag2.'Password:</span></strong>
689 </td>
690 <td> &nbsp;
691 </td>
692 <td valign="top">
693 '.$this->fontTag2.'
694 <input type="password" name="TYPO3_INSTALL[localconf.php][typo_db_password]" value="'.TYPO3_db_password.'"></span><br />
695 </td>
696 </tr>
697 <tr>
698 <td valign="top" nowrap="nowrap"><strong>
699 '.$this->fontTag2.'Host:</span></strong>
700 </td>
701 <td> &nbsp;
702 </td>
703 <td valign="top">
704 '.$this->fontTag2.'
705 <input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_host]" value="'.(TYPO3_db_host?TYPO3_db_host:'localhost').'"></span><br />
706 </td>
707 </tr>
708 <tr>
709 <td valign="top" nowrap="nowrap"><strong>
710 '.$this->fontTag1.'</span></strong>
711 </td>
712 <td> &nbsp;
713 </td>
714 <td valign="top">
715 '.$this->fontTag1.'<br />
716 <input type="hidden" name="step" value="2">
717 <input type="hidden" name="TYPO3_INSTALL[localconf.php][encryptionKey]" value="' . $this->createEncryptionKey() . '">
718 <input type="hidden" name="TYPO3_INSTALL[localconf.php][compat_version]" value="'.TYPO3_branch.'">
719 <input type="submit" value="Continue"><br /><br /><strong>NOTICE: </strong>By clicking this button, typo3conf/localconf.php is updated with new values for the parameters listed above!</span><br />
720 </td>
721 </tr>
722 </form>
723 </table>
724 <br />
725 <br />';
726 break;
727 case 2:
728 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) {
729 $dbArr = $this->getDatabaseList();
730 $options = '<option value="">[ SELECT DATABASE ]</option>';
731 $dbIncluded = 0;
732 foreach ($dbArr as $dbname) {
733 $options.='<option value="'.htmlspecialchars($dbname).'"'.($dbname==TYPO3_db?' selected="selected"':'').'>'.htmlspecialchars($dbname).'</option>';
734 if ($dbname==TYPO3_db) $dbIncluded=1;
735 }
736 if (!$dbIncluded && TYPO3_db) {
737 $options.='<option value="'.htmlspecialchars(TYPO3_db).'" selected="selected">'.htmlspecialchars(TYPO3_db).' (NO ACCESS!)</option>';
738 }
739 $select='<select name="TYPO3_INSTALL[localconf.php][typo_db]">'.$options.'</select>';
740 $msg='
741 <br />
742 <br />
743 <table border="0">
744 <form action="'.$this->action.'" method="post">
745 <tr>
746 <td valign="top" nowrap="nowrap"><strong>
747 '.$this->fontTag2.'
748 You have two options:<br />
749 <br /><br />
750
751 1: Select an existing <u>EMPTY</u> database:</span></strong>
752 </td>
753 </tr>
754 <tr>
755 <td valign="top">
756 '.$this->fontTag1.'Any existing tables which are used by TYPO3 will be overwritten in Step 3. So make sure this database is empty:<br />'.$select.'</span><br />
757 </td>
758 </tr>
759 <tr>
760 <td valign="top" nowrap="nowrap"><br />
761 <br />
762 <strong>
763 '.$this->fontTag2.'2: Create new database (recommended):</span></strong>
764 </td>
765 </tr>
766 <tr>
767 <td valign="top">
768 '.$this->fontTag1.'Enter the desired name of the database here:<br /><input type="text" name="TYPO3_INSTALL[localconf.php][NEW_DATABASE_NAME]" value=""></span><br />
769 </td>
770 </tr>
771 <tr>
772 <td valign="top"> <br />
773
774 '.$this->fontTag1.'<br />
775 <input type="hidden" name="step" value="3">
776 <input type="submit" value="Continue"><br /><br /><strong>NOTICE: </strong>By clicking this button, typo3conf/localconf.php is updated with new values for the parameters listed above!</span><br />
777 </td>
778 </tr>
779 </form>
780 </table>
781 <br />
782 <br />
783 ';
784 } else {
785 $msg=$error_missingConnect;
786 }
787 break;
788 case 3:
789 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) {
790 if ($GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) {
791 $sFiles = t3lib_div::getFilesInDir(PATH_typo3conf,'sql',1,1);
792
793 // Check if default database scheme "database.sql" already exists, otherwise create it
794 if (!strstr(implode(',',$sFiles).',', '/database.sql,')) {
795 array_unshift($sFiles,'Create default database tables');
796 }
797
798 $opt='';
799 foreach ($sFiles as $f) {
800 if ($f=='Create default database tables') $key='CURRENT_TABLES+STATIC';
801 else $key=htmlspecialchars($f);
802
803 $opt.='<option value="import|'.$key.'">'.htmlspecialchars(basename($f)).'</option>';
804 }
805
806
807 $content='
808 '.$this->fontTag2.'Please select a database dump:</span><br />
809 <input type="hidden" name="TYPO3_INSTALL[database_import_all]" value=1>
810 <input type="hidden" name="step" value="">
811 <input type="hidden" name="goto_step" value="go">
812 <select name="TYPO3_INSTALL[database_type]">'.$opt.'</select><br />';
813
814 $content = $this->getUpdateDbFormWrap('import', $content, 'Import database');
815
816 $msg='
817 <br />
818 '.$dbInfo.'<br />
819 <br />
820 '.$content.'
821
822 ';
823
824 } else {
825 $msg=$error_missingDB;
826 }
827 } else {
828 $msg=$error_missingConnect;
829 }
830 break;
831 case 'go':
832 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) {
833 if ($GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) {
834 if (count($whichTables)) {
835 $msg='
836 <br />
837 '.$this->fontTag2.'
838 '.nl2br($this->messageBasicFinished()).'
839 <br />
840 <hr />
841 <div align="center"><strong><img src="'.$this->backPath.'gfx/icon_warning.gif" hspace="5" width="18" height="16" class="absmiddle">IMPORTANT</strong></div><br />
842 <span class="smalltext">'.nl2br($this->securityRisk()).'
843 <br />
844 <strong>Enter <a href="'.$this->scriptSelf.'">"Normal" mode for the Install Tool</a> to change this!</strong><br />
845
846 </span>
847 </span><br />
848 ';
849 } else {
850 $msg=$error_emptyDB;
851 }
852 } else {
853 $msg=$error_missingDB;
854 }
855 } else {
856 $msg=$error_missingConnect;
857 }
858 break;
859 }
860 return $msg;
861 }
862
863 /**
864 * Calling the functions that checks the system
865 *
866 * @return [type] ...
867 */
868 function checkTheConfig() {
869 // Order important:
870 $this->checkDirs();
871 $this->checkConfiguration();
872 $this->checkExtensions();
873
874 if (TYPO3_OS=='WIN') {
875 $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\\');
876 } else {
877 $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/');
878 }
879
880 asort($paths);
881 if (ini_get('safe_mode')) {
882 $paths=array(ini_get('safe_mode_exec_dir'),'/usr/local/php/bin/');
883 }
884 if ($this->INSTALL['checkIM']['lzw']) {
885 $this->checkIMlzw=1;
886 }
887 if ($this->INSTALL['checkIM']['path']) {
888 $paths[]=trim($this->INSTALL['checkIM']['path']);
889 }
890 if ($this->checkIM) $this->checkImageMagick($paths);
891 $this->checkDatabase();
892 }
893
894 /**
895 * Editing files in typo3conf directory (or elsewhere if enabled)
896 *
897 * @return [type] ...
898 */
899 function typo3conf_edit() {
900 $EDIT_path = PATH_typo3conf; // default:
901 if ($this->allowFileEditOutsite_typo3conf_dir && $this->INSTALL['FILE']['EDIT_path']) {
902 if (t3lib_div::validPathStr($this->INSTALL['FILE']['EDIT_path']) && substr($this->INSTALL['FILE']['EDIT_path'],-1)=='/') {
903 $tmp_path = PATH_site.$this->INSTALL['FILE']['EDIT_path'];
904 if (is_dir($tmp_path)) {
905 $EDIT_path=$tmp_path;
906 } else {debug("'".$tmp_path."' was not dir");}
907 } else {
908 debug('BAD DIR_NAME (must be like t3lib/ or media/script/)');
909 }
910 }
911
912 $headCode = 'Edit files in '.basename($EDIT_path).'/';
913 $this->contentBeforeTable='';
914
915 if ($this->INSTALL['SAVE_FILE']) {
916 $save_to_file = $this->INSTALL['FILE']['name'];
917 if (@is_file($save_to_file)) {
918 $save_to_file_md5 = md5($save_to_file);
919 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')) {
920 $this->INSTALL['typo3conf_files'] = $save_to_file;
921 $save_fileContent = $this->INSTALL['FILE'][$save_to_file_md5];
922
923 if ($this->INSTALL['FILE']['win_to_unix_br']) {
924 $save_fileContent = str_replace(chr(13).chr(10),chr(10),$save_fileContent);
925 }
926
927 $backupFile = $this->getBackupFilename($save_to_file);
928 if ($this->INSTALL['FILE']['backup']) {
929 if (@is_file($backupFile)) { unlink($backupFile); }
930 rename($save_to_file,$backupFile);
931 $this->contentBeforeTable.='Backup written to <strong>'.$backupFile.'</strong><br />';
932 }
933
934 t3lib_div::writeFile($save_to_file,$save_fileContent);
935 $this->contentBeforeTable.='
936 File saved: <strong>'.$save_to_file.'</strong><br />
937 MD5-sum: '.$this->INSTALL['FILE']['prevMD5'].' (prev)<br />
938 MD5-sum: '.md5($save_fileContent).' (new)<br />
939 ';
940 }
941 }
942 }
943
944 // Filelist:
945 $typo3conf_files = t3lib_div::getFilesInDir($EDIT_path,'',1,1);
946 reset($typo3conf_files);
947 $lines=array();
948 $fileFound = 0;
949 while(list($k,$file)=each($typo3conf_files)) {
950 // Delete temp_CACHED files if option is set
951 if ( $this->INSTALL['delTempCached'] && preg_match('|/temp_CACHED_[a-z0-9_]+\.php|', $file)) {
952 unlink($file);
953 continue;
954 }
955 if ($this->INSTALL['typo3conf_files'] && !strcmp($this->INSTALL['typo3conf_files'],$file)) {
956 $wrap=array('<strong><span style="color:navy;">','</span></strong>');
957 $fileFound = 1;
958 } else {$wrap=array();}
959 $lines[]='<tr><td nowrap="nowrap"><a href="'.$this->action.'&TYPO3_INSTALL[typo3conf_files]='.rawurlencode($file).($this->allowFileEditOutsite_typo3conf_dir?'&TYPO3_INSTALL[FILE][EDIT_path]='.rawurlencode($this->INSTALL['FILE']['EDIT_path']):"").'">'.$this->fw($wrap[0].basename($file).$wrap[1].'&nbsp;&nbsp;&nbsp;').'</a></td><td>'.$this->fw(t3lib_div::formatSize(filesize($file))).'</td></tr>';
960 }
961 $fileList='<table border="0" cellpadding="0" cellspacing="0">'.implode('',$lines).'</table>';
962 $fileList.='<br />('.$EDIT_path.')';
963
964 if ($this->allowFileEditOutsite_typo3conf_dir) {
965 $fileList.='<br /><form action="'.$this->action.'" method="post">
966 '.PATH_site.'<input type="text" name="TYPO3_INSTALL[FILE][EDIT_path]" value="'.$this->INSTALL['FILE']['EDIT_path'].'"><input type="submit" name="" value="Set">
967 </form>';
968 }
969
970 // create link for deleting temp_CACHED files
971 $fileList .= '<br /><br /><a href="'.$this->action.'&TYPO3_INSTALL[delTempCached]=1">Delete temp_CACHED* files</a>';
972
973 if ($fileFound && @is_file($this->INSTALL['typo3conf_files'])) {
974
975 $backupFile = $this->getBackupFilename($this->INSTALL['typo3conf_files']);
976 $fileContent = t3lib_div::getUrl($this->INSTALL['typo3conf_files']);
977 $this->contentBeforeTable.= '<div class="editFile"><form action="'.$this->action.'" method="post">'.(substr($this->INSTALL['typo3conf_files'],-1)!='~' && !strstr($this->INSTALL['typo3conf_files'],'_bak') ? '
978 <input type="submit" name="TYPO3_INSTALL[SAVE_FILE]" value="Save file">&nbsp;' : '').'
979 <input type="submit" name="_close" value="Close">
980 <br />File: '.$this->INSTALL['typo3conf_files'].'
981 <br />MD5-sum: '.md5($fileContent).'
982 <br />
983
984 <input type="hidden" name="TYPO3_INSTALL[FILE][name]" value="'.$this->INSTALL['typo3conf_files'].'">
985 '.($this->allowFileEditOutsite_typo3conf_dir?'<input type="hidden" name="TYPO3_INSTALL[FILE][EDIT_path]" value="'.$this->INSTALL['FILE']['EDIT_path'].'">':'').'
986 <input type="hidden" name="TYPO3_INSTALL[FILE][prevMD5]" value="'.md5($fileContent).'">
987 <textarea rows="30" name="TYPO3_INSTALL[FILE]['.md5($this->INSTALL['typo3conf_files']).']" wrap="off"'.$this->formWidthText(48,'width:98%;height:80%','off').' class="fixed-font enable-tab">'.t3lib_div::formatForTextarea($fileContent).'</textarea><br />
988 <input type="checkbox" name="TYPO3_INSTALL[FILE][win_to_unix_br]" id="win_to_unix_br" value="1"'.(TYPO3_OS=='WIN'?'':' checked="checked"').'> <label for="win_to_unix_br">Convert Windows linebreaks (13-10) to Unix (10)</label><br />
989 <input type="checkbox" name="TYPO3_INSTALL[FILE][backup]" id="backup" value="1"'.(@is_file($backupFile) ? ' checked="checked"' : '').'> <label for="backup">Make backup copy (rename to '.basename($backupFile).')</label><br />
990 '.
991 '</form></div>';
992 }
993
994 if ($this->contentBeforeTable) {
995 $this->contentBeforeTable = $this->fw($this->contentBeforeTable);
996 }
997
998 $this->message($headCode,'Files in folder',$fileList);
999
1000 $this->output($this->outputWrapper($this->printAll()));
1001 }
1002
1003 /**
1004 * Outputs system information
1005 *
1006 * @return [type] ...
1007 */
1008 function phpinformation() {
1009 $headCode = 'PHP information';
1010
1011 $sVar = t3lib_div::getIndpEnv('_ARRAY');
1012 $sVar['CONST: PHP_OS']=PHP_OS;
1013 $sVar['CONST: TYPO3_OS']=TYPO3_OS;
1014 $sVar['CONST: PATH_thisScript']=PATH_thisScript;
1015 $sVar['CONST: php_sapi_name()']=PHP_SAPI;
1016 $sVar['OTHER: TYPO3_VERSION']=TYPO3_version;
1017 $sVar['OTHER: PHP_VERSION']=phpversion();
1018 $sVar['imagecreatefromgif()']=function_exists('imagecreatefromgif');
1019 $sVar['imagecreatefrompng()']=function_exists('imagecreatefrompng');
1020 $sVar['imagecreatefromjpeg()']=function_exists('imagecreatefromjpeg');
1021 $sVar['imagegif()']=function_exists('imagegif');
1022 $sVar['imagepng()']=function_exists('imagepng');
1023 $sVar['imagejpeg()']=function_exists('imagejpeg');
1024 $sVar['imagettftext()']=function_exists('imagettftext');
1025 $sVar['OTHER: IMAGE_TYPES']=function_exists('imagetypes') ? imagetypes() : 0;
1026 $sVar['OTHER: memory_limit']=ini_get('memory_limit');
1027
1028 $gE_keys = explode(',','SERVER_PORT,SERVER_SOFTWARE,GATEWAY_INTERFACE,SCRIPT_NAME,PATH_TRANSLATED');
1029 while(list(,$k)=each($gE_keys)) {
1030 $sVar['SERVER: '.$k]=$_SERVER[$k];
1031 }
1032
1033 $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');
1034 while(list(,$k)=each($gE_keys)) {
1035 $sVar['T3CV_GFX: '.$k]=$GLOBALS['TYPO3_CONF_VARS']['GFX'][$k];
1036 }
1037
1038 $debugInfo=array();
1039 $debugInfo[]='### DEBUG SYSTEM INFORMATION - START ###';
1040 reset($sVar);
1041 while(list($kkk,$vvv)=each($sVar)) {
1042 $debugInfo[]=str_pad(substr($kkk,0,20),20).': '.$vvv;
1043 }
1044 $debugInfo[]='### DEBUG SYSTEM INFORMATION - END ###';
1045
1046 $buf=$this->messageFunc_nl2br;
1047 $this->messageFunc_nl2br=0;
1048 $this->message($headCode,'DEBUG information','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!<br />
1049 <form action=""><textarea rows="10" '.$this->formWidthText(80,'width:100%; height:500px;','off').' wrap="off" class="fixed-font">'.t3lib_div::formatForTextarea(implode(chr(10),$debugInfo)).'</textarea></form>');
1050 $this->messageFunc_nl2br=$buf;
1051
1052 $getEnvArray = array();
1053 $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');
1054 while(list(,$k)=each($gE_keys)) {
1055 $getEnvArray[$k] = getenv($k);
1056 }
1057 $this->message($headCode,'t3lib_div::getIndpEnv()',t3lib_div::view_array(t3lib_div::getIndpEnv('_ARRAY')));
1058 $this->message($headCode,'getenv()',t3lib_div::view_array($getEnvArray));
1059 $this->message($headCode,'_ENV',t3lib_div::view_array($_ENV));
1060 $this->message($headCode,'_SERVER',t3lib_div::view_array($_SERVER));
1061 $this->message($headCode,'_COOKIE',t3lib_div::view_array($_COOKIE));
1062 $this->message($headCode,'_GET',t3lib_div::view_array($_GET));
1063
1064 ob_start();
1065 phpinfo();
1066 $contents = explode('<body>',ob_get_contents());
1067 ob_end_clean();
1068 $contents = explode('</body>',$contents[1]);
1069
1070 $this->message($headCode,'phpinfo()','<div class="phpinfo">' . $contents[0] . '</div>');
1071
1072 $this->output($this->outputWrapper($this->printAll()));
1073 }
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087 /*******************************
1088 *
1089 * typo3temp/ manager
1090 *
1091 *******************************/
1092
1093 /**
1094 * Provides a tool for deleting temporary files located in typo3temp/
1095 *
1096 * @return string HTML output
1097 */
1098 function typo3TempManager() {
1099 $headCode = 'typo3temp/ directory';
1100 $this->message($headCode,'What is it?','
1101 TYPO3 uses this directory for temporary files, mainly processed and cached images.
1102 The filenames are very cryptic; They are unique representations of the file properties made by md5-hashing a serialized array with information.
1103 Anyway this directory may contain many thousand files and a lot of them may be of no use anymore.
1104
1105 With this test you can delete the files in this folder. When you do that, you should also clear the cache database tables afterwards.
1106 ');
1107
1108 if (!$this->config_array['dir_typo3temp']) {
1109 $this->message('typo3temp/ directory','typo3temp/ not writable!',"
1110 You must make typo3temp/ write enabled before you can proceed with this test.
1111 ",2);
1112 $this->output($this->outputWrapper($this->printAll()));
1113 return;
1114 }
1115
1116 // Run through files
1117 $fileCounter = 0;
1118 $deleteCounter = 0;
1119 $criteriaMatch = 0;
1120 $tmap=array('day'=>1, 'week'=>7, 'month'=>30);
1121 $tt = $this->INSTALL['typo3temp_delete'];
1122 $subdir = $this->INSTALL['typo3temp_subdir'];
1123 if (strlen($subdir) && !preg_match('/^[[:alnum:]_]+\/$/',$subdir)) die('subdir "'.$subdir.'" was not allowed!');
1124 $action = $this->INSTALL['typo3temp_action'];
1125 $d = @dir($this->typo3temp_path.$subdir);
1126 if (is_object($d)) {
1127 while($entry=$d->read()) {
1128 $theFile = $this->typo3temp_path.$subdir.$entry;
1129 if (@is_file($theFile)) {
1130 $ok = 0;
1131 $fileCounter++;
1132 if ($tt) {
1133 if (t3lib_div::testInt($tt)) {
1134 if (filesize($theFile) > $tt*1024) $ok=1;
1135 } else {
1136 if (fileatime($theFile) < $GLOBALS['EXEC_TIME'] - (intval($tmap[$tt]) * 60 * 60 * 24)) {
1137 $ok = 1;
1138 }
1139 }
1140 } else {
1141 $ok = 1;
1142 }
1143 if ($ok) {
1144 $hashPart=substr(basename($theFile),-14,10);
1145 if (!preg_match('/[^a-f0-9]/',$hashPart) || substr($theFile,-6)==='.cache' || substr($theFile,-4)==='.tbl' || substr(basename($theFile),0,8)==='install_') { // This is a kind of check that the file being deleted has a 10 char hash in it
1146 if ($action && $deleteCounter<$action) {
1147 $deleteCounter++;
1148 unlink($theFile);
1149 } else {
1150 $criteriaMatch++;
1151 }
1152 }
1153 }
1154 }
1155 }
1156 $d->close();
1157 }
1158
1159 // Find sub-dirs:
1160 $subdirRegistry = array(''=>'');
1161 $d = @dir($this->typo3temp_path);
1162 if (is_object($d)) {
1163 while($entry=$d->read()) {
1164 $theFile = $entry;
1165 if (@is_dir($this->typo3temp_path.$theFile) && $theFile!='..' && $theFile!='.') {
1166 $subdirRegistry[$theFile.'/'] = $theFile.'/ (Files: '.count(t3lib_div::getFilesInDir($this->typo3temp_path.$theFile)).')';
1167 }
1168 }
1169 }
1170
1171 $deleteType=array(
1172 '0' => 'All',
1173 'day' => 'Last access more than a day ago',
1174 'week' => 'Last access more than a week ago',
1175 'month' => 'Last access more than a month ago',
1176 '10' => 'Filesize greater than 10KB',
1177 '50' => 'Filesize greater than 50KB',
1178 '100' => 'Filesize greater than 100KB'
1179 );
1180
1181 $actionType=array(
1182 '0' => "Don't delete, just display statistics",
1183 '100' => 'Delete 100',
1184 '500' => 'Delete 500',
1185 '1000' => 'Delete 1000'
1186 );
1187
1188 $content='<select name="TYPO3_INSTALL[typo3temp_delete]">'.$this->getSelectorOptions($deleteType,$tt).'</select>
1189 <br />
1190 Number of files at a time:
1191 <select name="TYPO3_INSTALL[typo3temp_action]">'.$this->getSelectorOptions($actionType).'</select>
1192
1193 From sub-directory:
1194 <select name="TYPO3_INSTALL[typo3temp_subdir]">'.$this->getSelectorOptions($subdirRegistry, $this->INSTALL['typo3temp_subdir']).'</select>
1195 ';
1196
1197 $form = '<form action="'.$this->action.'" method="post">'.$content.'
1198
1199 <input type="submit" value="Execute">
1200 </form>
1201 This tool will delete files only if the last 10 characters before the extension (3 chars+\'.\') are hexadecimal valid ciphers, which are lowercase a-f and 0-9.';
1202
1203 $this->message($headCode,'Statistics','
1204 Number of temporary files: <strong>'.($fileCounter-$deleteCounter)."</strong>
1205 Number matching '".htmlspecialchars($deleteType[$tt])."': <strong>".$criteriaMatch.'</strong>
1206 Number deleted: <strong>'.$deleteCounter.'</strong>
1207 <br />
1208 '.$form,1);
1209
1210 $this->output($this->outputWrapper($this->printAll()));
1211 }
1212
1213 /**
1214 * [Describe function...]
1215 *
1216 * @param [type] $deleteType: ...
1217 * @param [type] $tt: ...
1218 * @return [type] ...
1219 */
1220 function getSelectorOptions($deleteType,$tt='') {
1221 $out='';
1222 if (is_array($deleteType)) {
1223 reset($deleteType);
1224 while(list($v,$l)=each($deleteType)) {
1225 $out.='<option value="'.htmlspecialchars($v).'"'.(!strcmp($v,$tt)?' selected="selected"':'').'>'.htmlspecialchars($l).'</option>';
1226 }
1227 }
1228 return $out;
1229 }
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239 /*******************************
1240 *
1241 * cleanup manager
1242 *
1243 *******************************/
1244
1245 /**
1246 * Provides a tool cleaning up various tables in the database
1247 *
1248 * @return string HTML output
1249 * @author Robert Lemke <rl@robertlemke.de>
1250 * @todo Add more functionality ...
1251 */
1252 function cleanupManager() {
1253 $headCode = 'Clean up database';
1254 $this->message($headCode,'What is it?','
1255 This function will become a general clean up manager for various tables used by TYPO3. By now you can only empty the cache which is used for storing image sizes of all pictures used in TYPO3.
1256
1257 <strong>Clear cached image sizes</strong>
1258 Clears the cache used for memorizing sizes of all images used in your website. This information is cached in order to gain performance and will be stored each time a new image is being displayed in the frontend.
1259
1260 You should <em>Clear All Cache</em> in the backend after clearing this cache.
1261 ');
1262
1263 $tables = $this->getListOfTables();
1264 $action = $this->INSTALL['cleanup_type'];
1265
1266 if (($action == 'cache_imagesizes' || $action == 'all') && isset ($tables['cache_imagesizes'])) {
1267 $GLOBALS['TYPO3_DB']->exec_DELETEquery ('cache_imagesizes','');
1268 }
1269
1270 $cleanupType = array (
1271 'all' => 'Clean up everything',
1272 );
1273
1274 // Get cache_imagesizes info
1275 if (isset ($tables['cache_imagesizes'])) {
1276 $cleanupType['cache_imagesizes'] = 'Clear cached image sizes only';
1277 $cachedImageSizesCounter = intval($GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'cache_imagesizes'));
1278 } else {
1279 $this->message($headCode,'Table cache_imagesizes does not exist!',"
1280 The table cache_imagesizes was not found. Please check your database settings in Basic Configuration and compare your table definition with the Database Analyzer.
1281 ",2);
1282 $cachedImageSizesCounter = 'unknown';
1283 }
1284
1285 $content = '<select name="TYPO3_INSTALL[cleanup_type]">'.$this->getSelectorOptions($cleanupType).'</select> ';
1286 $form = '<form action="'.$this->action.'" method="post">'.$content.'<input type="submit" value="Execute"></form>';
1287 $this->message($headCode,'Statistics','
1288 Number cached image sizes: <strong>'.$cachedImageSizesCounter.'</strong><br />
1289 '.$form,1);
1290
1291 $this->output($this->outputWrapper($this->printAll()));
1292 }
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306 /*******************************
1307 *
1308 * CONFIGURATION FORM
1309 *
1310 ********************************/
1311
1312 /**
1313 * Creating the form for editing the TYPO3_CONF_VARS options.
1314 *
1315 * @param [type] $type: ...
1316 * @return [type] ...
1317 */
1318 function generateConfigForm($type='') {
1319 $default_config_content = t3lib_div::getUrl(PATH_t3lib.'config_default.php');
1320 $commentArr = $this->getDefaultConfigArrayComments($default_config_content);
1321
1322 switch($type) {
1323 case 'get_form':
1324 reset($GLOBALS['TYPO3_CONF_VARS']);
1325 $this->messageFunc_nl2br=0;
1326 while(list($k,$va)=each($GLOBALS['TYPO3_CONF_VARS'])) {
1327 $ext='['.$k.']';
1328 $this->message($ext, '$TYPO3_CONF_VARS[\''.$k.'\']',$commentArr[0][$k],1);
1329
1330 while(list($vk,$value)=each($va)) {
1331 $description = trim($commentArr[1][$k][$vk]);
1332 $isTextarea = preg_match('/^string \(textarea\)/i',$description) ? TRUE : FALSE;
1333 $doNotRender = preg_match('/^string \(exclude\)/i', $description) ? TRUE : FALSE;
1334
1335 if (!is_array($value) && !$doNotRender && ($this->checkForBadString($value) || $isTextarea)) {
1336 $k2 = '['.$vk.']';
1337 $msg = htmlspecialchars($description).'<br /><br /><em>'.$ext.$k2.' = '.htmlspecialchars(t3lib_div::fixed_lgd_cs($value,60)).'</em><br />';
1338
1339 if ($isTextarea) {
1340 $form = '<textarea name="TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']" cols="60" rows="5" wrap="off">'.htmlspecialchars($value).'</textarea>';
1341 } elseif (preg_match('/^boolean/i',$description)) {
1342 $form = '<input type="hidden" name="TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']" value="0">';
1343 $form.= '<input type="checkbox" name="TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']"'.($value?' checked="checked"':'').' value="'.($value&&strcmp($value,'0')?htmlspecialchars($value):1).'">';
1344 } else {
1345 $form = '<input type="text" size="80" name="TYPO3_INSTALL[extConfig][' . $k . '][' . $vk . ']" value="' . htmlspecialchars($value) . '">';
1346 }
1347 $this->message($ext, $k2,$msg.$form);
1348 }
1349 }
1350 }
1351 break;
1352 default:
1353 if (is_array($this->INSTALL['extConfig'])) {
1354 reset($this->INSTALL['extConfig']);
1355 $lines = $this->writeToLocalconf_control();
1356 while(list($k,$va)=each($this->INSTALL['extConfig'])) {
1357 if (is_array($GLOBALS['TYPO3_CONF_VARS'][$k])) {
1358 while(list($vk,$value)=each($va)) {
1359 if (isset($GLOBALS['TYPO3_CONF_VARS'][$k][$vk])) {
1360 $doit=1;
1361 if ($k=='BE' && $vk=='installToolPassword') {
1362 if ($value) {
1363 if (isset($_POST['installToolPassword_check']) && (!t3lib_div::_GP('installToolPassword_check') || strcmp(t3lib_div::_GP('installToolPassword_check'),$value))) {
1364 $doit=0;
1365 t3lib_div::debug('ERROR: The two passwords did not match! The password was not changed.');
1366 }
1367 if (t3lib_div::_GP('installToolPassword_md5')) $value =md5($value);
1368 } else $doit=0;
1369 }
1370
1371 $description = trim($commentArr[1][$k][$vk]);
1372 if (preg_match('/^string \(textarea\)/i', $description)) {
1373 $value = str_replace(chr(13),'',$value); // Force Unix linebreaks in textareas
1374 $value = str_replace(chr(10),"'.chr(10).'",$value); // Preserve linebreaks
1375 }
1376 if (preg_match('/^boolean/i', $description)) {
1377 // When submitting settings in the Install Tool, values that default to "false" or "true" in config_default.php will be sent as "0" resp. "1". Therefore, reset the values to their boolean equivalent.
1378 if ($GLOBALS['TYPO3_CONF_VARS'][$k][$vk] === false && $value === '0') {
1379 $value = false;
1380 } elseif ($GLOBALS['TYPO3_CONF_VARS'][$k][$vk] === true && $value === '1') {
1381 $value = true;
1382 }
1383 }
1384
1385 if ($doit && strcmp($GLOBALS['TYPO3_CONF_VARS'][$k][$vk],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\''.$k.'\'][\''.$vk.'\']', $value);
1386 }
1387 }
1388 }
1389 }
1390 $this->writeToLocalconf_control($lines);
1391 }
1392 break;
1393 }
1394 }
1395
1396 /**
1397 * [Describe function...]
1398 *
1399 * @param [type] $string: ...
1400 * @param [type] $mainArray: ...
1401 * @param [type] $commentArray: ...
1402 * @return [type] ...
1403 */
1404 function getDefaultConfigArrayComments($string,$mainArray=array(),$commentArray=array()) {
1405 $lines = explode(chr(10),$string);
1406 $in=0;
1407 $mainKey='';
1408 while(list(,$lc)=each($lines)) {
1409 $lc = trim($lc);
1410 if ($in) {
1411 if (!strcmp($lc,');')) {
1412 $in=0;
1413 } else {
1414 if (preg_match('/["\']([[:alnum:]_-]*)["\'][[:space:]]*=>(.*)/i',$lc,$reg)) {
1415 preg_match('/,[\t\s]*\/\/(.*)/i',$reg[2],$creg);
1416 $theComment = trim($creg[1]);
1417 if (substr(strtolower(trim($reg[2])),0,5)=='array' && !strcmp($reg[1],strtoupper($reg[1]))) {
1418 $mainKey=trim($reg[1]);
1419 $mainArray[$mainKey]=$theComment;
1420 } elseif ($mainKey) {
1421 $commentArray[$mainKey][$reg[1]]=$theComment;
1422 }
1423 }
1424 }
1425 }
1426 if (!strcmp($lc, '$TYPO3_CONF_VARS = array(')) {
1427 $in=1;
1428 }
1429 }
1430 return array($mainArray,$commentArray);
1431 }
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445 /*******************************
1446 *
1447 * CHECK CONFIGURATION FUNCTIONS
1448 *
1449 *******************************/
1450
1451 /**
1452 * Checking php.ini configuration and set appropriate messages and flags.
1453 *
1454 * @return [type] ...
1455 */
1456 function checkConfiguration() {
1457 $ext='php.ini configuration checked';
1458 $this->message($ext);
1459
1460 // *****************
1461 // Incoming values:
1462 // *****************
1463
1464 // Includepath
1465 $incPaths = t3lib_div::trimExplode(TYPO3_OS=='WIN'?';':':', ini_get('include_path'));
1466 if (!in_array('.',$incPaths)) {
1467 $this->message($ext, 'Current directory (./) is not in include path!',"
1468 <i>include_path=".ini_get('include_path')."</i>
1469 Normally the current path, '.', is included in the include_path of PHP. Although TYPO3 does not rely on this, it is an unusual setting that may introduce problems for some extensions.
1470 ",1);
1471 } else $this->message($ext, 'Current directory in include path',"",-1);
1472
1473 // *****************
1474 // File uploads
1475 // *****************
1476 if (!ini_get('file_uploads')) {
1477 $this->message($ext, 'File uploads not allowed',"
1478 <i>file_uploads=".ini_get('file_uploads')."</i>
1479 TYPO3 uses the ability to upload files from the browser in various cases.
1480 As long as this flag is disabled, you'll not be able to upload files.
1481 But it doesn't end here, because not only are files not accepted by the server - ALL content in the forms are discarded and therefore nothing at all will be editable if you don't set this flag!
1482 However if you cannot enable fileupload for some reason alternatively you change the default form encoding value with \$TYPO3_CONF_VARS[SYS][form_enctype].
1483 ",3);
1484 } else $this->message($ext, 'File uploads allowed',"",-1);
1485
1486 $upload_max_filesize = $this->convertByteSize(ini_get('upload_max_filesize'));
1487 $post_max_size = $this->convertByteSize(ini_get('post_max_size'));
1488 if ($upload_max_filesize<1024*1024*10) {
1489 $this->message($ext, 'Maximum upload filesize too small?',"
1490 <i>upload_max_filesize=".ini_get('upload_max_filesize')."</i>
1491 By default TYPO3 supports uploading, copying and moving files of sizes up to 10MB (You can alter the TYPO3 defaults by the config option TYPO3_CONF_VARS[BE][maxFileSize]).
1492 Your current value is below this, so at this point, PHP sets the limits for uploaded filesizes and not TYPO3.
1493 <strong>Notice:</strong> The limits for filesizes attached to database records are set in the tables.php configuration files (\$TCA) for each group/file field. You may override these values in localconf.php or by page TSconfig settings.
1494 ",1);
1495 }
1496 if ($upload_max_filesize > $post_max_size) {
1497 $this->message($ext, 'Maximum size for POST requests is smaller than max. upload filesize','
1498 <i>upload_max_filesize='.ini_get('upload_max_filesize').', post_max_size='.ini_get('post_max_size').'</i>
1499 You have defined a maximum size for file uploads which exceeds the allowed size for POST requests. Therefore the file uploads can not be larger than '.ini_get('post_max_size').'
1500 ',1);
1501 }
1502
1503 // *****************
1504 // Memory and functions
1505 // *****************
1506 $memory_limit_value = $this->convertByteSize(ini_get('memory_limit'));
1507 if ($memory_limit_value && $memory_limit_value < 16*1024*1024) {
1508 $this->message($ext, 'Memory limit below 16 MB',"
1509 <i>memory_limit=".ini_get('memory_limit')."</i>
1510 Your system is configured to enforce a memory limit of PHP scripts lower than 16 MB. The Extension Manager needs to include more PHP-classes than will fit into this memory space. There is nothing else to do than raise the limit. To be safe, ask the system administrator of the webserver to raise the limit to over 25 MB.
1511 ",3);
1512 } elseif(!$memory_limit_value) {
1513 $this->message($ext, 'Memory limit',"<i>No memory limit in effect.</i>",-1);
1514 } else $this->message($ext, 'Memory limit',"<i>memory_limit=".ini_get('memory_limit')."</i>",-1);
1515 if (ini_get('max_execution_time')<30) {
1516 $this->message($ext, 'Maximum execution time below 30 seconds',"
1517 <i>max_execution_time=".ini_get('max_execution_time')."</i>
1518 May impose problems if too low.
1519 ",1);
1520 } else {
1521 $this->message($ext, 'Maximum execution time',"<i>max_execution_time=".ini_get('max_execution_time')."</i>",-1);
1522 }
1523 if (ini_get('disable_functions')) {
1524 $this->message($ext, 'Functions disabled!',"
1525 <i>disable_functions=".ini_get('disable_functions')."</i>
1526 The above list of functions are disabled. If TYPO3 use any of these there might be trouble.
1527 TYPO3 is designed to use the default set of PHP4.3.0+ functions plus the functions of GDLib.
1528 Possibly these functions are disabled due to security risks and most likely the list would include a function like <i>exec()</i> which is use by TYPO3 to access ImageMagick.
1529 ",2);
1530 } else {
1531 $this->message($ext, 'Functions disabled: none',"",-1);
1532 }
1533 // Mail tests
1534 if (TYPO3_OS == 'WIN') {
1535 $smtp = ini_get('SMTP');
1536 $bad_smtp = false;
1537 if (!t3lib_div::validIP($smtp)) {
1538 $smtp_addr = @gethostbyname($smtp);
1539 $bad_smtp = ($smtp_addr == $smtp);
1540 }
1541 else {
1542 $smtp_addr = $smtp;
1543 }
1544 if (!$smtp || $bad_smtp || !t3lib_div::testInt(ini_get('smtp_port'))) {
1545 $this->message($ext, 'Mail configuration is not set correctly','
1546 Mail configuration is not set
1547 PHP mail() function requires SMTP and smtp_port to have correct values on Windows.',
1548 2);
1549 } else {
1550 if (($smtp_addr == '127.0.0.1' || $smtp_addr == '::1') && ($_SERVER['SERVER_ADDR'] == '127.0.0.1' || $_SERVER['SERVER_ADDR'] == '::1')) {
1551 $this->message($ext, 'Mail is configured (potential problem exists!)',
1552 '<i>SMTP=' . $smtp . '</i> - <b>Note:</b> this server! Are you sure it runs SMTP server?
1553 <i>smtp_port=' . ini_get('smtp_port') . '</i>
1554 '.$this->check_mail('get_form'), 1);
1555 } else {
1556 $this->message($ext, 'Mail is configured',
1557 '<i>SMTP=' . $smtp . '</i>
1558 <i>smtp_port=' . ini_get('smtp_port') . '</i>
1559 '.$this->check_mail('get_form'), -1);
1560 }
1561 }
1562 } elseif (!ini_get('sendmail_path')) {
1563 $this->message($ext, 'Sendmail path not defined!','
1564 This may be critical to TYPO3\'s use of the mail() function. Please be sure that the mail() function in your php-installation works!
1565 ' . $this->check_mail('get_form'),1);
1566 } else {
1567 list($prg) = explode(' ', ini_get('sendmail_path'));
1568 if (!@is_executable($prg)) {
1569 $this->message($ext, 'Sendmail program not found or not executable?','
1570 <i>sendmail_path=' . ini_get('sendmail_path') . '</i>
1571 This may be critical to TYPO3\'s use of the mail() function. Please be sure that the mail() function in your php-installation works!
1572 '.$this->check_mail('get_form'), 1);
1573 } else {
1574 $this->message($ext, 'Sendmail OK','
1575 <i>sendmail_path=' . ini_get('sendmail_path') . '</i>
1576 '.$this->check_mail('get_form'),-1);
1577 }
1578 }
1579
1580 // *****************
1581 // Safe mode related
1582 // *****************
1583 if (ini_get('safe_mode')) {
1584 $this->message($ext, 'Safe mode turned on',"
1585 <i>safe_mode=".ini_get('safe_mode')."</i>
1586 In safe_mode PHP is restricted in several ways. This is a good thing because it adds protection to your (and others) scripts. But it may also introduce problems. In TYPO3 this <em>may be</em> a problem in two areas: File administration and execution of external programs, in particular ImageMagick.
1587 If you just ignore this warning, you'll most likely find, that TYPO3 seems to work except from the image-generation. The problem in that case is that the external ImageMagick programs are not allowed to be executed from the regular paths like \"/usr/bin/\" or \"/usr/X11R6/bin/\".
1588 If you use safe_mode with TYPO3, you should disable use of external programs ([BE][disable_exec_function]=1).
1589 In safe mode you must ensure that all the php-scripts and upload folders are owned by the same user.
1590
1591 <i>safe_mode_exec_dir=".ini_get('safe_mode_exec_dir')."</i>
1592 If the ImageMagick utilities are located in this directory, everything is fine. Below on this page, you can see if ImageMagick is found here. If not, ask you ISP to put the three ImageMagick programs, 'convert', 'combine'/'composite' and 'identify' there (eg. with symlinks if Unix server)
1593
1594
1595 <strong>Example of safe_mode settings:</strong>
1596 Set this in the php.ini file:
1597
1598 ; Safe Mode
1599 safe_mode = On
1600 safe_mode_exec_dir = /usr/bin/
1601
1602 ...and the ImageMagick '/usr/bin/convert' will be executable.
1603 The last slash is important (..../) and you can only specify one directory.
1604
1605 <strong>Notice: </strong>
1606 ImageMagick 4.2.9 is recommended and the binaries are normally installed by RPM in /usr/X11R6/bin or by compiling in /usr/local/bin. Please look in the \"Inside TYPO3\" pdf-document for extensive information about ImageMagick issues.
1607 Paths to ImageMagick are defined in localconf.php and may be something else than /usr/bin/, but this is default for ImageMagick 5+
1608
1609
1610 ",2);
1611 if (ini_get('doc_root')) {
1612 $this->message($ext, 'doc_root set',"
1613 <i>doc_root=".ini_get('doc_root')."</i>
1614 PHP cannot execute scripts outside this directory. If that is a problem is please correct it.
1615 ",1);
1616 }
1617 $this->config_array['safemode']=1;
1618 } else $this->message($ext, 'safe_mode: off',"",-1);
1619 if (ini_get('sql.safe_mode')) {
1620 $this->message($ext, 'sql.safe_mode is enabled',"
1621 <i>sql.safe_mode=".ini_get('sql.safe_mode').'</i>
1622 This means that you can only connect to the database with a username corresponding to the user of the webserver process or fileowner. Consult your ISP for information about this. Also see '.$this->linkIt('http://www.wrox.com/Consumer/Store/Books/2963/29632002.htm').'
1623 The owner of the current file is: <strong>'.get_current_user ()."</strong>
1624 ",1);
1625 $this->config_array['sql.safe_mode_user'] = get_current_user();
1626 } else $this->message($ext, 'sql.safe_mode: off',"",-1);
1627 if (ini_get('open_basedir')) {
1628 $this->message($ext, 'open_basedir set',"
1629 <i>open_basedir=".ini_get('open_basedir')."</i>
1630 This restricts TYPO3 to open and include files only in this path. Please make sure that this does not prevent TYPO3 from running.
1631 <strong>Notice (UNIX):</strong> Before checking a path according to open_basedir, PHP resolves all symbolic links.
1632 ",1);
1633 // ???? If this option was set falsely you probably didn't see this page in the first place, but this option <strong>may spoil this configuration test</strong> when checking for such as ImageMagick executables.
1634 } else $this->message($ext, 'open_basedir: off',"",-1);
1635
1636 // Check availability of PHP session support
1637 if (extension_loaded('session')) {
1638 $this->message($ext, 'PHP sessions availiable','
1639 <i>PHP Sessions availiabe</i>
1640 PHP is compiled with session support and session support is available.
1641 ',-1);
1642 } else {
1643 $this->message($ext, 'PHP Sessions not availiabe','
1644 PHP is not compiled with session support, or session support is disabled in php.ini.
1645 TYPO3 needs session support
1646 ',3);
1647 }
1648 }
1649
1650 /**
1651 * Check if PHP function mail() works
1652 *
1653 * @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.
1654 * @return [type] ...
1655 */
1656 function check_mail($cmd='') {
1657 switch($cmd) {
1658 case 'get_form':
1659 $out='
1660 You can check the mail() function by entering your email address here and press the button. You should then receive a testmail from test@test.test.<br /> Since almost all mails in TYPO3 are sent using the t3lib_htmlmail class, sending with this class can be tested by checking the box <strong>Test t3lib_htmlmail</strong> below. The return-path of the mail is set to null@'.t3lib_div::getIndpEnv('HTTP_HOST').'. Some mail servers won\'t send the mail if the host of the return-path is not resolved correctly.
1661 <form action="'.$this->action.'" method="post"><input type="text" name="TYPO3_INSTALL[check_mail]"><br /><input type="checkbox" name="TYPO3_INSTALL[use_htmlmail]" id="use_htmlmail" ><label for="use_htmlmail">Test t3lib_htmlmail.</label>
1662 <input type="submit" value="Send test mail"></form>';
1663 break;
1664 default:
1665 if (trim($this->INSTALL['check_mail'])) {
1666 $subject = 'TEST SUBJECT';
1667 $email = trim($this->INSTALL['check_mail']);
1668
1669 if($this->INSTALL['use_htmlmail']) {
1670 $emailObj = t3lib_div::makeInstance('t3lib_htmlmail');
1671 /* @var $emailObj t3lib_htmlmail */
1672 $emailObj->start();
1673 $emailObj->subject = $subject;
1674 $emailObj->from_email = 'test@test.test';
1675 $emailObj->from_name = 'TYPO3 Install Tool';
1676 $emailObj->returnPath = 'null@'.t3lib_div::getIndpEnv('HTTP_HOST');
1677 $emailObj->addPlain('TEST CONTENT');
1678 $emailObj->setHTML($emailObj->encodeMsg('<html><body>HTML TEST CONTENT</body></html>'));
1679 $emailObj->send($email);
1680 } else {
1681 t3lib_div::plainMailEncoded($email,$subject,'TEST CONTENT','From: test@test.test');
1682 }
1683 $this->messages[]= 'MAIL WAS SENT TO: '.$email;
1684 }
1685 break;
1686 }
1687 return $out;
1688 }
1689
1690 /**
1691 * Checking php extensions, specifically GDLib and Freetype
1692 *
1693 * @return [type] ...
1694 */
1695 function checkExtensions() {
1696 $ext = 'GDLib';
1697 $this->message($ext);
1698
1699 $software_info=1;
1700 if (extension_loaded('gd') && $this->isGD()) {
1701 $this->config_array['gd']=1;
1702 $this->message($ext, 'GDLib found',"",-1);
1703 if ($this->isPNG()) {
1704 $this->config_array['gd_png']=1;
1705 $this->message($ext, 'PNG supported',"",-1);
1706 }
1707 if ($this->isGIF()) {
1708 $this->config_array['gd_gif']=1;
1709 $this->message($ext, 'GIF supported',"",-1);
1710 }
1711 if ($this->isJPG()) {
1712 $this->config_array['gd_jpg']=1;
1713 $this->message($ext, 'JPG supported (not used by TYPO3)','');
1714 }
1715 if (!$this->config_array['gd_gif'] && !$this->config_array['gd_png']) {
1716 $this->message($ext, 'PNG or GIF not supported', nl2br(trim('
1717 Your GDLib supports either GIF nor PNG. It must support either one of them.
1718 ')), 2);
1719 } else {
1720 $msg=array();
1721 if ($this->config_array['gd_gif'] && $this->config_array['gd_png']) {
1722 $msg[0]='You can choose between generating GIF or PNG files, as your GDLib supports both.';
1723 }
1724 if ($this->config_array['gd_gif']) {
1725 $msg[10]="You should watch out for the generated size of the GIF-files because some versions of the GD library do not compress them with LZW, but RLE and ImageMagick is subsequently used to compress with LZW. But in the case of ImageMagick failing this task (eg. not being compiled with LZW which is the case with some versions) you'll end up with GIF-filesizes all too big!
1726 This install tool tests what kinds of GIF compression are available in the ImageMagick installations by a physical test. You can also check it manually by opening a TYPO3 generated gif-file with Photoshop and save it in a new file. If the file sizes of the original and the new file are almost the same, you're having LZW compression and everything is fine.";
1727 }
1728 if ($this->config_array['gd_png']) {
1729 $msg[20]='TYPO3 prefers the use of GIF-files and most likely your visitors on your website does too as not all browsers support PNG yet.';
1730 }
1731 $this->message($ext, 'GIF / PNG issues', nl2br(trim(implode($msg,chr(10)))), 1);
1732 }
1733 if (!$this->isTTF()) {
1734 $this->message($ext, 'FreeType is apparently not installed', "
1735 It looks like the FreeType library is not compiled into GDLib. This is required when TYPO3 uses GDLib and you'll most likely get errors like 'ImageTTFBBox is not a function' or 'ImageTTFText is not a function'.
1736 ", 2);
1737 } else {
1738 $this->message($ext, 'FreeType quick-test ('.($this->isGIF()?'as GIF':'as PNG').')', '<img src="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI').'&testingTrueTypeSupport=1').'" alt=""><br />(If the text is exceeding the image borders you are using Freetype 2 and need to set TYPO3_CONF_VARS[GFX][TTFdpi]=96.<br />If there is no image at all Freetype is most likely NOT available and you can just as well disable GDlib for TYPO3...)', -1);
1739 $this->config_array['freetype']=1;
1740 }
1741 } else {
1742 $this->message($ext, 'GDLib not found', "
1743 GDLib is required if you want to use the GIFBUILDER object in TypoScript. GIFBUILDER is in charge of all advanced image generation in TypoScript, including graphical menuitems.
1744 GDLib is also used in the TYPO3 Backend (TBE) to generate record icons and new module tabs.
1745 It's highly recommended to install this library. Remember to compile GD with FreeType which is also required.
1746 If you choose not to install GDLib, you can disable it in the configuration with [GFX][gdlib]=0;.
1747 ", 2);
1748 }
1749 $this->message($ext, 'GDLib software information', nl2br(trim($this->getGDSoftwareInfo())));
1750 }
1751
1752 /**
1753 * Checking and testing that the required writable directories are writable.
1754 *
1755 * @return [type] ...
1756 */
1757 function checkDirs() {
1758 // Check typo3/temp/
1759 $ext='Directories';
1760 $this->message($ext);
1761
1762 $uniqueName = md5(uniqid(microtime()));
1763
1764 // The requirement level (the integer value, ie. the second value of the value array) has the following meanings:
1765 // -1 = not required, but if it exists may be writable or not
1766 // 0 = not required, if it exists the dir should be writable
1767 // 1 = required, don't has to be writable
1768 // 2 = required, has to be writable
1769
1770 $checkWrite=array(
1771 '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'),
1772 'typo3temp/pics/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'),
1773 'typo3temp/temp/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'),
1774 'typo3temp/llxml/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'),
1775 'typo3temp/cs/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'),
1776 'typo3temp/GB/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'),
1777 'typo3temp/locks/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'),
1778 '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),
1779 'typo3conf/ext/' => array('Location for local extensions. Must be writable if the Extension Manager is supposed to install extensions for this website.',0),
1780 'typo3conf/l10n/' => array('Location for translations. Must be writable if the Extension Manager is supposed to install translations for extensions.',0),
1781 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),
1782 'uploads/' => array('Location for uploaded files from RTE, in the subdirectories for uploaded files of content elements.',2),
1783 'uploads/pics/' => array('Typical location for uploaded files (images especially).',0),
1784 'uploads/media/' => array('Typical location for uploaded files (non-images especially).',0),
1785 'uploads/tf/' => array('Typical location for uploaded files (TS template resources).',0),
1786 'fileadmin/' => array('Location for local files such as templates, independent uploads etc.',-1),
1787 'fileadmin/_temp_/' => array('Typical temporary location for default upload of files by administrators.',0),
1788 );
1789
1790 foreach ($checkWrite as $relpath => $descr) {
1791
1792 // Check typo3temp/
1793 $general_message = $descr[0];
1794
1795 if (!@is_dir(PATH_site.$relpath)) { // If the directory is missing, try to create it
1796 t3lib_div::mkdir(PATH_site.$relpath);
1797 }
1798
1799 if (!@is_dir(PATH_site.$relpath)) {
1800 if ($descr[1]) { // required...
1801 $this->message($ext, $relpath.' directory does not exist and could not be created','
1802 <em>Full path: '.PATH_site.$relpath.'</em>
1803 '.$general_message.'
1804
1805 This error should not occur as '.$relpath.' must always be accessible in the root of a TYPO3 website.
1806 ',3);
1807 } else {
1808 if ($descr[1] == 0) {
1809 $msg = 'This directory does not necessarily have to exist but if it does it must be writable.';
1810 } else {
1811 $msg = 'This directory does not necessarily have to exist and if it does it can be writable or not.';
1812 }
1813 $this->message($ext, $relpath.' directory does not exist','
1814 <em>Full path: '.PATH_site.$relpath.'</em>
1815 '.$general_message.'
1816
1817 '.$msg.'
1818 ',2);
1819 }
1820 } else {
1821 $file = PATH_site.$relpath.$uniqueName;
1822 @touch($file);
1823 if (@is_file($file)) {
1824 unlink($file);
1825 if ($descr[2]) { $this->config_array[$descr[2]]=1; }
1826 $this->message($ext, $relpath.' writable','',-1);
1827 } else {
1828 $severity = ($descr[1]==2 || $descr[1]==0) ? 3 : 2;
1829 if ($descr[1] == 0 || $descr[1] == 2) {
1830 $msg = 'The directory '.$relpath.' must be writable!';
1831 } elseif ($descr[1] == -1 || $descr[1] == 1) {
1832 $msg = 'The directory '.$relpath.' does not neccesarily have to be writable.';
1833 }
1834 $this->message($ext, $relpath.' directory not writable','
1835 <em>Full path: '.$file.'</em>
1836 '.$general_message.'
1837
1838 Tried to write this file (with touch()) but didn\'t succeed.
1839 '.$msg.'
1840 ',$severity);
1841 }
1842 }
1843 }
1844 }
1845
1846 /**
1847 * Checking for existing ImageMagick installs.
1848 *
1849 * 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.
1850 *
1851 * @param [type] $paths: ...
1852 * @return [type] ...
1853 */
1854 function checkImageMagick($paths) {
1855 $ext='Check Image Magick';
1856 $this->message($ext);
1857
1858 $paths = array_unique($paths);
1859
1860 $programs = explode(',','gm,convert,combine,composite,identify');
1861 $isExt = TYPO3_OS=="WIN" ? ".exe" : "";
1862 $this->config_array['im_combine_filename']='combine';
1863 reset($paths);
1864 while(list($k,$v)=each($paths)) {
1865 reset($programs);
1866 if (!preg_match('/[\\/]$/',$v)) $v.='/';
1867 while(list(,$filename)=each($programs)) {
1868 if (ini_get('open_basedir') || (file_exists($v)&&@is_file($v.$filename.$isExt))) {
1869 $version = $this->_checkImageMagick_getVersion($filename,$v);
1870 if($version > 0) {
1871 if($filename=='gm') { // Assume GraphicsMagick
1872 $index[$v]['gm']=$version;
1873 continue; // No need to check for "identify" etc.
1874 } else { // Assume ImageMagick
1875 $index[$v][$filename]=$version;
1876 }
1877 }
1878 }
1879 }
1880 if (count($index[$v])>=3 || $index[$v]['gm']) { $this->config_array['im']=1; }
1881
1882 if ($index[$v]['gm'] || (!$index[$v]['composite'] && $index[$v]['combine'])) {
1883 $this->config_array['im_combine_filename']='combine';
1884 } elseif ($index[$v]['composite'] && !$index[$v]['combine']) {
1885 $this->config_array['im_combine_filename']='composite';
1886 }
1887
1888 if (isset($index[$v]['convert']) && $this->checkIMlzw) {
1889 $index[$v]['gif_capability'] = ''.$this->_checkImageMagickGifCapability($v);
1890 }
1891 }
1892 $this->config_array['im_versions']=$index;
1893 if (!$this->config_array['im']) {
1894 $this->message($ext, 'No ImageMagick installation available',"
1895 It seems that there is no adequate ImageMagick installation available at the checked locations (".implode($paths, ', ').")
1896 An 'adequate' installation for requires 'convert', 'combine'/'composite' and 'identify' to be available
1897 ",2);
1898 } else {
1899 $theCode='';
1900 reset($this->config_array['im_versions']);
1901 while(list($p,$v)=each($this->config_array['im_versions'])) {
1902 $ka=array();
1903 reset($v);
1904 while(list($ka[])=each($v)){}
1905 $theCode.='<tr><td>'.$this->fw($p).'</td><td>'.$this->fw(implode($ka,'<br />')).'</td><td>'.$this->fw(implode($v,'<br />')).'</td></tr>';
1906 }
1907 $this->message($ext, 'Available ImageMagick/GraphicsMagick installations:','<table border="1" cellpadding="2" cellspacing="2">'.$theCode.'</table>',-1);
1908 }
1909 $this->message($ext, 'Search for ImageMagick:','
1910 <form action="'.$this->action.'" method="post">
1911 <input type="checkbox" name="TYPO3_INSTALL[checkIM][lzw]" id="checkImLzw" value="1"'.($this->INSTALL['checkIM']['lzw']?' checked="checked"':'').'> <label for="checkImLzw">Check LZW capabilities.</label>
1912
1913 Check this path for ImageMagick installation:
1914 <input type="text" name="TYPO3_INSTALL[checkIM][path]" value="'.htmlspecialchars($this->INSTALL['checkIM']['path']).'">
1915 (Eg. "D:\wwwroot\im537\ImageMagick\" for Windows or "/usr/bin/" for Unix)<br />
1916
1917 <input type="submit" value="Send">
1918 </form>
1919 ',0);
1920
1921 }
1922
1923 /**
1924 * Checking GIF-compression capabilities of ImageMagick install
1925 *
1926 * @param [type] $file: ...
1927 * @return [type] ...
1928 */
1929 function _checkImageMagickGifCapability($path) {
1930 if ($this->config_array['dir_typo3temp']) { // && !$this->config_array['safemode']
1931 $tempPath = $this->typo3temp_path;
1932 $uniqueName = md5(uniqid(microtime()));
1933 $dest = $tempPath.$uniqueName.'.gif';
1934 $src = $this->backPath.'gfx/typo3logo.gif';
1935 if (@is_file($src) && !strstr($src,' ') && !strstr($dest,' ')) {
1936 $cmd = t3lib_div::imageMagickCommand('convert', $src.' '.$dest, $path);
1937 exec($cmd);
1938 } else die('No typo3/gfx/typo3logo.gif file!');
1939 $out='';
1940 if (@is_file($dest)) {
1941 $new_info = @getimagesize($dest);
1942 clearstatcache();
1943 $new_size = filesize($dest);
1944 $src_info = @getimagesize($src);
1945 clearstatcache();
1946 $src_size = @filesize($src);
1947
1948 if ($new_info[0]!=$src_info[0] || $new_info[1]!=$src_info[1] || !$new_size || !$src_size) {
1949 $out='error';
1950 } else {
1951 if ($new_size/$src_size > 4) { // NONE-LZW ratio was 5.5 in test
1952 $out='NONE';
1953 } elseif ($new_size/$src_size > 1.5) { // NONE-RLE ratio was not tested
1954 $out='RLE';
1955 } else {
1956 $out='LZW';
1957 }
1958 }
1959 unlink($dest);
1960 }
1961 return $out;
1962 }
1963 }
1964
1965 /**
1966 * Extracts the version number for ImageMagick
1967 *
1968 * @param string The program name to execute in order to find out the version number
1969 * @param string Path for the above program
1970 * @return string Version number of the found ImageMagick instance
1971 */
1972 function _checkImageMagick_getVersion($file, $path) {
1973 // Temporarily override some settings
1974 $im_version = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'];
1975 $combine_filename = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_combine_filename'];
1976
1977 if ($file=='gm') {
1978 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] = 'gm';
1979 $file = 'identify'; // Work-around, preventing execution of "gm gm"
1980 $parameters = '-version'; // Work-around - GM doesn't like to be executed without any arguments
1981 } else {
1982 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] = 'im5';
1983
1984 if($file=='combine' || $file=='composite') { // Override the combine_filename setting
1985 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_combine_filename'] = $file;
1986 }
1987 }
1988
1989 $cmd = t3lib_div::imageMagickCommand($file, $parameters, $path);
1990 $retVal = false;
1991 exec($cmd, $retVal);
1992 $string = $retVal[0];
1993 list(,$ver) = explode('Magick', $string);
1994 list($ver) = explode(' ',trim($ver));
1995
1996 // Restore the values
1997 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] = $im_version;
1998 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_combine_filename'] = $combine_filename;
1999 return trim($ver);
2000 }
2001
2002 /**
2003 * Checks database username/password/host/database
2004 *
2005 * @return [type] ...
2006 */
2007 function checkDatabase() {
2008 $ext='Check database';
2009 $this->message($ext);
2010
2011 if (!extension_loaded('mysql') && !t3lib_extMgm::isLoaded('dbal')) {
2012 $this->message($ext, 'MySQL not available',"
2013 PHP does not feature MySQL support (which is pretty unusual).
2014 ",2);
2015 } else {
2016 $cInfo='
2017 Username: <strong>'.TYPO3_db_username.'</strong>
2018 Host: <strong>'.TYPO3_db_host.'</strong>
2019 ';
2020 if (!TYPO3_db_host || !TYPO3_db_username) {
2021 $this->message($ext, 'Username, password or host not set',"
2022 You may need to enter data for these values:
2023 ".trim($cInfo)."
2024
2025 Use the form below.
2026 ",2);
2027 }
2028 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) {
2029 $this->message($ext, 'Connected to SQL database successfully',"
2030 ".trim($cInfo)."
2031 ",-1,1);
2032 $this->config_array['mysqlConnect']=1;
2033 if (!TYPO3_db) {
2034 $this->message($ext, 'No database selected',"
2035 Currently you have no database selected.
2036 Please select one or create a new database.
2037 ",3);
2038 $this->config_array['no_database']=1;
2039 } elseif (!$GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) {
2040 $this->message($ext, 'Database',"
2041 '".TYPO3_db."' could not be selected as database!
2042 Please select another one or create a new database.
2043 ",3,1);
2044 $this->config_array['no_database']=1;
2045 } else {
2046 $this->message($ext, 'Database',"
2047 <strong>".TYPO3_db."</strong> is selected as database.
2048 ",1,1);
2049 }
2050 } else {
2051 $this->message($ext, 'Could not connect to SQL database!',"
2052 Connecting to SQL database failed with these settings:
2053 ".trim($cInfo)."
2054
2055 Make sure you're using the correct set of data.".($this->config_array['sql.safe_mode_user']? "
2056 <strong>Notice:</strong> <em>sql.safe_mode</em> is turned on, so apparently your username to the database is the same as the scriptowner, which is '".$this->config_array['sql.safe_mode_user']."'":"")."
2057 ",3);
2058 }
2059 }
2060 }
2061
2062 /**
2063 * Prints form for updating localconf.php or updates localconf.php depending on $cmd
2064 *
2065 * @param string $cmd If "get_form" it outputs the form. Default is to write "localconf.php" based on input in ->INSTALL[localconf.php] array and flag ->setLocalconf
2066 * @return [type] ...
2067 */
2068 function setupGeneral($cmd='') {
2069 switch($cmd) {
2070 case 'get_form':
2071 // Database:
2072 $out='
2073 <form name="setupGeneral" action="'.$this->action.'" method="post">
2074 <table border="0" cellpadding="0" cellspacing="0">';
2075
2076 $out.=$this->wrapInCells('Username:', '<input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_username]" value="'.htmlspecialchars(TYPO3_db_username?TYPO3_db_username:($this->config_array['sql.safe_mode_user']?$this->config_array['sql.safe_mode_user']:"")).'">'.($this->config_array['sql.safe_mode_user']?"<br />sql.safe_mode_user: <strong>".$this->config_array['sql.safe_mode_user']."</strong>":""));
2077 $out.=$this->wrapInCells('Password:', '<input type="password" name="TYPO3_INSTALL[localconf.php][typo_db_password]" value="'.htmlspecialchars(TYPO3_db_password).'">');
2078 $out.=$this->wrapInCells('Host:', '<input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_host]" value="'.htmlspecialchars(TYPO3_db_host).'">');
2079 if ($this->config_array['mysqlConnect']) {
2080 $dbArr = $this->getDatabaseList();
2081 reset($dbArr);
2082 $options='';
2083 $dbIncluded=0;
2084 while(list(,$dbname)=each($dbArr)) {
2085 $options.='<option value="'.htmlspecialchars($dbname).'"'.($dbname==TYPO3_db?' selected="selected"':'').'>'.htmlspecialchars($dbname).'</option>';
2086 if ($dbname==TYPO3_db) $dbIncluded=1;
2087 }
2088 if (!$dbIncluded && TYPO3_db) {
2089 $options.='<option value="'.htmlspecialchars(TYPO3_db).'" selected="selected">'.htmlspecialchars(TYPO3_db).' (NO ACCESS!)</option>';
2090 }
2091 $theCode='<select name="TYPO3_INSTALL[localconf.php][typo_db]">'.$options.'</select><br />Create database? (Enter name):<br /><input type="text" name="TYPO3_INSTALL[localconf.php][NEW_DATABASE_NAME]" value="">';
2092 } else {
2093 $theCode='<strong>'.htmlspecialchars(TYPO3_db).'</strong><br />(Can only select database if username/password/host is correctly set first)<input type="hidden" name="TYPO3_INSTALL[localconf.php][typo_db]" value="'.htmlspecialchars(TYPO3_db).'">';
2094 }
2095 $out.=$this->wrapInCells('', '<br />');
2096 $out.=$this->wrapInCells('Database:', $theCode);
2097 $out.=$this->wrapInCells('', '<br />');
2098
2099 if ($this->mode!='123') {
2100 $this->headerStyle .= chr(10) .
2101 '<script type="text/javascript" src="' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir . 'contrib/prototype/prototype.js"></script>
2102 <script type="text/javascript" src="' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir . 'sysext/install/mod/install.js"></script>';
2103
2104
2105 $out.=$this->wrapInCells('Site name:', '<input type="text" name="TYPO3_INSTALL[localconf.php][sitename]" value="'.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']).'">');
2106 $out.=$this->wrapInCells('', '<br />');
2107 $out.=$this->wrapInCells('Encryption key:', '<a name="set_encryptionKey"></a><input type="text" name="TYPO3_INSTALL[localconf.php][encryptionKey]" value="'.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']).'"><br /><input type="button" onclick="EncryptionKey.load(this)" value="Generate random key">');
2108 $out.=$this->wrapInCells('', '<br />');
2109
2110 // Other
2111 $fA = $this->setupGeneralCalculate();
2112
2113 if (is_array($fA['disable_exec_function'])) {
2114 $out.=$this->wrapInCells('[BE][disable_exec_function]=', $this->getFormElement($fA['disable_exec_function'], $fA['disable_exec_function'], 'TYPO3_INSTALL[localconf.php][disable_exec_function]', $GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function']));
2115 }
2116 if (is_array($fA['gdlib'])) {
2117 $out.=$this->wrapInCells('[GFX][gdlib]=', $this->getFormElement($fA['gdlib'], $fA['gdlib'], 'TYPO3_INSTALL[localconf.php][gdlib]', $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']));
2118 if (is_array($fA['gdlib_png']) && $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) {
2119 $out.=$this->wrapInCells('[GFX][gdlib_png]=', $this->getFormElement($this->setLabelValueArray($fA['gdlib_png'],2), $fA['gdlib_png'], 'TYPO3_INSTALL[localconf.php][gdlib_png]', $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']));
2120 }
2121 }
2122 if (is_array($fA['im'])) {
2123 $out.=$this->wrapInCells('[GFX][im]=', $this->getFormElement($fA['im'], $fA['im'], 'TYPO3_INSTALL[localconf.php][im]', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im']));
2124 $out.=$this->wrapInCells('[GFX][im_combine_filename]=', $this->getFormElement($fA['im_combine_filename'], ($fA['im_combine_filename']?$fA['im_combine_filename']:"combine"), 'TYPO3_INSTALL[localconf.php][im_combine_filename]', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_combine_filename']));
2125 $out.=$this->wrapInCells('[GFX][im_version_5]=', $this->getFormElement($fA['im_version_5'], ($fA['im_version_5']?$fA['im_version_5']:''), 'TYPO3_INSTALL[localconf.php][im_version_5]', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']));
2126 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {
2127 if (is_array($fA['im_path'])) {
2128 $out.=$this->wrapInCells('[GFX][im_path]=', $this->getFormElement($this->setLabelValueArray($fA['im_path'],1), $this->setLabelValueArray($fA['im_path'],0), 'TYPO3_INSTALL[localconf.php][im_path]', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path']));
2129 }
2130 if (is_array($fA['im_path_lzw'])) {
2131 $out.=$this->wrapInCells('[GFX][im_path_lzw]=', $this->getFormElement($this->setLabelValueArray($fA['im_path_lzw'],1), $this->setLabelValueArray($fA['im_path_lzw'],0), 'TYPO3_INSTALL[localconf.php][im_path_lzw]', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']));
2132 }
2133 }
2134 }
2135 $out.=$this->wrapInCells('[GFX][TTFdpi]=', '<input type="text" name="TYPO3_INSTALL[localconf.php][TTFdpi]" value="'.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['GFX']['TTFdpi']).'">');
2136 }
2137
2138
2139 $out.=$this->wrapInCells('', '<br /><input type="submit" value="Update localconf.php"><br />
2140 <strong>NOTICE: </strong>By clicking this button, localconf.php is updated with new values for the parameters listed above!');
2141 $out.='
2142 </table>
2143 </form>';
2144 break;
2145 default:
2146 if (is_array($this->INSTALL['localconf.php'])) {
2147 $errorMessages=array();
2148 $lines = $this->writeToLocalconf_control();
2149
2150 // New database?
2151 #debug($this->INSTALL);
2152 if (trim($this->INSTALL['localconf.php']['NEW_DATABASE_NAME'])) {
2153 $newdbname=trim($this->INSTALL['localconf.php']['NEW_DATABASE_NAME']);
2154 if (!preg_match('/[^[:alnum:]_-]/',$newdbname)) {
2155 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) {
2156 if ($GLOBALS['TYPO3_DB']->admin_query('CREATE DATABASE '.$newdbname)) {
2157 $this->INSTALL['localconf.php']['typo_db'] = $newdbname;
2158 $this->messages[]= "Database '".$newdbname."' created";
2159 } else $this->messages[]= $errorMessages[] = "Could not create database '".$newdbname."' (...not created)";
2160 } else $this->messages[]= $errorMessages[] = "Could not connect to database when creating database '".$newdbname."' (...not created)";
2161 } else $this->messages[]= $errorMessages[] = "The NEW database name '".$newdbname."' was not alphanumeric, a-zA-Z0-9_- (...not created)";
2162 }
2163 #debug($this->messages) ;
2164 // Parsing values
2165 reset($this->INSTALL['localconf.php']);
2166 while(list($key,$value)=each($this->INSTALL['localconf.php'])) {
2167 switch((string)$key) {
2168 case 'typo_db_username':
2169 if (strlen($value)<50) {
2170 if (strcmp(TYPO3_db_username,$value)) $this->setValueInLocalconfFile($lines, '$typo_db_username', trim($value));
2171 } else $this->messages[]= $errorMessages[] = "Username '".$value."' was longer than 50 chars (...not saved)";
2172 break;
2173 case 'typo_db_password':
2174 if (strlen($value)<50) {
2175 if (strcmp(TYPO3_db_password,$value)) $this->setValueInLocalconfFile($lines, '$typo_db_password', trim($value));
2176 } else $this->messages[]= $errorMessages[] = "Password was longer than 50 chars (...not saved)";
2177 break;
2178 case 'typo_db_host':
2179 if (preg_match('/^[a-zA-Z0-9_\.-]+(:.+)?$/',$value) && strlen($value)<50) {
2180 if (strcmp(TYPO3_db_host,$value)) $this->setValueInLocalconfFile($lines, '$typo_db_host', $value);
2181 } else $this->messages[]= $errorMessages[] = "Host '".$value."' was not alphanumeric (a-z, A-Z, 0-9 or _-.), or longer than 50 chars (...not saved)";
2182 break;
2183 case 'typo_db':
2184 if (strlen($value)<50) {
2185 if (strcmp(TYPO3_db,$value)) $this->setValueInLocalconfFile($lines, '$typo_db', trim($value));
2186 } else $this->messages[]= $errorMessages[] = "Database name '".$value."' was longer than 50 chars (...not saved)";
2187 break;
2188 case 'disable_exec_function':
2189 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function'],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'BE\'][\'disable_exec_function\']', $value?1:0);
2190 break;
2191 case 'sitename':
2192 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'SYS\'][\'sitename\']', $value);
2193 break;
2194 case 'encryptionKey':
2195 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'SYS\'][\'encryptionKey\']', $value);
2196 break;
2197 case 'compat_version':
2198 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version'],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'SYS\'][\'compat_version\']', $value);
2199 break;
2200 case 'im_combine_filename':
2201 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_combine_filename'],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\'][\'im_combine_filename\']', $value);
2202 break;
2203 case 'gdlib':
2204 case 'gdlib_png':
2205 case 'im':
2206 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['GFX'][$key], $value)) {
2207 $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\'][\'' . $key . '\']', ($value ? 1 : 0));
2208 }
2209 break;
2210 case 'im_path':
2211 list($value,$version) = explode('|',$value);
2212 if (!preg_match('/[[:space:]]/',$value,$reg) && strlen($value)<100) {
2213 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['GFX'][$key], $value)) {
2214 $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\'][\'' . $key . '\']', $value);
2215 }
2216 if(doubleval($version)>0 && doubleval($version)<4) { // Assume GraphicsMagick
2217 $value_ext = 'gm';
2218 } elseif(doubleval($version)<5) { // Assume ImageMagick 4.x
2219 $value_ext = '';
2220 } elseif(doubleval($version) >= 6) { // Assume ImageMagick 6.x
2221 $value_ext = 'im6';
2222 } else { // Assume ImageMagick 5.x
2223 $value_ext = 'im5';
2224 }
2225 if (strcmp(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']),$value_ext)) {
2226 $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\'][\'im_version_5\']', $value_ext);
2227 }
2228 // if (strcmp(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']),$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS['GFX']['im_version_5']', $value);
2229 } else $this->messages[]= $errorMessages[] = "Path '".$value."' contains spaces or is longer than 100 chars (...not saved)";
2230 break;
2231 case 'im_path_lzw':
2232 list($value) = explode('|',$value);
2233 if (!preg_match('/[[:space:]]/',$value) && strlen($value)<100) {
2234 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['GFX'][$key], $value)) {
2235 $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\'][\'' . $key . '\']', $value);
2236 }
2237 } else $this->messages[]= $errorMessages[] = "Path '".$value."' contains spaces or is longer than 100 chars (...not saved)";
2238 break;
2239 case 'TTFdpi':
2240 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['GFX']['TTFdpi'],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\'][\'TTFdpi\']', $value);
2241 break;
2242 }
2243
2244
2245 }
2246
2247 if (count($errorMessages)) {
2248 echo '<h3>ERRORS</h3>';
2249 echo t3lib_div::view_array($errorMessages);
2250 echo 'Click the browsers "Back" button to reenter the values.';
2251 exit;
2252 }
2253 $this->writeToLocalconf_control($lines);
2254 }
2255 break;
2256 }
2257 return $out;
2258 }
2259
2260 /**
2261 * Writes or returns lines from localconf.php
2262 *
2263 * @param array Array of lines to write back to localconf.php. Possibly
2264 * @param boolean If TRUE then print what has been done.
2265 * @return mixed If $lines is not an array it will return an array with the lines from localconf.php. Otherwise it will return a status string, either "continue" (updated) or "nochange" (not updated)
2266 * @see parent::writeToLocalconf_control()
2267 */
2268 function writeToLocalconf_control($lines='', $showOutput=TRUE) {
2269 $returnVal = parent::writeToLocalconf_control($lines);
2270
2271 if ($showOutput) {
2272 switch($returnVal) {
2273 case 'continue':
2274 $content = '<br /><br />'.implode($this->messages,'<hr />').'<br /><br /><a href="'.$this->action.'">Click to continue...</a>';
2275 $this->outputExitBasedOnStep($content);
2276 break;
2277 case 'nochange':
2278 $content = '<strong>Writing to \'localconf.php\':</strong><br /><br />No values were changed, so nothing is updated!<br /><br /><a href="'.$this->action.'">Click to continue...</a>';
2279 $this->outputExitBasedOnStep('<br />'.$content);
2280 break;
2281 }
2282 }
2283 return $returnVal;
2284 }
2285
2286 /**
2287 * [Describe function...]
2288 *
2289 * @param [type] $content: ...
2290 * @return [type] ...
2291 */
2292 function outputExitBasedOnStep($content) {
2293 if ($this->step) {
2294 t3lib_div::redirect($this->action);
2295 } else {
2296 $this->output($this->outputWrapper($content));
2297 }
2298 exit;
2299 }
2300
2301 /**
2302 * This appends something to value in the input array based on $type. Private.
2303 *
2304 * @param [type] $arr: ...
2305 * @param [type] $type: ...
2306 * @return [type] ...
2307 */
2308 function setLabelValueArray($arr,$type) {
2309 reset($arr);
2310 while(list($k,$v)=each($arr)) {
2311 if($this->config_array['im_versions'][$v]['gm']) {
2312 $program = 'gm';
2313 } else {
2314 $program = 'convert';
2315 }
2316
2317 switch($type) {
2318 case 0: // value, im
2319 $arr[$k].='|'.$this->config_array['im_versions'][$v][$program];
2320 break;
2321 case 1: // labels, im
2322 if($this->config_array['im_versions'][$v][$program]) {
2323 $arr[$k].= ' ('.$this->config_array['im_versions'][$v][$program];
2324 $arr[$k].= ($this->config_array['im_versions'][$v]['gif_capability'] ? ', '.$this->config_array['im_versions'][$v]['gif_capability'] : '');
2325 $arr[$k].= ')';
2326 } else {
2327 $arr[$k].= '';
2328 }
2329 break;
2330 case 2: // labels, gd
2331 $arr[$k].=' ('.($v==1?'PNG':'GIF').')';
2332 break;
2333 }
2334 }
2335 return $arr;
2336 }
2337
2338 /**
2339 * Returns a form-element for the localconf.php update form
2340 *
2341 * @param [type] $labels: ...
2342 * @param [type] $values: ...
2343 * @param [type] $fieldName: ...
2344 * @param [type] $default: ...
2345 * @param [type] $msg: ...
2346 * @return [type] ...
2347 */
2348 function getFormElement($labels,$values,$fieldName,$default,$msg='') {
2349 $out.='<strong>'.htmlspecialchars(current($labels)).'</strong><br />current value is '.htmlspecialchars($default).($msg?'<br />'.$msg:'');
2350 if (count($labels)>1) {
2351 reset($labels);
2352 while(list($k,$v)=each($labels)) {
2353 list($cleanV) =explode('|',$values[$k]);
2354 $options.='<option value="'.htmlspecialchars($values[$k]).'"'.(!strcmp($default,$cleanV)?' selected="selected"':'').'>'.htmlspecialchars($v).'</option>';
2355 }
2356 $out.='<br /><select name="'.$fieldName.'">'.$options.'</select>';
2357 } else {
2358 $out.='<input type="hidden" name="'.$fieldName.'" value="'.htmlspecialchars(current($values)).'">';
2359 }
2360 return $out.'<br />';
2361 }
2362
2363 /**
2364 * Returns the list of available databases (with access-check based on username/password)
2365 *
2366 * @return [type] ...
2367 */
2368 function getDatabaseList() {
2369 $dbArr=array();
2370 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) {
2371 $dbArr = $GLOBALS['TYPO3_DB']->admin_get_dbs();
2372 }
2373 return $dbArr;
2374 }
2375
2376 /**
2377 * Calculates the suggested setup that should be written to localconf.php
2378 *
2379 * If safe_mode
2380 * - disable_exec_function = 1
2381 * - im = 0
2382 *
2383 * if PNG/GIF/GD
2384 * - disable gdlib if nothing
2385 * - select png/gif if only one of them is available, else PNG/GIF selector, defaulting to GIF
2386 * - (safe_mode is on)
2387 * - im_path (default to 4.2.9, preferable with LZW) im_ver5-flag is set based on im_path being 4.2.9 or 5+
2388 * - im_path_lzw (default to LZW version, pref. 4.2.9)
2389 *
2390 * @return [type] ...
2391 */
2392 function setupGeneralCalculate() {
2393 $formArray['disable_exec_function']=array(0);
2394 $formArray['im_path']=array('');
2395 $formArray['im_path_lzw']=array('');
2396 $formArray['im_combine_filename']=array('');
2397 $formArray['im_version_5']=array('');
2398 $formArray['im']=array(1);
2399 $formArray['gdlib']=array(1);
2400 if ($this->config_array['gd'] && ($this->config_array['gd_gif'] || $this->config_array['gd_png'])) {
2401 if ($this->config_array['gd_gif'] && !$this->config_array['gd_png']) {
2402 $formArray['gdlib_png']=array(0);
2403 } elseif (!$this->config_array['gd_gif'] && $this->config_array['gd_png']) {
2404 $formArray['gdlib_png']=array(1);
2405 } else {
2406 $formArray['gdlib_png']=array(0,1);
2407 }
2408 } else {
2409 $formArray['gdlib']=array(0);
2410 }
2411 if ($this->config_array['safemode']) {
2412 $formArray['disable_exec_function']=array(1);
2413 }
2414 if ($this->config_array['im']) {
2415 $formArray['im']=array(1);
2416 $LZW_found=0;
2417 $found=0;
2418 reset($this->config_array['im_versions']);
2419 $totalArr=array();
2420 while(list($path,$dat)=each($this->config_array['im_versions'])) {
2421 if (count($dat)>=3) {
2422 if (doubleval($dat['convert'])<5) {
2423 $formArray['im_version_5']=array(0);
2424 if ($dat['gif_capability']=='LZW') {
2425 $formArray['im_path']=array($path);
2426 $found=2;
2427 } elseif ($found<2) {
2428 $formArray['im_path']=array($path);
2429 $found=1;
2430 }
2431 } elseif (doubleval($dat['convert']) >= 6) {
2432 $formArray['im_version_5'] = array('im6');
2433 if ($dat['gif_capability'] == 'LZW') {
2434 $formArray['im_path'] = array($path);
2435 $found = 2;
2436 } elseif ($found < 2) {
2437 $formArray['im_path'] = array($path);
2438 $found = 1;
2439 }
2440 } elseif (!$found) {
2441 $formArray['im_version_5']=array('im5');
2442 $formArray['im_path']=array($path);
2443 $found=1;
2444 }
2445 } elseif ($dat['gm']) {
2446 $formArray['im_version_5']=array('gm');
2447 if ($dat['gif_capability']=='LZW') {
2448 $formArray['im_path']=array($path);
2449 $found=2;
2450 } elseif ($found<2) {
2451 $formArray['im_path']=array($path);
2452 $found=1;
2453 }
2454 }
2455 if ($dat['gif_capability']=='LZW') {
2456 if (doubleval($dat['convert'])<5 || !$LZW_found) {
2457 $formArray['im_path_lzw']=array($path);
2458 $LZW_found=1;
2459 }
2460 } elseif ($dat['gif_capability']=="RLE" && !$LZW_found) {
2461 $formArray['im_path_lzw']=array($path);
2462 }
2463 $totalArr[]=$path;
2464 }
2465 $formArray['im_path']=array_unique(array_merge($formArray['im_path'],$totalArr));
2466 $formArray['im_path_lzw']=array_unique(array_merge($formArray['im_path_lzw'],$totalArr));
2467 $formArray['im_combine_filename']=array($this->config_array['im_combine_filename']);
2468 } else {
2469 $formArray['im']=array(0);
2470 }
2471 return $formArray;
2472 }
2473
2474 /**
2475 * Returns the part of phpinfo() output that tells about GD library (HTML-code)
2476 *
2477 * @return [type] ...
2478 */
2479 function getGDPartOfPhpinfo() {
2480 ob_start();
2481 phpinfo();
2482 $contents = ob_get_contents();
2483 ob_end_clean();
2484 $start_string = $this->getGD_start_string;
2485 $end_string = $this->getGD_end_string;
2486 list(,$gdpart_tmp) = explode($start_string,$contents,2);
2487 list($gdpart) = explode($end_string,$start_string.$gdpart_tmp,2);
2488 $gdpart.=$end_string;
2489 return $gdpart;
2490 }
2491
2492 /**
2493 * Returns true if TTF lib is install according to phpinfo(). If $phpinfo supply as parameter that string is searched instead.
2494 *
2495 * @param [type] $phpinfo: ...
2496 * @return [type] ...
2497 */
2498 function isTTF($phpinfo='') {
2499 /* $phpinfo = $phpinfo?$phpinfo:$this->getGDPartOfPhpinfo();
2500 if (stristr($phpinfo, $this->getTTF_string)) return 1;
2501 if (stristr($phpinfo, $this->getTTF_string_alt)) return 1;
2502 */
2503
2504 if (!function_exists('imagettftext')) return 0; // Return right away if imageTTFtext does not exist.
2505
2506 // try, print truetype font:
2507 $im = @imagecreate (300, 50);
2508 $background_color = imagecolorallocate ($im, 255, 255, 55);
2509 $text_color = imagecolorallocate ($im, 233, 14, 91);
2510
2511 $test = @imagettftext($im, t3lib_div::freetypeDpiComp(20), 0, 10, 20, $text_color, PATH_t3lib."/fonts/vera.ttf", 'Testing Truetype support');
2512 if (t3lib_div::_GP('testingTrueTypeSupport')) {
2513 if ($this->isGIF()) {
2514 header ('Content-type: image/gif');
2515 imagegif ($im);
2516 } else {
2517 header ('Content-type: image/png');
2518 imagepng ($im);
2519 }
2520 exit;
2521 }
2522 return is_array($test)?1:0;
2523 }
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535 /*****************************************
2536 *
2537 * ABOUT the isXXX functions.
2538 *
2539 * I had a very real experience that these checks DID NOT fail eg PNG support if it didn't exist!
2540 * So first (1) we check if the functions are there. If they ARE we are going to make further investigations (2) by creating an actual image.
2541 * And if THAT succeeds also, then we can be certain of the support!
2542 */
2543
2544 /**
2545 * @return [type] ...
2546 */
2547 function isGD() {
2548 if (function_exists('imagecreate')) {
2549 if (@imagecreate (50, 100)) return 1;
2550 }
2551 }
2552
2553 /**
2554 * [Describe function...]
2555 *
2556 * @return [type] ...
2557 */
2558 function isGIF() {
2559 if (function_exists('imagecreatefromgif') && function_exists('imagegif') && ($this->ImageTypes() & IMG_GIF)) { // If GIF-functions exists, also do a real test of them:
2560 $im = @imagecreatefromgif(t3lib_extMgm::extPath('install').'imgs/jesus.gif');
2561 return $im?1:0;
2562 }
2563 }
2564
2565 /**
2566 * [Describe function...]
2567 *
2568 * @return [type] ...
2569 */
2570 function isJPG() {
2571 if (function_exists('imagecreatefromjpeg') && function_exists('imagejpeg') && ($this->ImageTypes() & IMG_JPG)) {
2572 return 1;
2573 }
2574 }
2575
2576 /**
2577 * [Describe function...]
2578 *
2579 * @return [type] ...
2580 */
2581 function isPNG() {
2582 if (function_exists('imagecreatefrompng') && function_exists('imagepng') && ($this->ImageTypes() & IMG_PNG)) {
2583 $im = imagecreatefrompng(t3lib_extMgm::extPath('install').'imgs/jesus.png');
2584 return $im?1:0;
2585 }
2586 }
2587
2588 /**
2589 * [Describe function...]
2590 *
2591 * @return [type] ...
2592 */
2593 function ImageTypes() {
2594 return imagetypes();
2595 }
2596
2597 /**
2598 * Returns general information about GDlib
2599 *
2600 * @return [type] ...
2601 */
2602 function getGDSoftwareInfo() {
2603 return trim('
2604 You can get GDLib in the PNG version from '.$this->linkIt('http://www.boutell.com/gd/').'.<br />FreeType is for download at '.$this->linkIt('http://www.freetype.org/').'.
2605 Generally, software for TYPO3 is found at '.$this->linkIt('http://typo3.sunsite.dk/software/').' and packages listed at '.$this->linkIt('http://typo3.org/1274.0.html').'.
2606 ');
2607 }
2608
2609 /**
2610 * Returns general information about configuration of TYPO3.
2611 *
2612 * @return [type] ...
2613 */
2614 function generallyAboutConfiguration() {
2615 $out='
2616 Local configuration is done by overriding default values in the included file, typo3conf/localconf.php. In this file you enter the database information along with values in the global array TYPO3_CONF_VARS.
2617 The options in the TYPO3_CONF_VARS array and how to use it for your own purposes is discussed in the base configuration file, t3lib/config_default.php. This file sets up the default values and subsequently includes the localconf.php file in which you can then override values.
2618 See this page for '.$this->linkIt('http://typo3.org/1275.0.html','more information about system requirements.').'
2619 ';
2620 return trim($out);
2621 }
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635 /**********************
2636 *
2637 * IMAGE processing
2638 *
2639 **********************/
2640
2641 /**
2642 * jesus.TIF: IBM/LZW
2643 * jesus.GIF: Save for web, 32 colors
2644 * jesus.JPG: Save for web, 30 quality
2645 * jesus.PNG: Save for web, PNG-24
2646 * jesus.tga 24 bit TGA file
2647 * jesus.pcx
2648 * jesus.bmp 24 bit BMP file
2649 * jesus_ps6.PDF: PDF w/layers and vector data
2650 * typo3logo.ai: Illustrator 8 file
2651 * pdf_from_imagemagick.PDF PDF-file made by Acrobat Distiller from InDesign PS-file
2652 *
2653 *
2654 * Imagemagick
2655 * - Read formats
2656 * - Write png, gif, jpg
2657 *
2658 * Problems may arise from the use of safe_mode (eg. png)
2659 * In safemode you will automatically execute the program convert in the safe_mode_exec_path no matter what other path you specify
2660 * check fileexist before anything...
2661 *
2662 * - compare gif size
2663 * - scaling (by stdgraphic)
2664 * - combining (by stdgraphic)
2665 *
2666 * GDlib:
2667 * - create from:....
2668 * - ttf text
2669 *
2670 * From TypoScript: (GD only, GD+IM, IM)
2671 *
2672 * @return [type] ...
2673 */
2674 function checkTheImageProcessing() {
2675 $this->message('Image Processing','What is it?',"
2676 TYPO3 is known for its ability to process images on the server.
2677 In the backend interface (TBE) thumbnails are automatically generated (by ImageMagick in thumbs.php) as well as icons, menu items and pane tabs (by GDLib).
2678 In the TypoScript enabled frontend all kinds of graphical elements are processed. Typically images are scaled down to fit the pages (by ImageMagick) and menu items, graphical headers and such are generated automatically (by GDLib + ImageMagick).
2679 In addition TYPO3 is able to handle many file formats (thanks to ImageMagick), for example TIF, BMP, PCX, TGA, AI and PDF in addition to the standard web formats; JPG, GIF, PNG.
2680
2681 In order to do this, TYPO3 uses two sets of tools:
2682
2683 <strong>ImageMagick:</strong>
2684 For conversion of non-web formats to webformats, combining images with alpha-masks, performing image-effects like blurring and sharpening.
2685 ImageMagick is a collection of external programs on the server called by the exec() function in PHP. TYPO3 uses three of these, namely 'convert' (converting fileformats, scaling, effects), 'combine'/'composite' (combining images with masks) and 'identify' (returns image information).
2686 Because ImageMagick are external programs, two requirements must be met: 1) The programs must be installed on the server and working and 2) if safe_mode is enabled, the programs must be located in the folder defined by the php.ini setting, <em>safe_mode_exec_dir</em> (else they are not executed).
2687 ImageMagick is available for both Windows and Unix. The current version is 5+, but TYPO3 enthusiasts prefer an old version 4.2.9 because that version has three main advantages: It's faster in some operations, the blur-function works, the sharpen-function works. Anyway you do it, you must tell TYPO3 by configuration whether you're using version 5+ or 4.2.9. (flag: [GFX][im_version_5])
2688 ImageMagick homepage is at ".$this->linkIt('http://www.imagemagick.org/')."
2689
2690 <strong>GDLib:</strong>
2691 For drawing boxes and rendering text on images with truetype fonts. Also used for icons, menuitems and generally the TypoScript GIFBUILDER object is based on GDlib, but extensively utilizing ImageMagick to process intermediate results.
2692 GDLib is accessed through internal functions in PHP, so in this case, you have no safe_mode problems, but you'll need a version of PHP with GDLib compiled in. Also in order to use TrueType fonts with GDLib you'll need FreeType compiled in as well.
2693 ".$this->getGDSoftwareInfo().'
2694
2695 You can disable all image processing options in TYPO3 ([GFX][image_processing]=0), but that would seriously disable TYPO3.
2696 ');
2697
2698 $this->message('Image Processing','Verifying the image processing capabilities of your server',"
2699 This page performs image processing and displays the result. It's a thorough check that everything you've configured is working correctly.
2700 It's quite simple to verify your installation; Just look down the page, the images in pairs should look like each other. If some images are not alike, something is wrong. You may also notice warnings and errors if this tool found signs of any problems.
2701
2702 The image to the right is the reference image (how it should be) and to the left the image made by your server.
2703 The reference images are made with the classic ImageMagick install based on the 4.2.9 RPM and 5.2.3 RPM. If the version 5 flag is set, the reference images are made by the 5.2.3 RPM.
2704
2705 This test will work only if your ImageMagick/GDLib configuration allows it to. The typo3temp/ folder must be writable for all the temporary image files. They are all prefixed 'install_' so they are easy to recognize and delete afterwards.
2706 ");
2707
2708 $im_path = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'];
2709 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']=='gm') {
2710 $im_path_version = $this->config_array['im_versions'][$im_path]['gm'];
2711 } else {
2712 $im_path_version = $this->config_array['im_versions'][$im_path]['convert'];
2713 }
2714 $im_path_lzw = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'];
2715 $im_path_lzw_version = $this->config_array['im_versions'][$im_path_lzw]['convert'];
2716 $msg = '
2717 ImageMagick enabled: <strong>'.$GLOBALS['TYPO3_CONF_VARS']['GFX']['im'].