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