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