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