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