Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00151 require_once (PATH_t3lib.'class.t3lib_install.php'); 00152 require_once (PATH_t3lib.'class.t3lib_stdgraphic.php'); 00153 00162 class tx_install extends t3lib_install { 00163 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() 00164 var $getGD_end_string = '</table>'; // Used to identify the end of the GD section (found with getGD_start_string) in the output from phpinfo() 00165 var $getTTF_string = 'with TTF library'; // Used to identify whether TTF-lib is included with GD 00166 var $getTTF_string_alt = 'with freetype'; // Used to identify whether TTF-lib is included with GD 00167 var $action = ''; // The url that calls this script 00168 var $scriptSelf = 'index.php'; // The url that calls this script 00169 var $fontTag2='<span class="bodytext">'; 00170 var $fontTag1='<span class="smalltext">'; 00171 var $updateIdentity = 'TYPO3 Install Tool'; 00172 var $headerStyle =''; 00173 var $contentBeforeTable=''; 00174 var $setAllCheckBoxesByDefault=0; 00175 00176 var $allowFileEditOutsite_typo3conf_dir=0; 00177 00178 var $INSTALL =array(); // In constructor: is set to global GET/POST var TYPO3_INSTALL 00179 var $checkIMlzw = 0; // If set, lzw capabilities of the available ImageMagick installs are check by actually writing a gif-file and comparing size 00180 var $checkIM = 0; // If set, ImageMagick is checked. 00181 var $dumpImCommands=1; // If set, the image Magick commands are always outputted in the image processing checker 00182 var $mode = ''; // If set to "123" then only most vital information is displayed. 00183 var $step = 0; // If set to 1,2,3 or GO it signifies various functions. 00184 00185 // internal 00186 var $passwordOK=0; // This is set, if the password check was ok. The function init() will exit if this is not set 00187 var $silent=1; // If set, the check routines don't add to the message-array 00188 var $messageFunc_nl2br=1; 00189 var $sections=array(); // Used to gather the message information. 00190 var $fatalError=0; // This is set if some error occured that will definitely prevent TYpo3 from running. 00191 var $sendNoCacheHeaders=1; 00192 var $config_array = array( // Flags are set in this array if the options are available and checked ok. 00193 'gd'=>0, 00194 'gd_gif'=>0, 00195 'gd_png'=>0, 00196 'gd_jpg'=>0, 00197 'freetype' => 0, 00198 'safemode' => 0, 00199 'dir_typo3temp' => 0, 00200 'dir_temp' => 0, 00201 'im_versions' => array(), 00202 'im' => 0, 00203 'sql.safe_mode_user' => '', 00204 'mysqlConnect' => 0, 00205 'no_database' => 0 00206 ); 00207 var $typo3temp_path=''; 00208 00209 var $menuitems = array( 00210 'config' => 'Basic Configuration', 00211 'database' => 'Database Analyser', 00212 'update' => 'Update Wizard', 00213 'images' => 'Image Processing', 00214 'extConfig' => 'All Configuration', 00215 'typo3temp' => 'typo3temp/', 00216 'cleanup' => 'Clean up database', 00217 'phpinfo' => 'phpinfo()', 00218 'typo3conf_edit' => 'Edit files in typo3conf/', 00219 'about' => 'About' 00220 ); 00221 var $cookie_name = 'Typo3InstallTool'; 00222 var $JSmessage = ''; 00223 00224 00225 00226 00227 00228 00234 function tx_install() { 00235 parent::t3lib_install(); 00236 00237 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';"); 00238 00239 if ($this->sendNoCacheHeaders) { 00240 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 00241 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 00242 header('Expires: 0'); 00243 header('Cache-Control: no-cache, must-revalidate'); 00244 header('Pragma: no-cache'); 00245 } 00246 00247 // **************************** 00248 // Initializing incoming vars. 00249 // **************************** 00250 $this->INSTALL = t3lib_div::_GP('TYPO3_INSTALL'); 00251 $this->mode = t3lib_div::_GP('mode'); 00252 $this->step = t3lib_div::_GP('step'); 00253 $this->redirect_url = t3lib_div::_GP('redirect_url'); 00254 00255 if ($_GET['TYPO3_INSTALL']['type']) { 00256 $this->INSTALL['type'] = $_GET['TYPO3_INSTALL']['type']; 00257 } 00258 00259 if ($this->step==3) { 00260 $this->INSTALL['type']='database'; 00261 } 00262 00263 if ($this->mode=='123') { 00264 $tempItems = $this->menuitems; 00265 unset($this->menuitems); 00266 $this->menuitems['config'] = $tempItems['config']; 00267 $this->menuitems['database'] = $tempItems['database']; 00268 if (!$this->INSTALL['type'] || !isset($this->menuitems[$this->INSTALL['type']])) $this->INSTALL['type'] = 'config'; 00269 } else { 00270 if (!$this->INSTALL['type'] || !isset($this->menuitems[$this->INSTALL['type']])) $this->INSTALL['type'] = 'about'; 00271 } 00272 00273 $this->action = $this->scriptSelf.'?TYPO3_INSTALL[type]='.$this->INSTALL['type'].($this->mode?'&mode='.rawurlencode($this->mode):'').($this->step?'&step='.rawurlencode($this->step):''); 00274 $this->typo3temp_path = PATH_site.'typo3temp/'; 00275 00276 00277 // **************** 00278 // Check password 00279 // **************** 00280 // Getting a unique session key, used to encode the session-access cookie later... 00281 $uKey = $_COOKIE[$this->cookie_name.'_key']; 00282 if (!$uKey) { 00283 $uKey = md5(uniqid(microtime())); 00284 SetCookie($this->cookie_name.'_key', $uKey, 0, '/'); // Cookie is set 00285 00286 $this->JSmessage='SECURITY: 00287 Make sure to protect the Install Tool with another password than "joh316". 00288 Better yet you can add a die() function call to typo3/install/index.php after usage. 00289 00290 IF THE INSTALL TOOL CRASHES... 00291 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. 00292 Workaround: Open the file typo3/sysext/install/mod/class.tx_install.php, go to the line where the function "isPNG()" is defined and make it return "0" hardcoded. PNG is not checked anymore and the rest of the Install Tool will work as expected. The same has been known with the other image formats as well. You can use a similar method to bypass the testing if that is also a problem. 00293 On behalf of PHP we regret this inconvenience. 00294 00295 BTW: This Install Tool will only work if cookies are accepted by your web browser. If this dialog pops up over and over again you didn\'t enable cookies. 00296 '; 00297 00298 } 00299 // Check if the password from TYPO3_CONF_VARS combined with uKey matches the sKey cookie. If not, ask for password. 00300 $sKey = $_COOKIE[$this->cookie_name]; 00301 00302 if (md5($GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword'].'|'.$uKey) == $sKey || $this->checkPassword($uKey)) { 00303 $this->passwordOK=1; 00304 if($this->redirect_url) { 00305 header('Location: '.$this->redirect_url); 00306 } 00307 } else { 00308 $this->loginForm(); 00309 } 00310 } 00311 00318 function checkPassword($uKey) { 00319 $p = t3lib_div::_GP('password'); 00320 00321 if ($p && md5($p)==$GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword']) { 00322 $sKey = md5($GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword'].'|'.$uKey); 00323 SetCookie($this->cookie_name, $sKey, 0, '/'); 00324 00325 // Sending warning email 00326 $wEmail = $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr']; 00327 if ($wEmail) { 00328 $subject="Install Tool Login at '".$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']."'"; 00329 $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').')'; 00330 mail($wEmail, 00331 $subject, 00332 $email_body, 00333 'From: TYPO3 Install Tool WARNING <>' 00334 ); 00335 } 00336 return true; 00337 } else { 00338 // Bad password, send warning: 00339 if ($p) { 00340 $wEmail = $GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr']; 00341 if ($wEmail) { 00342 $subject="Install Tool Login ATTEMPT at '".$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']."'"; 00343 $email_body="There has been a Install Tool login attempt at TYPO3 site '".$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']."' (".t3lib_div::getIndpEnv('HTTP_HOST')."). 00344 Password tried was '".$p."' 00345 REMOTE_ADDR was '".t3lib_div::getIndpEnv('REMOTE_ADDR')."' (".t3lib_div::getIndpEnv('REMOTE_HOST').')'; 00346 mail($wEmail, 00347 $subject, 00348 $email_body, 00349 'From: TYPO3 Install Tool WARNING <>' 00350 ); 00351 } 00352 } 00353 return false; 00354 } 00355 } 00356 00362 function loginForm() { 00363 $p = t3lib_div::_GP('password'); 00364 $redirect_url = $this->redirect_url ? $this->redirect_url : $this->action; 00365 00366 $this->messageFunc_nl2br=0; 00367 $this->silent=0; 00368 00369 $content = '<form action="index.php" method="post" name="passwordForm"> 00370 <input type="password" name="password"><br /> 00371 <input type="hidden" name="redirect_url" value="'.$redirect_url.'"> 00372 <input type="submit" value="Log in"><br /> 00373 <br /> 00374 00375 '.$this->fw('The Install Tool Password is <i>not</i> the admin password of TYPO3.<br /> 00376 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.'. 00377 ($p ? '<br /><br />The password you just tried has this md5-value: <br /><br />'.md5($p) : '') 00378 ).' 00379 </form> 00380 <script type="text/javascript"> 00381 <!-- 00382 document.passwordForm.password.focus(); 00383 //--> 00384 </script>'; 00385 00386 $this->message('Password', 'Enter the Install Tool Password', $content,3); 00387 echo $this->outputWrapper($this->printAll()); 00388 } 00389 00396 function init() { 00397 if (!defined('PATH_typo3')) exit; // Must be called after inclusion of init.php (or from init.php) 00398 if (!$this->passwordOK) exit; 00399 // debug($_COOKIE); 00400 00401 // Setting stuff... 00402 $this->check_mail(); 00403 $this->setupGeneral(); 00404 $this->generateConfigForm(); 00405 if (count($this->messages)) t3lib_div::debug($this->messages); 00406 00407 if ($this->step) { 00408 echo $this->outputWrapper($this->stepOutput()); 00409 } else { 00410 // Menu... 00411 switch($this->INSTALL['type']) { 00412 case 'images': 00413 $this->checkIM=1; 00414 $this->checkTheConfig(); 00415 $this->silent=0; 00416 $this->checkTheImageProcessing(); 00417 break; 00418 case 'database': 00419 $this->checkTheConfig(); 00420 $this->silent=0; 00421 $this->checkTheDatabase(); 00422 break; 00423 case 'update': 00424 $this->checkDatabase(); 00425 $this->silent=0; 00426 $this->updateWizard(); 00427 break; 00428 case 'config': 00429 $this->silent=0; 00430 $this->checkIM=1; 00431 $this->message('About configuration','How to configure TYPO3',$this->generallyAboutConfiguration()); 00432 $this->checkTheConfig(); 00433 00434 $ext = 'Write config to localconf.php'; 00435 if ($this->fatalError) { 00436 if ($this->config_array['no_database'] || !$this->config_array['mysqlConnect']) { 00437 $this->message($ext, 'Database not configured yet!', ' 00438 You need to specify database username, password and host as one of the first things. 00439 Next you\'ll have to select a database to use with TYPO3. 00440 Use the form below: 00441 ',2); 00442 } else { 00443 $this->message($ext, 'Fatal error encountered!', ' 00444 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! 00445 You should also check all warnings that may appear. 00446 ',2); 00447 } 00448 } elseif ($this->mode=='123') { 00449 if (!$this->fatalError) { 00450 $this->message($ext, 'Basic configuration completed', ' 00451 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. 00452 00453 <strong><span style="color:#f00;">Step 2:</span></strong> <a href="'.$this->scriptSelf.'?TYPO3_INSTALL[type]=database'.($this->mode?'&mode='.rawurlencode($this->mode):'').'">Click here to install the database.</a> 00454 ',-1,1); 00455 } 00456 } 00457 $this->message($ext, 'Very Important: Changing Image Processing settings', " 00458 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. 00459 The problem is solved by <a href=\"".htmlspecialchars($this->setScriptName('typo3temp'))."\">clearing the typo3temp/ folder</a>. Also make sure to clear the cache_pages table. 00460 ",1,1); 00461 $this->message($ext, 'Very Important: Changing Encryption Key setting', " 00462 When you change the setting for the Encryption Key you <i>must</i> take into account that a change to this value might invalidate temporary information, URLs etc. 00463 The problem is solved by <a href=\"".htmlspecialchars($this->setScriptName('typo3temp'))."\">clearing the typo3temp/ folder</a>. Also make sure to clear the cache_pages table. 00464 ",1,1); 00465 $this->message($ext, 'Update localconf.php', " 00466 This form updates the localconf.php file with the suggested values you see below. The values are based on the analysis above. 00467 You can change the values in case you have alternatives to the suggested defaults. 00468 By this final step you will configure TYPO3 for immediate use provided that you have no fatal errors left above." 00469 .$this->setupGeneral('get_form'),0,1); 00470 00471 echo $this->outputWrapper($this->printAll()); 00472 00473 break; 00474 case 'extConfig': 00475 $this->silent=0; 00476 00477 $this->generateConfigForm('get_form'); 00478 00479 $content = $this->printAll(); 00480 $content = '<form action="'.$this->action.'" method="post">'.$content.'<input type="submit" value="Write to localconf.php"><br /><br /> 00481 '.$this->fw('<strong>NOTICE: </strong>By clicking this button, localconf.php is updated with new values for the parameters listed above!<br />').' 00482 </form>'; 00483 echo $this->outputWrapper($content); 00484 break; 00485 case 'typo3temp': 00486 $this->checkTheConfig(); 00487 $this->silent=0; 00488 $this->typo3TempManager(); 00489 break; 00490 case 'cleanup': 00491 $this->checkTheConfig(); 00492 $this->silent=0; 00493 $this->cleanupManager(); 00494 break; 00495 case 'phpinfo': 00496 $this->silent=0; 00497 $this->phpinformation(); 00498 break; 00499 case 'typo3conf_edit': 00500 $this->silent=0; 00501 $this->typo3conf_edit(); 00502 break; 00503 case 'about': 00504 default: 00505 $this->silent=0; 00506 $this->message('About', 'Warning - very important!', $this->securityRisk().$this->alterPasswordForm(),2); 00507 00508 $this->message('About', 'Using this script', " 00509 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. 00510 There are three primary steps for you to take: 00511 00512 <strong>1: Basic Configuration</strong> 00513 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. 00514 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. 00515 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. 00516 00517 <strong>2: Database Analyser</strong> 00518 In this step you can either install a new database or update the database from any previous TYPO3 version. 00519 You can also get an overview of extra/missing fields/tables in the database compared to a raw sql-file. 00520 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. 00521 00522 <strong>3: Update Wizard</strong> 00523 Here you will find update methods taking care of changes to the TYPO3 core which are not backwards compatible. 00524 It is recommended to run this wizard after every update to make sure everything will still work flawlessly. 00525 00526 <strong>4: Image Processing</strong> 00527 This step is a visual guide to verify your configuration of the image processing software. 00528 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. 00529 00530 <strong>5: All Configuration</strong> 00531 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. 00532 00533 <strong>6: typo3temp/</strong> 00534 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. 00535 "); 00536 00537 $this->message('About', 'Why is this script stand-alone?', " 00538 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. 00539 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! 00540 "); 00541 00542 00543 $headCode='Header legend'; 00544 $this->message($headCode, 'Just information', ' 00545 This is a simple message with some information about something. 00546 '); 00547 $this->message($headCode, 'Check was successful', ' 00548 Indicates that something was checked and returned an expected result. 00549 ',-1); 00550 $this->message($headCode, 'Notice!', ' 00551 Indicates that something is important to be aware of. 00552 This does <em>not</em> indicate an error. 00553 ',1); 00554 $this->message($headCode, 'Warning!', ' 00555 Indicates that something may very well cause trouble and you should definitely look into it before proceeding. 00556 This indicates a <em>potential</em> error. 00557 ',2); 00558 $this->message($headCode, 'Error!', ' 00559 Indicates that something is definitely wrong and that TYPO3 will most likely not perform as expected if this problem is not solved. 00560 This indicates an actual error. 00561 ',3); 00562 00563 echo $this->outputWrapper($this->printAll()); 00564 break; 00565 } 00566 } 00567 } 00568 00574 function stepOutput() { 00575 $this->checkTheConfig(); 00576 $error_missingConnect='<br /> 00577 '.$this->fontTag2.'<img src="'.$this->backPath.'gfx/icon_fatalerror.gif" width="18" height="16" class="absmiddle"> 00578 There is no connection to the database!<br /> 00579 (Username: <i>'.TYPO3_db_username.'</i>, Password: <i>'.TYPO3_db_password.'</i>, Host: <i>'.TYPO3_db_host.'</i>).<br /> 00580 <br /> 00581 <strong>Go to Step 1</strong> and enter a proper username/password!</span> 00582 <br /> 00583 <br /> 00584 '; 00585 $error_missingDB='<br /> 00586 '.$this->fontTag2.'<img src="'.$this->backPath.'gfx/icon_fatalerror.gif" width="18" height="16" class="absmiddle"> 00587 There is no access to the database (<i>'.TYPO3_db.'</i>)!<br /> 00588 <br /> 00589 <strong>Go to Step 2</strong> and select an accessible database!</span> 00590 <br /> 00591 <br /> 00592 '; 00593 00594 $whichTables=$this->getListOfTables(); 00595 $dbInfo=' 00596 <table border="0" cellpadding="1" cellspacing="0"> 00597 <tr> 00598 <td valign="top" nowrap="nowrap" colspan="2" align="center">'.$this->fontTag2.'<strong><img src="'.$this->backPath.'gfx/icon_note.gif" hspace="5" width="18" height="16" class="absmiddle">Database summary:</strong></span></td> 00599 </tr> 00600 <tr> 00601 <td valign="top" nowrap="nowrap">'.$this->fontTag1.'Username:</span></td> 00602 <td valign="top" nowrap="nowrap"><strong>'.$this->fontTag1.''.TYPO3_db_username.'</span></strong></td> 00603 </tr> 00604 <tr> 00605 <td valign="top" nowrap="nowrap">'.$this->fontTag1.'Password:</span></td> 00606 <td valign="top" nowrap="nowrap"><strong>'.$this->fontTag1.''.TYPO3_db_password.'</span></strong></td> 00607 </tr> 00608 <tr> 00609 <td valign="top" nowrap="nowrap">'.$this->fontTag1.'Host:</span></td> 00610 <td valign="top" nowrap="nowrap"><strong>'.$this->fontTag1.''.TYPO3_db_host.'</span></strong></td> 00611 </tr> 00612 <tr> 00613 <td valign="top" nowrap="nowrap">'.$this->fontTag1.'Database:</span></td> 00614 <td valign="top" nowrap="nowrap"><strong>'.$this->fontTag1.''.TYPO3_db.'</span></strong></td> 00615 </tr> 00616 <tr> 00617 <td valign="top" nowrap="nowrap">'.$this->fontTag1.'# of tables:</span></td> 00618 <td valign="top" nowrap="nowrap"><strong>'.$this->fontTag1.''.(count($whichTables)?'<span style="color:#f00;">'.count($whichTables).'</span>':count($whichTables)).'</span></strong></td> 00619 </tr> 00620 </table> 00621 '; 00622 $error_emptyDB='<br /> 00623 '.$this->fontTag2.'<img src="'.$this->backPath.'gfx/icon_fatalerror.gif" width="18" height="16" class="absmiddle"> 00624 The database is still empty. There are no tables!<br /> 00625 <br /> 00626 <strong>Go to Step 3</strong> and import a database!</span> 00627 <br /> 00628 <br /> 00629 '; 00630 00631 switch(strtolower($this->step)) { 00632 case 1: 00633 $msg=' 00634 <br /> 00635 <br /> 00636 <table border="0"> 00637 <form action="'.$this->action.'" method="post"> 00638 <tr> 00639 <td valign="top" nowrap="nowrap"><strong> 00640 '.$this->fontTag2.'Username:</span></strong> 00641 </td> 00642 <td> 00643 </td> 00644 <td valign="top"> 00645 '.$this->fontTag2.' 00646 <input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_username]" value="'.TYPO3_db_username.'"></span><br /> 00647 </td> 00648 </tr> 00649 <tr> 00650 <td valign="top" nowrap="nowrap"><strong> 00651 '.$this->fontTag2.'Password:</span></strong> 00652 </td> 00653 <td> 00654 </td> 00655 <td valign="top"> 00656 '.$this->fontTag2.' 00657 <input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_password]" value="'.TYPO3_db_password.'"></span><br /> 00658 </td> 00659 </tr> 00660 <tr> 00661 <td valign="top" nowrap="nowrap"><strong> 00662 '.$this->fontTag2.'Host:</span></strong> 00663 </td> 00664 <td> 00665 </td> 00666 <td valign="top"> 00667 '.$this->fontTag2.' 00668 <input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_host]" value="'.(TYPO3_db_host?TYPO3_db_host:'localhost').'"></span><br /> 00669 </td> 00670 </tr> 00671 <tr> 00672 <td valign="top" nowrap="nowrap"><strong> 00673 '.$this->fontTag1.'</span></strong> 00674 </td> 00675 <td> 00676 </td> 00677 <td valign="top"> 00678 '.$this->fontTag1.'<br /> 00679 <input type="hidden" name="step" value="2"> 00680 <input type="hidden" name="TYPO3_INSTALL[localconf.php][encryptionKey]" value="'.md5(uniqid(rand(),true)).'"> 00681 <input type="hidden" name="TYPO3_INSTALL[localconf.php][compat_version]" value="'.TYPO3_version.'"> 00682 <input type="submit" value="Continue"><br /><br /><strong>NOTICE: </strong>By clicking this button, typo3conf/localconf.php is updated with new values for the parameters listed above!</span><br /> 00683 </td> 00684 </tr> 00685 </form> 00686 </table> 00687 <br /> 00688 <br /> 00689 '; 00690 break; 00691 case 2: 00692 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { 00693 $dbArr = $this->getDatabaseList(); 00694 reset($dbArr); 00695 $options=''; 00696 $options.='<option value="">[ SELECT DATABASE ]</option>'; 00697 $dbIncluded=0; 00698 while(list(,$dbname)=each($dbArr)) { 00699 $options.='<option value="'.htmlspecialchars($dbname).'"'.($dbname==TYPO3_db?' selected="selected"':'').'>'.htmlspecialchars($dbname).'</option>'; 00700 if ($dbname==TYPO3_db) $dbIncluded=1; 00701 } 00702 if (!$dbIncluded && TYPO3_db) { 00703 $options.='<option value="'.htmlspecialchars(TYPO3_db).'" selected="selected">'.htmlspecialchars(TYPO3_db).' (NO ACCESS!)</option>'; 00704 } 00705 $select='<select name="TYPO3_INSTALL[localconf.php][typo_db]">'.$options.'</select>'; 00706 $msg=' 00707 <br /> 00708 <br /> 00709 <table border="0"> 00710 <form action="'.$this->action.'" method="post"> 00711 <tr> 00712 <td valign="top" nowrap="nowrap"><strong> 00713 '.$this->fontTag2.' 00714 You have two options:<br /> 00715 <br /><br /> 00716 00717 1: Select an existing <u>EMPTY</u> database:</span></strong> 00718 </td> 00719 </tr> 00720 <tr> 00721 <td valign="top"> 00722 '.$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.'</span><br /> 00723 </td> 00724 </tr> 00725 <tr> 00726 <td valign="top" nowrap="nowrap"><br /> 00727 <br /> 00728 <strong> 00729 '.$this->fontTag2.'2: Create new database (recommended):</span></strong> 00730 </td> 00731 </tr> 00732 <tr> 00733 <td valign="top"> 00734 '.$this->fontTag1.'Enter the desired name of the database here:<br /><input type="text" name="TYPO3_INSTALL[localconf.php][NEW_DATABASE_NAME]" value=""></span><br /> 00735 </td> 00736 </tr> 00737 <tr> 00738 <td valign="top"> <br /> 00739 00740 '.$this->fontTag1.'<br /> 00741 <input type="hidden" name="step" value="3"> 00742 <input type="submit" value="Continue"><br /><br /><strong>NOTICE: </strong>By clicking this button, typo3conf/localconf.php is updated with new values for the parameters listed above!</span><br /> 00743 </td> 00744 </tr> 00745 </form> 00746 </table> 00747 <br /> 00748 <br /> 00749 '; 00750 } else { 00751 $msg=$error_missingConnect; 00752 } 00753 break; 00754 case 3: 00755 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { 00756 if ($GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) { 00757 $sFiles = t3lib_div::getFilesInDir(PATH_typo3conf,'sql',1,1); 00758 00759 // Check if default database scheme "database.sql" already exists, otherwise create it 00760 if (!strstr(implode(',',$sFiles).',', '/database.sql,')) { 00761 array_unshift($sFiles,'Create default database tables'); 00762 } 00763 00764 $opt=''; 00765 foreach ($sFiles as $f) { 00766 if ($f=='Create default database tables') $key='CURRENT_TABLES+STATIC'; 00767 else $key=htmlspecialchars($f); 00768 00769 $opt.='<option value="import|'.$key.'">'.htmlspecialchars(basename($f)).'</option>'; 00770 } 00771 00772 00773 $content=' 00774 '.$this->fontTag2.'Please select a database dump:</span><br /> 00775 <input type="hidden" name="TYPO3_INSTALL[database_import_all]" value=1> 00776 <input type="hidden" name="step" value=""> 00777 <input type="hidden" name="goto_step" value="go"> 00778 <select name="TYPO3_INSTALL[database_type]">'.$opt.'</select><br />'; 00779 00780 $content = $this->getUpdateDbFormWrap('import', $content, 'Import database'); 00781 00782 $msg=' 00783 <br /> 00784 '.$dbInfo.'<br /> 00785 <br /> 00786 '.$content.' 00787 00788 '; 00789 00790 } else { 00791 $msg=$error_missingDB; 00792 } 00793 } else { 00794 $msg=$error_missingConnect; 00795 } 00796 break; 00797 case 'go': 00798 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { 00799 if ($GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) { 00800 if (count($whichTables)) { 00801 $msg=' 00802 <br /> 00803 '.$this->fontTag2.' 00804 '.nl2br($this->messageBasicFinished()).' 00805 <br /> 00806 <hr /> 00807 <div align="center"><strong><img src="'.$this->backPath.'gfx/icon_warning.gif" hspace="5" width="18" height="16" class="absmiddle">IMPORTANT</strong></div><br /> 00808 <span class="smalltext">'.nl2br($this->securityRisk()).' 00809 <br /> 00810 <strong>Enter <a href="'.$this->scriptSelf.'">"Normal" mode for the Install Tool</a> to change this!</strong><br /> 00811 00812 </span> 00813 </span><br /> 00814 '; 00815 } else { 00816 $msg=$error_emptyDB; 00817 } 00818 } else { 00819 $msg=$error_missingDB; 00820 } 00821 } else { 00822 $msg=$error_missingConnect; 00823 } 00824 break; 00825 default: 00826 break; 00827 } 00828 return $msg; 00829 } 00830 00836 function checkTheConfig() { 00837 // Order important: 00838 $this->checkDirs(); 00839 $this->checkConfiguration(); 00840 $this->checkExtensions(); 00841 00842 if (TYPO3_OS=='WIN') { 00843 $paths=array($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'], $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'], 'c:\\php\\imagemagick\\', 'c:\\apache\\ImageMagick\\'); 00844 } else { 00845 $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/'); 00846 } 00847 00848 asort($paths); 00849 if (ini_get('safe_mode')) { 00850 $paths=array(ini_get('safe_mode_exec_dir'),'/usr/local/php/bin/'); 00851 } 00852 if ($this->INSTALL['checkIM']['lzw']) { 00853 $this->checkIMlzw=1; 00854 } 00855 if ($this->INSTALL['checkIM']['path']) { 00856 $paths[]=trim($this->INSTALL['checkIM']['path']); 00857 } 00858 if ($this->checkIM) $this->checkImageMagick($paths); 00859 $this->checkDatabase(); 00860 } 00861 00867 function typo3conf_edit() { 00868 $EDIT_path = PATH_typo3conf; // default: 00869 if ($this->allowFileEditOutsite_typo3conf_dir && $this->INSTALL['FILE']['EDIT_path']) { 00870 if (t3lib_div::validPathStr($this->INSTALL['FILE']['EDIT_path']) && substr($this->INSTALL['FILE']['EDIT_path'],-1)=='/') { 00871 $tmp_path = PATH_site.$this->INSTALL['FILE']['EDIT_path']; 00872 if (is_dir($tmp_path)) { 00873 $EDIT_path=$tmp_path; 00874 } else {debug("'".$tmp_path."' was not dir");} 00875 } else { 00876 debug('BAD DIR_NAME (must be like t3lib/ or media/script/)'); 00877 } 00878 } 00879 00880 $headCode = 'Edit files in '.basename($EDIT_path).'/'; 00881 $this->contentBeforeTable=''; 00882 00883 if ($this->INSTALL['SAVE_FILE']) { 00884 $save_to_file = $this->INSTALL['FILE']['name']; 00885 if (@is_file($save_to_file)) { 00886 $save_to_file_md5 = md5($save_to_file); 00887 if (isset($this->INSTALL['FILE'][$save_to_file_md5]) && t3lib_div::isFirstPartOfStr($save_to_file,$EDIT_path.'') && substr($save_to_file,-1)!='~' && !strstr($save_to_file,'_bak')) { 00888 $this->INSTALL['typo3conf_files'] = $save_to_file; 00889 $save_fileContent = $this->INSTALL['FILE'][$save_to_file_md5]; 00890 00891 if ($this->INSTALL['FILE']['win_to_unix_br']) { 00892 $save_fileContent = str_replace(chr(13).chr(10),chr(10),$save_fileContent); 00893 } 00894 00895 $backupFile = $this->getBackupFilename($save_to_file); 00896 if ($this->INSTALL['FILE']['backup']) { 00897 if (@is_file($backupFile)) { unlink($backupFile); } 00898 rename($save_to_file,$backupFile); 00899 $this->contentBeforeTable.='Backup written to <strong>'.$backupFile.'</strong><br />'; 00900 } 00901 00902 t3lib_div::writeFile($save_to_file,$save_fileContent); 00903 $this->contentBeforeTable.=' 00904 File saved: <strong>'.$save_to_file.'</strong><br /> 00905 MD5-sum: '.$this->INSTALL['FILE']['prevMD5'].' (prev)<br /> 00906 MD5-sum: '.md5($save_fileContent).' (new)<br /> 00907 '; 00908 } 00909 } 00910 } 00911 00912 00913 // Filelist: 00914 $typo3conf_files = t3lib_div::getFilesInDir($EDIT_path,'',1,1); 00915 reset($typo3conf_files); 00916 $lines=array(); 00917 $fileFound = 0; 00918 while(list($k,$file)=each($typo3conf_files)) { 00919 if ($this->INSTALL['typo3conf_files'] && !strcmp($this->INSTALL['typo3conf_files'],$file)) { 00920 $wrap=array('<strong><span style="color:navy;">','</span></strong>'); 00921 $fileFound = 1; 00922 } else {$wrap=array();} 00923 $lines[]='<tr><td nowrap="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].' ').'</a></td><td>'.$this->fw(t3lib_div::formatSize(filesize($file))).'</td></tr>'; 00924 } 00925 $fileList='<table border="0" cellpadding="0" cellspacing="0">'.implode('',$lines).'</table>'; 00926 $fileList.='<br />('.$EDIT_path.')'; 00927 00928 if ($this->allowFileEditOutsite_typo3conf_dir) { 00929 $fileList.='<br /><form action="'.$this->action.'" method="post"> 00930 '.PATH_site.'<input type="text" name="TYPO3_INSTALL[FILE][EDIT_path]" value="'.$this->INSTALL['FILE']['EDIT_path'].'"><input type="submit" name="" value="Set"> 00931 </form>'; 00932 } 00933 00934 if ($fileFound && @is_file($this->INSTALL['typo3conf_files'])) { 00935 $this->headerStyle = ' 00936 <style type="text/css"><!-- 00937 SELECT {font-family: Verdana,Arial,Helvetica,Sans-serif; font-size: 10px;} 00938 TEXTAREA {font-family: Verdana,Arial,Helvetica,Sans-serif; font-size: 10px;} 00939 INPUT {font-family: Verdana,Arial,Helvetica,Sans-serif; font-size: 10px;} 00940 //--></style> 00941 '; 00942 00943 $backupFile = $this->getBackupFilename($this->INSTALL['typo3conf_files']); 00944 $fileContent = t3lib_div::getUrl($this->INSTALL['typo3conf_files']); 00945 $this->contentBeforeTable.= '<form action="'.$this->action.'" method="post">'.(substr($this->INSTALL['typo3conf_files'],-1)!='~' && !strstr($this->INSTALL['typo3conf_files'],'_bak') ? ' 00946 <input type="submit" name="TYPO3_INSTALL[SAVE_FILE]" value="Save file"> ' : '').' 00947 <input type="submit" name="_close" value="Close"> 00948 <br />File: '.$this->INSTALL['typo3conf_files'].' 00949 <br />MD5-sum: '.md5($fileContent).' 00950 <br /> 00951 00952 <input type="hidden" name="TYPO3_INSTALL[FILE][name]" value="'.$this->INSTALL['typo3conf_files'].'"> 00953 '.($this->allowFileEditOutsite_typo3conf_dir?'<input type="hidden" name="TYPO3_INSTALL[FILE][EDIT_path]" value="'.$this->INSTALL['FILE']['EDIT_path'].'">':'').' 00954 <input type="hidden" name="TYPO3_INSTALL[FILE][prevMD5]" value="'.md5($fileContent).'"> 00955 <textarea rows="30" name="TYPO3_INSTALL[FILE]['.md5($this->INSTALL['typo3conf_files']).']" wrap="off"'.$this->formWidthText(48,'width:98%;height:80%','off').' class="fixed-font enable-tab">'.t3lib_div::formatForTextarea($fileContent).'</textarea><br /> 00956 <input type="checkbox" name="TYPO3_INSTALL[FILE][win_to_unix_br]" value="1"'.(TYPO3_OS=='WIN'?'':' checked="checked"').'> Convert Windows linebreaks (13-10) to Unix (10)<br /> 00957 <input type="checkbox" name="TYPO3_INSTALL[FILE][backup]" value="1"'.(@is_file($backupFile) ? ' checked="checked"' : '').'> Make backup copy (rename to '.basename($backupFile).')<br /> 00958 '. 00959 '</form>'; 00960 } 00961 00962 if ($this->contentBeforeTable) { 00963 $this->contentBeforeTable = $this->fw($this->contentBeforeTable); 00964 } 00965 00966 $this->message($headCode,'Files in folder',$fileList); 00967 00968 echo $this->outputWrapper($this->printAll()); 00969 } 00970 00976 function phpinformation() { 00977 $headCode = 'PHP information'; 00978 00979 $sVar = t3lib_div::getIndpEnv('_ARRAY'); 00980 $sVar['CONST: PHP_OS']=PHP_OS; 00981 $sVar['CONST: TYPO3_OS']=TYPO3_OS; 00982 $sVar['CONST: PATH_thisScript']=PATH_thisScript; 00983 $sVar['CONST: php_sapi_name()']=php_sapi_name(); 00984 $sVar['OTHER: TYPO3_VERSION']=$GLOBALS['TYPO_VERSION']; 00985 $sVar['OTHER: PHP_VERSION']=phpversion(); 00986 $sVar['imagecreatefromgif()']=function_exists('imagecreatefromgif'); 00987 $sVar['imagecreatefrompng()']=function_exists('imagecreatefrompng'); 00988 $sVar['imagecreatefromjpeg()']=function_exists('imagecreatefromjpeg'); 00989 $sVar['imagegif()']=function_exists('imagegif'); 00990 $sVar['imagepng()']=function_exists('imagepng'); 00991 $sVar['imagejpeg()']=function_exists('imagejpeg'); 00992 $sVar['imagettftext()']=function_exists('imagettftext'); 00993 $sVar['OTHER: IMAGE_TYPES']=function_exists('imagetypes') ? imagetypes() : 0; 00994 $sVar['OTHER: memory_limit']=ini_get('memory_limit'); 00995 00996 $gE_keys = explode(',','SERVER_PORT,SERVER_SOFTWARE,GATEWAY_INTERFACE,SCRIPT_NAME,PATH_TRANSLATED'); 00997 while(list(,$k)=each($gE_keys)) { 00998 $sVar['SERVER: '.$k]=$_SERVER[$k]; 00999 } 01000 01001 $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'); 01002 while(list(,$k)=each($gE_keys)) { 01003 $sVar['T3CV_GFX: '.$k]=$GLOBALS['TYPO3_CONF_VARS']['GFX'][$k]; 01004 } 01005 01006 $debugInfo=array(); 01007 $debugInfo[]='### DEBUG SYSTEM INFORMATION - START ###'; 01008 reset($sVar); 01009 while(list($kkk,$vvv)=each($sVar)) { 01010 $debugInfo[]=str_pad(substr($kkk,0,20),20).': '.$vvv; 01011 } 01012 $debugInfo[]='### DEBUG SYSTEM INFORMATION - END ###'; 01013 01014 $buf=$this->messageFunc_nl2br; 01015 $this->messageFunc_nl2br=0; 01016 $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 /> 01017 <form action=""><textarea rows="10" '.$this->formWidthText(80,'','off').' wrap="off" class="fixed-font">'.t3lib_div::formatForTextarea(implode(chr(10),$debugInfo)).'</textarea></form>'); 01018 $this->messageFunc_nl2br=$buf; 01019 01020 $getEnvArray = array(); 01021 $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'); 01022 while(list(,$k)=each($gE_keys)) { 01023 $getEnvArray[$k] = getenv($k); 01024 } 01025 $this->message($headCode,'t3lib_div::getIndpEnv()',t3lib_div::view_array(t3lib_div::getIndpEnv('_ARRAY'))); 01026 $this->message($headCode,'getenv()',t3lib_div::view_array($getEnvArray)); 01027 $this->message($headCode,'_ENV',t3lib_div::view_array($_ENV)); 01028 $this->message($headCode,'_SERVER',t3lib_div::view_array($_SERVER)); 01029 $this->message($headCode,'_COOKIE',t3lib_div::view_array($_COOKIE)); 01030 $this->message($headCode,'_GET',t3lib_div::view_array($_GET)); 01031 01032 ob_start(); 01033 phpinfo(); 01034 $contents = explode('<body>',ob_get_contents()); 01035 ob_end_clean(); 01036 $contents = explode('</body>',$contents[1]); 01037 01038 $this->message($headCode,'phpinfo()',$contents[0]); 01039 01040 01041 01042 $this->headerStyle = ' 01043 <style type="text/css"><!-- 01044 a { text-decoration: none; } 01045 a:hover { text-decoration: underline; } 01046 h1 { font-family: verdana,arial, helvetica, sans-serif; font-size: 14pt; font-weight: bold;} 01047 h2 { font-family: verdana,arial, helvetica, sans-serif; font-size: 12pt; font-weight: bold;} 01048 body, td { font-family: verdana,arial, helvetica, sans-serif; font-size: 10pt; } 01049 th { font-family: verdana,arial, helvetica, sans-serif; font-size: 10pt; font-weight: bold; } 01050 //--></style> 01051 '; 01052 01053 echo $this->outputWrapper($this->printAll()); 01054 } 01055 01056 01057 01058 01059 01060 01061 01062 01063 01064 01065 01066 01067 01068 /******************************* 01069 * 01070 * typo3temp/ manager 01071 * 01072 *******************************/ 01073 01079 function typo3TempManager() { 01080 $headCode = 'typo3temp/ directory'; 01081 $this->message($headCode,'What is it?',' 01082 TYPO3 uses this directory for temporary files, mainly processed and cached images. 01083 The filenames are very cryptic; They are unique representations of the file properties made by md5-hashing a serialized array with information. 01084 Anyway this directory may contain many thousand files and a lot of them may be of no use anymore. 01085 01086 With this test you can delete the files in this folder. When you do that, you should also clear the cache database tables afterwards. 01087 '); 01088 01089 if (!$this->config_array['dir_typo3temp']) { 01090 $this->message('typo3temp/ directory','typo3temp/ not writable!'," 01091 You must make typo3temp/ write enabled before you can proceed with this test. 01092 ",2); 01093 echo $this->outputWrapper($this->printAll()); 01094 return; 01095 } 01096 01097 // Run through files 01098 $fileCounter = 0; 01099 $deleteCounter = 0; 01100 $criteriaMatch = 0; 01101 $tmap=array('day'=>1, 'week'=>7, 'month'=>30); 01102 $tt = $this->INSTALL['typo3temp_delete']; 01103 $subdir = $this->INSTALL['typo3temp_subdir']; 01104 if (strlen($subdir) && !ereg('^[[:alnum:]_]+/$',$subdir)) die('subdir "'.$subdir.'" was not allowed!'); 01105 $action = $this->INSTALL['typo3temp_action']; 01106 $d = @dir($this->typo3temp_path.$subdir); 01107 if (is_object($d)) { 01108 while($entry=$d->read()) { 01109 $theFile = $this->typo3temp_path.$subdir.$entry; 01110 if (@is_file($theFile)) { 01111 $ok = 0; 01112 $fileCounter++; 01113 if ($tt) { 01114 if (t3lib_div::testInt($tt)) { 01115 if (filesize($theFile) > $tt*1024) $ok=1; 01116 } else { 01117 if (fileatime($theFile) < time()-(intval($tmap[$tt])*60*60*24)) $ok=1; 01118 } 01119 } else { 01120 $ok = 1; 01121 } 01122 if ($ok) { 01123 $hashPart=substr(basename($theFile),-14,10); 01124 if (!ereg('[^a-f0-9]',$hashPart) || substr($theFile,-6)==='.cache' || substr($theFile,-4)==='.tbl' || substr(basename($theFile),0,8)==='install_') { // This is a kind of check that the file being deleted has a 10 char hash in it 01125 if ($action && $deleteCounter<$action) { 01126 $deleteCounter++; 01127 unlink($theFile); 01128 } else { 01129 $criteriaMatch++; 01130 } 01131 } 01132 } 01133 } 01134 } 01135 $d->close(); 01136 } 01137 01138 // Find sub-dirs: 01139 $subdirRegistry = array(''=>''); 01140 $d = @dir($this->typo3temp_path); 01141 if (is_object($d)) { 01142 while($entry=$d->read()) { 01143 $theFile = $entry; 01144 if (@is_dir($this->typo3temp_path.$theFile) && $theFile!='..' && $theFile!='.') { 01145 $subdirRegistry[$theFile.'/'] = $theFile.'/ (Files: '.count(t3lib_div::getFilesInDir($this->typo3temp_path.$theFile)).')'; 01146 } 01147 } 01148 } 01149 01150 $deleteType=array( 01151 '0' => 'All', 01152 'day' => 'Last access more than a day ago', 01153 'week' => 'Last access more than a week ago', 01154 'month' => 'Last access more than a month ago', 01155 '10' => 'Filesize greater than 10 kb', 01156 '50' => 'Filesize greater than 50 kb', 01157 '100' => 'Filesize greater than 100 kb' 01158 ); 01159 01160 $actionType=array( 01161 '0' => "Don't delete, just display statistics", 01162 '100' => 'Delete 100', 01163 '500' => 'Delete 500', 01164 '1000' => 'Delete 1000' 01165 ); 01166 01167 $content='<select name="TYPO3_INSTALL[typo3temp_delete]">'.$this->getSelectorOptions($deleteType,$tt).'</select> 01168 <br /> 01169 Number of files at a time: 01170 <select name="TYPO3_INSTALL[typo3temp_action]">'.$this->getSelectorOptions($actionType).'</select> 01171 01172 From sub-directory: 01173 <select name="TYPO3_INSTALL[typo3temp_subdir]">'.$this->getSelectorOptions($subdirRegistry, $this->INSTALL['typo3temp_subdir']).'</select> 01174 '; 01175 01176 $form = '<form action="'.$this->action.'" method="post">'.$content.' 01177 01178 <input type="submit" value="Execute"> 01179 </form> 01180 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.'; 01181 01182 $this->message($headCode,'Statistics',' 01183 Number of temporary files: <strong>'.($fileCounter-$deleteCounter)."</strong> 01184 Number matching '".htmlspecialchars($deleteType[$tt])."': <strong>".$criteriaMatch.'</strong> 01185 Number deleted: <strong>'.$deleteCounter.'</strong> 01186 <br /> 01187 '.$form,1); 01188 01189 echo $this->outputWrapper($this->printAll()); 01190 } 01191 01199 function getSelectorOptions($deleteType,$tt='') { 01200 $out=''; 01201 if (is_array($deleteType)) { 01202 reset($deleteType); 01203 while(list($v,$l)=each($deleteType)) { 01204 $out.='<option value="'.htmlspecialchars($v).'"'.(!strcmp($v,$tt)?' selected="selected"':'').'>'.htmlspecialchars($l).'</option>'; 01205 } 01206 } 01207 return $out; 01208 } 01209 01210 01211 01212 01213 01214 01215 01216 01217 01218 /******************************* 01219 * 01220 * cleanup manager 01221 * 01222 *******************************/ 01223 01231 function cleanupManager() { 01232 $headCode = 'Clean up database'; 01233 $this->message($headCode,'What is it?',' 01234 This function will become a general clean up manager for various tables used by TYPO3. By now you can only empty the cache which is used for storing image sizes of all pictures used in TYPO3. 01235 01236 <strong>Clear cached image sizes</strong> 01237 Clears the cache used for memorizing sizes of all images used in your website. This information is cached in order to gain performance and will be stored each time a new image is being displayed in the frontend. 01238 01239 You should <em>Clear All Cache</em> in the backend after clearing this cache. 01240 '); 01241 01242 $tables = $this->getListOfTables(); 01243 $action = $this->INSTALL['cleanup_type']; 01244 01245 if (($action == 'cache_imagesizes' || $action == 'all') && isset ($tables['cache_imagesizes'])) { 01246 $GLOBALS['TYPO3_DB']->exec_DELETEquery ('cache_imagesizes',''); 01247 } 01248 01249 $cleanupType = array ( 01250 'all' => 'Clean up everything', 01251 ); 01252 01253 // Get cache_imagesizes info 01254 if (isset ($tables['cache_imagesizes'])) { 01255 $cleanupType['cache_imagesizes'] = 'Clear cached image sizes only'; 01256 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('COUNT(*) AS icount', 'cache_imagesizes', ''); 01257 $resArr = $GLOBALS['TYPO3_DB']->sql_fetch_assoc ($res); 01258 $cachedImageSizesCounter = intval ($resArr['icount']); 01259 } else { 01260 $this->message($headCode,'Table cache_imagesizes does not exist!'," 01261 The table cache_imagesizes was not found. Please check your database settings in Basic Configuration and compare your table definition with the Database Analyzer. 01262 ",2); 01263 $cachedImageSizesCounter = 'unknown'; 01264 } 01265 01266 $content = '<select name="TYPO3_INSTALL[cleanup_type]">'.$this->getSelectorOptions($cleanupType).'</select> '; 01267 $form = '<form action="'.$this->action.'" method="post">'.$content.'<input type="submit" value="Execute"></form>'; 01268 $this->message($headCode,'Statistics',' 01269 Number cached image sizes: <strong>'.$cachedImageSizesCounter.'</strong><br /> 01270 '.$form,1); 01271 01272 echo $this->outputWrapper($this->printAll()); 01273 } 01274 01275 01276 01277 01278 01279 01280 01281 01282 01283 01284 01285 01286 01287 /******************************* 01288 * 01289 * CONFIGURATION FORM 01290 * 01291 ********************************/ 01292 01299 function generateConfigForm($type='') { 01300 $default_config_content = t3lib_div::getUrl(PATH_t3lib.'config_default.php'); 01301 $commentArr = $this->getDefaultConfigArrayComments($default_config_content); 01302 01303 switch($type) { 01304 case 'get_form': 01305 reset($GLOBALS['TYPO3_CONF_VARS']); 01306 $this->messageFunc_nl2br=0; 01307 while(list($k,$va)=each($GLOBALS['TYPO3_CONF_VARS'])) { 01308 $ext='['.$k.']'; 01309 $this->message($ext, '$TYPO3_CONF_VARS[\''.$k.'\']',$commentArr[0][$k],1); 01310 01311 while(list($vk,$value)=each($va)) { 01312 $description = trim($commentArr[1][$k][$vk]); 01313 $isTextarea = preg_match('/^string \(textarea\)/i',$description) ? TRUE : FALSE; 01314 01315 if (!is_array($value) && ($this->checkForBadString($value) || $isTextarea)) { 01316 $k2='['.$vk.']'; 01317 $msg=$description.'<br /><br /><em>'.$ext.$k2.' = '.htmlspecialchars(t3lib_div::fixed_lgd($value,60)).'</em><br />'; 01318 01319 if ($isTextarea) { 01320 $form='<textarea name="TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']" cols="60" rows="5" wrap="off">'.htmlspecialchars($value).'</textarea>'; 01321 } elseif (preg_match('/^boolean/i',$description)) { 01322 $form='<input type="hidden" name="TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']" value="0">'; 01323 $form.='<input type="checkbox" name="TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']"'.($value?' checked="checked"':'').' value="'.($value&&strcmp($value,'0')?htmlspecialchars($value):1).'">'; 01324 } else { 01325 $form='<input type="text" size="40" name="TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']" value="'.htmlspecialchars($value).'">'; 01326 } 01327 $this->message($ext, $k2,$msg.$form); 01328 } 01329 } 01330 } 01331 break; 01332 default: 01333 if (is_array($this->INSTALL['extConfig'])) { 01334 reset($this->INSTALL['extConfig']); 01335 $lines = $this->writeToLocalconf_control(); 01336 while(list($k,$va)=each($this->INSTALL['extConfig'])) { 01337 if (is_array($GLOBALS['TYPO3_CONF_VARS'][$k])) { 01338 while(list($vk,$value)=each($va)) { 01339 if (isset($GLOBALS['TYPO3_CONF_VARS'][$k][$vk])) { 01340 $doit=1; 01341 if ($k=='BE' && $vk=='installToolPassword') { 01342 if ($value) { 01343 if (isset($_POST['installToolPassword_check']) && (!t3lib_div::_GP('installToolPassword_check') || strcmp(t3lib_div::_GP('installToolPassword_check'),$value))) { 01344 $doit=0; 01345 t3lib_div::debug('ERROR: The two passwords did not match! The password was not changed.'); 01346 } 01347 if (t3lib_div::_GP('installToolPassword_md5')) $value =md5($value); 01348 } else $doit=0; 01349 } 01350 01351 $description = trim($commentArr[1][$k][$vk]); 01352 if (preg_match('/^string \(textarea\)/i', $description)) { 01353 $value = str_replace(chr(13),'',$value); // Force Unix linebreaks in textareas 01354 $value = str_replace(chr(10),"'.chr(10).'",$value); // Preserve linebreaks 01355 } 01356 01357 if ($doit && strcmp($GLOBALS['TYPO3_CONF_VARS'][$k][$vk],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\''.$k.'\'][\''.$vk.'\']', $value); 01358 } 01359 } 01360 } 01361 } 01362 $this->writeToLocalconf_control($lines); 01363 } 01364 break; 01365 } 01366 } 01367 01376 function getDefaultConfigArrayComments($string,$mainArray=array(),$commentArray=array()) { 01377 $lines = explode(chr(10),$string); 01378 $in=0; 01379 $mainKey=''; 01380 while(list(,$lc)=each($lines)) { 01381 $lc = trim($lc); 01382 if ($in) { 01383 if (!strcmp($lc,');')) { 01384 $in=0; 01385 } else { 01386 if (preg_match('/["\']([[:alnum:]_-]*)["\'][[:space:]]*=>(.*)/i',$lc,$reg)) { 01387 preg_match('/,[\t\s]*\/\/(.*)/i',$reg[2],$creg); 01388 $theComment = trim($creg[1]); 01389 if (substr(strtolower(trim($reg[2])),0,5)=='array' && !strcmp($reg[1],strtoupper($reg[1]))) { 01390 $mainKey=trim($reg[1]); 01391 $mainArray[$mainKey]=$theComment; 01392 } elseif ($mainKey) { 01393 $commentArray[$mainKey][$reg[1]]=$theComment; 01394 } 01395 } 01396 } 01397 } 01398 if (!strcmp($lc,'$TYPO3_CONF_VARS = Array(')) { 01399 $in=1; 01400 } 01401 } 01402 return array($mainArray,$commentArray); 01403 } 01404 01405 01406 01407 01408 01409 01410 01411 01412 01413 01414 01415 01416 01417 /******************************* 01418 * 01419 * CHECK CONFIGURATION FUNCTIONS 01420 * 01421 *******************************/ 01422 01428 function checkConfiguration() { 01429 $ext='php.ini configuration checked'; 01430 $this->message($ext); 01431 01432 // ***************** 01433 // Incoming values: 01434 // ***************** 01435 01436 // Includepath 01437 $incPaths = t3lib_div::trimExplode(TYPO3_OS=='WIN'?';':':', ini_get('include_path')); 01438 if (!in_array('.',$incPaths)) { 01439 $this->message($ext, 'Current dir (./) is not in include path!'," 01440 <i>include_path=".ini_get('include_path')."</i> 01441 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. 01442 ",1); 01443 } else $this->message($ext, 'Current dir in include path',"",-1); 01444 01445 // ***************** 01446 // File uploads 01447 // ***************** 01448 if (!ini_get('file_uploads')) { 01449 $this->message($ext, 'File uploads not allowed'," 01450 <i>file_uploads=".ini_get('file_uploads')."</i> 01451 TYPO3 uses the ability to upload files from the browser in various cases. 01452 As long as this flag is disabled, you'll not be able to upload files. 01453 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! 01454 However if you cannot enable fileupload for some reason alternatively you change the default form encoding value with \$TYPO3_CONF_VARS[SYS][form_enctype]. 01455 ",3); 01456 } else $this->message($ext, 'File uploads allowed',"",-1); 01457 $upload_max_filesize = $this->convertByteSize(ini_get('upload_max_filesize')); 01458 if ($upload_max_filesize<10000*1024) { 01459 $this->message($ext, 'Max Upload filesize too small?'," 01460 <i>upload_max_filesize=".ini_get('upload_max_filesize')."</i> 01461 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]). 01462 Your current value is below this, so at this point, PHP sets the limits for uploaded filesizes and not TYPO3. 01463 <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. 01464 ",1); 01465 } 01466 01467 // ***************** 01468 // Memory and functions 01469 // ***************** 01470 $memory_limit_value = $this->convertByteSize(ini_get('memory_limit')); 01471 if ($memory_limit_value && $memory_limit_value < 16*1024*1024) { 01472 $this->message($ext, 'Memory Limit below 16 MB'," 01473 <i>memory_limit=".ini_get('memory_limit')."</i> 01474 Your system is configured to enforce a memory limit of PHP scripts lower than 16 MB. The Extension Manager needs to include more PHP-classes than will fit into this memory space. There is nothing else to do than raise the limit. To be safe, ask the system administrator of the webserver to raise the limit to over 25 MB. 01475 ",3); 01476 } elseif(!$memory_limit_value) { 01477 $this->message($ext, 'Memory Limit',"<i>No Memory Limit in effect.</i>",-1); 01478 } else $this->message($ext, 'Memory Limit',"<i>memory_limit=".ini_get('memory_limit')."</i>",-1); 01479 if (ini_get('max_execution_time')<30) { 01480 $this->message($ext, 'Max Execution Time below default 30 seconds'," 01481 <i>max_execution_time=".ini_get('max_execution_time')."</i> 01482 May impose problems if too low. 01483 ",1); 01484 } else $this->message($ext, 'Max Execution Time',"<i>max_execution_time=".ini_get('max_execution_time')."</i>",-1); 01485 if (ini_get('disable_functions')) { 01486 $this->message($ext, 'Functions disabled!'," 01487 <i>disable_functions=".ini_get('disable_functions')."</i> 01488 The above list of functions are disabled. If TYPO3 use any of these there might be trouble. 01489 TYPO3 is designed to use the default set of PHP4.0.6+ functions plus the functions from GDLib. 01490 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. 01491 ",2); 01492 } else $this->message($ext, 'Functions disabled: none',"",-1); 01493 if (!ini_get('sendmail_path')) { 01494 $this->message($ext, 'Sendmail path not defined!'," 01495 <i>sendmail_path=".ini_get('sendmail_path')."</i> 01496 This may be critical to TYPO3's use of the mail() function. Please be sure that the mail() function in your php-installation works! 01497 ".$this->check_mail('get_form'),1); 01498 } else { 01499 list($prg) = explode(' ',ini_get('sendmail_path')); 01500 if (TYPO3_OS=='WIN') { 01501 $this->message($ext, 'Sendmail program not searched for on Windows',"",1); 01502 } else { 01503 if (!@is_executable($prg)) { 01504 $this->message($ext, 'Sendmail program not found or not executable?'," 01505 <i>sendmail_path=".ini_get('sendmail_path')."</i> 01506 This may be critical to TYPO3's use of the mail() function. Please be sure that the mail() function in your php-installation works! 01507 ".$this->check_mail('get_form'),1); 01508 } else { 01509 $this->message($ext, 'Sendmail OK'," 01510 <i>sendmail_path=".ini_get('sendmail_path').'</i> 01511 You may check the mail() function by entering your emailaddress here: 01512 '.$this->check_mail('get_form'),-1); 01513 } 01514 } 01515 } 01516 01517 // ***************** 01518 // Safe mode related 01519 // ***************** 01520 if (ini_get('safe_mode')) { 01521 $this->message($ext, 'Safe mode turned on'," 01522 <i>safe_mode=".ini_get('safe_mode')."</i> 01523 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. 01524 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/\". 01525 If you use safe_mode with TYPO3, you should disable use of external programs ([BE][disable_exec_function]=1). 01526 In safe mode you must ensure that all the php-scripts and upload folders are owned by the same user. 01527 01528 <i>safe_mode_exec_dir=".ini_get('safe_mode_exec_dir')."</i> 01529 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) 01530 01531 01532 <strong>Example of safe_mode settings:</strong> 01533 Set this in the php.ini file: 01534 01535 ; Safe Mode 01536 safe_mode = On 01537 safe_mode_exec_dir = /usr/bin/ 01538 01539 ...and the ImageMagick '/usr/bin/convert' will be executable. 01540 The last slash is important (..../) and you can only specify one directory. 01541 01542 <strong>Notice: </strong> 01543 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. 01544 Paths to ImageMagick are defined in localconf.php and may be something else than /usr/bin/, but this is default for ImageMagick 5+ 01545 01546 01547 ",2); 01548 if (ini_get('doc_root')) { 01549 $this->message($ext, 'doc_root set'," 01550 <i>doc_root=".ini_get('doc_root')."</i> 01551 PHP cannot execute scripts outside this directory. If that is a problem is please correct it. 01552 ",1); 01553 } 01554 $this->config_array['safemode']=1; 01555 } else $this->message($ext, 'safe_mode: off',"",-1); 01556 if (ini_get('sql.safe_mode')) { 01557 $this->message($ext, 'sql.safe_mode is enabled'," 01558 <i>sql.safe_mode=".ini_get('sql.safe_mode').'</i> 01559 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').' 01560 The owner of the current file is: <strong>'.get_current_user ()."</strong> 01561 ",1); 01562 $this->config_array['sql.safe_mode_user'] = get_current_user(); 01563 } else $this->message($ext, 'sql.safe_mode: off',"",-1); 01564 if (ini_get('open_basedir')) { 01565 $this->message($ext, 'open_basedir set'," 01566 <i>open_basedir=".ini_get('open_basedir')."</i> 01567 This restricts TYPO3 to open and include files only in this path. Please make sure that this does not prevent TYPO3 from running. 01568 <strong>Notice (UNIX):</strong> Before checking a path according to open_basedir, PHP resolves all symbolic links. 01569 ",1); 01570 // ???? If this option was set falsely you probably didn't see this page in the first place, but this option <strong>may spoil this configuration test</strong> when checking for such as ImageMagick executables. 01571 } else $this->message($ext, 'open_basedir: off',"",-1); 01572 01573 } 01574 01581 function check_mail($cmd='') { 01582 switch($cmd) { 01583 case 'get_form': 01584 $out=' 01585 You can check the mail() function by entering your email address here and press the button. You should then receive a testmail from test@test.test.<br /> Since almost all mails in TYPO3 are sent using the t3lib_htmlmail class, sending with this class can be tested by checking the box <strong>Test t3lib_htmlmail</strong> below. The return-path of the mail is set to null@'.t3lib_div::getIndpEnv('HTTP_HOST').'. Some mail servers won\'t send the mail if the host of the return-path is not resolved correctly. 01586 <form action="'.$this->action.'" method="post"><input type="text" name="TYPO3_INSTALL[check_mail]"><br /><input type="checkbox" name="TYPO3_INSTALL[use_htmlmail]" >Test t3lib_htmlmail. 01587 <input type="submit" value="Send test mail"></form>'; 01588 break; 01589 default: 01590 if (trim($this->INSTALL['check_mail'])) { 01591 $subject = 'TEST SUBJECT'; 01592 $email = trim($this->INSTALL['check_mail']); 01593 01594 if($this->INSTALL['use_htmlmail']) { 01595 require_once (PATH_t3lib.'class.t3lib_htmlmail.php'); 01596 $emailObj = t3lib_div::makeInstance('t3lib_htmlmail'); 01597 $emailObj->start(); 01598 $emailObj->subject = $subject; 01599 $emailObj->from_email = 'test@test.test'; 01600 $emailObj->from_name = 'TYPO3 Install Tool'; 01601 $emailObj->returnPath = 'null@'.t3lib_div::getIndpEnv('HTTP_HOST'); 01602 $emailObj->addPlain('TEST CONTENT'); 01603 $emailObj->setHTML($emailObj->encodeMsg('<html><body>HTML TEST CONTENT</body></html>')); 01604 $emailObj->send($email); 01605 } else { 01606 t3lib_div::plainMailEncoded($email,$subject,'TEST CONTENT','From: test@test.test'); 01607 } 01608 $this->messages[]= 'MAIL WAS SENT TO: '.$email; 01609 } 01610 break; 01611 } 01612 return $out; 01613 } 01614 01620 function checkExtensions() { 01621 $ext = 'GDLib'; 01622 $this->message($ext); 01623 01624 $software_info=1; 01625 if (extension_loaded('gd') && $this->isGD()) { 01626 $this->config_array['gd']=1; 01627 $this->message($ext, 'GDLib found',"",-1); 01628 if ($this->isPNG()) { 01629 $this->config_array['gd_png']=1; 01630 $this->message($ext, 'PNG supported',"",-1); 01631 } 01632 if ($this->isGIF()) { 01633 $this->config_array['gd_gif']=1; 01634 $this->message($ext, 'GIF supported',"",-1); 01635 } 01636 if ($this->isJPG()) { 01637 $this->config_array['gd_jpg']=1; 01638 $this->message($ext, 'JPG supported (not used by TYPO3)',''); 01639 } 01640 if (!$this->config_array['gd_gif'] && !$this->config_array['gd_png']) { 01641 $this->message($ext, 'PNG or GIF not supported', nl2br(trim(' 01642 Your GDLib supports either GIF nor PNG. It must support either one of them. 01643 ')), 2); 01644 } else { 01645 $msg=array(); 01646 if ($this->config_array['gd_gif'] && $this->config_array['gd_png']) { 01647 $msg[0]='You can choose between generating GIF or PNG files, as your GDLib supports both.'; 01648 } 01649 if ($this->config_array['gd_gif']) { 01650 $msg[10]="You should watch out for the generated size of the GIF-files because some versions of the GD library do not compress them with LZW, but RLE and ImageMagick is subsequently used to compress with LZW. But in the case of ImageMagick failing this task (eg. not being compiled with LZW which is the case with some versions) you'll end up with GIF-filesizes all too big! 01651 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."; 01652 } 01653 if ($this->config_array['gd_png']) { 01654 $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.'; 01655 } 01656 $this->message($ext, 'GIF / PNG issues', nl2br(trim(implode($msg,chr(10)))), 1); 01657 } 01658 if (!$this->isTTF()) { 01659 $this->message($ext, 'FreeType is apparently not installed', " 01660 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'. 01661 ", 2); 01662 } else { 01663 $this->message($ext, 'FreeType Quick-test ('.($this->isGIF()?'as GIF':'as PNG').')', '<img src="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI').'&testingTrueTypeSupport=1').'" alt=""><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); 01664 $this->config_array['freetype']=1; 01665 } 01666 } else { 01667 $this->message($ext, 'GDLib not found', " 01668 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. 01669 GDLib is also used in the TYPO3 Backend (TBE) to generate record icons and new module tabs. 01670 It's highly recommended to install this library. Remember to compile GD with FreeType which is also required. 01671 If you choose not to install GDLib, you can disable it in the configuration with [GFX][gdlib]=0;. 01672 ", 2); 01673 } 01674 $this->message($ext, 'GDLib software information', nl2br(trim($this->getGDSoftwareInfo()))); 01675 } 01676 01682 function checkDirs() { 01683 // Check typo3/temp/ 01684 $ext='Directories'; 01685 $this->message($ext); 01686 01687 $uniqueName = md5(uniqid(microtime())); 01688 01689 // The requirement level (the integer value, ie. the second value of the value array) has the following meanings: 01690 // -1 = not required, but if it exists may be writable or not 01691 // 0 = not required, if it exists the dir should be writable 01692 // 1 = required, don't has to be writable 01693 // 2 = required, has to be writable 01694 01695 $checkWrite=array( 01696 'typo3temp/' => array('This folder is used by both the frontend (FE) and backend (BE) interface for image manipulated files.',2,'dir_typo3temp'), 01697 'typo3temp/pics/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'), 01698 'typo3temp/temp/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'), 01699 'typo3temp/llxml/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'), 01700 'typo3temp/cs/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'), 01701 'typo3temp/GB/' => array('This folder is part of the typo3temp/ section. It needs to be writable, too.',2,'dir_typo3temp'), 01702 'typo3conf/' => array('This directory contains the local configuration files of your website. TYPO3 must be able to write to these configuration files during setup and when the Extension Manager (EM) installs extensions.',2), 01703 'typo3conf/ext/' => array('Location for local extensions. Must be writable if the Extension Manager is supposed to install extensions for this website.',0), 01704 'typo3conf/l10n/' => array('Location for translations. Must be writable if the Extension Manager is supposed to install translations for extensions.',0), 01705 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), 01706 'uploads/' => array('Location for uploaded files from RTE + in the subdirs for tables.',2), 01707 'uploads/pics/' => array('Typical location for uploaded files (images especially).',0), 01708 'uploads/media/' => array('Typical location for uploaded files (non-images especially).',0), 01709 'uploads/tf/' => array('Typical location for uploaded files (TS template resources).',0), 01710 'fileadmin/' => array('Location for local files such as templates, independent uploads etc.',-1), 01711 'fileadmin/_temp_/' => array('Typical temporary location for default upload of files by administrators.',0), 01712 ); 01713 01714 foreach ($checkWrite as $relpath => $descr) { 01715 // Check typo3temp/ 01716 $general_message = $descr[0]; 01717 if (!@is_dir(PATH_site.$relpath)) { 01718 if ($descr[1]) { // required... 01719 $this->message($ext, $relpath.' directory does not exist',' 01720 <em>Full path: '.PATH_site.$relpath.'</em> 01721 '.$general_message.' 01722 01723 This error should not occur as '.$relpath.' must always be accessible in the root of a TYPO3 website. 01724 ',3); 01725 } else { 01726 if ($descr[1] == 0) { 01727 $msg = 'This directory does not necessarily have to exist but if it does it must be writable.'; 01728 } else { 01729 $msg = 'This directory does not necessarily have to exist and if it does it can be writable or not.'; 01730 } 01731 $this->message($ext, $relpath.' directory does not exist',' 01732 <em>Full path: '.PATH_site.$relpath.'</em> 01733 '.$general_message.' 01734 01735 '.$msg.' 01736 ',2); 01737 } 01738 } else { 01739 $file = PATH_site.$relpath.$uniqueName; 01740 @touch($file); 01741 if (@is_file($file)) { 01742 unlink($file); 01743 if ($descr[2]) { $this->config_array[$descr[2]]=1; } 01744 $this->message($ext, $relpath.' writable','',-1); 01745 } else { 01746 $severity = ($descr[1]==2 || $descr[1]==0) ? 3 : 2; 01747 if ($descr[1] == 0 || $descr[1] == 2) { 01748 $msg = 'The directory '.$relpath.' must be writable!'; 01749 } elseif ($descr[1] == -1 || $descr[1] == 1) { 01750 $msg = 'The directory '.$relpath.' does not neccesarily have to be writable.'; 01751 } 01752 $this->message($ext, $relpath.' directory not writable',' 01753 <em>Full path: '.$file.'</em> 01754 '.$general_message.' 01755 01756 Tried to write this file (with touch()) but didn\'t succeed. 01757 '.$msg.' 01758 ',$severity); 01759 } 01760 } 01761 } 01762 } 01763 01772 function checkImageMagick($paths) { 01773 $ext='Check Image Magick'; 01774 $this->message($ext); 01775 01776 $paths = array_unique($paths); 01777 01778 $programs = explode(',','gm,convert,combine,composite,identify'); 01779 $isExt = TYPO3_OS=="WIN" ? ".exe" : ""; 01780 $this->config_array['im_combine_filename']='combine'; 01781 reset($paths); 01782 while(list($k,$v)=each($paths)) { 01783 reset($programs); 01784 if (!ereg('[\\\/]$',$v)) $v.='/'; 01785 while(list(,$filename)=each($programs)) { 01786 if (ini_get('open_basedir') || (@file_exists($v)&&@is_file($v.$filename.$isExt))) { 01787 $version = $this->_checkImageMagick_getVersion($filename,$v); 01788 if($version > 0) { 01789 if($filename=='gm') { // Assume GraphicsMagick 01790 $index[$v]['gm']=$version; 01791 continue; // No need to check for "identify" etc. 01792 } else { // Assume ImageMagick 01793 $index[$v][$filename]=$version; 01794 } 01795 } 01796 } 01797 } 01798 if (count($index[$v])>=3 || $index[$v]['gm']) { $this->config_array['im']=1; } 01799 01800 if ($index[$v]['gm'] || (!$index[$v]['composite'] && $index[$v]['combine'])) { 01801 $this->config_array['im_combine_filename']='combine'; 01802 } elseif ($index[$v]['composite'] && !$index[$v]['combine']) { 01803 $this->config_array['im_combine_filename']='composite'; 01804 } 01805 01806 if (isset($index[$v]['convert']) && $this->checkIMlzw) { 01807 $index[$v]['gif_capability'] = ''.$this->_checkImageMagickGifCapability($v); 01808 } 01809 } 01810 $this->config_array['im_versions']=$index; 01811 if (!$this->config_array['im']) { 01812 $this->message($ext, 'No ImageMagick install available'," 01813 It seems that there is no adequate ImageMagick installation available at the checked locations (".implode($paths, ', ').") 01814 An 'adequate' installation for requires 'convert', 'combine'/'composite' and 'identify' to be available 01815 ",2); 01816 } else { 01817 $theCode=''; 01818 reset($this->config_array['im_versions']); 01819 while(list($p,$v)=each($this->config_array['im_versions'])) { 01820 $ka=array(); 01821 reset($v); 01822 while(list($ka[])=each($v)){} 01823 $theCode.='<tr><td>'.$this->fw($p).'</td><td>'.$this->fw(implode($ka,'<br />')).'</td><td>'.$this->fw(implode($v,'<br />')).'</td></tr>'; 01824 } 01825 $this->message($ext, 'Available ImageMagick/GraphicsMagick installations:','<table border="1" cellpadding="2" cellspacing="2">'.$theCode.'</table>',-1); 01826 } 01827 $this->message($ext, 'Search for ImageMagick:',' 01828 <form action="'.$this->action.'" method="post"> 01829 <input type="checkbox" name="TYPO3_INSTALL[checkIM][lzw]" value="1"'.($this->INSTALL['checkIM']['lzw']?' checked="checked"':'').'> Check LZW capabilities. 01830 01831 Check this path for ImageMagick installation: 01832 <input type="text" name="TYPO3_INSTALL[checkIM][path]" value="'.htmlspecialchars($this->INSTALL['checkIM']['path']).'"> 01833 (Eg. "D:\wwwroot\im537\ImageMagick\" for windows or "/usr/bin/" for Unix)<br /> 01834 01835 <input type="submit" value="Send"> 01836 </form> 01837 ',0); 01838 01839 } 01840 01847 function _checkImageMagickGifCapability($path) { 01848 if ($this->config_array['dir_typo3temp']) { // && !$this->config_array['safemode'] 01849 $tempPath = $this->typo3temp_path; 01850 $uniqueName = md5(uniqid(microtime())); 01851 $dest = $tempPath.$uniqueName.'.gif'; 01852 $src = $this->backPath.'gfx/typo3logo.gif'; 01853 if (@is_file($src) && !strstr($src,' ') && !strstr($dest,' ')) { 01854 $cmd = t3lib_div::imageMagickCommand('convert', $src.' '.$dest, $path); 01855 exec($cmd); 01856 } else die('No typo3/gfx/typo3logo.gif file!'); 01857 $out=''; 01858 if (@is_file($dest)) { 01859 $new_info = @getimagesize($dest); 01860 clearstatcache(); 01861 $new_size = filesize($dest); 01862 $src_info = @getimagesize($src); 01863 clearstatcache(); 01864 $src_size = @filesize($src); 01865 01866 if ($new_info[0]!=$src_info[0] || $new_info[1]!=$src_info[1] || !$new_size || !$src_size) { 01867 $out='error'; 01868 } else { 01869 if ($new_size/$src_size > 4) { // NONE-LZW ratio was 5.5 in test 01870 $out='NONE'; 01871 } elseif ($new_size/$src_size > 1.5) { // NONE-RLE ratio was not tested 01872 $out='RLE'; 01873 } else { 01874 $out='LZW'; 01875 } 01876 } 01877 unlink($dest); 01878 } 01879 return $out; 01880 } 01881 } 01882 01890 function _checkImageMagick_getVersion($file, $path) { 01891 // Temporarily override some settings 01892 $im_version = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']; 01893 $combine_filename = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_combine_filename']; 01894 01895 if ($file=='gm') { 01896 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] = 'gm'; 01897 $file = 'identify'; // Work-around, preventing execution of "gm gm" 01898 $parameters = '-version'; // Work-around - GM doesn't like to be executed without any arguments 01899 } else { 01900 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] = 'im5'; 01901 01902 if($file=='combine' || $file=='composite') { // Override the combine_filename setting 01903 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_combine_filename'] = $file; 01904 } 01905 } 01906 01907 $cmd = t3lib_div::imageMagickCommand($file, $parameters, $path); 01908 $retVal = false; 01909 exec($cmd, $retVal); 01910 $string = $retVal[0]; 01911 list(,$ver) = explode('Magick', $string); 01912 list($ver) = explode(' ',trim($ver)); 01913 01914 // Restore the values 01915 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] = $im_version; 01916 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_combine_filename'] = $combine_filename; 01917 return trim($ver); 01918 } 01919 01925 function checkDatabase() { 01926 $ext='Check database'; 01927 $this->message($ext); 01928 01929 if (!extension_loaded('mysql') && !t3lib_extMgm::isLoaded('dbal')) { 01930 $this->message($ext, 'MySQL not available'," 01931 PHP does not feature MySQL support (which is pretty unusual). 01932 ",2); 01933 } else { 01934 $cInfo=' 01935 Username: <strong>'.TYPO3_db_username.'</strong> 01936 Password: <strong>'.TYPO3_db_password.'</strong> 01937 Host: <strong>'.TYPO3_db_host.'</strong> 01938 '; 01939 if (!TYPO3_db_host || !TYPO3_db_username) { 01940 $this->message($ext, 'Username, password or host not set'," 01941 You may need to enter data for these values: 01942 ".trim($cInfo)." 01943 01944 Use the form below. 01945 ",2); 01946 } 01947 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { 01948 $this->message($ext, 'Connected to SQL database successfully'," 01949 ".trim($cInfo)." 01950 ",-1,1); 01951 $this->config_array['mysqlConnect']=1; 01952 if (!TYPO3_db) { 01953 $this->message($ext, 'No database selected'," 01954 Currently you have no database selected. 01955 Please select one or create a new database. 01956 ",3); 01957 $this->config_array['no_database']=1; 01958 } elseif (!$GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) { 01959 $this->message($ext, 'Database'," 01960 '".TYPO3_db."' could not be selected as database! 01961 Please select another one or create a new database. 01962 ",3,1); 01963 $this->config_array['no_database']=1; 01964 } else { 01965 $this->message($ext, 'Database'," 01966 <strong>".TYPO3_db."</strong> is selected as database. 01967 ",1,1); 01968 } 01969 } else { 01970 $this->message($ext, 'Could not connect to SQL database!'," 01971 Connecting to SQL database failed with these settings: 01972 ".trim($cInfo)." 01973 01974 Make sure you're using the correct set of data.".($this->config_array['sql.safe_mode_user']? " 01975 <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']."'":"")." 01976 ",3); 01977 } 01978 } 01979 } 01980 01987 function setupGeneral($cmd='') { 01988 switch($cmd) { 01989 case 'get_form': 01990 // Database: 01991 $out=' 01992 <form name="setupGeneral" action="'.$this->action.'" method="post"> 01993 <table border="0" cellpadding="0" cellspacing="0">'; 01994 01995 $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>":"")); 01996 $out.=$this->wrapInCells('Password:', '<input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_password]" value="'.htmlspecialchars(TYPO3_db_password).'">'); 01997 $out.=$this->wrapInCells('Host:', '<input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_host]" value="'.htmlspecialchars(TYPO3_db_host).'">'); 01998 if ($this->config_array['mysqlConnect']) { 01999 $dbArr = $this->getDatabaseList(); 02000 reset($dbArr); 02001 $options=''; 02002 $dbIncluded=0; 02003 while(list(,$dbname)=each($dbArr)) { 02004 $options.='<option value="'.htmlspecialchars($dbname).'"'.($dbname==TYPO3_db?' selected="selected"':'').'>'.htmlspecialchars($dbname).'</option>'; 02005 if ($dbname==TYPO3_db) $dbIncluded=1; 02006 } 02007 if (!$dbIncluded && TYPO3_db) { 02008 $options.='<option value="'.htmlspecialchars(TYPO3_db).'" selected="selected">'.htmlspecialchars(TYPO3_db).' (NO ACCESS!)</option>'; 02009 } 02010 $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="">'; 02011 } else { 02012 $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).'">'; 02013 } 02014 $out.=$this->wrapInCells('', '<br />'); 02015 $out.=$this->wrapInCells('Database:', $theCode); 02016 $out.=$this->wrapInCells('', '<br />'); 02017 02018 if ($this->mode!='123') { 02019 $out.=$this->wrapInCells('Site name:', '<input type="text" name="TYPO3_INSTALL[localconf.php][sitename]" value="'.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']).'">'); 02020 $out.=$this->wrapInCells('', '<br />'); 02021 $out.='<script type="text/javascript" src="../md5.js"></script><script type="text/javascript">function generateEncryptionKey(key) {time=new Date(); key=MD5(time.getMilliseconds().toString());while(key.length<66){key=key+MD5(key)};return key;}</script>'; 02022 $out.=$this->wrapInCells('Encryption key:', '<a name="set_encryptionKey"></a><input type="text" name="TYPO3_INSTALL[localconf.php][encryptionKey]" value="'.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']).'"><br /><input type="button" onclick="document.forms[\'setupGeneral\'].elements[\'TYPO3_INSTALL[localconf.php][encryptionKey]\'].value=generateEncryptionKey(document.forms[\'setupGeneral\'].elements[\'TYPO3_INSTALL[localconf.php][encryptionKey]\'].value);" value="Generate random key">'); 02023 $out.=$this->wrapInCells('', '<br />'); 02024 02025 // Other 02026 $fA = $this->setupGeneralCalculate(); 02027 02028 if (is_array($fA['disable_exec_function'])) { 02029 $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'])); 02030 } 02031 if (is_array($fA['gdlib'])) { 02032 $out.=$this->wrapInCells('[GFX][gdlib]=', $this->getFormElement($fA['gdlib'], $fA['gdlib'], 'TYPO3_INSTALL[localconf.php][gdlib]', $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'])); 02033 if (is_array($fA['gdlib_png']) && $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) { 02034 $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'])); 02035 } 02036 } 02037 if (is_array($fA['im'])) { 02038 $out.=$this->wrapInCells('[GFX][im]=', $this->getFormElement($fA['im'], $fA['im'], 'TYPO3_INSTALL[localconf.php][im]', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im'])); 02039 $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'])); 02040 $out.=$this->wrapInCells('[GFX][im_version_5]=', $this->getFormElement($fA['im_version_5'], ($fA['im_version_5']?$fA['im_version_5']:''), 'TYPO3_INSTALL[localconf.php][im_version_5]', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'])); 02041 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) { 02042 if (is_array($fA['im_path'])) { 02043 $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'])); 02044 } 02045 if (is_array($fA['im_path_lzw'])) { 02046 $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'])); 02047 } 02048 } 02049 } 02050 $out.=$this->wrapInCells('[GFX][TTFdpi]=', '<input type="text" name="TYPO3_INSTALL[localconf.php][TTFdpi]" value="'.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['GFX']['TTFdpi']).'">'); 02051 } 02052 02053 02054 $out.=$this->wrapInCells('', '<br /><input type="submit" value="Update localconf.php"><br /> 02055 <strong>NOTICE: </strong>By clicking this button, localconf.php is updated with new values for the parameters listed above!'); 02056 $out.=' 02057 </table> 02058 </form>'; 02059 break; 02060 default: 02061 if (is_array($this->INSTALL['localconf.php'])) { 02062 $errorMessages=array(); 02063 $lines = $this->writeToLocalconf_control(); 02064 02065 // New database? 02066 #debug($this->INSTALL); 02067 if (trim($this->INSTALL['localconf.php']['NEW_DATABASE_NAME'])) { 02068 $newdbname=trim($this->INSTALL['localconf.php']['NEW_DATABASE_NAME']); 02069 if (!ereg('[^[:alnum:]_-]',$newdbname)) { 02070 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { 02071 if ($GLOBALS['TYPO3_DB']->admin_query('CREATE DATABASE '.$newdbname)) { 02072 $this->INSTALL['localconf.php']['typo_db'] = $newdbname; 02073 $this->messages[]= "Database '".$newdbname."' created"; 02074 } else $this->messages[]= $errorMessages[] = "Could not create database '".$newdbname."' (...not created)"; 02075 } else $this->messages[]= $errorMessages[] = "Could not connect to database when creating database '".$newdbname."' (...not created)"; 02076 } else $this->messages[]= $errorMessages[] = "The NEW database name '".$newdbname."' was not alphanumeric, a-zA-Z0-9_- (...not created)"; 02077 } 02078 #debug($this->messages) ; 02079 // Parsing values 02080 reset($this->INSTALL['localconf.php']); 02081 while(list($key,$value)=each($this->INSTALL['localconf.php'])) { 02082 switch((string)$key) { 02083 case 'typo_db_username': 02084 if (strlen($value)<50) { 02085 if (strcmp(TYPO3_db_username,$value)) $this->setValueInLocalconfFile($lines, '$typo_db_username', trim($value)); 02086 } else $this->messages[]= $errorMessages[] = "Username '".$value."' was longer than 50 chars (...not saved)"; 02087 break; 02088 case 'typo_db_password': 02089 if (strlen($value)<50) { 02090 if (strcmp(TYPO3_db_password,$value)) $this->setValueInLocalconfFile($lines, '$typo_db_password', trim($value)); 02091 } else $this->messages[]= $errorMessages[] = "Password '".$value."' was longer than 50 chars (...not saved)"; 02092 break; 02093 case 'typo_db_host': 02094 if (!ereg("[^[:alnum:]_\.:-]",$value) && strlen($value)<50) { 02095 if (strcmp(TYPO3_db_host,$value)) $this->setValueInLocalconfFile($lines, '$typo_db_host', $value); 02096 } else $this->messages[]= $errorMessages[] = "Host '".$value."' was not alphanumeric, a-zA-Z0-9_-:., or longer than 50 chars (...not saved)"; 02097 break; 02098 case 'typo_db': 02099 if (strlen($value)<50) { 02100 if (strcmp(TYPO3_db,$value)) $this->setValueInLocalconfFile($lines, '$typo_db', trim($value)); 02101 } else $this->messages[]= $errorMessages[] = "Database name '".$value."' was longer than 50 chars (...not saved)"; 02102 break; 02103 case 'disable_exec_function': 02104 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['BE']['disable_exec_function'],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'BE\'][\'disable_exec_function\']', $value?1:0); 02105 break; 02106 case 'sitename': 02107 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'SYS\'][\'sitename\']', $value); 02108 break; 02109 case 'encryptionKey': 02110 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'SYS\'][\'encryptionKey\']', $value); 02111 break; 02112 case 'compat_version': 02113 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version'],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'SYS\'][\'compat_version\']', $value); 02114 break; 02115 case 'im_combine_filename': 02116 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_combine_filename'],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\'][\'im_combine_filename\']', $value); 02117 break; 02118 case 'gdlib': 02119 case 'gdlib_png': 02120 case 'im': 02121 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['GFX'][$key],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\']["'.$key.'"]', $value?1:0); 02122 break; 02123 case 'im_path': 02124 list($value,$version) = explode('|',$value); 02125 if (!ereg('[[:space:]]',$value,$reg) && strlen($value)<100) { 02126 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['GFX'][$key],$value)) { 02127 $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\']["'.$key.'"]', $value); 02128 } 02129 if(doubleval($version)>0 && doubleval($version)<4) { // Assume GraphicsMagick 02130 $value_ext = 'gm'; 02131 } elseif(doubleval($version)<5) { // Assume ImageMagick 4.x 02132 $value_ext = ''; 02133 } else { // Assume ImageMagick 5+ 02134 $value_ext = 'im5'; 02135 } 02136 if (strcmp(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']),$value_ext)) { 02137 $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\'][\'im_version_5\']', $value_ext); 02138 } 02139 // if (strcmp(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']),$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS['GFX']['im_version_5']', $value); 02140 } else $this->messages[]= $errorMessages[] = "Path '".$value."' contains spaces or is longer than 100 chars (...not saved)"; 02141 break; 02142 case 'im_path_lzw': 02143 list($value) = explode('|',$value); 02144 if (!ereg('[[:space:]]',$value) && strlen($value)<100) { 02145 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['GFX'][$key],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\']["'.$key.'"]', $value); 02146 } else $this->messages[]= $errorMessages[] = "Path '".$value."' contains spaces or is longer than 100 chars (...not saved)"; 02147 break; 02148 case 'TTFdpi': 02149 if (strcmp($GLOBALS['TYPO3_CONF_VARS']['GFX']['TTFdpi'],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'GFX\'][\'TTFdpi\']', $value); 02150 break; 02151 } 02152 02153 02154 } 02155 02156 if (count($errorMessages)) { 02157 echo '<h3>ERRORS</h3>'; 02158 echo t3lib_div::view_array($errorMessages); 02159 echo 'Click the browsers "Back" button to reenter the values.'; 02160 exit; 02161 } 02162 $this->writeToLocalconf_control($lines); 02163 } 02164 break; 02165 } 02166 return $out; 02167 } 02168 02176 function writeToLocalconf_control($lines="", $showOutput=1) { 02177 $returnVal = parent::writeToLocalconf_control($lines); 02178 02179 if ($showOutput) { 02180 switch($returnVal) { 02181 case 'continue': 02182 $content = '<br /><br />'.implode($this->messages,'<hr />').'<br /><br /><a href="'.$this->action.'">Click to continue...</a>'; 02183 $this->outputExitBasedOnStep($content); 02184 break; 02185 case 'nochange': 02186 $content = '<strong>Writing to \'localconf.php\':</strong><br /><br />No values were changed, so nothing is updated!<br /><br /><a href="'.$this->action.'">Click to continue...</a>'; 02187 $this->outputExitBasedOnStep('<br />'.$content); 02188 break; 02189 } 02190 } 02191 return $returnVal; 02192 } 02193 02200 function outputExitBasedOnStep($content) { 02201 if ($this->step) { 02202 Header('Location: '.t3lib_div::locationHeaderUrl($this->action)); 02203 } else { 02204 echo $this->outputWrapper($content); 02205 } 02206 exit; 02207 } 02208 02216 function setLabelValueArray($arr,$type) { 02217 reset($arr); 02218 while(list($k,$v)=each($arr)) { 02219 if($this->config_array['im_versions'][$v]['gm']) { 02220 $program = 'gm'; 02221 } else { 02222 $program = 'convert'; 02223 } 02224 02225 switch($type) { 02226 case 0: // value, im 02227 $arr[$k].='|'.$this->config_array['im_versions'][$v][$program]; 02228 break; 02229 case 1: // labels, im 02230 if($this->config_array['im_versions'][$v][$program]) { 02231 $arr[$k].= ' ('.$this->config_array['im_versions'][$v][$program]; 02232 $arr[$k].= ($this->config_array['im_versions'][$v]['gif_capability'] ? ', '.$this->config_array['im_versions'][$v]['gif_capability'] : ''); 02233 $arr[$k].= ')'; 02234 } else { 02235 $arr[$k].= ''; 02236 } 02237 break; 02238 case 2: // labels, gd 02239 $arr[$k].=' ('.($v==1?'PNG':'GIF').')'; 02240 break; 02241 } 02242 } 02243 return $arr; 02244 } 02245 02256 function getFormElement($labels,$values,$fieldName,$default,$msg='') { 02257 $out.='<strong>'.htmlspecialchars(current($labels)).'</strong><br />current value is '.htmlspecialchars($default).($msg?'<br />'.$msg:''); 02258 if (count($labels)>1) { 02259 reset($labels); 02260 while(list($k,$v)=each($labels)) { 02261 list($cleanV) =explode('|',$values[$k]); 02262 $options.='<option value="'.htmlspecialchars($values[$k]).'"'.(!strcmp($default,$cleanV)?' selected="selected"':'').'>'.htmlspecialchars($v).'</option>'; 02263 } 02264 $out.='<br /><select name="'.$fieldName.'">'.$options.'</select>'; 02265 } else { 02266 $out.='<input type="hidden" name="'.$fieldName.'" value="'.htmlspecialchars(current($values)).'">'; 02267 } 02268 return $out.'<br />'; 02269 } 02270 02276 function getDatabaseList() { 02277 $dbArr=array(); 02278 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { 02279 $dbArr = $GLOBALS['TYPO3_DB']->admin_get_dbs(); 02280 } 02281 return $dbArr; 02282 } 02283 02300 function setupGeneralCalculate() { 02301 $formArray['disable_exec_function']=array(0); 02302 $formArray['im_path']=array(''); 02303 $formArray['im_path_lzw']=array(''); 02304 $formArray['im_combine_filename']=array(''); 02305 $formArray['im_version_5']=array(''); 02306 $formArray['im']=array(1); 02307 $formArray['gdlib']=array(1); 02308 if ($this->config_array['gd'] && ($this->config_array['gd_gif'] || $this->config_array['gd_png'])) { 02309 if ($this->config_array['gd_gif'] && !$this->config_array['gd_png']) { 02310 $formArray['gdlib_png']=array(0); 02311 } elseif (!$this->config_array['gd_gif'] && $this->config_array['gd_png']) { 02312 $formArray['gdlib_png']=array(1); 02313 } else { 02314 $formArray['gdlib_png']=array(0,1); 02315 } 02316 } else { 02317 $formArray['gdlib']=array(0); 02318 } 02319 if ($this->config_array['safemode']) { 02320 $formArray['disable_exec_function']=array(1); 02321 } 02322 if ($this->config_array['im']) { 02323 $formArray['im']=array(1); 02324 $LZW_found=0; 02325 $found=0; 02326 reset($this->config_array['im_versions']); 02327 $totalArr=array(); 02328 while(list($path,$dat)=each($this->config_array['im_versions'])) { 02329 if (count($dat)>=3) { 02330 if (doubleval($dat['convert'])<5) { 02331 $formArray['im_version_5']=array(0); 02332 if ($dat['gif_capability']=='LZW') { 02333 $formArray['im_path']=array($path); 02334 $found=2; 02335 } elseif ($found<2) { 02336 $formArray['im_path']=array($path); 02337 $found=1; 02338 } 02339 } elseif (!$found) { 02340 $formArray['im_version_5']=array('im5'); 02341 $formArray['im_path']=array($path); 02342 $found=1; 02343 } 02344 } elseif ($dat['gm']) { 02345 $formArray['im_version_5']=array('gm'); 02346 if ($dat['gif_capability']=='LZW') { 02347 $formArray['im_path']=array($path); 02348 $found=2; 02349 } elseif ($found<2) { 02350 $formArray['im_path']=array($path); 02351 $found=1; 02352 } 02353 } 02354 if ($dat['gif_capability']=='LZW') { 02355 if (doubleval($dat['convert'])<5 || !$LZW_found) { 02356 $formArray['im_path_lzw']=array($path); 02357 $LZW_found=1; 02358 } 02359 } elseif ($dat['gif_capability']=="RLE" && !$LZW_found) { 02360 $formArray['im_path_lzw']=array($path); 02361 } 02362 $totalArr[]=$path; 02363 } 02364 $formArray['im_path']=array_unique(array_merge($formArray['im_path'],$totalArr)); 02365 $formArray['im_path_lzw']=array_unique(array_merge($formArray['im_path_lzw'],$totalArr)); 02366 $formArray['im_combine_filename']=array($this->config_array['im_combine_filename']); 02367 } else { 02368 $formArray['im']=array(0); 02369 } 02370 return $formArray; 02371 } 02372 02378 function getGDPartOfPhpinfo() { 02379 ob_start(); 02380 phpinfo(); 02381 $contents = ob_get_contents(); 02382 ob_end_clean(); 02383 $start_string = $this->getGD_start_string; 02384 $end_string = $this->getGD_end_string; 02385 list(,$gdpart_tmp) = explode($start_string,$contents,2); 02386 list($gdpart) = explode($end_string,$start_string.$gdpart_tmp,2); 02387 $gdpart.=$end_string; 02388 return $gdpart; 02389 } 02390 02397 function isTTF($phpinfo='') { 02398 /* $phpinfo = $phpinfo?$phpinfo:$this->getGDPartOfPhpinfo(); 02399 if (stristr($phpinfo, $this->getTTF_string)) return 1; 02400 if (stristr($phpinfo, $this->getTTF_string_alt)) return 1; 02401 */ 02402 02403 if (!function_exists('imagettftext')) return 0; // Return right away if imageTTFtext does not exist. 02404 02405 // try, print truetype font: 02406 $im = @imagecreate (300, 50); 02407 $background_color = imagecolorallocate ($im, 255, 255, 55); 02408 $text_color = imagecolorallocate ($im, 233, 14, 91); 02409 02410 $test = @imagettftext($im, t3lib_div::freetypeDpiComp(20), 0, 10, 20, $text_color, PATH_t3lib."/fonts/vera.ttf", 'Testing Truetype support'); 02411 if (t3lib_div::_GP('testingTrueTypeSupport')) { 02412 if ($this->isGIF()) { 02413 header ('Content-type: image/gif'); 02414 imagegif ($im); 02415 } else { 02416 header ('Content-type: image/png'); 02417 imagepng ($im); 02418 } 02419 exit; 02420 } 02421 return is_array($test)?1:0; 02422 } 02423 02424 02425 02426 02427 02428 02429 02430 02431 02432 02433 02434 /***************************************** 02435 * 02436 * ABOUT the isXXX functions. 02437 * 02438 * I had a very real experience that these checks DID NOT fail eg PNG support if it didn't exist! 02439 * 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. 02440 * And if THAT succeeds also, then we can be certain of the support! 02441 */ 02442 02446 function isGD() { 02447 if (function_exists('imagecreate')) { 02448 if (@imagecreate (50, 100)) return 1; 02449 } 02450 } 02451 02457 function isGIF() { 02458 if (function_exists('imagecreatefromgif') && function_exists('imagegif') && ($this->ImageTypes() & IMG_GIF)) { // If GIF-functions exists, also do a real test of them: 02459 $im = @imagecreatefromgif(t3lib_extMgm::extPath('install').'imgs/jesus.gif'); 02460 return $im?1:0; 02461 } 02462 } 02463 02469 function isJPG() { 02470 if (function_exists('imagecreatefromjpeg') && function_exists('imagejpeg') && ($this->ImageTypes() & IMG_JPG)) { 02471 return 1; 02472 } 02473 } 02474 02480 function isPNG() { 02481 if (function_exists('imagecreatefrompng') && function_exists('imagepng') && ($this->ImageTypes() & IMG_PNG)) { 02482 $im = imagecreatefrompng(t3lib_extMgm::extPath('install').'imgs/jesus.png'); 02483 return $im?1:0; 02484 } 02485 } 02486 02492 function ImageTypes() { 02493 if (phpversion()!='4.1.2') { 02494 return imagetypes(); 02495 } else return IMG_GIF+IMG_JPG+IMG_PNG; // all... 02496 } 02497 02503 function getGDSoftwareInfo() { 02504 return trim(' 02505 You can get GDLib in the PNG version from '.$this->linkIt('http://www.boutell.com/gd/').'.<br />FreeType is for download at '.$this->linkIt('http://www.freetype.org/').'. 02506 Generally, software for TYPO3 is found at '.$this->linkIt('http://typo3.sunsite.dk/software/').' and packages listed at '.$this->linkIt('http://typo3.org/1274.0.html').'. 02507 '); 02508 } 02509 02515 function generallyAboutConfiguration() { 02516 $out=' 02517 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. 02518 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. 02519 See this page for '.$this->linkIt('http://typo3.org/1275.0.html','more information about system requirements.').' 02520 '; 02521 return trim($out); 02522 } 02523 02524 02525 02526 02527 02528 02529 02530 02531 02532 02533 02534 02535 02536 /********************** 02537 * 02538 * IMAGE processing 02539 * 02540 **********************/ 02541 02575 function checkTheImageProcessing() { 02576 $this->message('Image Processing','What is it?'," 02577 TYPO3 is known for its ability to process images on the server. 02578 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). 02579 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). 02580 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. 02581 02582 In order to do this, TYPO3 uses two sets of tools: 02583 02584 <strong>ImageMagick:</strong> 02585 For conversion of non-web formats to webformats, combining images with alpha-masks, performing image-effects like blurring and sharpening. 02586 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). 02587 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). 02588 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]) 02589 ImageMagick homepage is at ".$this->linkIt('http://www.imagemagick.org/')." 02590 02591 <strong>GDLib:</strong> 02592 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. 02593 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. 02594 ".$this->getGDSoftwareInfo().' 02595 02596 You can disable all image processing options in TYPO3 ([GFX][image_processing]=0), but that would seriously disable TYPO3. 02597 '); 02598 02599 $this->message('Image Processing','Verifying the image processing capabilities of your server'," 02600 This page performs image processing and displays the result. It's a thorough check that everything you've configured is working correctly. 02601 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. 02602 02603 The image to the right is the reference image (how it should be) and to the left the image made by your server. 02604 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. 02605 02606 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. 02607 "); 02608 02609 $im_path = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path']; 02610 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']=='gm') { 02611 $im_path_version = $this->config_array['im_versions'][$im_path]['gm']; 02612 } else { 02613 $im_path_version = $this->config_array['im_versions'][$im_path]['convert']; 02614 } 02615 $im_path_lzw = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']; 02616 $im_path_lzw_version = $this->config_array['im_versions'][$im_path_lzw]['convert']; 02617 $msg = ' 02618 ImageMagick enabled: <strong>'.$GLOBALS['TYPO3_CONF_VARS']['GFX']['im'].'</strong> 02619 ImageMagick path: <strong>'.$im_path.'</strong> ('.$im_path_version.') 02620 ImageMagick path/LZW: <strong>'.$im_path_lzw.'</strong> ('.$im_path_lzw_version.') 02621 Version 5/GraphicsMagick flag: <strong>'.$GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'].'</strong> 02622 02623 GDLib enabled: <strong>'.$GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'].'</strong> 02624 GDLib using PNG: <strong>'.$GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'].'</strong> 02625 GDLib 2 enabled: <strong>'.$GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_2'].'</strong> 02626 IM5 effects enabled: <strong>'.$GLOBALS['TYPO3_CONF_VARS']['GFX']['im_v5effects'].'</strong> (Blurring/Sharpening with IM 5+) 02627 Freetype DPI: <strong>'.$GLOBALS['TYPO3_CONF_VARS']['GFX']['TTFdpi'].'</strong> (Should be 96 for Freetype 2) 02628 Mask invert: <strong>'.$GLOBALS['TYPO3_CONF_VARS']['GFX']['im_imvMaskState'].'</strong> (Should be set for some IM versions approx. 5.4+) 02629 02630 File Formats: <strong>'.$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'].'</strong> 02631 '; 02632 02633 // Various checks to detect IM/GM version mismatches 02634 $mismatch=false; 02635 switch (strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'])) { 02636 case 'gm': 02637 if (doubleval($im_path_version)>=2) $mismatch=true; 02638 break; 02639 case 'im4': 02640 if (doubleval($im_path_version)>=5) $mismatch=true; 02641 break; 02642 default: 02643 if (($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']?true:false) != (doubleval($im_path_version)>=5)) $mismatch=true; 02644 break; 02645 } 02646 02647 if ($mismatch) { 02648 $msg.= 'Warning: Mismatch between the version of ImageMagick'. 02649 ' ('.$im_path_version.') and the configuration of '. 02650 '[GFX][im_version_5] ('.$GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'].')'; 02651 $etype=2; 02652 } else $etype=1; 02653 02654 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']=='gm') { 02655 $msg = str_replace('ImageMagick','GraphicsMagick',$msg); 02656 } 02657 02658 $this->message('Image Processing','Current configuration',$msg,$etype); 02659 02660 02661 02662 02663 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['image_processing']) { 02664 $this->message('Image Processing','Image Processing disabled!'," 02665 Image Processing is disabled by the config flag <nobr>[GFX][image_processing]</nobr> set to false (zero) 02666 ",2); 02667 echo $this->outputWrapper($this->printAll()); 02668 return; 02669 } 02670 if (!$this->config_array['dir_typo3temp']) { 02671 $this->message('Image Processing','typo3temp/ not writable!'," 02672 You must make typo3temp/ write enabled before you can proceed with this test. 02673 ",2); 02674 echo $this->outputWrapper($this->printAll()); 02675 return; 02676 } 02677 02678 02679 02680 $msg='<a name="testmenu"></a>Click each of these links in turn to test a topic. <strong>Please be aware that each test may take several seconds!</strong>: 02681 02682 '.$this->imagemenu(); 02683 $this->message('Image Processing','Testmenu',$msg,''); 02684 02685 02686 $this->messageFunc_nl2br=0; 02687 $parseStart = microtime(); 02688 $imageProc = t3lib_div::makeInstance('t3lib_stdGraphic'); 02689 $imageProc->init(); 02690 $imageProc->tempPath = $this->typo3temp_path; 02691 $imageProc->dontCheckForExistingTempFile=1; 02692 // $imageProc->filenamePrefix='install_'.($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']?"v5":""); 02693 $imageProc->filenamePrefix='install_'; 02694 $imageProc->dontCompress=1; 02695 $imageProc->alternativeOutputKey='TYPO3_INSTALL_SCRIPT'; 02696 $imageProc->noFramePrepended=$GLOBALS['TYPO3_CONF_VARS']['GFX']['im_noFramePrepended']; 02697 02698 // Very temporary!!! 02699 $imageProc->dontUnlinkTempFiles=0; 02700 02701 02702 $imActive = ($this->config_array['im'] && $im_path); 02703 $gdActive = ($this->config_array['gd'] && $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']); 02704 02705 switch($this->INSTALL['images_type']) { 02706 case 'read': 02707 $refParseTime='5600'; // 4.2.9 02708 $refParseTime='3300'; // 5.2.3 02709 $headCode = 'Reading and converting images'; 02710 $this->message($headCode,'Supported file formats'," 02711 This verifies that your ImageMagick installation is able to read the nine default file formats; JPG, GIF, PNG, TIF, BMP, PCX, TGA, PDF, AI. 02712 The tool 'identify' will be used to read the pixeldimensions of non-web formats. 02713 The tool 'convert' is used to read the image and write a temporary JPG-file 02714 "); 02715 02716 if ($imActive) { 02717 // Reading formats - writing JPG 02718 02719 $extArr = explode(',','jpg,gif,png,tif,bmp,pcx,tga'); 02720 while(list(,$ext)=each($extArr)) { 02721 if ($this->isExtensionEnabled($ext, $headCode, "Read ".strtoupper($ext))) { 02722 $imageProc->IM_commands=array(); 02723 $theFile = t3lib_extMgm::extPath('install').'imgs/jesus.'.$ext; 02724 if (!@is_file($theFile)) die('Error: '.$theFile.' was not a file'); 02725 02726 $imageProc->imageMagickConvert_forceFileNameBody='read_'.$ext; 02727 $fileInfo = $imageProc->imageMagickConvert($theFile,'jpg',"",'',"",'',"",1); 02728 $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); 02729 $this->message($headCode,"Read ".strtoupper($ext),$result[0],$result[1]); 02730 } 02731 } 02732 02733 if ($this->isExtensionEnabled('pdf', $headCode, 'Read PDF')) { 02734 $imageProc->IM_commands=array(); 02735 $theFile = t3lib_extMgm::extPath('install').'imgs/pdf_from_imagemagick.pdf'; 02736 if (!@is_file($theFile)) die('Error: '.$theFile.' was not a file'); 02737 02738 $imageProc->imageMagickConvert_forceFileNameBody='read_pdf'; 02739 $fileInfo = $imageProc->imageMagickConvert($theFile,'jpg',"170",'',"",'',"",1); 02740 $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); 02741 $this->message($headCode,'Read PDF',$result[0],$result[1]); 02742 } 02743 if ($this->isExtensionEnabled('ai', $headCode, 'Read AI')) { 02744 $imageProc->IM_commands=array(); 02745 $theFile = t3lib_extMgm::extPath('install').'imgs/typo3logotype.ai'; 02746 if (!@is_file($theFile)) die('Error: '.$theFile.' was not a file'); 02747 02748 $imageProc->imageMagickConvert_forceFileNameBody='read_ai'; 02749 $fileInfo = $imageProc->imageMagickConvert($theFile,'jpg',"170",'',"",'',"",1); 02750 $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); 02751 $this->message($headCode,'Read AI',$result[0],$result[1]); 02752 } 02753 } else { 02754 $this->message($headCode,'Test skipped'," 02755 Use of ImageMagick has been disabled in the configuration. 02756 Refer to section 'Basic Configuration' to change or review you configuration settings 02757 ",2); 02758 } 02759 break; 02760 case 'write': 02761 $refParseTime='300'; 02762 02763 // Writingformats - writing JPG 02764 $headCode = 'Writing images'; 02765 $this->message($headCode,'Writing GIF and PNG',' 02766 This verifies that ImageMagick is able to write GIF and PNG files. 02767 The GIF-file is attempted compressed with LZW by the t3lib_div::gif_compress() function. 02768 '); 02769 02770 if ($imActive) { 02771 // Writing GIF 02772 $imageProc->IM_commands=array(); 02773 $theFile = t3lib_extMgm::extPath('install').'imgs/jesus.gif'; 02774 if (!@is_file($theFile)) die('Error: '.$theFile.' was not a file'); 02775 02776 $imageProc->imageMagickConvert_forceFileNameBody='write_gif'; 02777 $fileInfo = $imageProc->imageMagickConvert($theFile,'gif',"",'',"",'',"",1); 02778 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gif_compress']) { 02779 clearstatcache(); 02780 $prevSize=t3lib_div::formatSize(@filesize($fileInfo[3])); 02781 $returnCode = t3lib_div::gif_compress($fileInfo[3],''); 02782 clearstatcache(); 02783 $curSize=t3lib_div::formatSize(@filesize($fileInfo[3])); 02784 $note = array('Note on gif_compress() function:',"The 'gif_compress' method used was '".$returnCode."'.<br />Previous filesize: ".$prevSize.'. Current filesize:'.$curSize); 02785 } else $note=array('Note on gif_compress() function:','<em>Not used! Disabled by [GFX][gif_compress]</em>'); 02786 $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands, $note); 02787 $this->message($headCode,'Write GIF',$result[0],$result[1]); 02788 02789 02790 // Writing PNG 02791 $imageProc->IM_commands=array(); 02792 $theFile = t3lib_extMgm::extPath('install').'imgs/jesus.gif'; 02793 02794 $imageProc->imageMagickConvert_forceFileNameBody='write_png'; 02795 $fileInfo = $imageProc->imageMagickConvert($theFile,'png',"",'',"",'',"",1); 02796 $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); 02797 $this->message($headCode,'Write PNG',$result[0],$result[1]); 02798 } else { 02799 $this->message($headCode,'Test skipped'," 02800 Use of ImageMagick has been disabled in the configuration. 02801 Refer to section 'Basic Configuration' to change or review you configuration settings 02802 ",2); 02803 } 02804 break; 02805 case 'scaling': 02806 $refParseTime='650'; 02807 02808 // Scaling 02809 $headCode = 'Scaling images'; 02810 $this->message($headCode,'Scaling transparent images',' 02811 This shows how ImageMagick reacts when scaling transparent GIF and PNG files. 02812 '); 02813 02814 if ($imActive) { 02815 // Scaling transparent image 02816 $imageProc->IM_commands=array(); 02817 $theFile = t3lib_extMgm::extPath('install').'imgs/jesus2_transp.gif'; 02818 if (!@is_file($theFile)) die('Error: '.$theFile.' was not a file'); 02819 02820 $imageProc->imageMagickConvert_forceFileNameBody='scale_gif'; 02821 $fileInfo = $imageProc->imageMagickConvert($theFile,'gif',"150",'',"",'',"",1); 02822 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gif_compress']) { 02823 clearstatcache(); 02824 $prevSize=t3lib_div::formatSize(@filesize($fileInfo[3])); 02825 $returnCode = t3lib_div::gif_compress($fileInfo[3],''); 02826 clearstatcache(); 02827 $curSize=t3lib_div::formatSize(@filesize($fileInfo[3])); 02828 $note = array('Note on gif_compress() function:',"The 'gif_compress' method used was '".$returnCode."'.<br />Previous filesize: ".$prevSize.'. Current filesize:'.$curSize); 02829 } else $note=array('Note on gif_compress() function:','<em>Not used! Disabled by [GFX][gif_compress]</em>'); 02830 $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands,$note); 02831 $this->message($headCode,'GIF to GIF, 150 pixels wide',$result[0],$result[1]); 02832 02833 $imageProc->IM_commands=array(); 02834 $theFile = t3lib_extMgm::extPath('install').'imgs/jesus2_transp.png'; 02835 if (!@is_file($theFile)) die('Error: '.$theFile.' was not a file'); 02836 02837 $imageProc->imageMagickConvert_forceFileNameBody='scale_png'; 02838 $fileInfo = $imageProc->imageMagickConvert($theFile,'png',"150",'',"",'',"",1); 02839 $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); 02840 $this->message($headCode,'PNG to PNG, 150 pixels wide',$result[0],$result[1]); 02841 02842 $imageProc->IM_commands=array(); 02843 $theFile = t3lib_extMgm::extPath('install').'imgs/jesus2_transp.gif'; 02844 if (!@is_file($theFile)) die('Error: '.$theFile.' was not a file'); 02845 $imageProc->imageMagickConvert_forceFileNameBody='scale_jpg'; 02846 $fileInfo = $imageProc->imageMagickConvert($theFile,'jpg',"150",'',"",'',"",1); 02847 $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); 02848 $this->message($headCode,'GIF to JPG, 150 pixels wide',$result[0],$result[1]); 02849 } else { 02850 $this->message($headCode,'Test skipped'," 02851 Use of ImageMagick has been disabled in the configuration. 02852 Refer to section 'Basic Configuration' to change or review you configuration settings 02853 ",2); 02854 } 02855 break; 02856 case 'combining': 02857 $refParseTime='150'; // 4.2.9 02858 $refParseTime='250'; // 5.2.3 02859 // Combine 02860 $headCode = 'Combining images'; 02861 $this->message($headCode,'Combining images'," 02862 This verifies that the ImageMagick tool, 'combine'/'composite', is able to combine two images through a grayscale mask.<br /> 02863 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) 02864 "); 02865 02866 if ($imActive) { 02867 $imageProc->IM_commands=array(); 02868 $input = t3lib_extMgm::extPath('install').'imgs/greenback.gif'; 02869 $overlay = t3lib_extMgm::extPath('install').'imgs/jesus.jpg'; 02870 $mask = t3lib_extMgm::extPath('install').'imgs/blackwhite_mask.gif'; 02871 if (!@is_file($input)) die('Error: '.$input.' was not a file'); 02872 if (!@is_file($overlay)) die('Error: '.$overlay.' was not a file'); 02873 if (!@is_file($mask)) die('Error: '.$mask.' was not a file'); 02874 02875 $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5($imageProc->alternativeOutputKey.'combine1').'.jpg'; 02876 $imageProc->combineExec($input,$overlay,$mask,$output, true); 02877 $fileInfo = $imageProc->getImageDimensions($output); 02878 $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); 02879 $this->message($headCode,'Combine using a GIF mask with only black and white',$result[0],$result[1]); 02880 02881 // Combine 02882 $imageProc->IM_commands=array(); 02883 $input = t3lib_extMgm::extPath('install').'imgs/combine_back.jpg'; 02884 $overlay = t3lib_extMgm::extPath('install').'imgs/jesus.jpg'; 02885 $mask = t3lib_extMgm::extPath('install').'imgs/combine_mask.jpg'; 02886 if (!@is_file($input)) die('Error: '.$input.' was not a file'); 02887 if (!@is_file($overlay)) die('Error: '.$overlay.' was not a file'); 02888 if (!@is_file($mask)) die('Error: '.$mask.' was not a file'); 02889 02890 $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5($imageProc->alternativeOutputKey.'combine2').'.jpg'; 02891 $imageProc->combineExec($input,$overlay,$mask,$output, true); 02892 $fileInfo = $imageProc->getImageDimensions($output); 02893 $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); 02894 $this->message($headCode,'Combine using a JPG mask with graylevels',$result[0],$result[1]); 02895 } else { 02896 $this->message($headCode,'Test skipped'," 02897 Use of ImageMagick has been disabled in the configuration. 02898 Refer to section 'Basic Configuration' to change or review you configuration settings 02899 ",2); 02900 } 02901 break; 02902 case 'gdlib': 02903 $refParseTime='1800'; // GIF / 4.2.9 / LZW (5.2.3) 02904 $refParseTime='2700'; // PNG / 4.2.9 / LZW (5.2.3) 02905 $refParseTime='1600'; // GIF / 5.2.3 / LZW (5.2.3) 02906 // GDLibrary 02907 $headCode = 'GDLib'; 02908 $this->message($headCode,'Testing GDLib',' 02909 This verifies that the GDLib installation works properly. 02910 '); 02911 02912 02913 if ($gdActive) { 02914 // GD with box 02915 $imageProc->IM_commands=array(); 02916 $im = $imageProc->imageCreate(170,136); 02917 $Bcolor = ImageColorAllocate ($im, 0, 0, 0); 02918 ImageFilledRectangle($im, 0, 0, 170, 136, $Bcolor); 02919 $workArea=array(0,0,170,136); 02920 $conf=array( 02921 'dimensions' => '10,50,150,36', 02922 'color' => 'olive' 02923 ); 02924 $imageProc->makeBox($im,$conf,$workArea); 02925 $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5('GDbox').'.'.$imageProc->gifExtension; 02926 $imageProc->ImageWrite($im,$output); 02927 $fileInfo = $imageProc->getImageDimensions($output); 02928 $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); 02929 $this->message($headCode,'Create simple image',$result[0],$result[1]); 02930 02931 02932 // GD from image with box 02933 $imageProc->IM_commands=array(); 02934 $input = t3lib_extMgm::extPath('install').'imgs/jesus.'.$imageProc->gifExtension; 02935 if (!@is_file($input)) die('Error: '.$input.' was not a file'); 02936 $im = $imageProc->imageCreateFromFile($input); 02937 $workArea=array(0,0,170,136); 02938 $conf=array(); 02939 $conf['dimensions']='10,50,150,36'; 02940 $conf['color']='olive'; 02941 $imageProc->makeBox($im,$conf,$workArea); 02942 $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5('GDfromImage+box').'.'.$imageProc->gifExtension; 02943 $imageProc->ImageWrite($im,$output); 02944 $fileInfo = $imageProc->getImageDimensions($output); 02945 $GDWithBox_filesize = @filesize($output); 02946 $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); 02947 $this->message($headCode,'Create image from file',$result[0],$result[1]); 02948 02949 02950 // GD with text 02951 $imageProc->IM_commands=array(); 02952 $im = $imageProc->imageCreate(170,136); 02953 $Bcolor = ImageColorAllocate ($im, 128,128,150); 02954 ImageFilledRectangle($im, 0, 0, 170, 136, $Bcolor); 02955 $workArea=array(0,0,170,136); 02956 $conf=array( 02957 'iterations' => 1, 02958 'angle' => 0, 02959 'antiAlias' => 1, 02960 'text' => 'HELLO WORLD', 02961 'fontColor' => '#003366', 02962 'fontSize' => 18, 02963 'fontFile' => $this->backPath.'../t3lib/fonts/vera.ttf', 02964 'offset' => '17,40' 02965 ); 02966 $conf['BBOX'] = $imageProc->calcBBox($conf); 02967 $imageProc->makeText($im,$conf,$workArea); 02968 02969 $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5('GDwithText').'.'.$imageProc->gifExtension; 02970 $imageProc->ImageWrite($im,$output); 02971 $fileInfo = $imageProc->getImageDimensions($output); 02972 $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); 02973 $this->message($headCode,'Render text with TrueType font',$result[0],$result[1]); 02974 02975 if ($imActive) { 02976 // extension: GD with text, niceText 02977 $conf['offset'] = '17,65'; 02978 $conf['niceText'] = 1; 02979 $imageProc->makeText($im,$conf,$workArea); 02980 02981 $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5('GDwithText-niceText').'.'.$imageProc->gifExtension; 02982 $imageProc->ImageWrite($im,$output); 02983 $fileInfo = $imageProc->getImageDimensions($output); 02984 $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'.")); 02985 $this->message($headCode,"Render text with TrueType font using 'niceText' option", 02986 "(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 />". 02987 $result[0],$result[1]); 02988 } else { 02989 $this->message($headCode,"Render text with TrueType font using 'niceText' option"," 02990 <strong>Test is skipped!</strong><br /><br /> 02991 02992 Use of ImageMagick has been disabled in the configuration. ImageMagick is needed to generate text with the niceText option. 02993 Refer to section 'Basic Configuration' to change or review you configuration settings 02994 ",2); 02995 } 02996 02997 if ($imActive) { 02998 // extension: GD with text, niceText AND shadow 02999 $conf['offset'] = '17,90'; 03000 $conf['niceText'] = 1; 03001 $conf['shadow.'] = array( 03002 'offset'=>'2,2', 03003 'blur' => $imageProc->V5_EFFECTS?"20":"90", 03004 'opacity' => '50', 03005 'color' => 'black' 03006 ); 03007 $imageProc->makeShadow($im,$conf['shadow.'],$workArea,$conf); 03008 $imageProc->makeText($im,$conf,$workArea); 03009 03010 $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5('GDwithText-niceText-shadow').'.'.$imageProc->gifExtension; 03011 $imageProc->ImageWrite($im,$output); 03012 $fileInfo = $imageProc->getImageDimensions($output); 03013 $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.')); 03014 $this->message($headCode,"Render 'niceText' with a shadow under", 03015 "(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 />". 03016 $result[0],$result[1]); 03017 } else { 03018 $this->message($headCode,"Render 'niceText' with a shadow under"," 03019 <strong>Test is skipped!</strong><br /><br /> 03020 03021 Use of ImageMagick has been disabled in the configuration. ImageMagick is needed to generate shadows. 03022 Refer to section 'Basic Configuration' to change or review you configuration settings 03023 ",2); 03024 } 03025 03026 if ($imageProc->gifExtension=='gif') { 03027 $buffer=20; 03028 $assess = "This assessment is based on the filesize from 'Create image from file' test, which were ".$GDWithBox_filesize.' bytes'; 03029 $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!"; 03030 if ($GDWithBox_filesize<8784+$buffer) { 03031 $msg="<strong>Your GDLib appears to have LZW compression!</strong><br /> 03032 This assessment is based on the filesize from 'Create image from file' test, which were ".$GDWithBox_filesize." bytes.<br /> 03033 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 /> 03034 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) 03035 "; 03036 } elseif ($GDWithBox_filesize>19000) { 03037 $msg='<strong>Your GDLib appears to have no compression at all!</strong><br /> 03038 '.$assess.'<br />'.$goodNews; 03039 } else { 03040 $msg='Your GDLib appears to have RLE compression<br /> 03041 '.$assess.'<br />'.$goodNews; 03042 } 03043 $this->message($headCode,'GIF compressing in GDLib'," 03044 ".$msg." 03045 ",1); 03046 } 03047 03048 } else { 03049 $this->message($headCode,'Test skipped'," 03050 Use of GDLib has been disabled in the configuration. 03051 Refer to section 'Basic Configuration' to change or review you configuration settings 03052 ",2); 03053 } 03054 break; 03055 } 03056 03057 if ($this->INSTALL['images_type']) { 03058 // End info 03059 if ($this->fatalError) { 03060 $this->message('Info','Errors'," 03061 It seems that you had some fatal errors in this test. Please make sure that your ImageMagick and GDLib settings are correct. 03062 Refer to the 'Basic Configuration' section for more information and debugging of your settings. 03063 "); 03064 } 03065 03066 $parseStop = microtime(); 03067 $parseMS = t3lib_div::convertMicrotime($parseStop)-t3lib_div::convertMicrotime($parseStart); 03068 $this->message('Info','Parsetime',$parseMS.' ms'); 03069 } 03070 echo $this->outputWrapper($this->printAll()); 03071 } 03072 03081 function isExtensionEnabled($ext, $headCode, $short) { 03082 if (!t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],$ext)) { 03083 $this->message($headCode,$short,'Skipped - extension not in the list of allowed extensions ([GFX][imagefile_ext]).',1); 03084 } else { 03085 return 1; 03086 } 03087 } 03088 03097 function displayTwinImage ($imageFile, $IMcommands=array(), $note='') { 03098 $ex_rows=''; 03099 $errorLevels=array(-1); 03100 if ($imageFile) { 03101 $verifyFile = t3lib_extMgm::extPath('install').'verify_imgs/'.basename($imageFile); 03102 #debug(array($imageFile,$this->backPath.'../'.substr($imageFile,strlen(PATH_site))),1); 03103 $destImg = @getImageSize($imageFile); 03104 $destImgCode ='<img src="'.$this->backPath.'../'.substr($imageFile,strlen(PATH_site)).'" '.$destImg[3].'>'; 03105 $verifyImg = @getImageSize($verifyFile); 03106 $verifyImgCode = '<img src="'.$this->backPath.t3lib_extMgm::extRelPath('install').'verify_imgs/'.basename($verifyFile).'" '.$verifyImg[3].'>'; 03107 if (!$verifyImg) { 03108 $gifVersion=1; 03109 $verifyFile_alt = substr($verifyFile,0,-3).'gif'; 03110 $verifyImg = @getImageSize($verifyFile_alt); 03111 if ($verifyImg) { 03112 // FIXME what is that? old code? t3lib/install/verify_imgs/ do not exist 03113 $verifyImgCode = '<img src="'.$this->backPath.'t3lib/install/verify_imgs/'.basename($verifyFile_alt).'" '.$verifyImg[3].'>'; 03114 $verifyImgCode= '<table border="0" cellpadding="4" cellspacing="0" bgcolor="red"><tr><td align="center">'.$verifyImgCode.'<br />'.$this->fw('<strong>NO REFERENCE FOUND!</strong><br /><br />GIF version looks like this.').'</td></tr></table>'; 03115 } else { 03116 $verifyImgCode= '<table border="0" cellpadding="4" cellspacing="0" bgcolor="red"><tr><td align="center">'.$this->fw('<strong>NO REFERENCE FOUND!</strong><br /><br />'.basename($verifyFile)).'</td></tr></table>'; 03117 } 03118 } 03119 03120 clearstatcache(); 03121 $destImg['filesize'] = @filesize($imageFile); 03122 clearstatcache(); 03123 $verifyImg['filesize'] = @filesize($verifyFile); 03124 03125 $ex_rows.='<tr>'; 03126 $ex_rows.='<td>'.$destImgCode.'</td>'; 03127 $ex_rows.='<td><img src="clear.gif" width="30" height="1"></td>'; 03128 $ex_rows.='<td>'.$verifyImgCode.'</td>'; 03129 $ex_rows.='</tr>'; 03130 03131 $ex_rows.=$this->getTwinImageMessage('', 'Your server:', 'Reference:'); 03132 $ex_rows.=$this->getTwinImageMessage('', t3lib_div::formatSize($destImg['filesize']).', '.$destImg[0].'x'.$destImg[1].' pixels', t3lib_div::formatSize($verifyImg['filesize']).', '.$verifyImg[0].'x'.$verifyImg[1].' pixels'); 03133 03134 if (($destImg['filesize']!=$verifyImg['filesize']) && (intval($destImg['filesize']) && ($destImg['filesize']-$verifyImg['filesize']) > 2048)) { // Display a warning if the generated image is more than 2KB larger than its reference... 03135 $ex_rows.=$this->getTwinImageMessage('File size is very different from reference', $destImg['filesize'], $verifyImg['filesize']); 03136 $errorLevels[]=2; 03137 } 03138 if ($destImg[0]!=$verifyImg[0] || $destImg[1]!=$verifyImg[1]) { 03139 $ex_rows.=$this->getTwinImageMessage('Pixel dimension are not equal!'); 03140 $errorLevels[]=2; 03141 } 03142 if ($note) { 03143 $ex_rows.=$this->getTwinImageMessage($note[0],$note[1]); 03144 } 03145 if ($this->dumpImCommands && count($IMcommands)) { 03146 $ex_rows.=$this->getTwinImageMessage('ImageMagick commands executed:',$this->formatImCmds($IMcommands)); 03147 } 03148 } else { 03149 $ex_rows.=$this->getTwinImageMessage('There was no result from the ImageMagick operation', "Below there's a dump of the ImageMagick commands executed:<br />".$this->formatImCmds($IMcommands)); 03150 $errorLevels[]=3; 03151 } 03152 $out='<table border="0" cellpadding="0" cellspacing="0" align="center" width="300">'.$ex_rows.'</table>'; 03153 03154 return array($out,max($errorLevels)); 03155 } 03156 03165 function getTwinImageMessage($message, $label_1="", $label_2='') { 03166 if ($message) $out.='<tr><td colspan="3"><strong>'.$this->fw($message).'</strong></td></tr>'; 03167 if ($label_1 && !$label_2) { 03168 $out.='<tr><td colspan="3">'.$this->fw($label_1).'</td></tr>'; 03169 } elseif ($label_1 || $label_2) { 03170 $out.='<tr><td>'.$this->fw($label_1).'</td><td></td><td>'.$this->fw($label_2).'</td></tr>'; 03171 } 03172 return $out; 03173 } 03174 03181 function formatImCmds($arr) { 03182 $out=array(); 03183 if (is_array($arr)) { 03184 reset($arr); 03185 while(list($k,$v)=each($arr)) { 03186 $out[]=$v[1]; 03187 if ($v[2]) $out[]=' RETURNED: '.$v[2]; 03188 } 03189 } 03190 if (count($out)) { 03191 $col = t3lib_div::intInRange(count($out),2,10); 03192 $outputStr = '<textarea cols=40 rows='.$col.' wrap="off" class="fixed-font">'.htmlspecialchars(implode($out,chr(10))).'</textarea>'; 03193 return '<form action="">'.$outputStr.'</form>'; 03194 }; 03195 } 03196 03202 function imagemenu() { 03203 $menuitems = array( 03204 'read' => 'Reading image formats', 03205 'write' => 'Writing GIF and PNG', 03206 'scaling' => 'Scaling images', 03207 'combining' => 'Combining images', 03208 'gdlib' => 'GD library functions' 03209 ); 03210 reset($menuitems); 03211 $c=0; 03212 $out=array(); 03213 while(list($k,$v)=each($menuitems)) { 03214 $bgcolor = ($this->INSTALL['images_type']==$k ? ' bgcolor="#ABBBB4"' : ' bgcolor="#F4F0E8"'); 03215 $c++; 03216 $out[]='<tr><td'.$bgcolor.'><a href="'.htmlspecialchars($this->action.'&TYPO3_INSTALL[images_type]='.$k.'#testmenu').'">'.$this->fw($c.': '.$v).'</a></td></tr>'; 03217 } 03218 03219 $code = '<table border="0" cellpadding="0" cellspacing="1">'.implode($out,'').'</table>'; 03220 $code = '<table border="0" cellpadding="0" cellspacing="0" bgcolor="#ABBBB4"><tr><td>'.$code.'</td></tr></table>'; 03221 return '<div align="center">'.$code.'</div>'; 03222 } 03223 03224 03225 03226 03227 03228 03229 03230 03231 03232 03233 03234 03235 /********************** 03236 * 03237 * DATABASE analysing 03238 * 03239 **********************/ 03240 03244 function checkTheDatabase() { 03245 if (!$this->config_array['mysqlConnect']) { 03246 $this->message('Database Analyser','Your database connection failed'," 03247 Please go to the 'Basic Configuration' section and correct this problem first. 03248 ",2); 03249 echo $this->outputWrapper($this->printAll()); 03250 return; 03251 } 03252 if ($this->config_array['no_database']) { 03253 $this->message('Database Analyser','No database selected'," 03254 Please go to the 'Basic Configuration' section and correct this problem first. 03255 ",2); 03256 echo $this->outputWrapper($this->printAll()); 03257 return; 03258 } 03259 03260 // Getting current tables 03261 $whichTables=$this->getListOfTables(); 03262 03263 03264 // Getting number of static_template records 03265 if ($whichTables['static_template']) { 03266 $res_static = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'static_template', ''); 03267 list($static_template_count) = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res_static); 03268 } 03269 $static_template_count=intval($static_template_count); 03270 03271 $headCode ='Database Analyser'; 03272 $this->message($headCode,'What is it?'," 03273 In this section you can get an overview of your currently selected database compared to sql-files. You can also import sql-data directly into the database or upgrade tables from earlier versions of TYPO3. 03274 ",0); 03275 03276 $cInfo=' 03277 Username: <strong>'.TYPO3_db_username.'</strong> 03278 Password: <strong>'.TYPO3_db_password.'</strong> 03279 Host: <strong>'.TYPO3_db_host.'</strong> 03280 '; 03281 $this->message($headCode, 'Connected to SQL database successfully'," 03282 ".trim($cInfo)." 03283 ",-1,1); 03284 $this->message($headCode, 'Database'," 03285 <strong>".TYPO3_db.'</strong> is selected as database. 03286 Has <strong>'.count($whichTables)."</strong> tables. 03287 ",-1,1); 03288 03289 03290 // Menu 03291 03292 $this->messageFunc_nl2br = 0; 03293 03294 $sql_files = array_merge( 03295 t3lib_div::getFilesInDir(PATH_typo3conf,'sql',1,1), 03296 # t3lib_div::getFilesInDir(PATH_t3lib."stddb/",'sql',1,1), 03297 array() 03298 ); 03299 03300 $action_type = $this->INSTALL['database_type']; 03301 $actionParts = explode('|',$action_type); 03302 if (count($actionParts)<2) { 03303 $action_type=''; 03304 } 03305 03306 $out=''; 03307 03308 03309 $out.='<tr> 03310 <td nowrap="nowrap"><strong>'.$this->fw('Update required tables').'</strong></td> 03311 <td'.($action_type=='cmpFile|CURRENT_TABLES'?' bgcolor="#D9D5C9"':'').'>'.$this->fw('<a href="'.htmlspecialchars($this->action.'&TYPO3_INSTALL[database_type]=cmpFile|CURRENT_TABLES#bottom').'"><strong>COMPARE</strong></a>').'</td> 03312 <td>'.$this->fw(' ').'</td> 03313 <td>'.$this->fw(' ').'</td> 03314 </tr>'; 03315 03316 $out.='<tr> 03317 <td nowrap="nowrap"><strong>'.$this->fw('Dump static data').'</strong></td> 03318 <td>'.$this->fw(' ').'</td> 03319 <td nowrap="nowrap"'.($action_type=='import|CURRENT_STATIC'?' bgcolor="#D9D5C9"':'').'>'.$this->fw('<a href="'.htmlspecialchars($this->action.'&TYPO3_INSTALL[database_type]=import|CURRENT_STATIC#bottom').'"><strong>IMPORT</strong></a>').'</td> 03320 <td>'.$this->fw(' ').'</td> 03321 </tr>'; 03322 03323 $out.='<tr> 03324 <td colspan="4"> </td> 03325 </tr>'; 03326 03327 03328 03329 03330 reset($sql_files); 03331 $directJump=''; 03332 while(list($k,$file)=each($sql_files)) { 03333 if ($this->mode=="123" && !count($whichTables) && strstr($file,'_testsite')) { 03334 $directJump = $this->action.'&TYPO3_INSTALL[database_type]=import|'.rawurlencode($file); 03335 } 03336 $lf=t3lib_div::testInt($k); 03337 $fShortName = substr($file,strlen(PATH_site)); 03338 03339 /* 03340 $spec1 = (!count($whichTables) && $fShortName==TYPO3_mainDir.'t3lib/install/tables_'.str_replace('.','',$GLOBALS['TYPO_VERSION']).".sql" ? " <font color=#000066>(1)</span>" : ""); 03341 $spec2 = (count($whichTables) && !$static_template_count && $fShortName==TYPO3_mainDir.'t3lib/install/static_template_'.str_replace('.','',$GLOBALS['TYPO_VERSION'])."+adt.sql" ? " <font color=#000066>(2)</span>" : ""); 03342 */ 03343 $spec1 = $spec2 = ''; 03344 03345 $out.='<tr> 03346 <td nowrap="nowrap">'.$this->fw($fShortName.' ('.t3lib_div::formatSize(filesize($file)).')').'</td> 03347 <td'.($action_type=='cmpFile|'.$file?' bgcolor="#D9D5C9"':'').'>'.$this->fw('<a href="'.htmlspecialchars($this->action.'&TYPO3_INSTALL[database_type]=cmpFile|'.rawurlencode($file).'#bottom').'"><strong>COMPARE</strong></a>').'</td> 03348 <td nowrap="nowrap"'.($action_type=='import|'.$file?' bgcolor="#D9D5C9"':'').'>'.$this->fw('<a href="'.htmlspecialchars($this->action.'&TYPO3_INSTALL[database_type]=import|'.rawurlencode($file).'#bottom').'"><strong>IMPORT'.$spec1.$spec2.'</strong></a>').'</td> 03349 <td nowrap="nowrap"'.($action_type=='view|'.$file?' bgcolor="#D9D5C9"':'').'>'.$this->fw('<a href="'.htmlspecialchars($this->action.'&TYPO3_INSTALL[database_type]=view|'.rawurlencode($file).'#bottom').'"><strong>VIEW'.$spec1.$spec2.'</strong></a>').'</td> 03350 </tr>'; 03351 } 03352 // TCA 03353 $out.='<tr> 03354 <td></td> 03355 <td colspan="3"'.($action_type=="cmpTCA|"?' bgcolor="#D9D5C9"':'').'><strong>'.$this->fw('<a href="'.htmlspecialchars($this->action.'&TYPO3_INSTALL[database_type]=cmpTCA|#bottom').'">Compare with $TCA</a>').'</strong></td> 03356 </tr>'; 03357 $out.='<tr> 03358 <td></td> 03359 <td colspan="3"'.($action_type=="adminUser|"?' bgcolor="#D9D5C9"':'').'><strong>'.$this->fw('<a href="'.htmlspecialchars($this->action.'&TYPO3_INSTALL[database_type]=adminUser|#bottom').'">Create "admin" user</a>').'</strong></td> 03360 </tr>'; 03361 $out.='<tr> 03362 <td></td> 03363 <td colspan="3"'.($action_type=="UC|"?' bgcolor="#D9D5C9"':'').'><strong>'.$this->fw('<a href="'.htmlspecialchars($this->action.'&TYPO3_INSTALL[database_type]=UC|#bottom').'">Reset user preferences</a>').'</strong></td> 03364 </tr>'; 03365 $out.='<tr> 03366 <td></td> 03367 <td colspan="3"'.($action_type=="cache|"?' bgcolor="#D9D5C9"':'').'><strong>'.$this->fw('<a href="'.htmlspecialchars($this->action.'&TYPO3_INSTALL[database_type]=cache|#bottom').'">Clear tables</a>').'</strong></td> 03368 </tr>'; 03369 03370 $theForm='<table border="0" cellpadding="2" cellspacing="2">'.$out.'</table>'; 03371 $theForm.='<a name="bottom"></a>'; 03372 03373 if ($directJump) { 03374 if (!$action_type) { 03375 $this->message($headCode, 'Menu',' 03376 <script language="javascript" type="text/javascript"> 03377 window.location.href = "'.$directJump.'"; 03378 </script>',0,1); 03379 } 03380 } else { 03381 $this->message($headCode, 'Menu'," 03382 From this menu you can select which of the available SQL files you want to either compare or import/merge with the existing database.<br /><br /> 03383 <strong>COMPARE:</strong> Compares the tables and fields of the current database and the selected file. It also offers to 'update' the difference found.<br /> 03384 <strong>IMPORT:</strong> Imports the SQL-dump file into the current database. You can either dump the raw file or choose which tables to import. In any case, you'll see a new screen where you must confirm the operation.<br /> 03385 <strong>VIEW:</strong> Shows the content of the SQL-file, limiting characters on a single line to a reader-friendly amount.<br /><br /> 03386 The SQL-files are selected from typo3conf/ (here you can put your own) and t3lib/stddb/ (TYPO3 distribution). The SQL-files should be made by the <em>mysqldump</em> tool or at least be formatted like that tool would do. 03387 <br /> 03388 <br /> 03389 ".$theForm." 03390 ",0,1); 03391 } 03392 03393 03394 // Install user 03395 // clear uc 03396 if ($action_type) { 03397 switch($actionParts[0]) { 03398 case 'cmpFile': 03399 $tblFileContent=''; 03400 if (!strcmp($actionParts[1],'CURRENT_TABLES')) { 03401 $tblFileContent = t3lib_div::getUrl(PATH_t3lib.'stddb/tables.sql'); 03402 03403 reset($GLOBALS['TYPO3_LOADED_EXT']); 03404 while(list(,$loadedExtConf)=each($GLOBALS['TYPO3_LOADED_EXT'])) { 03405 if (is_array($loadedExtConf) && $loadedExtConf['ext_tables.sql']) { 03406 $tblFileContent.= chr(10).chr(10).chr(10).chr(10).t3lib_div::getUrl($loadedExtConf['ext_tables.sql']); 03407 } 03408 } 03409 } elseif (@is_file($actionParts[1])) { 03410 $tblFileContent = t3lib_div::getUrl($actionParts[1]); 03411 } 03412 if ($tblFileContent) { 03413 $fileContent = implode( 03414 $this->getStatementArray($tblFileContent,1,'^CREATE TABLE '), 03415 chr(10) 03416 ); 03417 $FDfile = $this->getFieldDefinitions_sqlContent($fileContent); 03418 if (!count($FDfile)) { 03419 die ("Error: There were no 'CREATE TABLE' definitions in the provided file"); 03420 } 03421 03422 // Updating database... 03423 if (is_array($this->INSTALL['database_update'])) { 03424 $FDdb = $this->getFieldDefinitions_database(); 03425 $diff = $this->getDatabaseExtra($FDfile, $FDdb); 03426 $update_statements = $this->getUpdateSuggestions($diff); 03427 $diff = $this->getDatabaseExtra($FDdb, $FDfile); 03428 $remove_statements = $this->getUpdateSuggestions($diff,'remove'); 03429 03430 $this->performUpdateQueries($update_statements['add'],$this->INSTALL['database_update']); 03431 $this->performUpdateQueries($update_statements['change'],$this->INSTALL['database_update']); 03432 $this->performUpdateQueries($remove_statements['change'],$this->INSTALL['database_update']); 03433 $this->performUpdateQueries($remove_statements['drop'],$this->INSTALL['database_update']); 03434 03435 $this->performUpdateQueries($update_statements['create_table'],$this->INSTALL['database_update']); 03436 $this->performUpdateQueries($remove_statements['change_table'],$this->INSTALL['database_update']); 03437 $this->performUpdateQueries($remove_statements['drop_table'],$this->INSTALL['database_update']); 03438 } 03439 03440 // Init again / first time depending... 03441 $FDdb = $this->getFieldDefinitions_database(); 03442 03443 $diff = $this->getDatabaseExtra($FDfile, $FDdb); 03444 $update_statements = $this->getUpdateSuggestions($diff); 03445 03446 $diff = $this->getDatabaseExtra($FDdb, $FDfile); 03447 $remove_statements = $this->getUpdateSuggestions($diff,'remove'); 03448 03449 $tLabel = 'Update database tables and fields'; 03450 03451 if ($remove_statements || $update_statements) { 03452 $formContent = $this->generateUpdateDatabaseForm('get_form',$update_statements,$remove_statements,$action_type); 03453 $this->message($tLabel,'Table and field definitions should be updated'," 03454 There seems to be a number of differencies between the database and the selected SQL-file. 03455 Please select which statements you want to execute in order to update your database:<br /><br /> 03456 ".$formContent." 03457 ",2); 03458 } else { 03459 $formContent = $this->generateUpdateDatabaseForm('get_form',$update_statements,$remove_statements,$action_type); 03460 $this->message($tLabel,'Table and field definitions are OK.'," 03461 The tables and fields in the current database corresponds perfectly to the database in the selected SQL-file. 03462 ",-1); 03463 } 03464 } 03465 break; 03466 case 'cmpTCA': 03467 $this->includeTCA(); 03468 $FDdb = $this->getFieldDefinitions_database(); 03469 03470 // Displaying configured fields which are not in the database 03471 $tLabel='Tables and fields in $TCA, but not in database'; 03472 $cmpTCA_DB = $this->compareTCAandDatabase($GLOBALS['TCA'],$FDdb); 03473 if (!count($cmpTCA_DB['extra'])) { 03474 $this->message($tLabel,'Table and field definitions OK',' 03475 All fields and tables configured in $TCA appeared to exist in the database as well 03476 ',-1); 03477 } else { 03478 $this->message($tLabel,'Invalid table and field definitions in $TCA!',' 03479 There are some tables and/or fields configured in the \$TCA array which does not exist in the database! 03480 This will most likely cause you trouble with the TYPO3 backend interface! 03481 ',3); 03482 while(list($tableName, $conf)=each($cmpTCA_DB['extra'])) { 03483 $this->message($tLabel, $tableName,$this->displayFields($conf['fields'],0,'Suggested database field:'),2); 03484 } 03485 } 03486 03487 // Displaying tables that are not setup in 03488 $cmpDB_TCA = $this->compareDatabaseAndTCA($FDdb,$GLOBALS['TCA']); 03489 $excludeTables='be_sessions,fe_session_data,fe_sessions'; 03490 if (TYPO3_OS=='WIN') {$excludeTables = strtolower($excludeTables);} 03491 $excludeFields = array( 03492 'be_users' => 'uc,lastlogin,usergroup_cached_list', 03493 'fe_users' => 'uc,lastlogin,fe_cruser_id', 03494 'pages' => 'SYS_LASTCHANGED', 03495 'sys_dmail' => 'mailContent', 03496 'tt_board' => 'doublePostCheck', 03497 'tt_guest' => 'doublePostCheck', 03498 'tt_products' => 'ordered' 03499 ); 03500 $tCount=0; 03501 $fCount=0; 03502 $tLabel="Tables from database, but not in \$TCA"; 03503 $fLabel="Fields from database, but not in \$TCA"; 03504 $this->message($tLabel); 03505 if (is_array($cmpDB_TCA['extra'])) { 03506 while(list($tableName, $conf)=each($cmpDB_TCA['extra'])) { 03507 if (!t3lib_div::inList($excludeTables,$tableName) 03508 && substr($tableName,0,4)!="sys_" 03509 && substr($tableName,-3)!="_mm" 03510 && substr($tableName,0,6)!="index_" 03511 && substr($tableName,0,6)!='cache_') { 03512 if ($conf['whole_table']) { 03513 $this->message($tLabel, $tableName,$this->displayFields($conf['fields']),1); 03514 $tCount++; 03515 } else { 03516 list($theContent, $fC) = $this->displaySuggestions($conf['fields'],$excludeFields[$tableName]); 03517 $fCount+=$fC; 03518 if ($fC) $this->message($fLabel, $tableName,$theContent,1); 03519 } 03520 } 03521 } 03522 } 03523 if (!$tCount) { 03524 $this->message($tLabel,'Correct number of tables in the database'," 03525 There are no extra tables in the database compared to the configured tables in the \$TCA array. 03526 ",-1); 03527 } else { 03528 $this->message($tLabel,'Extra tables in the database'," 03529 There are some tables in the database which are not configured in the \$TCA array. 03530 You should probably not worry about this, but please make sure that you know what these tables are about and why they are not configured in \$TCA. 03531 ",2); 03532 } 03533 03534 if (!$fCount) { 03535 $this->message($fLabel,'Correct number of fields in the database'," 03536 There are no additional fields in the database tables compared to the configured fields in the \$TCA array. 03537 ",-1); 03538 } else { 03539 $this->message($fLabel,'Extra fields in the database'," 03540 There are some additional fields the database tables which are not configured in the \$TCA array. 03541 You should probably not worry about this, but please make sure that you know what these fields are about and why they are not configured in \$TCA. 03542 ",2); 03543 } 03544 03545 // Displaying actual and suggested field database defitions 03546 if (is_array($cmpTCA_DB['matching'])) { 03547 $tLabel="Comparison between database and \$TCA"; 03548 03549 $this->message($tLabel,'Actual and suggested field definitions'," 03550 This table shows you the suggested field definitions which are calculated based on the configuration in \$TCA. 03551 If the suggested value differs from the actual current database value, you should not panic, but simply check if the datatype of that field is sufficient compared to the data, you want TYPO3 to put there. 03552 ",0); 03553 while(list($tableName, $conf)=each($cmpTCA_DB['matching'])) { 03554 $this->message($tLabel, $tableName,$this->displayFieldComp($conf['fields'], $FDdb[$tableName]['fields']),1); 03555 } 03556 } 03557 break; 03558 case 'import': 03559 $mode123Imported=0; 03560 $tblFileContent=''; 03561 if (preg_match('/^CURRENT_/', $actionParts[1])) { 03562 if (!strcmp($actionParts[1],'CURRENT_TABLES') || !strcmp($actionParts[1],'CURRENT_TABLES+STATIC')) { 03563 $tblFileContent = t3lib_div::getUrl(PATH_t3lib.'stddb/tables.sql'); 03564 03565 reset($GLOBALS['TYPO3_LOADED_EXT']); 03566 while(list(,$loadedExtConf)=each($GLOBALS['TYPO3_LOADED_EXT'])) { 03567 if (is_array($loadedExtConf) && $loadedExtConf['ext_tables.sql']) { 03568 $tblFileContent.= chr(10).chr(10).chr(10).chr(10).t3lib_div::getUrl($loadedExtConf['ext_tables.sql']); 03569 } 03570 } 03571 } 03572 if (!strcmp($actionParts[1],'CURRENT_STATIC') || !strcmp($actionParts[1],'CURRENT_TABLES+STATIC')) { 03573 reset($GLOBALS['TYPO3_LOADED_EXT']); 03574 while(list(,$loadedExtConf)=each($GLOBALS['TYPO3_LOADED_EXT'])) { 03575 if (is_array($loadedExtConf) && $loadedExtConf['ext_tables_static+adt.sql']) { 03576 $tblFileContent.= chr(10).chr(10).chr(10).chr(10).t3lib_div::getUrl($loadedExtConf['ext_tables_static+adt.sql']); 03577 } 03578 } 03579 } 03580 } elseif (@is_file($actionParts[1])) { 03581 $tblFileContent = t3lib_div::getUrl($actionParts[1]); 03582 } 03583 03584 if ($tblFileContent) { 03585 $tLabel='Import SQL dump'; 03586 // Getting statement array from 03587 $statements = $this->getStatementArray($tblFileContent,1); 03588 list($statements_table, $insertCount) = $this->getCreateTables($statements,1); 03589 03590 // Updating database... 03591 if ($this->INSTALL['database_import_all']) { 03592 $r=0; 03593 foreach ($statements as $k=>$v) { 03594 $res = $GLOBALS['TYPO3_DB']->admin_query($v); 03595 $r++; 03596 } 03597 03598 // Make a database comparison because some tables that are defined twice have not been created at this point. This applies to the "pages.*" fields defined in sysext/cms/ext_tables.sql for example. 03599 $fileContent = implode( 03600 $this->getStatementArray($tblFileContent,1,'^CREATE TABLE '), 03601 chr(10) 03602 ); 03603 $FDfile = $this->getFieldDefinitions_sqlContent($fileContent); 03604 $FDdb = $this->getFieldDefinitions_database(); 03605 $diff = $this->getDatabaseExtra($FDfile, $FDdb); 03606 $update_statements = $this->getUpdateSuggestions($diff); 03607 if (is_array($update_statements['add'])) { 03608 foreach ($update_statements['add'] as $statement) { 03609 $res = $GLOBALS['TYPO3_DB']->admin_query($statement); 03610 } 03611 } 03612 03613 if ($this->mode=='123') { 03614 // Create default be_user admin/password 03615 $username = 'admin'; 03616 $pass = 'password'; 03617 03618 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'be_users', 'username='.$GLOBALS['TYPO3_DB']->fullQuoteStr($username, 'be_users')); 03619 if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 03620 $insertFields = array( 03621 'username' => $username, 03622 'password' => md5($pass), 03623 'admin' => 1, 03624 'uc' => '', 03625 'fileoper_perms' => 7, 03626 'tstamp' => time(), 03627 'crdate' => time() 03628 ); 03629 03630 $GLOBALS['TYPO3_DB']->exec_INSERTquery('be_users', $insertFields); 03631 } 03632 } 03633 03634 $this->message($tLabel,'Imported ALL'," 03635 Queries: ".$r." 03636 ",1,1); 03637 if (t3lib_div::_GP('goto_step')) { 03638 $this->action.='&step='.t3lib_div::_GP('goto_step'); 03639 Header('Location: '.t3lib_div::locationHeaderUrl($this->action)); 03640 exit; 03641 } 03642 } elseif (is_array($this->INSTALL['database_import'])) { 03643 // Traverse the tables 03644 reset($this->INSTALL['database_import']); 03645 while(list($table,$md5str)=each($this->INSTALL['database_import'])) { 03646 if ($md5str==md5($statements_table[$table])) { 03647 $res = $GLOBALS['TYPO3_DB']->admin_query('DROP TABLE IF EXISTS '.$table); 03648 $res = $GLOBALS['TYPO3_DB']->admin_query($statements_table[$table]); 03649 03650 if ($insertCount[$table]) { 03651 $statements_insert = $this->getTableInsertStatements($statements, $table); 03652 reset($statements_insert); 03653 while(list($k,$v)=each($statements_insert)) { 03654 $res = $GLOBALS['TYPO3_DB']->admin_query($v); 03655 } 03656 } 03657 03658 $this->message($tLabel,"Imported '".$table."'"," 03659 Rows: ".$insertCount[$table]." 03660 ",1,1); 03661 } 03662 } 03663 } 03664 03665 $mode123Imported=$this->isBasicComplete($tLabel); 03666 03667 if (!$mode123Imported) { 03668 // Re-Getting current tables - may have been changed during import 03669 $whichTables=$this->getListOfTables(); 03670 03671 if (count($statements_table)) { 03672 reset($statements_table); 03673 $out=''; 03674 while(list($table,$definition)=each($statements_table)) { 03675 $exist=isset($whichTables[$table]); 03676 $out.='<tr> 03677 <td><input type="checkbox" name="TYPO3_INSTALL[database_import]['.$table.']" value="'.md5($definition).'"></td> 03678 <td><strong>'.$this->fw($table).'</strong></td> 03679 <td><img src="clear.gif" width="10" height="1"></td> 03680 <td nowrap="nowrap">'.$this->fw($insertCount[$table]?"Rows: ".$insertCount[$table]:"").'</td> 03681 <td><img src="clear.gif" width="10" height="1"></td> 03682 <td nowrap="nowrap">'.($exist?'<img src="'.$this->backPath.'gfx/icon_warning.gif" width="18" height="16" align="top" alt="">'.$this->fw('Table exists!'):'').'</td> 03683 </tr>'; 03684 } 03685 03686 $content =''; 03687 if ($this->mode!='123') { 03688 $content.='<table border="0" cellpadding="0" cellspacing="0">'.$out.'</table> 03689 <hr /> 03690 '; 03691 } 03692 $content.='<input type="checkbox" name="TYPO3_INSTALL[database_import_all]" value="1"'.($this->mode=="123"||t3lib_div::_GP('presetWholeTable')?' checked="checked"':'').'>'.$this->fw("Import the whole file '".basename($actionParts[1])."' directly (ignores selections above):").'<br /> 03693 03694 '; 03695 $form = $this->getUpdateDbFormWrap($action_type, $content); 03696 $this->message($tLabel,'Select tables to import'," 03697 This is an overview of the CREATE TABLE definitions in the SQL file. 03698 Select which tables you want to dump to the database. 03699 Any table you choose dump to the database is dropped from the database first, so you'll lose all data in existing tables. 03700 ".$form,1,1); 03701 } else { 03702 $this->message($tLabel,'No tables'," 03703 There seems to be no CREATE TABLE definitions in the SQL file. 03704 This tool is intelligently creating one table at a time and not just dumping the whole content of the file uncritically. That's why there must be defined tables in the SQL file. 03705 ",3,1); 03706 } 03707 } 03708 } 03709 break; 03710 case 'view': 03711 if (@is_file($actionParts[1])) { 03712 $tLabel='Import SQL dump'; 03713 // Getting statement array from 03714 $sqlContent = t3lib_div::getUrl($actionParts[1]); 03715 $statements = $this->getStatementArray($sqlContent,1); 03716 $maxL=1000; 03717 $strLen = strlen($sqlContent); 03718 $maxlen = 200+($maxL-t3lib_div::intInRange(($strLen-20000)/100,0,$maxL)); 03719 if (count($statements)) { 03720 reset($statements); 03721 $out=''; 03722 while(list(,$statement)=each($statements)) { 03723 $out.=nl2br(htmlspecialchars(t3lib_div::fixed_lgd($statement,$maxlen)).chr(10).chr(10)); 03724 } 03725 } 03726 $this->message($tLabel,'Content of '.basename($actionParts[1]),$out,1); 03727 } 03728 break; 03729 case 'adminUser': 03730 if ($whichTables['be_users']) { 03731 if (is_array($this->INSTALL['database_adminUser'])) { 03732 $username = ereg_replace('[^[:alnum:]_-]','',trim($this->INSTALL['database_adminUser']['username'])); 03733 $username = str_replace(' ','_',$username); 03734 $pass = trim($this->INSTALL['database_adminUser']['password']); 03735 if ($username && $pass) { 03736 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'be_users', 'username='.$GLOBALS['TYPO3_DB']->fullQuoteStr($username, 'be_users')); 03737 if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 03738 03739 $insertFields = array( 03740 'username' => $username, 03741 'password' => md5($pass), 03742 'admin' => 1, 03743 'uc' => '', 03744 'fileoper_perms' => 7, 03745 'tstamp' => time(), 03746 'crdate' => time() 03747 ); 03748 03749 $GLOBALS['TYPO3_DB']->exec_INSERTquery('be_users', $insertFields); 03750 03751 $this->isBasicComplete($headCode); 03752 03753 $this->message($headCode,'User created',' 03754 Username: <strong>'.htmlspecialchars($username).'</strong><br /> 03755 Password: <strong>'.htmlspecialchars($pass).'</strong><br />' 03756 ,1,1); 03757 } else { 03758 $this->message($headCode,'Username not unique!',' 03759 The username, <strong>'.htmlspecialchars($username).'</strong>, was not unique.',2,1); 03760 } 03761 } 03762 } 03763 $content = ' 03764 <input type="text" name="TYPO3_INSTALL[database_adminUser][username]"> username - unique, no space, lowercase<br /> 03765 <input type="text" name="TYPO3_INSTALL[database_adminUser][password]"> password 03766 '; 03767 $form = $this->getUpdateDbFormWrap($action_type, $content); 03768 $this->message($headCode,'Create admin user'," 03769 Enter username and password for a new admin user.<br /> 03770 You should use this function only if there are no admin users in the database, for instance if this is a blank database.<br /> 03771 After you've created the user, log in and add the rest of the user information, like email and real name.<br /> 03772 <br /> 03773 ".$form." 03774 ",0,1); 03775 } else { 03776 $this->message($headCode,'Required table not in database'," 03777 'be_users' must be a table in the database! 03778 ",3,1); 03779 } 03780 break; 03781 case 'UC': 03782 if ($whichTables['be_users']) { 03783 if (!strcmp($this->INSTALL['database_UC'],1)) { 03784 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_users', '', array('uc' => '')); 03785 $this->message($headCode,'Clearing be_users.uc','Done.',1); 03786 } 03787 $content = ' 03788 <input type="checkbox" name="TYPO3_INSTALL[database_UC]" value="1" checked="checked"> Clear be_users preferences ("uc" field) 03789 '; 03790 $form = $this->getUpdateDbFormWrap($action_type, $content); 03791 $this->message($headCode,'Clear user preferences'," 03792 If you press this button all backend users from the tables be_users will have their user preferences cleared (field 'uc' set to an empty string).<br /> 03793 This may come in handy in rare cases where that configuration may be corrupt.<br /> 03794 Clearing this will clear all user settings from the 'Setup' module.<br /> 03795 <br /> 03796 ".$form); 03797 } else { 03798 $this->message($headCode,'Required table not in database'," 03799 'be_users' must be a table in the database! 03800 ",3); 03801 } 03802 break; 03803 case 'cache': 03804 $tableListArr = explode(',','cache_pages,cache_pagesection,cache_hash,cache_imagesizes,--div--,sys_log,sys_history,--div--,be_sessions,fe_sessions,fe_session_data'. 03805 (t3lib_extMgm::isLoaded('indexed_search') ? ',--div--,index_words,index_rel,index_phash,index_grlist,index_section,index_fulltext' : ''). 03806 (t3lib_extMgm::isLoaded('tt_products') ? ',--div--,sys_products_orders,sys_products_orders_mm_tt_products' : ''). 03807 (t3lib_extMgm::isLoaded('direct_mail') ? ',--div--,sys_dmail_maillog' : ''). 03808 (t3lib_extMgm::isLoaded('sys_stat') ? ',--div--,sys_stat' : '') 03809 ); 03810 03811 if (is_array($this->INSTALL['database_clearcache'])) { 03812 $qList=array(); 03813 reset($tableListArr); 03814 while(list(,$table)=each($tableListArr)) { 03815 if ($table!='--div--') { 03816 $table_c = TYPO3_OS=='WIN' ? strtolower($table) : $table; 03817 if ($this->INSTALL['database_clearcache'][$table] && $whichTables[$table_c]) { 03818 $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, ''); 03819 $qList[] = $table; 03820 } 03821 } 03822 } 03823 if (count($qList)) { 03824 $this->message($headCode,'Clearing cache',' 03825 The following tables were emptied:<br /><br /> 03826 '.implode($qList,'<br />') 03827 ,1); 03828 } 03829 } 03830 // Count entries and make checkboxes 03831 $labelArr = array( 03832 'cache_pages' => 'Pages', 03833 'cache_pagesection' => 'TS template related information', 03834 'cache_hash' => 'Multipurpose md5-hash cache', 03835 + 'cache_imagesizes' => 'Cached image sizes', 03836 'sys_log' => 'Backend action logging', 03837 'sys_stat' => 'Page hit statistics', 03838 'sys_history' => 'Addendum to the sys_log which tracks ALL changes to content through TCE. May become huge by time. Is used for rollback (undo) and the WorkFlow engine.', 03839 'be_sessions' => 'Backend User sessions', 03840 'fe_sessions' => 'Frontend User sessions', 03841 'fe_session_data' => 'Frontend User sessions data', 03842 'sys_dmail_maillog' => 'Direct Mail log', 03843 'sys_products_orders' => 'tt_product orders', 03844 'sys_products_orders_mm_tt_products' => 'relations between tt_products and sys_products_orders' 03845 ); 03846 03847 $checkBoxes=array(); 03848 $countEntries=array(); 03849 reset($tableListArr); 03850 while(list(,$table)=each($tableListArr)) { 03851 if ($table!='--div--') { 03852 $table_c = TYPO3_OS=='WIN' ? strtolower($table) : $table; 03853 if ($whichTables[$table_c]) { 03854 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, ''); 03855 list($countEntries[$table]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); 03856 // Checkboxes: 03857 $checkBoxes[]= '<input type="checkbox" name="TYPO3_INSTALL[database_clearcache]['.$table.']" id="TYPO3_INSTALL[database_clearcache]['.$table.']" value="1"'.($this->INSTALL['database_clearcache'][$table]||$_GET['PRESET']['database_clearcache'][$table]?' checked="checked"':'').'> <label for="TYPO3_INSTALL[database_clearcache]['.$table.']"><strong>'.$table.'</strong> ('.$countEntries[$table].' rows) - '.$labelArr[$table].'</label>'; 03858 } 03859 } else { 03860 $checkBoxes[]= '<hr />'; 03861 } 03862 } 03863 03864 $content = implode('<br />',$checkBoxes).'<br /><br />'; 03865 03866 $form = $this->getUpdateDbFormWrap($action_type, $content); 03867 $this->message($headCode,'Clear out selected tables',' 03868 Pressing this button will delete all records from the selected tables.<br /> 03869 <br /> 03870 '.$form.' 03871 '); 03872 break; 03873 } 03874 } 03875 03876 echo $this->outputWrapper($this->printAll()); 03877 } 03878 03884 function updateWizard() { 03885 global $TYPO3_CONF_VARS; 03886 03887 // clear cache files 03888 t3lib_extMgm::removeCacheFiles(); 03889 03890 // generate new cache files and include them 03891 $GLOBALS['TYPO3_CONF_VARS']['EXT']['extCache'] = 1; 03892 $TYPO3_LOADED_EXT = t3lib_extMgm::typo3_loadExtensions(); 03893 if ($TYPO3_LOADED_EXT['_CACHEFILE']) { 03894 require(PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_localconf.php'); 03895 } 03896 03897 // call wizard 03898 $action = ($this->INSTALL['database_type']?$this->INSTALL['database_type']:'checkForUpdate'); 03899 $this->updateWizard_parts($action); 03900 echo $this->outputWrapper($this->printAll()); 03901 } 03908 function updateWizard_parts($action) { 03909 $content = ''; 03910 switch ($action) { 03911 case 'checkForUpdate': // first step - check for updates available 03912 $title = 'Update wizards'; 03913 $updateWizardBoxes = ''; 03914 if (!$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']) { 03915 $content = '<strong>No updates registered!</strong>'; 03916 break; 03917 } 03918 03919 // step through list of updates, and check if update is needed and if yes, output an explanation 03920 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] as $identifier => $className) { 03921 $tmpObj = $this->getUpgradeObjInstance($className, $identifier); 03922 if (method_exists($tmpObj,'checkForUpdate')) { 03923 $explanation = ''; 03924 if ($tmpObj->checkForUpdate($explanation)) { 03925 $updateWizardBoxes .= ' 03926 <div style="border: 1px solid; padding: 10px; margin: 10px; padding-top:0px;"> 03927 <h3>'.$identifier.'</h3> 03928 <p>'.str_replace(chr(10),'<br />',$explanation).'</p> 03929 <input type="submit" name="TYPO3_INSTALL[update]['.$identifier.']" id="TYPO3_INSTALL[update]['.$identifier.']" value="'.$identifier.'" /> 03930 </div> 03931 '; 03932 } 03933 } 03934 } 03935 03936 if ($updateWizardBoxes) { 03937 $updateWizardBoxes = '<table><tr><td>'.$updateWizardBoxes.'</td></tr></table>'; 03938 $content = ' 03939 <form action="'.$this->action.'#bottom" method="post"> 03940 <input type="hidden" name="TYPO3_INSTALL[database_type]" value="'.htmlspecialchars('getUserInput').'"> 03941 '.$updateWizardBoxes.'<br /> 03942 </form> 03943 '; 03944 } else { 03945 $content = '<strong>No updates to perform!</strong>'; 03946 } 03947 break; 03948 case 'getUserInput': // second step - get user input and ask for final confirmation 03949 $title = '2 - configuration of updates'; 03950 $formContent = '<strong>The following updates will be performed:</strong>'; 03951 if (!$this->INSTALL['update']) { 03952 $content = '<strong>No updates selected!</strong>'; 03953 break; 03954 } 03955 // update methods might need to get custom data 03956 foreach ($this->INSTALL['update'] as $identifier => $tmp) { 03957 $className = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][$identifier]; 03958 03959 $tmpObj = $this->getUpgradeObjInstance($className, $identifier); 03960 03961 $formContent .= '<p><strong>'.$identifier.'</strong><input type="hidden" name="TYPO3_INSTALL[update][extList][]" value="'.$identifier.'" /><br />'; 03962 if (method_exists($tmpObj,'getUserInput')) { 03963 $formContent .= $tmpObj->getUserInput('TYPO3_INSTALL[update]['.$identifier.']'); 03964 } 03965 $formContent .= '</p><hr />'; 03966 } 03967 $formContent .= '<p><input type="checkbox" name="TYPO3_INSTALL[update][showDatabaseQueries]" id="TYPO3_INSTALL[update][showDatabaseQueries]" value="1" /> <label for="TYPO3_INSTALL[update][showDatabaseQueries]">Show database queries performed</label></p>'; 03968 $content = $this->getUpdateDbFormWrap('performUpdate', $formContent,'3 -Perform updates!'); 03969 break; 03970 case 'performUpdate': // third step - perform update 03971 $title = '3 - perform updates'; 03972 if (!$this->INSTALL['update']['extList']) { break; } 03973 03974 $GLOBALS['TYPO3_DB']->store_lastBuiltQuery = TRUE; 03975 foreach ($this->INSTALL['update']['extList'] as $identifier) { 03976 $className = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'][$identifier]; 03977 03978 $tmpObj = &$this->getUpgradeObjInstance($className, $identifier); 03979 03980 $content = '<p><strong>'.$identifier.'</strong><br />'; 03981 // check user input if testing method is available 03982 if (method_exists($tmpObj,'checkUserInput')) { 03983 $customOutput = ''; 03984 if (!$tmpObj->checkUserInput($customOutput)) { 03985 $content .= '<strong>'.($customOutput?$customOutput:'Something went wrong').'</strong>'; 03986 $content .= '<br /><a href="javascript:history.back()">Go back to update configuration</a>'; 03987 break; 03988 } 03989 } 03990 03991 if (method_exists($tmpObj,'performUpdate')) { 03992 $customOutput = ''; 03993 $dbQueries = array(); 03994 if ($tmpObj->performUpdate($dbQueries, $customOutput)) { 03995 $content .= '<strong>Update successful!</strong>'; 03996 } else { 03997 $content .= '<strong>FAILURE!</strong>'; 03998 } 03999 if ($this->INSTALL['update']['showDatabaseQueries']) { 04000 $content .= '<br />' . implode('<br />',$dbQueries); 04001 } 04002 $content .= '<br />' . $customOutput; 04003 04004 } else { 04005 $content .= '<strong>No update method available!</strong>'; 04006 } 04007 $content .= '</p><hr />'; 04008 } 04009 $GLOBALS['TYPO3_DB']->store_lastBuiltQuery = FALSE; 04010 break; 04011 } 04012 $this->message('Update Wizard',$title,$content); 04013 } 04014 04022 function getUpgradeObjInstance($className, $identifier) { 04023 $tmpObj = &t3lib_div::getUserObj($className); 04024 $tmpObj->versionNumber = t3lib_div::int_from_ver(TYPO3_version); 04025 $tmpObj->pObj = $this; 04026 $tmpObj->userInput = $this->INSTALL['update'][$identifier]; 04027 return $tmpObj; 04028 } 04029 04035 function isBackendAdminUser() { 04036 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'be_users', 'admin=1'); 04037 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); 04038 return current($row); 04039 } 04040 04046 function isStaticTemplates() { 04047 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'static_template', ''); 04048 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); 04049 return current($row); 04050 } 04051 04058 function isBasicComplete($tLabel) { 04059 if ($this->mode=='123') { 04060 $tables = $this->getListOfTables(); 04061 04062 if (count($tables)) { 04063 $beuser = $this->isBackendAdminUser(); 04064 $static = $this->isStaticTemplates(); 04065 } 04066 if (count($tables) && $beuser && $static) { 04067 $mode123Imported=1; 04068 $this->message($tLabel,'Basic Installation Completed',nl2br($this->messageBasicFinished()),-1,1); 04069 $this->message($tLabel,'Security Risk!',nl2br($this->securityRisk().$this->alterPasswordForm()),2,1); 04070 } else { 04071 $this->message($tLabel,'Still missing something?',nl2br(' 04072 You may be missing one of these points before your TYPO3 installation is complete: 04073 04074 '.(count($tables)?'':'- You haven\'t imported any tables yet. 04075 ') 04076 .($static?'':'- You haven\'t imported the static_template table. 04077 ') 04078 .($beuser?'':'- You haven\'t created an admin-user yet. 04079 ') 04080 .' 04081 04082 You you\'re about to import a database with a complete site in it, these three points should be met. 04083 '),-1,1); 04084 } 04085 } 04086 return $mode123Imported; 04087 } 04088 04098 function generateUpdateDatabaseForm($type, $arr_update, $arr_remove, $action_type) { 04099 $content = ''; 04100 switch($type) { 04101 case 'get_form': 04102 $content=''; 04103 $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_update['add'],'Add fields'); 04104 $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_update['change'],'Changing fields',(t3lib_extMgm::isLoaded('dbal')?0:1),0,$arr_update['change_currentValue']); 04105 $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_remove['change'],'Remove unused fields (rename with prefix)',$this->setAllCheckBoxesByDefault,1); 04106 $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_remove['drop'],'Drop fields (really!)',$this->setAllCheckBoxesByDefault); 04107 04108 $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_update['create_table'],'Add tables'); 04109 $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_remove['change_table'],'Removing tables (rename with prefix)',$this->setAllCheckBoxesByDefault,1,$arr_remove['tables_count'],1); 04110 $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_remove['drop_table'],'Drop tables (really!)',$this->setAllCheckBoxesByDefault,0,$arr_remove['tables_count'],1); 04111 04112 $content = $this->getUpdateDbFormWrap($action_type, $content); 04113 break; 04114 default: 04115 04116 break; 04117 } 04118 return $content; 04119 } 04120 04129 function getUpdateDbFormWrap($action_type, $content, $label='Write to database') { 04130 $form = '<form action="'.$this->action.'#bottom" method="post"><input type="hidden" name="TYPO3_INSTALL[database_type]" value="'.htmlspecialchars($action_type).'">'.$content.'<br /><input type="submit" value="'.$label.'">'; 04131 return $form; 04132 } 04133 04142 function displayFields($arr, $pre=0, $label='') { 04143 $out=''; 04144 $out.='<tr><td bgcolor="#9BA1A8" align="center"><strong>'.$this->fw('Field name:').'</strong></td><td bgcolor="#9BA1A8" align="center"><strong>'.$this->fw($label?$label:'Info:').'</strong></td></tr>'; 04145 if (is_array($arr)) { 04146 reset($arr); 04147 while(list($fieldname, $fieldContent)=each($arr)) { 04148 if ($pre) { 04149 $fieldContent = '<pre>'.trim($fieldContent).'</pre>'; 04150 } else { 04151 $fieldContent = $this->fw($fieldContent); 04152 } 04153 $out.='<tr><td bgcolor="#ABBBB4">'.$this->fw($fieldname).'</td><td bgcolor="#ABBBB4">'.$fieldContent.'</td></tr>'; 04154 } 04155 } 04156 $out= '<table border="0" cellpadding="0" cellspacing="0">'.$out.'</table>'; 04157 return $out; 04158 } 04159 04167 function displayFieldComp($arr, $arr_db) { 04168 $out=''; 04169 $out.='<tr><td bgcolor="#9BA1A8" align="center"><strong>'.$this->fw('Field name:').'</strong></td> 04170 <td bgcolor="#9BA1A8" align="center"><strong>'.$this->fw("Suggested value from \$TCA:").'</strong></td> 04171 <td bgcolor="#9BA1A8" align="center"><strong>'.$this->fw('Actual value from database:').'</strong></td> 04172 </tr>'; 04173 if (is_array($arr)) { 04174 reset($arr); 04175 while(list($fieldname, $fieldContent)=each($arr)) { 04176 // This tries to equalize the types tinyint and int 04177 $str1 = $fieldContent; 04178 $str2 = trim($arr_db[$fieldname]); 04179 $str1 = str_replace('tinyint(3)','tinyint(4)',$str1); 04180 $str2 = str_replace('tinyint(3)','tinyint(4)',$str2); 04181 $str1 = str_replace('int(10)','int(11)',$str1); 04182 $str2 = str_replace('int(10)','int(11)',$str2); 04183 // Compare: 04184 if (strcmp($str1,$str2)) { 04185 $bgcolor=' bgcolor="#ABBBB4"'; 04186 } else { 04187 $bgcolor=' bgcolor="#D9D5C9"'; 04188 } 04189 $fieldContent = $this->fw($fieldContent); 04190 $fieldContent_db = $this->fw($arr_db[$fieldname]); 04191 $out.='<tr> 04192 <td bgcolor="#D9D5C9">'.$this->fw($fieldname).'</td> 04193 <td'.$bgcolor.'>'.$fieldContent.'</td> 04194 <td'.$bgcolor.'>'.$fieldContent_db.'</td> 04195 </tr>'; 04196 } 04197 } 04198 $out= '<table border="0" cellpadding="2" cellspacing="2">'.$out.'</table>'; 04199 return $out; 04200 } 04201 04209 function displaySuggestions($arr, $excludeList='') { 04210 $out=''; 04211 $out.='<tr><td bgcolor="#9BA1A8" align="center"><strong>'.$this->fw('Field name:').'</strong></td><td bgcolor="#9BA1A8" align="center"><strong>'.$this->fw('Info / Suggestion for the field:').'</strong></td></tr>'; 04212 $fC=0; 04213 if (is_array($arr)) { 04214 reset($arr); 04215 while(list($fieldname, $fieldContent)=each($arr)) { 04216 if (!t3lib_div::inList($excludeList,$fieldname) && substr($fieldname,0,strlen($this->deletedPrefixKey))!=$this->deletedPrefixKey && substr($fieldname,-1)!='.') { 04217 $fieldContent = $this->fw($fieldContent); 04218 if ($arr[$fieldname.'.']) { 04219 $fieldContent.= '<hr />'; 04220 $fieldContent.= '<pre>'.trim($arr[$fieldname.'.']).'</pre>'; 04221 } 04222 $out.='<tr><td bgcolor="#ABBBB4">'.$this->fw($fieldname).'</td><td bgcolor="#ABBBB4">'.$fieldContent.'</td></tr>'; 04223 $fC++; 04224 } 04225 } 04226 } 04227 $out= '<table border="0" cellpadding="2" cellspacing="2">'.$out.'</table>'; 04228 return array($out,$fC); 04229 } 04230 04239 function compareDatabaseAndTCA($FDsrc, $TCA, $onlyFields=0) { 04240 $extraArr=array(); 04241 if (is_array($FDsrc)) { 04242 reset($FDsrc); 04243 while(list($table,$info)=each($FDsrc)) { 04244 if (!isset($TCA[$table])) { 04245 if (!$onlyFields) { 04246 $extraArr[$table]=$info; // If the table was not in the FDcomp-array, the result array is loaded with that table. 04247 $extraArr[$table]['whole_table']=1; 04248 unset($extraArr[$table]['keys']); 04249 } 04250 } else { 04251 $theKey='fields'; 04252 $excludeListArr=array(); 04253 if (is_array($TCA[$table]['ctrl']['enablecolumns'])) $excludeListArr[]=$TCA[$table]['ctrl']['enablecolumns']; 04254 $excludeListArr[]=$TCA[$table]['ctrl']['tstamp']; 04255 $excludeListArr[]=$TCA[$table]['ctrl']['sortby']; 04256 $excludeListArr[]=$TCA[$table]['ctrl']['delete']; 04257 $excludeListArr[]=$TCA[$table]['ctrl']['cruser_id']; 04258 $excludeListArr[]=$TCA[$table]['ctrl']['crdate']; 04259 $excludeListArr[]='uid'; 04260 $excludeListArr[]='pid'; 04261 if ($table=='pages') { 04262 $excludeListArr[]='perms_userid'; 04263 $excludeListArr[]='perms_groupid'; 04264 $excludeListArr[]='perms_user'; 04265 $excludeListArr[]='perms_group'; 04266 $excludeListArr[]='perms_everybody'; 04267 } 04268 if ($table=='sys_dmail') { 04269 $excludeListArr[]='scheduled'; 04270 $excludeListArr[]='scheduled_begin'; 04271 $excludeListArr[]='scheduled_end'; 04272 $excludeListArr[]='query_info'; 04273 } 04274 04275 if (is_array($info[$theKey])) { 04276 reset($info[$theKey]); 04277 while(list($fieldN,$fieldC)=each($info[$theKey])) { 04278 if (!isset($TCA[$table]['columns'][$fieldN]) && !in_array($fieldN,$excludeListArr)) { 04279 $extraArr[$table][$theKey][$fieldN] = $info['fields'][$fieldN]; 04280 $extraArr[$table][$theKey][$fieldN.'.']=$this->suggestTCAFieldDefinition($fieldN,$fieldC); 04281 } 04282 } 04283 } 04284 } 04285 } 04286 } 04287 return array('extra'=>$extraArr); 04288 } 04289 04297 function compareTCAandDatabase($TCA, $FDcomp) { 04298 $extraArr=array(); 04299 $matchingArr=array(); 04300 if (is_array($TCA)) { 04301 reset($TCA); 04302 while(list($table)=each($TCA)) { 04303 $info=$TCA[$table]; 04304 if (!isset($FDcomp[$table])) { 04305 // $extraArr[$table]=$info; // If the table was not in the FDcomp-array, the result array is loaded with that table. 04306 $extraArr[$table]['whole_table']=1; 04307 } else { 04308 reset($info['columns']); 04309 while(list($fieldN,$fieldC)=each($info['columns'])) { 04310 $fieldDef = $this->suggestFieldDefinition($fieldC); 04311 if (!is_array($fieldDef)) { 04312 if (!isset($FDcomp[$table]['fields'][$fieldN])) { 04313 $extraArr[$table]['fields'][$fieldN]=$fieldDef; 04314 } else { 04315 $matchingArr[$table]['fields'][$fieldN]=$fieldDef; 04316 } 04317 } 04318 } 04319 } 04320 } 04321 } 04322 return array('extra'=>$extraArr, 'matching'=>$matchingArr); 04323 } 04324 04331 function suggestFieldDefinition($fieldInfo) { 04332 $out=''; 04333 switch($fieldInfo['config']['type']) { 04334 case 'input': 04335 if (ereg('date|time|int|year',$fieldInfo['config']['eval'])) { 04336 $out = "int(11) NOT NULL default '0'"; 04337 } else { 04338 $max = intval($fieldInfo['config']['max']); 04339 if ($max>0 && $max<200) { 04340 $out = 'varchar('.$max.") NOT NULL default ''"; 04341 } else { 04342 $out = 'tinytext NOT NULL'; 04343 } 04344 } 04345 break; 04346 case 'text': 04347 $out = 'text NOT NULL'; 04348 break; 04349 case 'check': 04350 if (is_array($fieldInfo['config']['items']) && count($fieldInfo['config']['items'])>8) { 04351 $out = "int(11) NOT NULL default '0'"; 04352 } else { 04353 $out = "tinyint(3) NOT NULL default '0'"; 04354 } 04355 break; 04356 case 'radio': 04357 if (is_array($fieldInfo['config']['items'])) { 04358 $out = $this->getItemArrayType($fieldInfo['config']['items']); 04359 } else { 04360 $out = 'ERROR: Radiobox did not have items!'; 04361 } 04362 break; 04363 case 'group': 04364 if ($fieldInfo['config']['internal_type']=='db') { 04365 $max = t3lib_div::intInRange($fieldInfo['config']['maxitems'],1,10000); 04366 if (count(explode(',',$fieldInfo['config']['allowed']))>1) { 04367 $len = $max*(10+1+5+1); // Tablenames are 10, "_" 1, uid's 5, comma 1 04368 $out=$this->getItemBlobSize($len); 04369 } elseif ($max<=1) { 04370 $out = "int(11) NOT NULL default '0'"; 04371 } else { 04372 $len = $max*(5+1); // uid's 5, comma 1 04373 $out=$this->getItemBlobSize($len); 04374 } 04375 } 04376 if ($fieldInfo['config']['internal_type']=='file') { 04377 $max = t3lib_div::intInRange($fieldInfo['config']['maxitems'],1,10000); 04378 $len = $max*(30+1); // Filenames is 30+ chars.... 04379 $out=$this->getItemBlobSize($len); 04380 } 04381 break; 04382 case 'select': 04383 $max = t3lib_div::intInRange($fieldInfo['config']['maxitems'],1,10000); 04384 if ($max<=1) { 04385 if ($fieldInfo['config']['foreign_table']) { 04386 $out = "int(11) NOT NULL default '0'"; 04387 } else { 04388 $out = $this->getItemArrayType($fieldInfo['config']['items']); 04389 } 04390 } else { 04391 // five chars (special=10) + comma: 04392 $len = $max*(($fieldInfo['config']['special']?10:5)+1); 04393 $out=$this->getItemBlobSize($len); 04394 } 04395 break; 04396 default: 04397 break; 04398 } 04399 return $out?$out:$fieldInfo; 04400 } 04401 04408 function getItemArrayType($arr) { 04409 if (is_array($arr)) { 04410 reset($arr); 04411 $type[]=0; 04412 $intSize[]=0; 04413 while(list(,$item)=each($arr)) { 04414 if (!t3lib_div::testInt($item[1]) && $item[1]!='--div--') { 04415 $type[]=strlen($item[1]); 04416 } else { 04417 $intSize[]=$item[1]; 04418 } 04419 } 04420 $us = min($intSize)>=0 ? ' unsigned' : ''; 04421 if (max($type)>0) { 04422 $out = 'varchar('.max($type).") NOT NULL default ''"; 04423 } else { 04424 $out = "int(11) NOT NULL default '0'"; 04425 } 04426 } 04427 return $out; 04428 } 04429 04436 function getItemBlobSize($len) { 04437 return ($len>255 ? 'tiny' : '').'blob NOT NULL'; 04438 } 04439 04447 function suggestTCAFieldDefinition($fieldName,$fieldInfo) { 04448 list($type,$len) = split(' |\(|\)',$fieldInfo,3); 04449 switch($type) { 04450 case 'int': 04451 $out=" 04452 '".$fieldName."' => array ( 04453 'label' => '".strtoupper($fieldName).":', 04454 'exclude' => 0, 04455 'config' => array ( 04456 'type' => 'input', 04457 'size' => '8', 04458 'max' => '20', 04459 'eval' => 'date', 04460 'default' => '0', 04461 'checkbox' => '0' 04462 ) 04463 ), 04464 04465 ----- OR ----- 04466 04467 '".$fieldName."' => array ( 04468 'label' => '".strtoupper($fieldName).":', 04469 'exclude' => 0, 04470 'config' => array ( 04471 'type' => 'select', 04472 'items' => array ( 04473 array('[nothing]', 0), 04474 array('Extra choice! Only negative values here.', -1), 04475 array('__Divider:__', '--div--') 04476 ), 04477 'foreign_table' => '[some_table_name]' 04478 ) 04479 ),"; 04480 break; 04481 case 'varchar': 04482 if ($len>10) { 04483 $out=" 04484 '".$fieldName."' => array ( 04485 'label' => '".strtoupper($fieldName).":', 04486 'exclude' => 0, 04487 'config' => array ( 04488 'type' => 'input', 04489 'size' => '8', 04490 'max' => '".$len."', 04491 'eval' => 'trim', 04492 'default' => '' 04493 ) 04494 ),"; 04495 } else { 04496 $out=" 04497 '".$fieldName."' => array ( 04498 'label' => '".strtoupper($fieldName).":', 04499 'exclude' => 0, 04500 'config' => array ( 04501 'type' => 'select', 04502 'items' => array ( 04503 array('Item number 1', 'key1'), 04504 array('Item number 2', 'key2'), 04505 array('-----', '--div--'), 04506 array('Item number 3', 'key3') 04507 ), 04508 'default' => '1' 04509 ) 04510 ),"; 04511 } 04512 break; 04513 case 'tinyint': 04514 $out=" 04515 '".$fieldName."' => array ( 04516 'label' => '".strtoupper($fieldName).":', 04517 'exclude' => 0, 04518 'config' => array ( 04519 'type' => 'select', 04520 'items' => array ( 04521 array('Item number 1', '1'), 04522 array('Item number 2', '2'), 04523 array('-----', '--div--'), 04524 array('Item number 3', '3') 04525 ), 04526 'default' => '1' 04527 ) 04528 ), 04529 04530 ----- OR ----- 04531 04532 '".$fieldName."' => array ( 04533 'label' => '".strtoupper($fieldName).":', 04534 'exclude' => 0, 04535 'config' => array ( 04536 'type' => 'check', 04537 'default' => '1' 04538 ) 04539 ),"; 04540 break; 04541 case 'tinytext': 04542 $out=" 04543 '".$fieldName."' => array ( 04544 'label' => '".strtoupper($fieldName).":', 04545 'exclude' => 0, 04546 'config' => array ( 04547 'type' => 'input', 04548 'size' => '40', 04549 'max' => '255', 04550 'eval' => '', 04551 'default' => '' 04552 ) 04553 ),"; 04554 break; 04555 case 'text': 04556 case 'mediumtext': 04557 $out=" 04558 '".$fieldName."' => array ( 04559 'label' => '".strtoupper($fieldName).":', 04560 'config' => array ( 04561 'type' => 'text', 04562 'cols' => '48', 04563 'rows' => '5' 04564 ) 04565 ),"; 04566 break; 04567 default: 04568 $out=" 04569 '".$fieldName."' => array ( 04570 'label' => '".strtoupper($fieldName).":', 04571 'exclude' => 0, 04572 'config' => array ( 04573 'type' => 'input', 04574 'size' => '30', 04575 'max' => '', 04576 'eval' => '', 04577 'default' => '' 04578 ) 04579 ),"; 04580 break; 04581 } 04582 return $out?$out:$fieldInfo; 04583 } 04584 04590 function includeTCA() { 04591 global $TCA; 04592 04593 include (TYPO3_tables_script ? PATH_typo3conf.TYPO3_tables_script : PATH_t3lib.'stddb/tables.php'); 04594 04595 // Extension additions 04596 if ($GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE']) { 04597 include(PATH_typo3conf.$GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'].'_ext_tables.php'); 04598 } else { 04599 include(PATH_t3lib.'stddb/load_ext_tables.php'); 04600 } 04601 04602 if (TYPO3_extTableDef_script) { 04603 include (PATH_typo3conf.TYPO3_extTableDef_script); 04604 } 04605 04606 reset($TCA); 04607 while(list($table)=each($TCA)) { 04608 t3lib_div::loadTCA($table); 04609 } 04610 } 04611 04612 04613 04614 04615 04616 04617 04618 04619 /********************** 04620 * 04621 * GENERAL FUNCTIONS 04622 * 04623 **********************/ 04624 04632 function linkIt($url,$link='') { 04633 return '<a href="'.$url.'" target="_blank">'.($link?$link:$url).'</a>'; 04634 } 04635 04646 function message($head, $short_string='', $long_string='', $type=0, $force=0) { 04647 if (!$force && $this->mode=='123' && $type<2) { return; } // Return directly if mode-123 is enabled. 04648 04649 if ($type==3) { $this->fatalError=1; } 04650 if ($this->messageFunc_nl2br && !preg_match('/<\/table>/', $long_string)) { 04651 $long_string = nl2br(trim($long_string)); 04652 } else { 04653 $long_string = trim($long_string); 04654 } 04655 if (!$this->silent) $this->printSection($head, $short_string, $long_string, $type); 04656 } 04657 04667 function printSection($head, $short_string, $long_string, $type) { 04668 $icon=''; 04669 04670 $bgCol =' bgcolor="#D9D5C9"'; // The default color 04671 switch($type) { 04672 case '3': 04673 $bgCol =' bgcolor="red"'; 04674 $icon = 'gfx/icon_fatalerror.gif'; 04675 break; 04676 case '2': 04677 $bgCol =' bgcolor="#9BA1A8"'; 04678 $icon = 'gfx/icon_warning.gif'; 04679 break; 04680 case '1': 04681 // $bgCol =' bgcolor="#ABBBB4"'; 04682 $icon = 'gfx/icon_note.gif'; 04683 break; 04684 case '-1': 04685 // $bgCol =' bgcolor="yellow"'; 04686 $icon = 'gfx/icon_ok.gif'; 04687 break; 04688 default: 04689 $bgCol =' bgcolor="#D3D9DC"'; 04690 break; 04691 } 04692 if (!trim($short_string)) { 04693 $this->sections[$head][]=''; 04694 } else { 04695 $this->sections[$head][]=' 04696 <tr><td'.$bgCol.' nowrap="nowrap">'.($icon?'<img src="'.$this->backPath.$icon.'" width="18" height="16" align="top" alt="">':'').'<strong>'.$this->fw($short_string).'</strong></td></tr>'.(trim($long_string)?' 04697 <tr><td>'.$this->fw($long_string).'<br /><br /></td></tr>' : ''); 04698 } 04699 } 04700 04708 function fw($str,$size=1) { 04709 04710 if (preg_match('/^<table/', $str) && preg_match('/<\/table>$/', $str)) { 04711 // no wrap 04712 } else { 04713 if($size==1) { 04714 $size = 'class="smalltext"'; 04715 } elseif ($size==2) { 04716 $size = 'class="bodytext"'; 04717 } else { 04718 $size = 'size="size'.$size.'text"'; 04719 } 04720 $str = '<span '.$size.'>'.$str.'</span>'; 04721 } 04722 return $str; 04723 } 04724 04731 function fwheader($str) { 04732 return '<div align="center"><strong>'.$this->fw($str,3).'</strong></div>'; 04733 } 04734 04742 function wrapInCells($label,$content) { 04743 return '<tr><td valign="top" nowrap="nowrap"><strong>'.$this->fw($label).'</strong></td><td> </td><td valign="top">'.$this->fw($content).'<br /></td></tr>'; 04744 } 04745 04751 function printAll() { 04752 reset($this->sections); 04753 $out=''; 04754 while(list($header,$valArray)=each($this->sections)) { 04755 $out.=' 04756 <tr><td> </td></tr> 04757 <tr><td><div align="center"><strong>'.$this->fw($header.':',2).'</strong></div></td></tr> 04758 '; 04759 $out.=implode($valArray,chr(10)); 04760 } 04761 return '<table border="0" cellpadding="2" cellspacing="2">'.$out.'</table>'; 04762 } 04763 04770 function outputWrapper($content) { 04771 $out=' 04772 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 04773 "http://www.w3.org/TR/html4/loose.dtd"> 04774 <html> 04775 <head> 04776 04777 <style type="text/css"> 04778 body, p, td, a, span, input, .bodytext { 04779 font-family:verdana,sans-serif; 04780 font-size:1em; 04781 color:#000; 04782 text-align: left; 04783 } 04784 .smalltext { 04785 font-size:0.9em; 04786 } 04787 .size3text { 04788 font-size:1.2em; 04789 } 04790 .size4text { 04791 font-size:1.5em; 04792 } 04793 a {color: #600; text-decoration: none;} 04794 a:active {text-decoration: none;} 04795 a:hover {color: #006; text-decoration:underline:} 04796 </style> 04797 '.$this->headerStyle.' 04798 04799 <title>TYPO3 Install Tool</title> 04800 '.($this->JSmessage?' 04801 <script language="javascript" type="text/javascript">alert(unescape(\''.rawurlencode($this->JSmessage).'\'));</script> 04802 04803 ':'').' 04804 </head> 04805 <body bgcolor="white" alink="maroon" link="maroon" vlink="maroon">'.$this->contentBeforeTable.' 04806 <div align="center"> 04807 <table border="0" cellspacing="0" cellpadding="0" width="333" bgcolor="white"> 04808 <tr> 04809 <td style="text-align:center;"><img src="'.$this->backPath.'gfx/typo3logo.gif" width="123" height="34" vspace="10" hspace="50" alt="TYPO3"></td> 04810 </tr> 04811 <tr> 04812 <td bgcolor="black"> 04813 <table width="100%" border="0" cellspacing="1" cellpadding="10"> 04814 <tr> 04815 <td bgcolor="#F4F0E8"> 04816 <div align="center"><span class="size4text"><strong>TYPO3 '.$GLOBALS['TYPO_VERSION'].' Install Tool</strong></span></div> 04817 <div align="center"><span style="color:navy;"><strong>Site: '.$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'].'</strong></span></div><br /> 04818 04819 '.($this->step?$this->stepHeader():$this->menu()).$content.'<hr />'.$this->note123().$this->endNotes().' 04820 </td> 04821 </tr> 04822 </table> 04823 </td> 04824 </tr> 04825 </table> 04826 </div> 04827 </body> 04828 </html>'; 04829 return $out; 04830 } 04831 04837 function menu() { 04838 if (!$this->passwordOK) return; 04839 04840 reset($this->menuitems); 04841 $c=0; 04842 $out=array(); 04843 while(list($k,$v)=each($this->menuitems)) { 04844 $bgcolor = ($this->INSTALL['type']==$k ? ' bgcolor="#ABBBB4"' : ' bgcolor="#F4F0E8"'); 04845 $c++; 04846 $out[]='<tr><td'.$bgcolor.'><a href="'.htmlspecialchars($this->scriptSelf.'?TYPO3_INSTALL[type]='.$k.($this->mode?'&mode='.rawurlencode($this->mode):'')).'">'.$this->fw($c.': '.$v).'</a></td></tr>'; 04847 } 04848 04849 $code = '<table border="0" cellpadding="0" cellspacing="1">'.implode($out,chr(10)).'</table>'; 04850 $code = '<table border="0" cellpadding="0" cellspacing="0" bgcolor="#ABBBB4"><tr><td>'.$code.'</td></tr></table>'; 04851 return '<div align="center">'.$code.'</div>'; 04852 } 04853 04859 function stepHeader() { 04860 $msg1='Type in your database parameters here:'; 04861 $msg2='Database'; 04862 $msg3='Import the database sql-file'; 04863 $msg4='You\'re done!'; 04864 $out='<img src="'.$this->backPath.'gfx/123_'.$this->step.'.png" width="402" height="73" border="0" alt="" usemap="#id123_print_Map"> 04865 <map name="id123_print_Map"> 04866 <area title="'.$msg4.'" shape="poly" alt="" coords="299,35, 303,19, 313,9, 335,5, 366,6, 379,11, 388,21, 392,35, 390,47, 381,58, 376,64, 359,67, 320,66, 307,60, 302,51, 300,44" href="'.htmlspecialchars($this->scriptSelf.'?mode='.$this->mode.'&step=go').'"> 04867 <area title="'.$msg3.'" shape="circle" alt="" coords="234,36,32" href="'.htmlspecialchars($this->scriptSelf.'?mode='.$this->mode.'&step=3').'"> 04868 <area title="'.$msg2.'" shape="circle" alt="" coords="136,37,30" href="'.htmlspecialchars($this->scriptSelf.'?mode='.$this->mode.'&step=2').'"> 04869 <area title="'.$msg1.'" shape="circle" alt="" coords="40,36,29" href="'.htmlspecialchars($this->scriptSelf.'?mode='.$this->mode.'&step=1').'"> 04870 </map> 04871 04872 04873 <br />'; 04874 $msg=''; 04875 switch(strtolower($this->step)) { 04876 case 1: 04877 $msg=$msg1; 04878 break; 04879 case 2: 04880 $msg=$msg2; 04881 break; 04882 case 3: 04883 $msg=$msg3; 04884 break; 04885 case 'go': 04886 $msg=$msg4; 04887 break; 04888 default: 04889 break; 04890 } 04891 $out.='<br /><div align="center"><strong>'.$this->fw($msg,2).'</strong></div>'; 04892 04893 return $out; 04894 } 04895 04901 function note123() { 04902 if ($this->mode=='123') { 04903 $c='<table border="0" cellpadding="0" cellspacing="0" width="100%"> 04904 <tr><td bgcolor="#D9D5C9" nowrap="nowrap"><img src="'.$this->backPath.'gfx/icon_note.gif" width="18" height="16" align="top" alt=""><strong>'.$this->fontTag1.'NOTICE: Install Tool is running in \'123\' mode. <a href="'.$this->scriptSelf.'">Click here to disable.</a></span></strong></td></tr> 04905 </table>'; 04906 return $c; 04907 } 04908 } 04909 04915 function endNotes() { 04916 if ($this->mode!='123' && $this->passwordOK) { 04917 $c.='OS detected: <strong>'.(TYPO3_OS=='WIN'?'WIN':'UNIX').'</strong><br />'; 04918 $c.='UNIX/CGI detected: <strong>'.(php_sapi_name()=='cgi' ? 'YES' : 'NO').'</strong><br />'; 04919 $c.='PATH_thisScript: <strong>'.PATH_thisScript.'</strong><br />'; 04920 $c.='<br />'; 04921 $c.='<a href="../index.php" target="install_backend">Backend admin in new window.</a><br />'; 04922 $c.='<a href="../../index.php" target="install_frontend">Frontend website in new window.</a><br />'; 04923 04924 return $this->fw($c); 04925 } 04926 } 04927 04934 function convertByteSize($bytes) { 04935 if (stristr($bytes,'m')) { 04936 $bytes=doubleval($bytes)*1024*1024; 04937 } elseif (stristr($bytes,'k')) { 04938 $bytes=doubleval($bytes)*1024; 04939 } 04940 return $bytes; 04941 } 04942 04948 function securityRisk() { 04949 $c='This script is a <strong>great danger to the security of TYPO3</strong> if you don\'t secure it somehow. 04950 We suggest one of the following: 04951 04952 - change the password as defined by the md5-hash in TYPO3_CONF_VARS[BE][installToolPassword]. 04953 - delete the folder \'typo3/install/\' with this script in or just insert an \'exit;\' line in the script-file there. 04954 - password protect the \'typo3/install/\' folder, eg. with a .htaccess file 04955 04956 The TYPO3_CONF_VARS[BE][installToolPassword] is always active, but choosing one of the other options will improve security and is recommended highly. 04957 '; 04958 return $c; 04959 } 04960 04966 function alterPasswordForm() { 04967 $content = '<form action="'.$this->scriptSelf.'?TYPO3_INSTALL[type]=extConfig" method="post"> 04968 Enter new password: 04969 <input type="password" name="TYPO3_INSTALL[extConfig][BE][installToolPassword]" /><br />Enter again: 04970 <input type="password" name="installToolPassword_check" /> 04971 <input type="hidden" name="installToolPassword_md5" value="1" /> 04972 <input type="submit" value="Set new password" /><br /> 04973 </form>'; 04974 return $content; 04975 } 04976 04982 function messageBasicFinished() { 04983 $msg =' 04984 Apparently you have completed the basic setup of the TYPO3 database. 04985 Now you can choose between these options: 04986 04987 - <a href="../../index.php"><strong>Go to the frontend pages</strong></a> 04988 04989 - <a href="../index.php"><strong>Go to the backend login</strong></a> 04990 (username may be: <i>admin</i>, password may be: <i>password</i>.) 04991 04992 - <a href="'.$this->scriptSelf.'"><strong>Continue to configure TYPO3</strong></a> (Recommended). 04993 This will let you analyse and verify that everything in your PHP installation is alright. Also if you want to configure TYPO3 to use all the cool features, you <em>must</em> dig into the this! 04994 '; 04995 return $msg; 04996 } 04997 05004 function setScriptName($type) { 05005 $value = $this->scriptSelf.'?TYPO3_INSTALL[type]='.$type.($this->mode?'&mode='.rawurlencode($this->mode):'').($this->step?'&step='.rawurlencode($this->step):''); 05006 return $value; 05007 } 05008 05017 function formWidth($size=48,$textarea=0,$styleOverride='') { 05018 // Input or text-field attribute (size or cols) 05019 $wAttrib = $textarea?'cols':'size'; 05020 if (!$GLOBALS['CLIENT']['FORMSTYLE']) { // If not setting the width by style-attribute 05021 $size = ceil($size*1); 05022 $retVal = ' '.$wAttrib.'="'.$size.'"'; 05023 } else { // Setting width by style-attribute. "cols" MUST be avoided with NN6+ 05024 $pixels = ceil($size*10); 05025 $retVal = $styleOverride ? ' style="'.$styleOverride.'"' : ' style="width:'.$pixels.'px;"'; 05026 } 05027 return $retVal; 05028 } 05029 05038 function formWidthText($size=48,$styleOverride='',$wrap='') { 05039 $wTags = $this->formWidth($size,1,$styleOverride); 05040 // Netscape 6+ seems to have this ODD problem where there WILL ALWAYS be wrapping with the cols-attribute set and NEVER without the col-attribute... 05041 if (strtolower(trim($wrap))!='off' && $GLOBALS['CLIENT']['BROWSER']=='net' && $GLOBALS['CLIENT']['VERSION']>=5) { 05042 $wTags.=' cols="'.$size.'"'; 05043 } 05044 return $wTags; 05045 } 05046 05054 function getBackupFilename($filename) { 05055 if (preg_match('/\.php$/', $filename)) { 05056 $backupFile = str_replace('.php', '_bak.php', $filename); 05057 } else { 05058 $backupFile = $filename.'~'; 05059 } 05060 05061 return $backupFile; 05062 } 05063 } 05064 05065 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/install/mod/class.tx_install.php']) { 05066 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/install/mod/class.tx_install.php']); 05067 } 05068 ?>