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