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