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