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