Fixed bug #14050: CleanUp - CGL format of t3lib files - t3lib_positionmap
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_install.php
old mode 100755 (executable)
new mode 100644 (file)
index 9848176..9705070
 <?php
 /***************************************************************
-*  Copyright notice
-*  
-*  (c) 1999-2003 Kasper Skaarhoj (kasper@typo3.com)
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is 
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-* 
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license 
-*  from the author is found in LICENSE.txt distributed with these scripts.
-*
-* 
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-/** 
- * Used to setup localconf.php and verify the TYPO3 installation
- * This script should reduce the number of questions on the mailing with more than 50%... :-)
+ *  Copyright notice
  *
- * $Id$
+ *  (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
+ *  All rights reserved
  *
- * @author     Kasper Skaarhoj <kasper@typo3.com>
- */
-/**
- * [CLASS/FUNCTION INDEX of SCRIPT]
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
  *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
  *
  *
- *  165: class t3lib_install 
- *  243:     function t3lib_install()  
- *  320:     function checkPassword($uKey)     
- *  380:     function init()   
- *  540:     function stepOutput()     
- *  791:     function checkTheConfig() 
- *  822:     function typo3conf_edit() 
- *  932:     function phpinformation() 
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
  *
- *              SECTION: typo3temp/ manager
- * 1033:     function typo3TempManager()       
- * 1134:     function getSelectorOptions($deleteType,$tt="")   
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+/**
+ * Class to setup values in localconf.php and verify the TYPO3 DB tables/fields
+ *
+ * $Id$
  *
- *              SECTION: CONFIGURATION FORM
- * 1167:     function generateConfigForm($type="")     
- * 1239:     function getDefaultConfigArrayComments($string,$mainArray=array(),$commentArray=array())  
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
+ */
+/**
+ * [CLASS/FUNCTION INDEX of SCRIPT]
  *
- *              SECTION: CHECK CONFIGURATION FUNCTIONS
- * 1292:     function checkConfiguration()     
- * 1481:     function check_mail($cmd="")      
- * 1504:     function checkExtensions()        
- * 1567:     function checkDirs()      
- * 1636:     function checkImageMagick($paths) 
- * 1697:     function _checkImageMagickGifCapability($file)    
- * 1739:     function _checkImageMagick_getVersion($file)      
- * 1752:     function checkDatabase()          
- * 1814:     function setupGeneral($cmd="")    
- * 1979:     function writeToLocalconf_control($lines="",$dontOutputContent=0) 
- * 2027:     function outputExitBasedOnStep($content)  
- * 2042:     function checkForBadString($string)       
- * 2057:     function setValueInLocalconfFile(&$line_array, $variable, $value) 
- * 2104:     function slashValueForSingleDashes($value)        
- * 2115:     function setLabelValueArray($arr,$type)   
- * 2143:     function getFormElement($labels,$values,$fieldName,$default,$msg="")      
- * 2163:     function getDatabaseList()        
- * 2192:     function setupGeneralCalculate()  
- * 2261:     function getGDPartOfPhpinfo()     
- * 2280:     function isTTF($phpinfo="")       
  *
- *              SECTION: ABOUT the isXXX functions.
- * 2329:     function isGD()   
- * 2340:     function isGIF()  
- * 2352:     function isJPG()  
- * 2363:     function isPNG()  
- * 2375:     function ImageTypes()     
- * 2386:     function getGDSoftwareInfo()      
- * 2398:     function generallyAboutConfiguration()    
  *
- *              SECTION: IMAGE processing
- * 2458:     function checkTheImageProcessing()        
- * 2937:     function isExtensionEnabled($ext, $headCode, $short)      
- * 2953:     function displayTwinImage ($imageFile, $IMcommands=array(), $note="")     
- * 3024:     function getTwinImageMessage($message, $label_1="", $label_2="")  
- * 3040:     function formatImCmds($arr)       
- * 3061:     function imagemenu()      
+ *   83: class t3lib_install
+ *  108:        function t3lib_install()
  *
- *              SECTION: DATABASE analysing
- * 3103:     function checkTheDatabase()       
- * 3702:     function isBackendAdminUser() 
- * 3714:     function isStaticTemplates()      
- * 3727:     function isBasicComplete($tLabel) 
- * 3763:     function getListOfTables()        
- * 3783:     function generateUpdateDatabaseForm($type, $arr_update, $arr_remove, $action_type)        
- * 3813:     function getUpdateDbFormWrap($action_type, $content, $label="Write to database")  
- * 3829:     function generateUpdateDatabaseForm_checkboxes($arr,$label,$checked=1,$iconDis=0,$currentValue=array(),$cVfullMsg=0)      
- * 3863:     function preformUpdateQueries($arr,$keyArr)       
- * 3884:     function displayFields($arr, $pre=0, $label="")   
- * 3909:     function displayFieldComp($arr, $arr_db)  
- * 3951:     function displaySuggestions($arr, $excludeList="")        
- * 3980:     function getCreateTables($statements, $insertCountFlag=0) 
- * 4005:     function getTableInsertStatements($statements, $table)    
- * 4031:     function getStatementArray($sqlcode,$removeNonSQL=0,$query_regex="")      
- * 4067:     function assembleFieldDefinition($row)    
- * 4094:     function getFieldDefinitions_database($database)  
- * 4132:     function getFieldDefinitions_sqlContent($sqlContent)      
- * 4172:     function getDatabaseExtra($FDsrc, $FDcomp)        
- * 4210:     function compareDatabaseAndTCA($FDsrc, $TCA, $onlyFields=0)       
- * 4268:     function compareTCAandDatabase($TCA, $FDcomp)     
- * 4303:     function getUpdateSuggestions($diffArr,$keyList="extra,diff")     
- * 4405:     function suggestFieldDefinition($fieldInfo)       
- * 4483:     function getItemArrayType($arr)   
- * 4513:     function getItemBlobSize($len)    
- * 4524:     function suggestTCAFieldDefinition($fieldName,$fieldInfo) 
- * 4667:     function includeTCA()     
+ *                       SECTION: Writing to localconf.php
+ *  132:        function setValueInLocalconfFile(&$line_array, $variable, $value)
+ *  183:        function writeToLocalconf_control($inlines='',$absFullPath='')
+ *  253:        function checkForBadString($string)
+ *  266:        function slashValueForSingleDashes($value)
  *
- *              SECTION: GENERAL FUNCTIONS
- * 4709:     function linkIt($url,$link="")    
- * 4737:     function printSection($head, $short_string, $long_string, $type)  
- * 4778:     function fw($str,$size=1) 
- * 4791:     function fwheader($str)   
- * 4802:     function wrapInCells($label,$content)     
- * 4811:     function printAll()       
- * 4830:     function outputWrapper($content)  
- * 4883:     function menu()   
- * 4905:     function stepHeader()     
- * 4947:     function note123()        
- * 4961:     function endNotes()       
- * 4980:     function convertByteSize($bytes)  
- * 4994:     function securityRisk()   
- * 5012:     function alterPasswordForm()      
- * 5028:     function messageBasicFinished()   
- * 5050:     function setScriptName($type)     
- * 5063:     function formWidth($size=48,$textarea=0,$styleOverride="") 
- * 5084:     function formWidthText($size=48,$styleOverride="",$wrap="") 
+ *                       SECTION: SQL
+ *  291:        function getFieldDefinitions_fileContent($fileContent)
+ *  359:        function getFieldDefinitions_sqlContent_parseTypes(&$total)
+ *  406:        function getFieldDefinitions_database()
+ *  450:        function getDatabaseExtra($FDsrc, $FDcomp, $onlyTableList='')
+ *  496:        function getUpdateSuggestions($diffArr,$keyList='extra,diff')
+ *  589:        function assembleFieldDefinition($row)
+ *  611:        function getStatementArray($sqlcode,$removeNonSQL=0,$query_regex='')
+ *  649:        function getCreateTables($statements, $insertCountFlag=0)
+ *  683:        function getTableInsertStatements($statements, $table)
+ *  704:        function performUpdateQueries($arr,$keyArr)
+ *  720:        function getListOfTables()
+ *  736:        function generateUpdateDatabaseForm_checkboxes($arr,$label,$checked=1,$iconDis=0,$currentValue=array(),$cVfullMsg=0)
  *
- * TOTAL FUNCTIONS: 89
+ * TOTAL FUNCTIONS: 17
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
-
-
-
-
-
-
 
 
 /**
- * Used to setup localconf.php and verify the TYPO3 installation
- * 
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * Class to setup values in localconf.php and verify the TYPO3 DB tables/fields
+ *
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage t3lib
  */
 class t3lib_install {
-       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()
-       var $getGD_end_string = '</TABLE>';     // Used to identify the end of the GD section (found with getGD_start_string) in the output from phpinfo()
-       var $getTTF_string = 'with TTF library';        // Used to identify whether TTF-lib is included with GD
-       var $getTTF_string_alt = 'with freetype';       // Used to identify whether TTF-lib is included with GD
-       var $action = "";               // The url that calls this script
-       var $scriptSelf = "index.php";          // The url that calls this script
-       var $fontTag2='<font face="verdana,sans-serif" size=2 color=black>';
-       var $fontTag1='<font face="verdana,sans-serif" size=1 color=black>';
-       var $updateIdentity = "TYPO3 Install Tool";
-       var $headerStyle ='';
-       var $contentBeforeTable="";
-       var $setAllCheckBoxesByDefault=0;
-
-       var $allowFileEditOutsite_typo3conf_dir=0;
-
-       var $INSTALL =array();          // In constructor: is set to global GET/POST var TYPO3_INSTALL
-       var $messages = array();        // Used to set (error)messages from the executing functions like mail-sending, writing Localconf and such
-       var $checkIMlzw = 0;            // If set, lzw capabilities of the available ImageMagick installs are check by actually writing a gif-file and comparing size
-       var $checkIM = 0;                       // If set, ImageMagick is checked.
-       var $localconf_addLinesOnly=0;  // If this is set, modifications to localconf.php is done by adding new lines to the array only. If unset, existing values are recognized and changed.
-       var $localconf_editPointToken="INSTALL SCRIPT EDIT POINT TOKEN - all lines after this points may be changed by the install script!";            // If set and addLinesOnly is disabled, lines will be change only if they are after this token (on a single line!) in the file
-       var $allowUpdateLocalConf=0;    // If set, this class will allow the user to update the localconf.php file. Is set true in the init.php file.
-       var $dumpImCommands=1;                  // If set, the image Magick commands are always outputted in the image processing checker
-       var $deletedPrefixKey="zzz_deleted_";   //
-       var $backPath="../";
-       var $mysqlVersion = "3.22";             // 3.22 or 3.23 If set to 3.23, then the expected format of the incoming sql-dump files are changed. 'DEFAULT' and 'NOT NULL' are reversed in order and 'DEFAULT' is lowercase. Also auto_incremented fields are without default definitions.
-       var $mode = ""; // If set to "123" then only most vital information is displayed.
-       var $step = 0;  // If set to 1,2,3 or GO it signifies various functions.
-       
-       // internal
-       var $passwordOK=0;                      // This is set, if the password check was ok. The function init() will exit if this is not set
-       var $silent=1;                          // If set, the check routines don't add to the message-array
-       var $messageFunc_nl2br=1;
-       var $setLocalconf=0;            // Used to indicate that a value is change in the line-array of localconf and that it should be written.
-       var $sections=array();          // Used to gather the message information.
-       var $fatalError=0;                      // This is set if some error occured that will definitely prevent TYpo3 from running.
-       var $sendNoCacheHeaders=1;      
-       var $config_array = array(      // Flags are set in this array if the options are available and checked ok.
-               "gd"=>0,
-               "gd_gif"=>0,
-               "gd_png"=>0,
-               "gd_jpg"=>0,
-               "freetype" => 0,
-               "safemode" => 0,
-               "dir_typo3temp" => 0,
-               "dir_temp" => 0,
-               "im_versions" => array(),
-               "im" => 0,
-               "sql.safe_mode_user" => "",
-               "mysqlConnect" => 0,
-               "no_database" => 0
-       );
-       var $typo3temp_path="";
-       
-       var $menuitems = array(
-               "config" => "Basic Configuration",
-               "database" => "Database Analyser",
-               "images" => "Image Processing",
-               "extConfig" => "All Configuration",
-               "typo3temp" => "typo3temp/",
-               "phpinfo" => "phpinfo()",
-               "typo3conf_edit" => "Edit files in typo3conf/",
-               "about" => "About"
-       );
-       var $cookie_name = "Typo3InstallTool";
-       var $JSmessage = '';
 
 
+               // External, Static
+       var $updateIdentity = ''; // Set to string which identifies the script using this class.
+       var $deletedPrefixKey = 'zzz_deleted_'; // Prefix used for tables/fields when deleted/renamed.
+       var $dbUpdateCheckboxPrefix = 'TYPO3_INSTALL[database_update]'; // Prefix for checkbox fields when updating database.
+       var $localconf_addLinesOnly = 0; // If this is set, modifications to localconf.php is done by adding new lines to the array only. If unset, existing values are recognized and changed.
+       var $localconf_editPointToken = 'INSTALL SCRIPT EDIT POINT TOKEN - all lines after this points may be changed by the install script!'; // If set and addLinesOnly is disabled, lines will be change only if they are after this token (on a single line!) in the file
+       var $allowUpdateLocalConf = 0; // If true, this class will allow the user to update the localconf.php file. Is set true in the init.php file.
+       var $backPath = '../'; // Backpath (used for icons etc.)
 
+       var $multiplySize = 1; // Multiplier of SQL field size (for char, varchar and text fields)
+       var $character_sets = array(); // Caching output of $GLOBALS['TYPO3_DB']->admin_get_charsets()
 
+               // Internal, dynamic:
+       var $setLocalconf = 0; // Used to indicate that a value is change in the line-array of localconf and that it should be written.
+       var $messages = array(); // Used to set (error)messages from the executing functions like mail-sending, writing Localconf and such
+       var $touchedLine = 0; // updated with line in localconf.php file that was changed.
 
 
        /**
-        * Constructor
-        * 
-        * @return      [type]          ...
+        * Constructor function
+        *
+        * @return      void
         */
-       function t3lib_install()        {
-               if (!$GLOBALS["TYPO3_CONF_VARS"]["BE"]["installToolPassword"])  die("Install Tool deactivated.<BR>You must enable it by setting a password in typo3conf/localconf.php. If you insert the line below, the password will be 'joh316':<BR><BR>\$TYPO3_CONF_VARS[\"BE\"][\"installToolPassword\"] = \"bacb98acf97e0b6112b1d1b650b84971\";<BR><BR>See the document 'installing_upgrading_32b1.pdf' for more info.");
-               if (!t3lib_extMgm::isLoaded("install")) die("Install Tool is not loaded as an extension.<BR>You must add the key 'install' to the list of installed extensions in localconf.php, TYPO3_CONF_VARS[EXT][extList].");
-               
-               if ($this->sendNoCacheHeaders)  {
-                       header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
-                       header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
-                       header("Expires: 0");
-                       header("Cache-Control: no-cache, must-revalidate");
-                       header("Pragma: no-cache");
+       function t3lib_install() {
+               if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['multiplyDBfieldSize'] >= 1 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['multiplyDBfieldSize'] <= 5) {
+                       $this->multiplySize = (double) $GLOBALS['TYPO3_CONF_VARS']['SYS']['multiplyDBfieldSize'];
                }
-               
-                       // ****************************
-                       // Initializing incoming vars.
-                       // ****************************
-               $this->INSTALL = t3lib_div::GPvar("TYPO3_INSTALL");
-               $this->mode = t3lib_div::GPvar("mode");
-               $this->step = t3lib_div::GPvar("step");
-               if ($GLOBALS["HTTP_GET_VARS"]["TYPO3_INSTALL"]["type"]) $this->INSTALL["type"] = $GLOBALS["HTTP_GET_VARS"]["TYPO3_INSTALL"]["type"];
+       }
 
-               if ($this->step==3)     {
-                       $this->INSTALL["type"]="database";
-               }
-               
-               if ($this->mode=="123") {
-                       $tempItems = $this->menuitems;
-                       unset($this->menuitems);
-                       $this->menuitems["config"] = $tempItems["config"];
-                       $this->menuitems["database"] = $tempItems["database"];
-                       if (!$this->INSTALL["type"] || !isset($this->menuitems[$this->INSTALL["type"]]))        $this->INSTALL["type"] = "config";
-               } else {
-                       if (!$this->INSTALL["type"] || !isset($this->menuitems[$this->INSTALL["type"]]))        $this->INSTALL["type"] = "about";
-               }
 
-               $this->action = $this->scriptSelf."?TYPO3_INSTALL[type]=".$this->INSTALL["type"].($this->mode?"&mode=".rawurlencode($this->mode):"").($this->step?"&step=".rawurlencode($this->step):"");
-               $this->typo3temp_path = PATH_site."typo3temp/";
+       /**************************************
+        *
+        * Writing to localconf.php
+        *
 
+        **************************************/
 
-                       // ****************
-                       // Check password
-                       // ****************
-                       // Getting a unique session key, used to encode the session-access cookie later...
-               $uKey = $GLOBALS["HTTP_COOKIE_VARS"][$this->cookie_name."_key"];
-               if (!$uKey)     {
-                       $uKey = md5(uniqid(microtime()));
-                       SetCookie($this->cookie_name."_key", $uKey, 0, "/");            // Cookie is set
+       /**
+        * This functions takes an array with lines from localconf.php, finds a variable and inserts the new value.
+        *
+        * @param       array           $line_array     the localconf.php file exploded into an array by linebreaks. (see writeToLocalconf_control())
+        * @param       string          $variable       The variable name to find and substitute. This string must match the first part of a trimmed line in the line-array. Matching is done backwards so the last appearing line will be substituted.
+        * @param       string          $value          Is the value to be insert for the variable
+        * @param       boolean         $quoteValue     Whether the given value should be quoted before being written
+        * @return      void
+        * @see writeToLocalconf_control()
+        */
+       public function setValueInLocalconfFile(&$line_array, $variable, $value, $quoteValue = TRUE) {
+               if (!$this->checkForBadString($value)) {
+                       return 0;
+               }
 
-                       $this->JSmessage='SECURITY:
-Make sure to protect the Install Tool with another password than "joh316". 
-Better yet you can add a die() function call to typo3/install/index.php after usage.
+                       // Initialize:
+               $found = 0;
+               $this->touchedLine = '';
+               $commentKey = '## ';
+               $inArray = in_array($commentKey . $this->localconf_editPointToken, $line_array);
+               $tokenSet = ($this->localconf_editPointToken && !$inArray); // Flag is set if the token should be set but is not yet...
+               $stopAtToken = ($this->localconf_editPointToken && $inArray);
+               $comment = ' Modified or inserted by ' . $this->updateIdentity . '.';
+               $replace = array('["', '"]');
+               $search = array('[\'', '\']');
+               $varDoubleQuotes = str_replace($search, $replace, $variable);
 
-IF THE INSTALL TOOL CRASHES...
-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.
-Workaround: Open the file typo3/t3lib/class.t3lib_install.php, go to line 2042, make the function isPNG() return "0" hardcoded. PNG is not checked anymore and the rest of the Install Tool will work as expected. The same has been known with the other image formats as well. You can use a similar method to bypass the testing if that is also a problem.
-On behalf of PHP we regret this inconvenience.
-';
-                       
+                       // Search for variable name:
+               if (!$this->localconf_addLinesOnly && !$tokenSet) {
+                       $line_array = array_reverse($line_array);
+                       foreach ($line_array as $k => $v) {
+                               $v2 = trim($v);
+                               if ($stopAtToken && !strcmp($v2, $commentKey . $this->localconf_editPointToken)) {
+                                       break;
+                               } // If stopAtToken and token found, break out of the loop..
+                               if (!strcmp(substr($v2, 0, strlen($variable . ' ')), $variable . ' ')) {
+                                       $mainparts = explode($variable, $v, 2);
+                                       if (count($mainparts) == 2) { // should ALWAYS be....
+                                               $subparts = explode('//', $mainparts[1], 2);
+                                               if ($quoteValue) {
+                                                       $value = '\'' . $this->slashValueForSingleDashes($value) . '\'';
+                                               }
+                                               $line_array[$k] = $mainparts[0] . $variable . " = " . $value . ";       " . ('//' . $comment . str_replace($comment, '', $subparts[1]));
+                                               $this->touchedLine = count($line_array) - $k - 1;
+                                               $found = 1;
+                                               break;
+                                       }
+                               } elseif (!strcmp(substr($v2, 0, strlen($varDoubleQuotes . ' ')), $varDoubleQuotes . ' ')) {
+                                               // Due to a bug in the update wizard (fixed in TYPO3 4.1.7) it is possible
+                                               // that $TYPO3_CONF_VARS['SYS']['compat_version'] was enclosed by "" (double
+                                               // quotes) instead of the expected '' (single quotes) when is was written to
+                                               // localconf.php. The following code was added to make sure that values with
+                                               // double quotes are updated, too.
+                                       $mainparts = explode($varDoubleQuotes, $v, 2);
+                                       if (count($mainparts) == 2) { // should ALWAYS be....
+                                               $subparts = explode('//', $mainparts[1], 2);
+                                               if ($quoteValue) {
+                                                       $value = '\'' . $this->slashValueForSingleDashes($value) . '\'';
+                                               }
+                                               $line_array[$k] = $mainparts[0] . $variable . " = " . $value . ";       " . ('//' . $comment . str_replace($comment, '', $subparts[1]));
+                                               $this->touchedLine = count($line_array) - $k - 1;
+                                               $found = 1;
+                                               break;
+                                       }
+                               }
+                       }
+                       $line_array = array_reverse($line_array);
                }
-                       // Check if the password from TYPO3_CONF_VARS combined with uKey matches the sKey cookie. If not, ask for password.
-               $sKey = $GLOBALS["HTTP_COOKIE_VARS"][$this->cookie_name];
-               
-               if (md5($GLOBALS["TYPO3_CONF_VARS"]["BE"]["installToolPassword"]."|".$uKey) == $sKey || $this->checkPassword($uKey))    {
-                       $this->passwordOK=1;
+               if (!$found) {
+                       if ($tokenSet) {
+                               $line_array[] = $commentKey . $this->localconf_editPointToken;
+                               $line_array[] = '';
+                       }
+                       if ($quoteValue) {
+                               $value = '\'' . $this->slashValueForSingleDashes($value) . '\'';
+                       }
+                       $line_array[] = $variable . " = " . $value . "; // " . $comment;
+                       $this->touchedLine = -1;
                }
-               
-               if ($GLOBALS["CLIENT"]["SYSTEM"]=="unix" && $GLOBALS["CLIENT"]["BROWSER"]=="konqu")     {
-                       $this->fontTag2='<font face="verdana,sans-serif" size=4 color=black>';
-                       $this->fontTag1='<font face="verdana,sans-serif" size=3 color=black>';
+               if ($variable == '$typo_db_password') {
+                       $this->messages[] = 'Updated ' . $variable;
+               } else {
+                       $this->messages[] = $variable . " = " . htmlspecialchars($value);
                }
+               $this->setLocalconf = 1;
        }
 
        /**
-        * Returns true if submitted password is ok. Else displays a form in which to enter password.
-        * 
-        * @param       [type]          $uKey: ...
-        * @return      [type]          ...
-        */
-       function checkPassword($uKey)   {
-               $p = t3lib_div::GPvar("password");
-
-               if ($p && md5($p)==$GLOBALS["TYPO3_CONF_VARS"]["BE"]["installToolPassword"])    {
-                       $sKey = md5($GLOBALS["TYPO3_CONF_VARS"]["BE"]["installToolPassword"]."|".$uKey);
-                       SetCookie($this->cookie_name, $sKey, 0, "/");
-
-                               // Sending warning email
-                       $wEmail = $GLOBALS["TYPO3_CONF_VARS"]["BE"]["warning_email_addr"];
-                       if ($wEmail)    {
-                               $subject="Install Tool Login at '".$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"]."'";
-                               $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").")";
-                               mail($wEmail,
-                                       $subject,
-                                       $email_body,
-                                       "From: TYPO3 Install Tool WARNING <>"
-                               );
+        * Takes an array with lines from localconf.php, finds a variable and inserts the new array value.
+        *
+        * @param array $lines the localconf.php file exploded into an array by line breaks. {@see writeToLocalconf_control()}
+        * @param string $variable the variable name to find and substitute. This string must match the first part of a trimmed line in the line-array. Matching is done backwards so the last appearing line will be substituted.
+        * @param array $value value to be assigned to the variable
+        * @return void
+        * @see writeToLocalconf_control()
+        */
+       public function setArrayValueInLocalconfFile(array &$lines, $variable, array $value) {
+               $commentKey = '## ';
+               $inArray = in_array($commentKey . $this->localconf_editPointToken, $lines);
+               $tokenSet = $this->localconf_editPointToken && !$inArray; // Flag is set if the token should be set but is not yet
+               $stopAtToken = $this->localconf_editPointToken && $inArray;
+               $comment = 'Modified or inserted by ' . $this->updateIdentity . '.';
+               $format = "%s = %s;\t// " . $comment;
+
+               $insertPos = count($lines);
+               $startPos = 0;
+               if (!($this->localconf_addLinesOnly || $tokenSet)) {
+                       for ($i = count($lines) - 1; $i > 0; $i--) {
+                               $line = trim($lines[$i]);
+                               if ($stopAtToken && t3lib_div::isFirstPartOfStr($line, $this->localconf_editPointToken)) {
+                                       break;
+                               }
+                               if (t3lib_div::isFirstPartOfStr($line, '?>')) {
+                                       $insertPos = $i;
+                               }
+                               if (t3lib_div::isFirstPartOfStr($line, $variable)) {
+                                       $startPos = $i;
+                                       break;
+                               }
                        }
-                       return true;
-               } else {
-                       $this->messageFunc_nl2br=0;
-                       $this->silent=0;
-                       $content = '<form action="'.$this->action.'" method="POST">
-                       <input type="password" name="password"><BR>
-                       <input type="submit" value="Log in"><br>
-                       <br>
-                       
-                       '.$this->fw('The Install Tool Password is <i>not</i> the admin password of TYPO3.<BR>
-                               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.'.
-                               ($p?"<BR><BR>The password you just tried has this md5-value: <BR><BR>".md5($p):"")
-                               ).'
-                       </form>';
-
-                       $this->message("Password", "Enter the Install Tool Password", $content,3);
-                       echo $this->outputWrapper($this->printAll());
-                               // Bad password, send warning:
-                       if ($p) {
-                               $wEmail = $GLOBALS["TYPO3_CONF_VARS"]["BE"]["warning_email_addr"];
-                               if ($wEmail)    {
-                                       $subject="Install Tool Login ATTEMPT at '".$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"]."'";
-                                       $email_body="There has been a Install Tool login attempt at TYPO3 site '".$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"]."' (".t3lib_div::getIndpEnv("HTTP_HOST")."). 
-Password tried was '".$p."'
-REMOTE_ADDR was '".t3lib_div::getIndpEnv("REMOTE_ADDR")."' (".t3lib_div::getIndpEnv("REMOTE_HOST").")";
-                                       mail($wEmail,
-                                               $subject,
-                                               $email_body,
-                                               "From: TYPO3 Install Tool WARNING <>"
-                                       );
+               }
+               if ($startPos) {
+                       $this->touchedLine = $startPos;
+                       $endPos = $startPos;
+                       for ($i = $startPos; $i < count($lines); $i++) {
+                               $line = trim($lines[$i]);
+                               if (t3lib_div::isFirstPartOfStr($line, ');')) {
+                                       $endPos = $i;
+                                       break;
                                }
                        }
 
-                       return false;
+                       $startLines = array_slice($lines, 0, $startPos);
+                       $endLines = array_slice($lines, $endPos + 1);
+
+                       $lines = $startLines;
+                       $definition = $this->array_export($value);
+                       $lines[] = sprintf($format, $variable, $definition);
+                       foreach ($endLines as $line) {
+                               $lines[] = $line;
+                       }
+               } else {
+                       $lines[$insertPos] = sprintf($format, $variable, $this->array_export($value));
+                       $lines[] = '?>';
+                       $this->touchedLine = -1;
                }
        }
-       
+
        /**
-        * Calling function that checks system, IM, GD, dirs, database and lets you alter localconf.php
-        * 
-        * @return      [type]          ...
+        * Returns a parsable string representation of an array variable. This methods enhances
+        * standard method var_export from PHP to take TYPO3's CGL into account.
+        *
+        * @param array $variable
+        * @return string
         */
-       function init() {
-               if (!defined("PATH_typo3"))     exit;           // Must be called after inclusion of init.php (or from init.php)
-               if (!$this->passwordOK) exit;
-//             debug($GLOBALS["HTTP_COOKIE_VARS"]);
-       
-                       // Setting stuff...
-               $this->check_mail();
-               $this->setupGeneral();
-               $this->generateConfigForm();
-               if (count($this->messages))     debug($this->messages);
+       protected function array_export(array $variable) {
+               $lines = explode("\n", var_export($variable, TRUE));
+               $out = 'array(';
 
-               if ($this->step)        {
-                       echo $this->outputWrapper($this->stepOutput());
-               } else {
-                               // Menu...
-                       switch($this->INSTALL["type"])  {
-                               case "images":
-                                       $this->checkIM=1;
-                                       $this->checkTheConfig();
-                                       $this->silent=0;
-                                       $this->checkTheImageProcessing();
-                               break;
-                               case "database":
-                                       $this->checkTheConfig();
-                                       $this->silent=0;
-                                       $this->checkTheDatabase();                              
-                               break;
-                               case "config":
-                                       $this->silent=0;
-                                       $this->checkIM=1;
-                                       $this->message("About configuration","How to configure TYPO3",$this->generallyAboutConfiguration());
-                                       $this->checkTheConfig();
-                                       
-                                       $ext = "Write config to localconf.php";
-                                       if ($this->fatalError)  {
-                                               if ($this->config_array["no_database"] || !$this->config_array["mysqlConnect"]) {
-                                                       $this->message($ext, "Database not configured yet!", "
-                                                               You need to specify database username, password and host as one of the first things. 
-                                                               Next you'll have to select a database to use with TYPO3.
-                                                               Use the form below:
-                                                       ",2);
-                                               } else {
-                                                       $this->message($ext, "Fatal error encountered!", "
-                                                               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!
-                                                               You should also check all warnings that may appear.
-                                                       ",2);
-                                               }
-                                       } elseif ($this->mode=="123") { 
-                                               if (!$this->fatalError) {
-                                                       $this->message($ext, "Basic configuration completed", '
-                                                               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.
-       
-                                                               <B><font color=red>Step 2:</font></B> <a href="'.$this->scriptSelf.'?TYPO3_INSTALL[type]=database'.($this->mode?"&mode=".rawurlencode($this->mode):"").'">Click here to install the database.</a>
-                                                       ',-1,1);
-                                               }
-                                       }
-                                       $this->message($ext, "Very Important: Changing Image Processing settings", "
-                                               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.
-                                               The problem is solved by <a href=\"".$this->setScriptName("typo3temp")."\">clearing the typo3temp/ folder</a>. Also make sure to clear the cache_pages table.
-                                               ",1,1);
-                                       $this->message($ext, "Update localconf.php", "
-                                               This form updates the localconf.php file with the suggested values you see below. The values are based on the analysis above.
-                                               You can change the values in case you have alternatives to the suggested defaults.
-                                               By this final step you will configure TYPO3 for immediate use provided that you have no fatal errors left above."
-                                               .$this->setupGeneral("get_form"),0,1);
-                       
-                                       echo $this->outputWrapper($this->printAll());
-                       //              debug($this->config_array);
-                               break;
-                               case "extConfig":
-                                       $this->silent=0;
-                                       
-                                       $this->generateConfigForm("get_form");
-                                       
-                                       $content = $this->printAll();
-                                       $content = '<form action="'.$this->action.'" method="POST">'.$content.'<input type="submit" value="Write to localconf.php"><BR><BR>
-                                       '.$this->fw("<strong>NOTICE: </strong>By clicking this button, localconf.php is updated with new values for the parameters listed above!<BR>").'
-                                       </form>';
-                                       echo $this->outputWrapper($content);
-                               break;
-                               case "typo3temp":
-                                       $this->checkTheConfig();
-                                       $this->silent=0;
-                                       $this->typo3TempManager();                      
-                               break;
-                               case "phpinfo":
-                                       $this->silent=0;
-                                       $this->phpinformation();                        
-                               break;
-                               case "typo3conf_edit":
-                                       $this->silent=0;
-                                       $this->typo3conf_edit();                        
-                               break;
-                               case "about":
-                               default:
-                                       $this->silent=0;
-                                       $this->message("About", "Warning - very important!", $this->securityRisk().$this->alterPasswordForm(),2);
-       
-                                       $this->message("About", "Using this script", "
-                                       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.
-                                       There are three primary steps for you to take:
-                                       
-                                       <strong>1: Basic Configuration</strong>
-                                       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.
-                                       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.
-                                       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.
-       
-                                       <strong>2: Database Analyser</strong>
-                                       In this step you can either install a new database or update the database from any previous TYPO3 version. 
-                                       You can also get an overview of extra/missing fields/tables in the database compared to a raw sql-file. 
-                                       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.
-                                       
-                                       <strong>3: Image Processing</strong>
-                                       This step is a visual guide to verify your configuration of the image processing software.
-                                       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.                               
-       
-                                       <strong>4: All Configuration</strong>
-                                       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.
-
-                                       <strong>5: typo3temp/</strong>
-                                       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.
-                                       ");
-       
-                                       $this->message("About", "Why is this script stand-alone?", "
-                                       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.
-                                       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!
-                                       ");
-       
-       
-                                       $headCode="Header legend";
-                                       $this->message($headCode, "Just information", "
-                                       This is a simple message with some information about something.
-                                       ");
-                                       $this->message($headCode, "Check was successful", "
-                                       Indicates that something was checked and returned an expected result.
-                                       ",-1);
-                                       $this->message($headCode, "Notice!", "
-                                       Indicates that something is important to be aware of.
-                                       This does <em>not</em> indicate an error.
-                                       ",1);
-                                       $this->message($headCode, "Warning!", "
-                                       Indicates that something may very well cause trouble and you should definitely look into it before proceeding.
-                                       This indicates a <em>potential</em> error.
-                                       ",2);
-                                       $this->message($headCode, "Error!", "
-                                       Indicates that something is definitely wrong and that TYPO3 will most likely not perform as expected if this problem is not solved.
-                                       This indicates an actual error.
-                                       ",3);
-       
-                                       echo $this->outputWrapper($this->printAll());                   
-                               break;
+               for ($i = 1; $i < count($lines); $i++) {
+                       $out .= "\n";
+                               // Make the space-indented declaration tab-indented instead
+                       while (substr($lines[$i], 0, 2) === '  ') {
+                               $out .= "\t";
+                               $lines[$i] = substr($lines[$i], 2);
+                       }
+                       $out .= $lines[$i];
+                               // Array declaration should be next to the assignment and no space between
+                               // "array" and its opening parenthesis should exist
+                       if (preg_match('/\s=>\s$/', $lines[$i])) {
+                               $out .= preg_replace('/^\s*array \(/', 'array(', $lines[$i + 1]);
+                               $i++;
                        }
                }
+
+               return $out;
        }
-       
+
        /**
-        * Controls the step 1-2-3-go process
-        * 
-        * @return      [type]          ...
+        * Writes or returns lines from localconf.php
+        *
+        * @param       array           Array of lines to write back to localconf.php. Possibly
+        * @param       string          Absolute path of alternative file to use (Notice: this path is not validated in terms of being inside 'TYPO3 space')
+        * @return      mixed           If $inlines is not an array it will return an array with the lines from localconf.php. Otherwise it will return a status string, either "continue" (updated) or "nochange" (not updated)
+        * @see setValueInLocalconfFile()
         */
-       function stepOutput()   {
-               $this->checkTheConfig();
-               $error_missingConnect='<br>
-                       '.$this->fontTag2.'<img src="../t3lib/gfx/icon_fatalerror.gif" width=18 height=16 class="absmiddle">
-                       There is no connection to the database!<br>
-                       (Username: <i>'.TYPO3_db_username.'</i>, Password: <i>'.TYPO3_db_password.'</i>, Host: <i>'.TYPO3_db_host.'</i>).<BR>
-                       <br>
-                       <strong>Go to Step 1</strong> and enter a proper username/password!</font>
-                       <br>
-                       <br>
-               ';
-               $error_missingDB='<br>
-                       '.$this->fontTag2.'<img src="../t3lib/gfx/icon_fatalerror.gif" width=18 height=16 class="absmiddle">
-                       There is no access to the database (<i>'.TYPO3_db.'</i>)!<br>
-                       <br>
-                       <strong>Go to Step 2</strong> and select an accessible database!</font>
-                       <br>
-                       <br>
-               ';
+       function writeToLocalconf_control($inlines = '', $absFullPath = '') {
+               $tmpExt = '.TMP.php';
+               $writeToLocalconf_dat = array();
+               $writeToLocalconf_dat['file'] = $absFullPath ? $absFullPath : PATH_typo3conf . 'localconf.php';
+               $writeToLocalconf_dat['tmpfile'] = $writeToLocalconf_dat['file'] . $tmpExt;
 
-               $whichTables=$this->getListOfTables();
-               $dbInfo='
-                                       <table border=0 cellpadding=1 cellspacing=0>
-                                               <tr>
-                                                       <td valign="top" nowrap colspan=2 align=center>'.$this->fontTag2.'<strong><img src="../t3lib/gfx/icon_note.gif" hspace=5 width=18 height=16 class="absmiddle">Database summary:</strong></font></td>
-                                               </tr>
-                                               <tr>
-                                                       <td valign="top" nowrap>'.$this->fontTag1.'Username:</font></td>
-                                                       <td valign="top" nowrap><strong>'.$this->fontTag1.''.TYPO3_db_username.'</font></strong></td>
-                                               </tr>
-                                               <tr>
-                                                       <td valign="top" nowrap>'.$this->fontTag1.'Password:</font></td>
-                                                       <td valign="top" nowrap><strong>'.$this->fontTag1.''.TYPO3_db_password.'</font></strong></td>
-                                               </tr>
-                                               <tr>
-                                                       <td valign="top" nowrap>'.$this->fontTag1.'Host:</font></td>
-                                                       <td valign="top" nowrap><strong>'.$this->fontTag1.''.TYPO3_db_host.'</font></strong></td>
-                                               </tr>
-                                               <tr>
-                                                       <td valign="top" nowrap>'.$this->fontTag1.'Database:</font></td>
-                                                       <td valign="top" nowrap><strong>'.$this->fontTag1.''.TYPO3_db.'</font></strong></td>
-                                               </tr>
-                                               <tr>
-                                                       <td valign="top" nowrap>'.$this->fontTag1.'# of tables:</font></td>
-                                                       <td valign="top" nowrap><strong>'.$this->fontTag1.''.(count($whichTables)?'<font color=red>'.count($whichTables).'</font>':count($whichTables)).'</font></strong></td>
-                                               </tr>
-                                       </table>
-               ';
-               $error_emptyDB='<br>
-                       '.$this->fontTag2.'<img src="../t3lib/gfx/icon_fatalerror.gif" width=18 height=16 class="absmiddle">
-                       The database is still empty. There are no tables!<br>
-                       <br>
-                       <strong>Go to Step 3</strong> and import a database!</font>
-                       <br>
-                       <br>
-               ';
+                       // Checking write state of localconf.php:
+               if (!$this->allowUpdateLocalConf) {
+                       throw new RuntimeException(
+                               'TYPO3 Fatal Error: ->allowUpdateLocalConf flag in the install object is not set and therefore "localconf.php" cannot be altered.',
+                               1270853915
+                       );
+               }
+               if (!@is_writable($writeToLocalconf_dat['file'])) {
+                       throw new RuntimeException(
+                               'TYPO3 Fatal Error: ' . $writeToLocalconf_dat['file'] . ' is not writable!',
+                               1270853916
+                       );
+               }
 
-               switch(strtolower($this->step)) {
-                       case 1:
-                               $msg='
-<br>
-<br>
-                                       <table border=0>
-                                          <form action="'.$this->action.'" method="POST">
-                                               <tr>
-                                                       <td valign="top" nowrap><strong>                   
-                                                          '.$this->fontTag2.'Username:</font></strong>
-                                                       </td>
-                                                       <td>    &nbsp;
-                                                       </td>
-                                                       <td valign="top">                  
-                                                          '.$this->fontTag2.'
-                                                          <input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_username]" value="'.TYPO3_db_username.'"></font><BR>
-                                                       </td>
-                                               </tr>
-                                               <tr>
-                                                       <td valign="top" nowrap><strong>                   
-                                                          '.$this->fontTag2.'Password:</font></strong>
-                                                       </td>
-                                                       <td>    &nbsp;
-                                                       </td>
-                                                       <td valign="top">                  
-                                                          '.$this->fontTag2.'
-                                                          <input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_password]" value="'.TYPO3_db_password.'"></font><BR>
-                                                       </td>
-                                               </tr>
-                                               <tr>
-                                                       <td valign="top" nowrap><strong>                   
-                                                          '.$this->fontTag2.'Host:</font></strong>
-                                                       </td>
-                                                       <td>    &nbsp;
-                                                       </td>
-                                                       <td valign="top">                  
-                                                          '.$this->fontTag2.'
-                                                          <input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_host]" value="'.(TYPO3_db_host?TYPO3_db_host:'localhost').'"></font><BR>
-                                                       </td>
-                                               </tr>
-                                               <tr>
-                                                       <td valign="top" nowrap><strong>                   
-                                                          '.$this->fontTag1.'</font></strong>
-                                                       </td>
-                                                       <td>    &nbsp;
-                                                       </td>
-                                                       <td valign="top">                  
-                                                          '.$this->fontTag1.'<BR>
-                                                          <input type="hidden" name="step" value="2">
-                                                          <input type="submit" value="Update localconf.php"><BR><br /><strong>NOTICE: </strong>By clicking this button, typo3conf/localconf.php is updated with new values for the parameters listed above!</font><BR>
-                                                       </td>
-                                               </tr>
-                                          </form>
-                                       </table>                                
-<br>
-<br>
-                               ';
-                       break;
-                       case 2:
-                               if ($result = @mysql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))     {
-                                       $dbArr = $this->getDatabaseList();
-                                       reset($dbArr);
-                                       $options="";
-                                       $dbIncluded=0;
-                                       while(list(,$dbname)=each($dbArr))      {
-                                               $options.='<option value="'.htmlspecialchars($dbname).'"'.($dbname==TYPO3_db?' selected':'').'>'.htmlspecialchars($dbname).'</option>';
-                                               if ($dbname==TYPO3_db)  $dbIncluded=1;
-                                       }
-                                       if (!$dbIncluded && TYPO3_db)   {
-                                               $options.='<option value="'.htmlspecialchars(TYPO3_db).'" selected>'.htmlspecialchars(TYPO3_db).' (NO ACCESS!)</option>';
-                                       }
-                                       $select='<select name="TYPO3_INSTALL[localconf.php][typo_db]">'.$options.'</select>';
-                                       $msg='
-<br>
-<br>
-                                       <table border=0>
-                                          <form action="'.$this->action.'" method="POST">
-                                               <tr>
-                                                       <td valign="top" nowrap><strong>                   
-                                                          '.$this->fontTag2.'
-                                                          You have two options:<br>
-                                                          <br><br>
-                                                          
-                                                          1: Select an existing <u>EMPTY</u> database:</font></strong>
-                                                       </td>
-                                               </tr>
-                                               <tr>
-                                                       <td valign="top">                  
-                                                          '.$this->fontTag1.'Any existing tables which are used by TYPO3 will be overwritten in Step 3. So make sure this database is empty:<BR>'.$select.'</font><BR>
-                                                       </td>
-                                               </tr>
-                                               <tr>
-                                                       <td valign="top" nowrap><br>
-                                                       <br>
-<strong>                  
-                                                          '.$this->fontTag2.'2: Create new database (recommended):</font></strong>
-                                                       </td>
-                                               </tr>
-                                               <tr>
-                                                       <td valign="top">                  
-                                                          '.$this->fontTag1.'Enter the desired name of the database here:<BR><input type="text" name="TYPO3_INSTALL[localconf.php][NEW_DATABASE_NAME]" value=""></font><BR>
-                                                       </td>
-                                               </tr>
-                                               <tr>
-                                                       <td valign="top">                  <br>
-                                                       
-                                                          '.$this->fontTag1.'<BR>
-                                                          <input type="hidden" name="step" value="3">
-                                                          <input type="submit" value="Update localconf.php"><BR><br /><strong>NOTICE: </strong>By clicking this button, typo3conf/localconf.php is updated with new values for the parameters listed above!</font><BR>
-                                                       </td>
-                                               </tr>
-                                          </form>
-                                       </table>                                
-<br>
-<br>
-                               ';
-                               } else {
-                                       $msg=$error_missingConnect;
-                               }
-                       break;
-                       case 3:
-                               if ($result = @mysql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))     {
-                                       if (mysql_select_db(TYPO3_db))  {
-                                               $sFiles = t3lib_div::getFilesInDir(PATH_typo3conf,"sql",1,1);
-                                               reset($sFiles);
-                                               $opt="";
-                                               while(list(,$f)=each($sFiles))  {
-                                                       $opt.='<option value="import|'.htmlspecialchars($f).'">'.htmlspecialchars(basename($f)).'</option>';
-                                               }
-                                               
-                                               
-                                               $content='
-                                                       '.$this->fontTag2.'Databases in typo3conf/ directory:</font><BR>
-                                                       <input type="hidden" name="TYPO3_INSTALL[database_import_all]" value=1>
-                                                  <input type="hidden" name="step" value="">
-                                                  <input type="hidden" name="goto_step" value="go">
-                                                       <select name="TYPO3_INSTALL[database_type]">'.$opt.'</select><BR>';
+                       // Splitting localconf.php file into lines:
+               $lines = explode(LF, str_replace(CR, '', trim(t3lib_div::getUrl($writeToLocalconf_dat['file']))));
+               $writeToLocalconf_dat['endLine'] = array_pop($lines); // Getting "? >" ending.
 
-                                               $content = $this->getUpdateDbFormWrap("import", $content, "Import database");
+                       // Checking if "updated" line was set by this tool - if so remove old line.
+               $updatedLine = array_pop($lines);
+               $writeToLocalconf_dat['updatedText'] = '// Updated by ' . $this->updateIdentity . ' ';
 
-                                               $msg='
-                                               <br>
-                                               '.$dbInfo.'<br>
-                                               <br>
-                                               '.$content.'
+               if (!strstr($updatedLine, $writeToLocalconf_dat['updatedText'])) {
+                       array_push($lines, $updatedLine);
+               }
 
-                                               ';
-                                               
-                                       } else {
-                                               $msg=$error_missingDB;
-                                       }
-                               } else {
-                                       $msg=$error_missingConnect;
-                               }
-                       break;
-                       case "go":
-                               if ($result = @mysql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))     {
-                                       if (mysql_select_db(TYPO3_db))  {
-                                               if (count($whichTables))        {
-                                                       $msg='
-                                                       <br>
-                                                       '.$this->fontTag2.'
-                                                       '.nl2br($this->messageBasicFinished()).'
-                                                       <br>
-                                                       <hr>
-                                                       <div align="center"><strong><img src="../t3lib/gfx/icon_warning.gif" hspace=5 width=18 height=16 class="absmiddle">IMPORTANT</strong></div><br>
-                                                       <font size=1>'.nl2br($this->securityRisk()).'
-                                                       <br>
-                                                       <strong>Enter <a href="'.$this->scriptSelf.'">"Normal" mode for the Install Tool</a> to change this!</strong><br>
-                                                                                                               
-                                                       </font>
-                                                       </font><BR>
-                                                       ';
-                                               } else {
-                                                       $msg=$error_emptyDB;
-                                               }
-                                       } else {
-                                               $msg=$error_missingDB;
-                                       }
+               if (is_array($inlines)) { // Setting a line and write:
+                               // Setting configuration
+                       $updatedLine = $writeToLocalconf_dat['updatedText'] . date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' H:i:s');
+                       array_push($inlines, $updatedLine);
+                       array_push($inlines, $writeToLocalconf_dat['endLine']);
+
+                       if ($this->setLocalconf) {
+                               $success = $this->writeToLocalconf($inlines, $absFullPath);
+
+                               if ($success) {
+                                       return 'continue';
                                } else {
-                                       $msg=$error_missingConnect;
+                                       return 'nochange';
                                }
-                       break;
-                       default:
-                       break;
+                       } else {
+                               return 'nochange';
+                       }
+               } else { // Return lines found in localconf.php
+                       return $lines;
                }
-               return $msg;
        }
 
        /**
-        * Calling the functions that checks the system
-        * 
-        * @return      [type]          ...
+        * Writes lines to localconf.php.
+        *
+        * @param array Array of lines to write back to localconf.php
+        * @param string Absolute path of alternative file to use (Notice: this path is not validated in terms of being inside 'TYPO3 space')
+        * @return boolean TRUE if method succeeded, otherwise FALSE
         */
-       function checkTheConfig()       {
-                       // Order important:     
-               $this->checkDirs();
-               $this->checkConfiguration();
-               $this->checkExtensions();
+       public function writeToLocalconf(array $lines, $absFullPath = '') {
+               $tmpExt = '.TMP.php';
+               $writeToLocalconf_dat = array();
+               $writeToLocalconf_dat['file'] = $absFullPath ? $absFullPath : PATH_typo3conf . 'localconf.php';
+               $writeToLocalconf_dat['tmpfile'] = $writeToLocalconf_dat['file'] . $tmpExt;
 
-               if (TYPO3_OS=="WIN")    {
-                       $paths=array($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path_lzw"], $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path"], "c:\\php\\imagemagick\\", 'c:\\apache\\ImageMagick\\');
-               } else {
-                       $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/");
-               }
-               
-               asort($paths);
-               if (ini_get("safe_mode"))       {
-                       $paths=array(ini_get("safe_mode_exec_dir"),"/usr/local/php/bin/");
+                       // Checking write state of localconf.php:
+               if (!$this->allowUpdateLocalConf) {
+                       throw new RuntimeException(
+                               'TYPO3 Fatal Error: ->allowUpdateLocalConf flag in the install object is not set and therefore "localconf.php" cannot be altered.',
+                               1270853915
+                       );
                }
-               if ($this->INSTALL["checkIM"]["lzw"])   {
-                       $this->checkIMlzw=1;
+               if (!@is_writable($writeToLocalconf_dat['file'])) {
+                       throw new RuntimeException(
+                               'TYPO3 Fatal Error: ' . $writeToLocalconf_dat['file'] . ' is not writable!',
+                               1270853916
+                       );
                }
-               if ($this->INSTALL["checkIM"]["path"])  {
-                       $paths[]=trim(stripslashes($this->INSTALL["checkIM"]["path"]));
+
+               $writeToLocalconf_dat['endLine'] = array_pop($lines); // Getting "? >" ending.
+               if (!strstr('?' . '>', $writeToLocalconf_dat['endLine'])) {
+                       $lines[] = $writeToLocalconf_dat['endLine'];
+                       $writeToLocalconf_dat['endLine'] = '?' . '>';
                }
-               if ($this->checkIM)     $this->checkImageMagick($paths);
-               $this->checkDatabase();
-       }
+                       // Checking if "updated" line was set by this tool - if so remove old line.
+               $updatedLine = array_pop($lines);
+               $writeToLocalconf_dat['updatedText'] = '// Updated by ' . $this->updateIdentity . ' ';
 
-       /**
-        * [Describe function...]
-        * 
-        * @return      [type]          ...
-        */
-       function typo3conf_edit()       {
-               $EDIT_path = PATH_typo3conf;    // default:
-               if ($this->allowFileEditOutsite_typo3conf_dir && $this->INSTALL["FILE"]["EDIT_path"])   {
-                       if (t3lib_div::validPathStr($this->INSTALL["FILE"]["EDIT_path"]) && substr($this->INSTALL["FILE"]["EDIT_path"],-1)=="/")        {
-                               $tmp_path = PATH_site.$this->INSTALL["FILE"]["EDIT_path"];
-                               if (is_dir($tmp_path))  {
-                                       $EDIT_path=$tmp_path;
-                               } else {debug("'".$tmp_path."' was not dir");}
-                       } else {
-                               debug("BAD DIR_NAME (must be like t3lib/ or media/script/)");
-                       }
+               if (!strstr($updatedLine, $writeToLocalconf_dat['updatedText'])) {
+                       $lines[] = $updatedLine;
                }
-               
-               $headCode = "Edit files in ".basename($EDIT_path)."/";
-               $this->contentBeforeTable="";
-               
-               if ($this->INSTALL["SAVE_FILE"])        {
-                       $save_to_file = $this->INSTALL["FILE"]["name"];
-                       if (@is_file($save_to_file))    {
-                               $save_to_file_md5 = md5($save_to_file);
-                               if (isset($this->INSTALL["FILE"][$save_to_file_md5]) && t3lib_div::isFirstPartOfStr($save_to_file,$EDIT_path."") && substr($save_to_file,-1)!="~")      {
-                                       $this->INSTALL["typo3conf_files"] = $save_to_file;
-                                       $save_fileContent = stripslashes($this->INSTALL["FILE"][$save_to_file_md5]);
 
-                                       if ($this->INSTALL["FILE"]["win_to_unix_br"])   {
-                                               $save_fileContent = str_replace(chr(13).chr(10),chr(10),$save_fileContent);
-                                       }
-                                       if ($this->INSTALL["FILE"]["backup"])   {
-                                               if (@is_file($save_to_file."~"))        unlink($save_to_file."~");
-                                               rename($save_to_file,$save_to_file."~");
-                                               $this->contentBeforeTable.='Backup written to <strong>'.$save_to_file.'~</strong><BR>';
-                                       } else {
-                                               if (@is_file($save_to_file."~"))        {
-                                                       unlink($save_to_file."~");
-                                                       $this->contentBeforeTable.='Backup REMOVED! (<strong>'.$save_to_file.'~</strong>)<BR>';
-                                               }
-                                       }
+               $updatedLine = $writeToLocalconf_dat['updatedText'] . date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' H:i:s');
+               $lines[] = $updatedLine;
+               $lines[] = $writeToLocalconf_dat['endLine'];
 
-                                       t3lib_div::writeFile($save_to_file,$save_fileContent);
-                                       $this->contentBeforeTable.='
-                                               File saved: <strong>'.$save_to_file.'</strong><BR>
-                                               MD5-sum: '.$this->INSTALL["FILE"]["prevMD5"].' (prev)<BR>
-                                               MD5-sum: '.md5($save_fileContent).' (new)<BR>
-                                       ';
-                               }
-                       }
+               $success = FALSE;
+               if (!t3lib_div::writeFile($writeToLocalconf_dat['tmpfile'], implode(LF, $lines))) {
+                       $msg = 'typo3conf/localconf.php' . $tmpExt . ' could not be written - maybe a write access problem?';
                }
-               
-               
-                       // Filelist:
-               $typo3conf_files = t3lib_div::getFilesInDir($EDIT_path,"",1,1);
-               reset($typo3conf_files);
-               $lines=array();
-               $fileFound = 0;
-               while(list($k,$file)=each($typo3conf_files))    {
-                       if ($this->INSTALL["typo3conf_files"] && !strcmp($this->INSTALL["typo3conf_files"],$file))      {
-                               $wrap=array('<strong><font color=navy>','</font></strong>');
-                               $fileFound = 1;
-                       } else {$wrap=array();}
-                       $lines[]='<tr><td nowrap><a href="'.$this->action.'&TYPO3_INSTALL[typo3conf_files]='.rawurlencode($file).($this->allowFileEditOutsite_typo3conf_dir?'&TYPO3_INSTALL[FILE][EDIT_path]='.rawurlencode($this->INSTALL["FILE"]["EDIT_path"]):"").'">'.$this->fw($wrap[0].basename($file).$wrap[1]."&nbsp;&nbsp;&nbsp;").'</a></td><td>'.$this->fw(t3lib_div::formatSize(filesize($file))).'</td></tr>';
+               elseif (strcmp(t3lib_div::getUrl($writeToLocalconf_dat['tmpfile']), implode(LF, $lines))) {
+                       @unlink($writeToLocalconf_dat['tmpfile']);
+                       $msg = 'typo3conf/localconf.php' . $tmpExt . ' was NOT written properly (written content didn\'t match file content) - maybe a disk space problem?';
                }
-               $fileList='<table border=0 cellpadding=0 cellspacing=0>'.implode("",$lines).'</table>';
-               $fileList.="<BR>(".$EDIT_path.")";
-               
-               if ($this->allowFileEditOutsite_typo3conf_dir)  {
-                       $fileList.='<BR><form action="'.$this->action.'" method="POST">
-                       '.PATH_site.'<input type="text" name="TYPO3_INSTALL[FILE][EDIT_path]" value="'.$this->INSTALL["FILE"]["EDIT_path"].'"><input type="submit" name="" value="Set">
-                       </form>';
+               elseif (!@copy($writeToLocalconf_dat['tmpfile'], $writeToLocalconf_dat['file'])) {
+                       $msg = 'typo3conf/localconf.php could not be replaced by typo3conf/localconf.php' . $tmpExt . ' - maybe a write access problem?';
                }
-
-               if ($fileFound && @is_file($this->INSTALL["typo3conf_files"]))  {
-                       $this->headerStyle = '
-                       <style type="text/css"><!--
-                               SELECT {font-family: Verdana,Arial,Helvetica,Sans-serif; font-size: 10px;}
-                               TEXTAREA  {font-family: Verdana,Arial,Helvetica,Sans-serif; font-size: 10px;} 
-                               INPUT {font-family: Verdana,Arial,Helvetica,Sans-serif; font-size: 10px;}
-                       //--></style>
-                       ';
-
-                       $fileContent = t3lib_div::getUrl($this->INSTALL["typo3conf_files"]);
-                       $this->contentBeforeTable.= '<form action="'.$this->action.'" method="POST">
-                               '.(substr($this->INSTALL["typo3conf_files"],-1)!="~"?'<input type="submit" name="TYPO3_INSTALL[SAVE_FILE]" value="Save file">&nbsp;':'').'<input type="submit" name="_close" value="Close">
-                               <BR>File: '.$this->INSTALL["typo3conf_files"].'
-                               <BR>MD5-sum: '.md5($fileContent).'
-                               <BR>
-                               
-                               <input type="hidden" name="TYPO3_INSTALL[FILE][name]" value="'.$this->INSTALL["typo3conf_files"].'">
-                               '.($this->allowFileEditOutsite_typo3conf_dir?'<input type="hidden" name="TYPO3_INSTALL[FILE][EDIT_path]" value="'.$this->INSTALL["FILE"]["EDIT_path"].'">':'').'
-                               <input type="hidden" name="TYPO3_INSTALL[FILE][prevMD5]" value="'.md5($fileContent).'">
-                               <textarea rows="30" name="TYPO3_INSTALL[FILE]['.md5($this->INSTALL["typo3conf_files"]).']" wrap="off"'.$this->formWidthText(48,"width:98%;height:80%","off").'>'.t3lib_div::formatForTextarea($fileContent).'</textarea><BR>
-                               <input type="checkbox" name="TYPO3_INSTALL[FILE][win_to_unix_br]" value="1"'.(TYPO3_OS=="WIN"?"":" CHECKED").'> Convert windows linebreaks (13-10) to unix (10)<BR>
-                               <input type="checkbox" name="TYPO3_INSTALL[FILE][backup]" value="1"'.(@is_file($this->INSTALL["typo3conf_files"]."~") ? " CHECKED":"").'> Make backup copy (else remove any backup copy, prepended by "~")<BR>
-                               '.
-                       '</form>';
+               else {
+                       @unlink($writeToLocalconf_dat['tmpfile']);
+                       $success = TRUE;
+                       $msg = 'Configuration written to typo3conf/localconf.php';
                }
-               
-               if ($this->contentBeforeTable)  {
-                       $this->contentBeforeTable = $this->fw($this->contentBeforeTable);
+               $this->messages[] = $msg;
+
+               if (!$success) {
+                       t3lib_div::sysLog($msg, 'Core', 3);
                }
 
-               $this->message($headCode,"Files in folder",$fileList);
-       
-               echo $this->outputWrapper($this->printAll());                   
+               return $success;
        }
 
        /**
-        * [Describe function...]
-        * 
-        * @return      [type]          ...
+        * Checking for linebreaks in the string
+        *
+        * @param       string          String to test
+        * @return      boolean         Returns TRUE if string is OK
+        * @see setValueInLocalconfFile()
         */
-       function phpinformation()       {
-               $headCode = "PHP information";
-               
-               $sVar = t3lib_div::getIndpEnv("_ARRAY");
-               $sVar["CONST: PHP_OS"]=PHP_OS;
-               $sVar["CONST: TYPO3_OS"]=TYPO3_OS;
-               $sVar["CONST: PATH_thisScript"]=PATH_thisScript;
-               $sVar["CONST: php_sapi_name()"]=php_sapi_name();
-               $sVar["OTHER: TYPO3_VERSION"]=$GLOBALS["TYPO_VERSION"];
-               $sVar["OTHER: PHP_VERSION"]=phpversion();
-               $sVar["imagecreatefromgif()"]=function_exists("imagecreatefromgif");
-               $sVar["imagecreatefrompng()"]=function_exists("imagecreatefrompng");
-               $sVar["imagecreatefromjpeg()"]=function_exists("imagecreatefromjpeg");
-               $sVar["imagegif()"]=function_exists("imagegif");
-               $sVar["imagepng()"]=function_exists("imagepng");
-               $sVar["imagejpeg()"]=function_exists("imagejpeg");
-               $sVar["imagettftext()"]=function_exists("imagettftext");
-               $sVar["OTHER: IMAGE_TYPES"]=imagetypes();
-               $sVar["OTHER: memory_limit"]=get_cfg_var("memory_limit");
-               
-               $gE_keys = explode(",","SERVER_PORT,SERVER_SOFTWARE,GATEWAY_INTERFACE,SCRIPT_NAME,PATH_TRANSLATED");
-               while(list(,$k)=each($gE_keys)) {
-                       $sVar["SERVER: ".$k]=$GLOBALS["HTTP_SERVER_VARS"][$k];
-               }
-
-               $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");
-               while(list(,$k)=each($gE_keys)) {
-                       $sVar["T3CV_GFX: ".$k]=$GLOBALS["TYPO3_CONF_VARS"]["GFX"][$k];
-               }
-
-               $debugInfo=array();
-               $debugInfo[]="### DEBUG SYSTEM INFORMATION - START ###";
-               reset($sVar);
-               while(list($kkk,$vvv)=each($sVar))      {
-                       $debugInfo[]=str_pad(substr($kkk,0,20),20).": ".$vvv;
-               }
-               $debugInfo[]="### DEBUG SYSTEM INFORMATION - END ###";
-
-               $buf=$this->messageFunc_nl2br;
-               $this->messageFunc_nl2br=0;
-               $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>
-               <form action=""><textarea rows="10" '.$this->formWidthText(80,"","off").' wrap="OFF">'.t3lib_div::formatForTextarea(implode(chr(10),$debugInfo)).'</textarea></form>');
-               $this->messageFunc_nl2br=$buf;
-
-               $getEnvArray = array();
-               $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");
-               while(list(,$k)=each($gE_keys)) {
-                       $getEnvArray[$k] = getenv($k);
-               }
-               $this->message($headCode,"t3lib_div::getIndpEnv()",t3lib_div::view_array(t3lib_div::getIndpEnv("_ARRAY")));
-               $this->message($headCode,"getenv()",t3lib_div::view_array($getEnvArray));
-               $this->message($headCode,"HTTP_ENV_VARS",t3lib_div::view_array($GLOBALS["HTTP_ENV_VARS"]));
-               $this->message($headCode,"HTTP_SERVER_VARS",t3lib_div::view_array($GLOBALS["HTTP_SERVER_VARS"]));
-               $this->message($headCode,"HTTP_COOKIE_VARS",t3lib_div::view_array($GLOBALS["HTTP_COOKIE_VARS"]));
-               $this->message($headCode,"HTTP_GET_VARS",t3lib_div::view_array($GLOBALS["HTTP_GET_VARS"]));
-
-               ob_start();
-               phpinfo();
-               $contents = explode("<body>",ob_get_contents());
-               ob_end_clean();
-               $contents = explode("</body>",$contents[1]);
+       function checkForBadString($string) {
+               return preg_match('/[' . LF . CR . ']/', $string) ? FALSE : TRUE;
+       }
 
-               $this->message($headCode,"phpinfo()",$contents[0]);
+       /**
+        * Replaces ' with \' and \ with \\
+        *
+        * @param       string          Input value
+        * @return      string          Output value
+        * @see setValueInLocalconfFile()
+        */
+       function slashValueForSingleDashes($value) {
+               $value = str_replace("'.LF.'", '###INSTALL_TOOL_LINEBREAK###', $value);
+               $value = str_replace("'", "\'", str_replace('\\', '\\\\', $value));
+               $value = str_replace('###INSTALL_TOOL_LINEBREAK###', "'.LF.'", $value);
 
+               return $value;
+       }
 
-               
-$this->headerStyle = '
-<style type="text/css"><!--
-a { text-decoration: none; }
-a:hover { text-decoration: underline; }
-h1 { font-family: verdana,arial, helvetica, sans-serif; font-size: 14pt; font-weight: bold;}
-h2 { font-family: verdana,arial, helvetica, sans-serif; font-size: 12pt; font-weight: bold;}
-body, td { font-family: verdana,arial, helvetica, sans-serif; font-size: 10pt; }
-th { font-family: verdana,arial, helvetica, sans-serif; font-size: 10pt; font-weight: bold; }
-//--></style>
-';
-               
-               echo $this->outputWrapper($this->printAll());                   
-       }       
-       
 
+       /*************************************
+        *
+        * SQL
+        *
+        *************************************/
 
+       /**
+        * Reads the field definitions for the input SQL-file string
+        *
+        * @param       string          Should be a string read from an SQL-file made with 'mysqldump [database_name] -d'
+        * @return      array           Array with information about table.
+        */
+       function getFieldDefinitions_fileContent($fileContent) {
+               $lines = t3lib_div::trimExplode(LF, $fileContent, 1);
+               $table = '';
+               $total = array();
 
+               foreach ($lines as $value) {
+                       if (substr($value, 0, 1) == '#') {
+                               continue; // Ignore comments
+                       }
 
+                       if (!strlen($table)) {
+                               $parts = t3lib_div::trimExplode(' ', $value, TRUE);
+                               if (strtoupper($parts[0]) === 'CREATE' && strtoupper($parts[1]) === 'TABLE') {
+                                       $table = str_replace('`', '', $parts[2]);
+                                       if (TYPO3_OS == 'WIN') { // tablenames are always lowercase on windows!
+                                               $table = strtolower($table);
+                                       }
+                               }
+                       } else {
+                               if (substr($value, 0, 1) == ')' && substr($value, -1) == ';') {
+                                       $ttype = array();
+                                       if (preg_match('/(ENGINE|TYPE)[ ]*=[ ]*([a-zA-Z]*)/', $value, $ttype)) {
+                                               $total[$table]['extra']['ENGINE'] = $ttype[2];
+                                       } // Otherwise, just do nothing: If table engine is not defined, just accept the system default.
+
+                                               // Set the collation, if specified
+                                       if (preg_match('/(COLLATE)[ ]*=[ ]*([a-zA-z0-9_-]+)/', $value, $tcollation)) {
+                                               $total[$table]['extra']['COLLATE'] = $tcollation[2];
+                                       } else {
+                                                       // Otherwise, get the CHARACTER SET and try to find the default collation for it as returned by "SHOW CHARACTER SET" query (for details, see http://dev.mysql.com/doc/refman/5.1/en/charset-table.html)
+                                               if (preg_match('/(CHARSET|CHARACTER SET)[ ]*=[ ]*([a-zA-z0-9_-]+)/', $value, $tcharset)) { // Note: Keywords "DEFAULT CHARSET" and "CHARSET" are the same, so "DEFAULT" can just be ignored
+                                                       $charset = $tcharset[2];
+                                               } else {
+                                                       $charset = $GLOBALS['TYPO3_DB']->default_charset; // Fallback to default charset
+                                               }
+                                               $total[$table]['extra']['COLLATE'] = $this->getCollationForCharset($charset);
+                                       }
 
+                                       $table = ''; // Remove table marker and start looking for the next "CREATE TABLE" statement
+                               } else {
+                                       $lineV = preg_replace('/,$/', '', $value); // Strip trailing commas
+                                       $lineV = str_replace('`', '', $lineV);
+                                       $lineV = str_replace('  ', ' ', $lineV); // Remove double blanks
 
+                                       $parts = explode(' ', $lineV, 2);
+                                       if (!preg_match('/(PRIMARY|UNIQUE|FULLTEXT|INDEX|KEY)/', $parts[0])) { // Field definition
 
+                                                       // Make sure there is no default value when auto_increment is set
+                                               if (stristr($parts[1], 'auto_increment')) {
+                                                       $parts[1] = preg_replace('/ default \'0\'/i', '', $parts[1]);
+                                               }
+                                                       // "default" is always lower-case
+                                               if (stristr($parts[1], ' DEFAULT ')) {
+                                                       $parts[1] = str_ireplace(' DEFAULT ', ' default ', $parts[1]);
+                                               }
 
+                                                       // Change order of "default" and "null" statements
+                                               $parts[1] = preg_replace('/(.*) (default .*) (NOT NULL)/', '$1 $3 $2', $parts[1]);
+                                               $parts[1] = preg_replace('/(.*) (default .*) (NULL)/', '$1 $3 $2', $parts[1]);
 
+                                               $key = $parts[0];
+                                               $total[$table]['fields'][$key] = $parts[1];
 
+                                       } else { // Key definition
+                                               $search = array('/UNIQUE (INDEX|KEY)/', '/FULLTEXT (INDEX|KEY)/', '/INDEX/');
+                                               $replace = array('UNIQUE', 'FULLTEXT', 'KEY');
+                                               $lineV = preg_replace($search, $replace, $lineV);
 
+                                               if (preg_match('/PRIMARY|UNIQUE|FULLTEXT/', $parts[0])) {
+                                                       $parts[1] = preg_replace('/^(KEY|INDEX) /', '', $parts[1]);
+                                               }
 
-       /*******************************
-        *
-        * typo3temp/ manager
-        *
-        *******************************/
+                                               $newParts = explode(' ', $parts[1], 2);
+                                               $key = $parts[0] == 'PRIMARY' ? $parts[0] : $newParts[0];
 
-       /**
-        * @return      [type]          ...
-        */
-       function typo3TempManager()     {
-               $headCode = "typo3temp/ directory";
-               $this->message($headCode,"What is it?","
-               TYPO3 uses this directory for temporary files, mainly processed and cached images.
-               The filenames are very cryptic; They are unique representations of the file properties made by md5-hashing a serialized array with information.
-               Anyway this directory may contain many thousand files and a lot of them may be of no use anymore.
-               
-               With this test you can delete the files in this folder. When you do that, you should also clear the cache database tables afterwards.
-               ");
-       
-               if (!$this->config_array["dir_typo3temp"])      {
-                       $this->message("typo3temp/ directory","typo3temp/ not writeable!","
-                               You must make typo3temp/ write enabled before you can proceed with this test.
-                       ",2);
-                       echo $this->outputWrapper($this->printAll());
-                       return;
-               }
+                                               $total[$table]['keys'][$key] = $lineV;
 
-                       // Run through files 
-               $fileCounter=0;
-               $deleteCounter=0;
-               $criteriaMatch=0;
-               $tmap=array("day"=>1,"week"=>7,"month"=>30);
-               $tt=$this->INSTALL["typo3temp_delete"];
-               $action=$this->INSTALL["typo3temp_action"];
-               $d = @dir($this->typo3temp_path);
-               if (is_object($d))      {
-                       while($entry=$d->read()) {
-                               $theFile = $this->typo3temp_path.$entry;
-                               if (@is_file($theFile)) {       
-                                       $ok=0;
-                                       $fileCounter++;
-                                       if ($tt)        {
-                                               if (t3lib_div::testInt($tt))    {
-                                                       if (filesize($theFile) > $tt*1024)      $ok=1;
-                                               } else {
-                                                       if (fileatime($theFile) < time()-(intval($tmap[$tt])*60*60*24)) $ok=1;
-                                               }
-                                       } else {
-                                               $ok=1;
-                                       }
-                                       if ($ok)        {
-                                               $hashPart=substr(basename($theFile),-14,10);
-                                               if (!ereg("[^a-f0-9]",$hashPart))       {               // This is a kind of check that the file being deleted has a 10 char hash in it
-                                                       if ($action && $deleteCounter<$action)  {
-                                                               $deleteCounter++;
-                                                               unlink($theFile);
-                                                       } else {
-                                                               $criteriaMatch++;
-                                                       }
+                                                       // This is a protection against doing something stupid: Only allow clearing of cache_* and index_* tables.
+                                               if (preg_match('/^(cache|index)_/', $table)) {
+                                                               // Suggest to truncate (clear) this table
+                                                       $total[$table]['extra']['CLEAR'] = 1;
                                                }
                                        }
                                }
                        }
-                       $d->close();
                }
 
-               
-               $deleteType=array(
-                       "0" => "All",
-                       "day" => "Last access more than a day ago",
-                       "week" => "Last access more than a week ago",
-                       "month" => "Last access more than a month ago",
-                       "10" => "Filesize greater than 10 kb",
-                       "50" => "Filesize greater than 50 kb",
-                       "100" => "Filesize greater than 100 kb"
-               );
-               $actionType=array(
-                       "0" => "Don't delete, just display statistics",
-                       "100" => "Delete 100",
-                       "500" => "Delete 500",
-                       "1000" => "Delete 1000"
-               );
-               $content='<select name="TYPO3_INSTALL[typo3temp_delete]">'.$this->getSelectorOptions($deleteType,$tt).'</select>
-               <br>
-Number of files at a time:
-               <select name="TYPO3_INSTALL[typo3temp_action]">'.$this->getSelectorOptions($actionType).'</select>';
-
-               $form = '<form action="'.$this->action.'" method="POST">'.$content.'
-               
-               <input type="submit" value="Execute">
-               </form>
-               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.';
-       
-               $this->message($headCode,"Statestics","
-               Number of temporary files: <strong>".($fileCounter-$deleteCounter)."</strong>
-               Number matching '".htmlspecialchars($deleteType[$tt])."': <strong>".$criteriaMatch."</strong>
-               Number deleted: <strong>".$deleteCounter."</strong>
-               <BR>
-               ".$form,1);
-       
-               echo $this->outputWrapper($this->printAll());                   
+               $this->getFieldDefinitions_sqlContent_parseTypes($total);
+               return $total;
        }
 
        /**
-        * [Describe function...]
-        * 
-        * @param       [type]          $deleteType: ...
-        * @param       [type]          $tt: ...
-        * @return      [type]          ...
-        */
-       function getSelectorOptions($deleteType,$tt="") {
-               $out="";
-               if (is_array($deleteType))      {
-                       reset($deleteType);
-                       while(list($v,$l)=each($deleteType))    {
-                               $out.='<option value="'.htmlspecialchars($v).'"'.(!strcmp($v,$tt)?" selected":"").'>'.htmlspecialchars($l).'</option>';
-                       }
-               }
-               return $out;
-       }
-       
-
-
-
-
-
-
-
-
-
-
-
-
-       /*******************************
+        * Multiplies varchars/tinytext fields in size according to $this->multiplySize
+        * Useful if you want to use UTF-8 in the database and needs to extend the field sizes in the database so UTF-8 chars are not discarded. For most charsets available as single byte sets, multiplication with 2 should be enough. For chinese, use 3.
         *
-        * CONFIGURATION FORM
-        *
-        ********************************/
-       
-       /**
-        * @param       [type]          $type: ...
-        * @return      [type]          ...
-        */
-       function generateConfigForm($type="")   {
-               switch($type)   {
-                       case "get_form":
-                               $default_config_content = t3lib_div::getUrl(PATH_t3lib."config_default.php");
-                               $commentArr = $this->getDefaultConfigArrayComments($default_config_content);
-/*                     
-                               $localconf_content = t3lib_div::getUrl(PATH_typo3conf."localconf.php");
-                               $commentArr2 = $this->getConfigArrayComments($localconf_content);
-                               debug($commentArr2);
-*/                             
-                               reset($GLOBALS["TYPO3_CONF_VARS"]);
-                               $this->messageFunc_nl2br=0;
-                               while(list($k,$va)=each($GLOBALS["TYPO3_CONF_VARS"]))   {
-                                       $ext="[".$k."]";
-                                       $this->message($ext, '$TYPO3_CONF_VARS["'.$k.'"]',$commentArr[0][$k],1);
-                                       while(list($vk,$value)=each($va))       {
-                                               if (!is_array($value) && $this->checkForBadString($value))      {
-                                                       $k2="[".$vk."]";
-                                                       $description = trim($commentArr[1][$k][$vk]);
-                                                       $msg=$description."<BR><BR><em>".$ext.$k2." = ".htmlspecialchars(t3lib_div::fixed_lgd($value,60))."</em><BR>";
-                                                       
-                                                       if (strstr($value,chr(10)))     {
-                                                                               // Never used at this point:
-                                                               $form='<textarea name="TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']" cols=40 rows=5 wrap="off">'.htmlspecialchars($value).'</textarea>';
-                                                       } elseif (eregi("^boolean",$description)) {
-                                                               $form='<input type="hidden" name="TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']" value="0">';
-                                                               $form.='<input type="checkbox" name="TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']"'.($value?" checked":"").' value="'.($value&&strcmp($value,"0")?htmlspecialchars($value):1).'">';
-                                                       } else {
-                                                               $form='<input type="text" size=40 name="TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']" value="'.htmlspecialchars($value).'">';
-                                                       }
-                                                       $this->message($ext, $k2,$msg.$form);
-                                               }
-                                       }
-                               }
-                       break;
-                       default:
-                               if (is_array($this->INSTALL["extConfig"]))              {
-                                       reset($this->INSTALL["extConfig"]);
-                                       $lines = $this->writeToLocalconf_control();
-                                       while(list($k,$va)=each($this->INSTALL["extConfig"]))   {
-                                               if (is_array($GLOBALS["TYPO3_CONF_VARS"][$k]))  {
-                                                       while(list($vk,$value)=each($va))       {
-                                                               if (isset($GLOBALS["TYPO3_CONF_VARS"][$k][$vk]))        {
-                                                                       $doit=1;
-                                                                       if ($k=="BE" && $vk=="installToolPassword")     {
-                                                                               if ($value)     {
-                                                                                       if (isset($GLOBALS["HTTP_POST_VARS"]["installToolPassword_check"]) && (!t3lib_div::GPvar("installToolPassword_check") || strcmp(t3lib_div::GPvar("installToolPassword_check"),$value))) {
-                                                                                               $doit=0;
-                                                                                               debug("ERROR: The two passwords did not match! The password was not changed.");
+        * @param       array           Total array (from getFieldDefinitions_fileContent())
+        * @return      void
+        * @access private
+        * @see getFieldDefinitions_fileContent()
+        */
+       function getFieldDefinitions_sqlContent_parseTypes(&$total) {
+
+               $mSize = (double) $this->multiplySize;
+               if ($mSize > 1) {
+
+                               // Init SQL parser:
+                       $sqlParser = t3lib_div::makeInstance('t3lib_sqlparser');
+                       foreach ($total as $table => $cfg) {
+                               if (is_array($cfg['fields'])) {
+                                       foreach ($cfg['fields'] as $fN => $fType) {
+                                               $orig_fType = $fType;
+                                               $fInfo = $sqlParser->parseFieldDef($fType);
+
+                                               switch ($fInfo['fieldType']) {
+                                                       case 'char':
+                                                       case 'varchar':
+                                                               $newSize = round($fInfo['value'] * $mSize);
+
+                                                               if ($newSize <= 255) {
+                                                                       $fInfo['value'] = $newSize;
+                                                               } else {
+                                                                       $fInfo = array(
+                                                                               'fieldType' => 'text',
+                                                                               'featureIndex' => array(
+                                                                                       'NOTNULL' => array(
+                                                                                               'keyword' => 'NOT NULL'
+                                                                                       )
+                                                                               )
+                                                                       );
+                                                                               // Change key definition if necessary (must use "prefix" on TEXT columns)
+                                                                       if (is_array($cfg['keys'])) {
+                                                                               foreach ($cfg['keys'] as $kN => $kType) {
+                                                                                       $match = array();
+                                                                                       preg_match('/^([^(]*)\(([^)]+)\)(.*)/', $kType, $match);
+                                                                                       $keys = array();
+                                                                                       foreach (t3lib_div::trimExplode(',', $match[2]) as $kfN) {
+                                                                                               if ($fN == $kfN) {
+                                                                                                       $kfN .= '(' . $newSize . ')';
+                                                                                               }
+                                                                                               $keys[] = $kfN;
                                                                                        }
-                                                                                       if (t3lib_div::GPvar("installToolPassword_md5"))        $value =md5($value);
-                                                                               } else $doit=0;
+                                                                                       $total[$table]['keys'][$kN] = $match[1] . '(' . implode(',', $keys) . ')' . $match[3];
+                                                                               }
                                                                        }
-                                                                       if ($doit && strcmp($GLOBALS["TYPO3_CONF_VARS"][$k][$vk],stripslashes($value))) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["'.$k.'"]["'.$vk.'"]', $value);
                                                                }
-                                                       }
+                                                       break;
+                                                       case 'tinytext':
+                                                               $fInfo['fieldType'] = 'text';
+                                                       break;
                                                }
-                                       }
-                                       $this->writeToLocalconf_control($lines);
-                               }
-                       break;
-               }
-       }
 
-       /**
-        * [Describe function...]
-        * 
-        * @param       [type]          $string: ...
-        * @param       [type]          $mainArray: ...
-        * @param       [type]          $commentArray: ...
-        * @return      [type]          ...
-        */
-       function getDefaultConfigArrayComments($string,$mainArray=array(),$commentArray=array())        {
-               $lines = explode(chr(10),$string);
-               $in=0;
-               $mainKey="";
-               while(list(,$lc)=each($lines))  {
-                       $lc = trim($lc);
-                       if ($in) {
-                               if (!strcmp($lc,");"))  {
-                                       $in=0;
-                               } else {
-                                       if (eregi('["\']([[:alnum:]_-]*)["\'][[:space:]]*=>(.*)',$lc,$reg))     {
-                                               list(,$theComment)=explode("//",$reg[2],2);
-                                               if (substr(strtolower(trim($reg[2])),0,5)=="array" && !strcmp($reg[1],strtoupper($reg[1])))     {
-                                                       $mainKey=trim($reg[1]);
-                                                       $mainArray[$mainKey]=trim($theComment);
-                                               } elseif ($mainKey) {
-                                                       $commentArray[$mainKey][$reg[1]]=trim($theComment);
+                                               $total[$table]['fields'][$fN] = $sqlParser->compileFieldCfg($fInfo);
+                                               if ($sqlParser->parse_error) {
+                                                       throw new RuntimeException(
+                                                               'TYPO3 Fatal Error: ' . $sqlParser->parse_error,
+                                                               1270853961
+                                                       );
                                                }
-                                       } else {
-                                               //debug($lc,1);
                                        }
                                }
                        }
-                       if (!strcmp($lc,'$TYPO3_CONF_VARS = Array('))   {
-                               $in=1;
-                       }
                }
-               return array($mainArray,$commentArray);
        }
-       
-
-
-
-
-
-
-
-
 
+       /**
+        * Look up the default collation for specified character set based on "SHOW CHARACTER SET" output
+        *
+        * @param       string          Character set
+        * @return      string          Corresponding default collation
+        */
+       function getCollationForCharset($charset) {
+                       // Load character sets, if not cached already
+               if (!count($this->character_sets)) {
+                       if (method_exists($GLOBALS['TYPO3_DB'], 'admin_get_charsets')) {
+                               $this->character_sets = $GLOBALS['TYPO3_DB']->admin_get_charsets();
+                       } else {
+                               $this->character_sets[$charset] = array(); // Add empty element to avoid that the check will be repeated
+                       }
+               }
 
+               $collation = '';
+               if (isset($this->character_sets[$charset]['Default collation'])) {
+                       $collation = $this->character_sets[$charset]['Default collation'];
+               }
 
+               return $collation;
+       }
 
-       /*******************************
-        *
-        * CHECK CONFIGURATION FUNCTIONS
-        *
-        *******************************/
-       
        /**
-        * Checking php.ini configuration and set appropriate messages and flags.
-        * 
-        * @return      [type]          ...
+        * Reads the field definitions for the current database
+        *
+        * @return      array           Array with information about table.
         */
-       function checkConfiguration()   {
-               $ext="php.ini configuration checked";
-               $this->message($ext);
+       function getFieldDefinitions_database() {
+               $total = array();
+               $tempKeys = array();
+               $tempKeysPrefix = array();
 
-                       // *****************
-                       // Incoming values:
-                       // *****************
-                       
-               if (!get_cfg_var("track_vars")) {
-                       $this->message($ext, "Tracking Vars not set","
-                               <i>track_vars=".get_cfg_var("track_vars")."</i>
-                               Tracking vars are essential for almost any PHP-application. 
-                               The fact that the value is not set may not impose a problem, because it's always set in version 4.03+ of PHP.
-                       ",1);
-               } else $this->message($ext, "Tracking Vars enabled","",-1);
+               $GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db);
+               echo $GLOBALS['TYPO3_DB']->sql_error();
 
-/*
-               if (!get_cfg_var("allow_url_fopen"))    {
-                       $this->message($ext, "fopen() not allowed to open URL's","
-                               <i>allow_url_fopen=".get_cfg_var("allow_url_fopen")."</i>
-                               allow_url_fopen should be enabled if you want TYPO3 to connect to the online TYPO3 Extension Repository.
-                       ",2);
-               } else $this->message($ext, "fopen() allowed to open URL's","",-1);
-*/
+               $tables = $GLOBALS['TYPO3_DB']->admin_get_tables(TYPO3_db);
+               foreach ($tables as $tableName => $tableStatus) {
 
-                       // Includepath
-               $incPaths = t3lib_div::trimExplode(TYPO3_OS=="WIN"?";":":", ini_get("include_path"));
-               if (!in_array(".",$incPaths))   {
-                       $this->message($ext, "Current dir (./) is not in include path!","
-                               <i>include_path=".ini_get("include_path")."</i>
-                               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.
-                       ",1);
-               } else $this->message($ext, "Current dir in include path","",-1);
-               if (!ini_get("register_globals"))       {
-                       $this->message($ext, "Register globals disabled","
-                               <i>register_globals=".ini_get("register_globals")."</i>
-                               Incoming values by GET or POST method are not registered as globals. TYPO3 is designed to cope with that - actually we encourage that setting - but you should be aware if your included PHP-scripts (or TypoScript configurations) are compatible with this setting.
-                               You should always use the function t3lib_div::GPvar(\"<i>[the_var_name_from_GET_or_POST]</i>\") to retrieve values passed to your script from outside.
-                       ",1);
-               } else $this->message($ext, "Register globals enabled","You should always use the function t3lib_div::GPvar(\"<i>[the_var_name_from_GET_or_POST]</i>\") to retrieve values passed to your script from outside.",1);
-               if (!ini_get("magic_quotes_gpc"))       {
-                       $this->message($ext, "magic_quotes_gpc","
-                               <i>magic_quotes_gpc=".ini_get("magic_quotes_gpc")."</i>
-                               Incoming \" and ' chars in values by GET or POST method are currently <i>not</i> escaped. TYPO3 is designed to cope with that but it may be on the expense of a minor performance loss, because all incoming values are addslashes()'ed.
-                       ",1);
-               } else $this->message($ext, "magic_quotes_gpc","<i>magic_quotes_gpc=".ini_get("magic_quotes_gpc")."</i>",-1);
-               if (ini_get("magic_quotes_runtime"))    {
-                       $this->message($ext, "Magic Quotes Runtime is enabled","
-                               <i>magic_quotes_runtime=".ini_get("magic_quotes_runtime")."</i>
-                               TYPO3 is depending on this option NOT being enabled! 
-                       ",3);
-               } else $this->message($ext, "magic_quotes_runtime","<i>magic_quotes_runtime=".ini_get("magic_quotes_runtime")."</i>",-1);
-               if (ini_get("gpc_order")!="GPC")        {
-                       $this->message($ext, "GPC order non-standard","
-                               <i>gpc_order=".ini_get("gpc_order")."</i>
-                               The order of GET, POST and COOKIE vars are non-standard. The value should be \"GPC\".
-                       ",2);
-               } else $this->message($ext, "GPC order","",-1);
+                               // Fields:
+                       $fieldInformation = $GLOBALS['TYPO3_DB']->admin_get_fields($tableName);
+                       foreach ($fieldInformation as $fN => $fieldRow) {
+                               $total[$tableName]['fields'][$fN] = $this->assembleFieldDefinition($fieldRow);
+                       }
 
-                       // *****************
-                       // File uploads
-                       // *****************
-               if (!ini_get("file_uploads"))   {
-                       $this->message($ext, "File uploads not allowed","
-                               <i>file_uploads=".ini_get("file_uploads")."</i>
-                               TYPO3 uses the ability to upload files from the browser in various cases.
-                               As long as this flag is disabled, you'll not be able to upload files. 
-                               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!
-                               However if you cannot enable fileupload for some reason alternatively you change the default form encoding value with \$TYPO3_CONF_VARS[SYS][form_enctype].
-                       ",3);
-               } else $this->message($ext, "File uploads allowed","",-1);
-               $upload_max_filesize = $this->convertByteSize(ini_get("upload_max_filesize"));
-               if ($upload_max_filesize<10000*1024)    {
-                       $this->message($ext, "Max Upload filesize too small?","
-                               <i>upload_max_filesize=".ini_get("upload_max_filesize")."</i>
-                               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]).
-                               Your current value is below this, so at this point, PHP sets the limits for uploaded filesizes and not TYPO3. 
-                               <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.
-                       ",1);
-               }
+                               // Keys:
+                       $keyInformation = $GLOBALS['TYPO3_DB']->admin_get_keys($tableName);
 
-                       // *****************
-                       // Memory and functions
-                       // *****************
-               $memory_limit_value = $this->convertByteSize(get_cfg_var("memory_limit"));
-               if ($memory_limit_value<8*1024*1024)    {
-                       $this->message($ext, "Memory Limit below default 8 MB","
-                               <i>memory_limit=".get_cfg_var("memory_limit")."</i>
-                               May impose problems if too low.
-                       ",1);
-               } else $this->message($ext, "Memory Limit","<i>memory_limit=".get_cfg_var("memory_limit")."</i>",-1);
-               if (ini_get("max_execution_time")<30)   {
-                       $this->message($ext, "Max Execution Time below default 30 seconds","
-                               <i>max_execution_time=".ini_get("max_execution_time")."</i>
-                               May impose problems if too low.
-                       ",1);
-               } else $this->message($ext, "Max Execution Time","<i>max_execution_time=".ini_get("max_execution_time")."</i>",-1);
-               if (ini_get("disable_functions"))       {
-                       $this->message($ext, "Functions disabled!","
-                               <i>disable_functions=".ini_get("disable_functions")."</i>
-                               The above list of functions are disabled. If TYPO3 use any of these there might be trouble.
-                               TYPO3 is designed to use the default set of PHP4.0.6+ functions plus the functions from GDLib. 
-                               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.
-                       ",2);
-               } else $this->message($ext, "Functions disabled: none","",-1);
-               if (!ini_get("sendmail_path"))  {
-                       $this->message($ext, "Sendmail path not defined!","
-                               <i>sendmail_path=".ini_get("sendmail_path")."</i>
-                               This may be critical to TYPO3's use of the mail() function. Please be sure that the mail() function in your php-installation works!
-                       ".$this->check_mail("get_form"),1);
-               } else {
-                       list($prg) = explode(" ",ini_get("sendmail_path"));
-                       if (TYPO3_OS=='WIN')    {
-                               $this->message($ext, "Sendmail program not searched for on Windows","",1);
-                       } else {
-                               if (!@is_executable($prg))      {
-                                       $this->message($ext, "Sendmail program not found or not executable?","
-                                               <i>sendmail_path=".ini_get("sendmail_path")."</i>
-                                               This may be critical to TYPO3's use of the mail() function. Please be sure that the mail() function in your php-installation works!
-                                       ".$this->check_mail("get_form"),1);
+                       foreach ($keyInformation as $keyRow) {
+                               $keyName = $keyRow['Key_name'];
+                               $colName = $keyRow['Column_name'];
+                               if ($keyRow['Sub_part']) {
+                                       $colName .= '(' . $keyRow['Sub_part'] . ')';
+                               }
+                               $tempKeys[$tableName][$keyName][$keyRow['Seq_in_index']] = $colName;
+                               if ($keyName == 'PRIMARY') {
+                                       $prefix = 'PRIMARY KEY';
                                } else {
-                                       $this->message($ext, "Sendmail OK","
-                                               <i>sendmail_path=".ini_get("sendmail_path")."</i>
-                                               You may check the mail() function by entering your emailaddress here:
-                                       ".$this->check_mail("get_form"),-1);
+                                       if ($keyRow['Index_type'] == 'FULLTEXT') {
+                                               $prefix = 'FULLTEXT';
+                                       } elseif ($keyRow['Non_unique']) {
+                                               $prefix = 'KEY';
+                                       } else {
+                                               $prefix = 'UNIQUE';
+                                       }
+                                       $prefix .= ' ' . $keyName;
                                }
+                               $tempKeysPrefix[$tableName][$keyName] = $prefix;
                        }
-               }
-               
-                       // *****************
-                       // Safe mode related
-                       // *****************
-               if (ini_get("safe_mode"))       {
-                       $this->message($ext, "Safe mode turned on","
-                               <i>safe_mode=".ini_get("safe_mode")."</i>
-                               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.
-                               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/\".
-                               If you use safe_mode with TYPO3, you should disable use of external programs ([BE][disable_exec_function]=1).
-                               In safe mode you must ensure that all the php-scripts and upload folders are owned by the same user.
-
-                                       <i>safe_mode_exec_dir=".ini_get("safe_mode_exec_dir")."</i>
-                                       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)
-                                       
 
-                                       <strong>Example of safe_mode settings:</strong>
-                                       Set this in the php.ini file:
-
-                                       ; Safe Mode
-                                       safe_mode               =       On
-                                       safe_mode_exec_dir      = /usr/bin/
-
-                                       ...and the ImageMagick '/usr/bin/convert' will be executable.
-                                       The last slash is important (..../) and you can only specify one directory.
+                               // Table status (storage engine, collaction, etc.)
+                       if (is_array($tableStatus)) {
+                               $tableExtraFields = array(
+                                       'Engine' => 'ENGINE',
+                                       'Collation' => 'COLLATE',
+                               );
 
-                                       <strong>Notice: </strong>
-                                       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.
-                                       Paths to ImageMagick are defined in localconf.php and may be something else than /usr/bin/, but this is default for ImageMagick 5+
-                                       
-                       
-                       ",2);
-                       if (ini_get("doc_root"))        {
-                               $this->message($ext, "doc_root set","
-                                       <i>doc_root=".ini_get("doc_root")."</i>
-                                       PHP cannot execute scripts outside this directory. If that is a problem is please correct it.
-                               ",1);
+                               foreach ($tableExtraFields as $mysqlKey => $internalKey) {
+                                       if (isset($tableStatus[$mysqlKey])) {
+                                               $total[$tableName]['extra'][$internalKey] = $tableStatus[$mysqlKey];
+                                       }
+                               }
                        }
-                       $this->config_array["safemode"]=1;
-               } else $this->message($ext, "safe_mode: off","",-1);
-               if (ini_get("sql.safe_mode"))   {
-                       $this->message($ext, "sql.safe_mode is enabled","
-                               <i>sql.safe_mode=".ini_get("sql.safe_mode")."</i>
-                               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")."
-                               The owner of the current file is: <strong>".get_current_user ()."</strong>
-                       ",1);
-                       $this->config_array["sql.safe_mode_user"] = get_current_user();
-               } else $this->message($ext, "sql.safe_mode: off","",-1);
-               if (ini_get("open_basedir"))    {
-                       $this->message($ext, "open_basedir set","
-                               <i>open_basedir=".ini_get("open_basedir")."</i>
-                               This restricts TYPO3 to open and include files only in this path. Please make sure that this does not prevent TYPO3 from running.
-                               <strong>Notice (UNIX):</strong> Before checking a path according to open_basedir, PHP resolves all symbolic links.
-                       ",1);
-//     ????                    If this option was set falsely you probably didn't see this page in the first place, but this option <B>may spoil this configuration test</B> when checking for such as ImageMagick executables.
-               } else $this->message($ext, "open_basedir: off","",-1);
-       
-       }
+               }
 
-       /**
-        * Check if php function mail() works
-        * 
-        * @param       string          $cmd    If "get_form" then a formfield for the mail-address is shown. If not, it's checked if "check_mail" was in the INSTALL array and if so a test mail is sent to the recipient given.
-        * @return      [type]          ...
-        */
-       function check_mail($cmd="")    {
-               switch($cmd)    {
-                       case "get_form":
-                               $out='
-                               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.
-                               <form action="'.$this->action.'" method="POST"><input type="text" name="TYPO3_INSTALL[check_mail]">
-                                       <input type="submit" value="Send test mail"></form>';
-                       break;
-                       default:
-                               if (trim($this->INSTALL["check_mail"])) {
-                                       mail(trim($this->INSTALL["check_mail"]), "TEST SUBJECT", "TEST CONTENT", "From: test@test.test");
-                                       $this->messages[]= "MAIL WAS SENT TO: ".$this->INSTALL["check_mail"];
+                       // Compile key information:
+               if (count($tempKeys)) {
+                       foreach ($tempKeys as $table => $keyInf) {
+                               foreach ($keyInf as $kName => $index) {
+                                       ksort($index);
+                                       $total[$table]['keys'][$kName] = $tempKeysPrefix[$table][$kName] . ' (' . implode(',', $index) . ')';
                                }
-                       break;
+                       }
                }
-               return $out;
+
+               return $total;
        }
 
        /**
-        * Checking php extensions, specifically GDLib and Freetype
-        * 
-        * @return      [type]          ...
-        */
-       function checkExtensions()      {
-               $ext = "GDLib";
-               $this->message($ext);
+        * Compares two arrays with field information and returns information about fields that are MISSING and fields that have CHANGED.
+        * FDsrc and FDcomp can be switched if you want the list of stuff to remove rather than update.
+        *
+        * @param       array           Field definitions, source (from getFieldDefinitions_fileContent())
+        * @param       array           Field definitions, comparison. (from getFieldDefinitions_database())
+        * @param       string          Table names (in list) which is the ONLY one observed.
+        * @param       boolean         If set, this function ignores NOT NULL statements of the SQL file field definition when comparing current field definition from database with field definition from SQL file. This way, NOT NULL statements will be executed when the field is initially created, but the SQL parser will never complain about missing NOT NULL statements afterwards.
+        * @return      array           Returns an array with 1) all elements from $FDsrc that is not in $FDcomp (in key 'extra') and 2) all elements from $FDsrc that is different from the ones in $FDcomp
+        */
+       function getDatabaseExtra($FDsrc, $FDcomp, $onlyTableList = '', $ignoreNotNullWhenComparing = TRUE) {
+               $extraArr = array();
+               $diffArr = array();
+
+               if (is_array($FDsrc)) {
+                       foreach ($FDsrc as $table => $info) {
+                               if (!strlen($onlyTableList) || t3lib_div::inList($onlyTableList, $table)) {
+                                       if (!isset($FDcomp[$table])) {
+                                               $extraArr[$table] = $info; // If the table was not in the FDcomp-array, the result array is loaded with that table.
+                                               $extraArr[$table]['whole_table'] = 1;
+                                       } else {
+                                               $keyTypes = explode(',', 'extra,fields,keys');
+                                               foreach ($keyTypes as $theKey) {
+                                                       if (is_array($info[$theKey])) {
+                                                               foreach ($info[$theKey] as $fieldN => $fieldC) {
+                                                                       $fieldN = str_replace('`', '', $fieldN);
+                                                                       if ($fieldN == 'COLLATE') {
+                                                                               continue; // TODO: collation support is currently disabled (needs more testing)
+                                                                       }
 
-               $software_info=1;
-               if (extension_loaded("gd") && $this->isGD())    {
-                       $this->config_array["gd"]=1;
-                       $this->message($ext, "GDLib found","",-1);
-                       if ($this->isPNG()) {
-                               $this->config_array["gd_png"]=1;
-                               $this->message($ext, "PNG supported","",-1);
-                       }
-                       if ($this->isGIF()) {
-                               $this->config_array["gd_gif"]=1;
-                               $this->message($ext, "GIF supported","",-1);
-                       }
-                       if ($this->isJPG()) {
-                               $this->config_array["gd_jpg"]=1;
-                               $this->message($ext, "JPG supported (not used by TYPO3)","");
-                       }
-                       if (!$this->config_array["gd_gif"] && !$this->config_array["gd_png"])   {
-                               $this->message($ext, "PNG or GIF not supported", nl2br(trim("
-                                       Your GDLib supports either GIF nor PNG. It must support either one of them.
-                               ")), 2);
-                       } else {
-                               $msg=array();
-                               if ($this->config_array["gd_gif"] && $this->config_array["gd_png"])             {
-                                       $msg[0]="You can choose between generating GIF or PNG files, as your GDLib supports both.";
-                               }
-                               if ($this->config_array["gd_gif"])              {
-                                       $msg[10]="You should know that generating GIF files are covered by a UNISYS patent. <a target=\"_blank\" href=\"http://www.boutell.com/gd/\">Read more for details.</a>";
-                                       $msg[11]="In addition you should watch out for the generated size of the GIF-files because GDLib does not compress them with LZW, but RLE and ImageMagick is subsequently used to compress with LZW. But in the case of ImageMagick failing this task (eg. not being compiled with LZW which is the case with newer versions) you'll end up with GIF-filesizes all too big! 
-                                       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.";
-                               }
-                               if ($this->config_array["gd_png"])              {
-                                       $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.";
-                               }
-                               $this->message($ext, "GIF / PNG issues", nl2br(trim(implode($msg,chr(10)))), 1);
-                       }
-                       if (!$this->isTTF())    {
-                               $this->message($ext, "FreeType is apparently not installed", "
-                                       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'.
-                               ", 2);
-                       } else {
-                               $this->message($ext, "FreeType Quick-test (".($this->isGIF()?"as GIF":"as PNG").")", '<img src="'.t3lib_div::getIndpEnv("REQUEST_URI").'&testingTrueTypeSupport=1"><BR>(If the text is exceeding the image borders you are using Freetype 2 and need to set TYPO3_CONF_VARS[GFX][TTFdpi]=96.<BR>If there is no image at all Freetype is most likely NOT available and you can just as well disable GDlib for TYPO3...)', -1);
-                               $this->config_array["freetype"]=1;
-                       }
-               } else {
-                       $this->message($ext, "GDLib not found", "
-                               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. 
-                               GDLib is also used in the TYPO3 Backend (TBE) to generate record icons and new module tabs.
-                               It's highly recommended to install this library. Remember to compile GD with FreeType which is also required.
-                               If you choose not to install GDLib, you can disable it in the configuration with [GFX][gdlib]=0;.
-                       ", 2);
-               }
-               $this->message($ext, "GDLib software information", nl2br(trim($this->getGDSoftwareInfo())));
-       }
-
-       /**
-        * Checking and testing that the required writable directories are writable.
-        * 
-        * @return      [type]          ...
-        */
-       function checkDirs()    {
-               // Check typo3/temp/
-               $ext="Directories";
-               $this->message($ext);
-
-               $uniqueName = md5(uniqid(microtime()));
-
-               $checkWrite=array(
-                       "typo3temp/" => array("The folder is used by both the frontend (FE) and backend interface (TBE) for image manipulated files.",1,"dir_typo3temp"),
-#                      TYPO3_mainDir."temp/" => array("The folder is used by the backend interface only (TBE) for icons, pane tabs and click-menu items. The directory is usually not empty in the distribution, but you should be able to clear it out and TYPO3 should generate new files automatically.",1,"dir_temp"),
-                       "typo3conf/" => array("This directory contains the local configuration files of your website. TYPO3 must be able to write to these configuration files during setup and when the Extension Manager (EM) installs extensions.",1),
-                       "typo3conf/ext/" => array("Location for local extensions. Must be writable if the Extension Manager is supposed to install extensions for this website.",0),
-                       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),
-                       "uploads/" => array("Location for uploaded files from RTE + in the subdirs for tables.",1),
-                       "uploads/pics/" => array("Typical location for uploaded files (images especially).",0),
-                       "uploads/media/" => array("Typical location for uploaded files (non-images especially).",0),
-                       "uploads/tf/" => array("Typical location for uploaded files (TS template resources).",0),
-                       "fileadmin/" => array("Location for local files such as templates, independent uploads etc.",0),
-                       "fileadmin/_temp_/" => array("Typical temporary location for default upload of files by administrators.",0),
-               );
-               
-               reset($checkWrite);
-               while(list($relpath,$descr)=each($checkWrite))  {
-                       // Check typo3temp/
-                       $general_message = $descr[0];
-                       if (!@is_dir(PATH_site.$relpath))       {
-                               if ($descr[1])  {       // required...
-                                       $this->message($ext, $relpath." directory does not exist","
-                                       <em>Full path: ".PATH_site.$relpath."</em>
-                                       ".$general_message."
-                                       
-                                       This error should not occur as ".$relpath." must always be accessible in the root of a TYPO3 website. 
-                                       ",3);
-                               } else {
-                                       $this->message($ext, $relpath." directory does not exist","
-                                       <em>Full path: ".PATH_site.$relpath."</em>
-                                       ".$general_message."
-
-                                       This directory does not necessarily have to exist but if it does it must be writable.
-                                       ",2);
-                               }
-                       } else {
-                               $file = PATH_site.$relpath.$uniqueName;
-                               @touch($file);
-                               if (@is_file($file))    {
-                                       unlink($file);
-                                       if ($descr[2])  { $this->config_array[$descr[2]]=1; }
-                                       $this->message($ext, $relpath." writeable","",-1);
-                               } else {
-                                       $this->message($ext, $relpath." directory not writeable","
-                                       <em>Full path: ".$file."</em>
-                                       ".$general_message."
-                                       
-                                       Tried to write this file (with touch()) but didn't succeed.
-                                       The directory ".$relpath." must be writable!
-                                       ",3);
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Checking for existing ImageMagick installs.
-        * 
-        * This tries to find available ImageMagick installations and tries to find the version numbers by executing "convert" without parameters. If the ->checkIMlzw is set, LZW capabilities of the IM installs are check also.
-        * 
-        * @param       [type]          $paths: ...
-        * @return      [type]          ...
-        */
-       function checkImageMagick($paths)       {
-               $ext="Check Image Magick";
-               $this->message($ext);
-
-               $paths = array_unique($paths);
-
-               $programs = explode(",","convert,combine,composite,identify");  // Added composite (substitution for combine in newer versions?)
-               $isExt = TYPO3_OS=="WIN" ? ".exe" : "";
-               $this->config_array["im_combine_filename"]="combine";
-               reset($paths);
-               while(list($k,$v)=each($paths)) {
-                       reset($programs);
-                       while(list(,$filename)=each($programs)) {
-#                              if (@file_exists($v) && @is_file($v.$filename.$isExt))    {       // file_exists was necessary on windows, because is_file issued a warning if the path was not correct.
-                               if($this->_checkImageMagick_getVersion($v.$filename.$isExt) > 0 ) {
-                                       $index[$v][$filename]=$this->_checkImageMagick_getVersion($v.$filename.$isExt);
-                               }
-                       }
-                       if (count($index[$v])>=3)       {$this->config_array["im"]=1;}
-                       if ($index[$v]["composite"] && !$index[$v]["combine"])  {
-                               $this->config_array["im_combine_filename"]="composite";
-                       }
-                       if (isset($index[$v]["convert"]) && $this->checkIMlzw)  {
-                               $index[$v]["gif_capability"] = "".$this->_checkImageMagickGifCapability($v);
-                       }
-               }
-               $this->config_array["im_versions"]=$index;
-               if (!$this->config_array["im"]) {
-                       $this->message($ext, "No ImageMagick install available","
-                       It seems that there is no adequate ImageMagick installation available at the checked locations (".implode($paths, ", ").")
-                       An 'adequate' installation for requires 'convert', 'combine'/'composite' and 'identify' to be available
-                       ",2);
-               } else {
-                       $theCode="";
-                       reset($this->config_array["im_versions"]);
-                       while(list($p,$v)=each($this->config_array["im_versions"]))     {
-                               $ka=array();
-                               reset($v);
-                               while(list($ka[])=each($v)){}
-                               $theCode.='<tr><td>'.$this->fw($p).'</td><td>'.$this->fw(implode($ka,"<BR>")).'</td><td>'.$this->fw(implode($v,"<BR>")).'</td></tr>';
-                       }
-                       $this->message($ext, "Available ImageMagick installations:",'<table border=1 cellpadding=2 cellspacing=2>'.$theCode.'</table>',-1);
-               }
-               $this->message($ext, "Search for ImageMagick:",'
-                       <form action="'.$this->action.'" method="POST">'.$content.'<input type="checkbox" name="TYPO3_INSTALL[checkIM][lzw]" value="1"'.($this->INSTALL["checkIM"]["lzw"]?" checked":"").'> Check LZW capabilities.
-
-                               Check this path for ImageMagick installation:
-                               <input type="text" name="TYPO3_INSTALL[checkIM][path]" value="'.htmlspecialchars(stripslashes($this->INSTALL["checkIM"]["path"])).'"> 
-                               (Eg. "D:\wwwroot\im537\ImageMagick\" for windows or "/usr/bin/" for Unix)<br>
-                               
-                               <input type="submit" value="Send">
-                       </form>         
-               ',0);
-               
-       }
-
-       /**
-        * Checking GIF-compression capabilities of ImageMagick install
-        * 
-        * @param       [type]          $file: ...
-        * @return      [type]          ...
-        */
-       function _checkImageMagickGifCapability($file)  {
-               if ($this->config_array["dir_typo3temp"])       {               //  && !$this->config_array["safemode"]
-                       $path = $this->typo3temp_path;
-                       $uniqueName = md5(uniqid(microtime()));
-                       $dest = $path.$uniqueName.".gif";
-                       $src = PATH_t3lib."gfx/typo3logo.gif";
-                       if (@is_file($src) && !strstr($src," ") && !strstr($dest," "))  {
-                               $cmd = $file.'convert '.$src.' '.$dest;
-                               exec($cmd);
-                       } else die("No t3lib/gfx/typo3logo.gif file!");
-                       $out="";
-                       if (@is_file($dest))    {
-                               $new_info = @getimagesize($dest);
-                               clearstatcache();
-                               $new_size = filesize($dest);
-                               $src_info = @getimagesize($src);
-                               clearstatcache();
-                               $src_size = @filesize($src);
-                               
-                               if ($new_info[0]!=$src_info[0] || $new_info[1]!=$src_info[1] || !$new_size || !$src_size)       {
-                                       $out="error";
-                               } else {
-                                       if ($new_size/$src_size > 4) {  // NONE-LZW ratio was 5.5 in test
-                                               $out="NONE";
-                                       } elseif ($new_size/$src_size > 1.5) {  // NONE-RLE ratio was not tested
-                                               $out="RLE";
-                                       } else {
-                                               $out="LZW";
-                                       }
-                               }
-                               unlink($dest);
-                       }
-                       return $out;
-               }
-       }
-
-       /**
-        * Extracts the version number for imagemagick
-        * 
-        * @param       string          $file   This is the path to the convert-program to execute in order to find the version number
-        * @return      [type]          ...
-        */
-       function _checkImageMagick_getVersion($file)    {
-               exec($file, $retVal);
-               $string = $retVal[0];
-               list(,$ver) = explode("ImageMagick", $string);
-               list($ver) = explode(" ",trim($ver));
-               return trim($ver);
-       }
-
-       /**
-        * Checks database username/password/host/database
-        * 
-        * @return      [type]          ...
-        */
-       function checkDatabase()                {
-               $ext="Check database";
-               $this->message($ext);
-
-               if (!extension_loaded("mysql")) {
-                       $this->message($ext, "MySQL not available","
-                               PHP does not feature MySQL support (which is pretty unusual).
-                       ",2);
-               } else {
-                       $cInfo="
-                               Username: <strong>".TYPO3_db_username."</strong>
-                               Password: <strong>".TYPO3_db_password."</strong>
-                               Host: <strong>".TYPO3_db_host."</strong>
-                       ";
-                       if (!TYPO3_db_host || !TYPO3_db_username)       {
-                               $this->message($ext, "Username, password or host not set","
-                                       You may need to enter data for these values:
-                                       ".trim($cInfo)."
-                                       
-                                       Use the form below.
-                               ",2);
-                       }
-                       if ($result = @mysql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))     {
-                               $this->message($ext, "Connected to MySQL successfully","
-                               ".trim($cInfo)."
-                               ",-1,1);
-                               $this->config_array["mysqlConnect"]=1;
-                               if (!TYPO3_db)  {
-                                       $this->message($ext, "No database selected","
-                                               Currently you have no database selected.
-                                               Please select one or create a new database.
-                                       ",3);
-                                       $this->config_array["no_database"]=1;
-                               } elseif (!mysql_select_db(TYPO3_db))  {
-                                       $this->message($ext, "Database","
-                                               '".TYPO3_db."' could not be selected as database!
-                                               Please select another one or create a new database.
-                                       ",3,1);
-                                       $this->config_array["no_database"]=1;
-                               } else  {
-                                       $this->message($ext, "Database","
-                                               <strong>".TYPO3_db."</strong> is selected as database.
-                                       ",1,1);
-                               }
-                       } else {
-                               $this->message($ext, "Could not connect to MySQL!","
-                               Connecting to MySQL failed with these settings:
-                               ".trim($cInfo)."
-                               
-                               Make sure you're using the correct set of data.".($this->config_array["sql.safe_mode_user"]? "
-                               <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"]."'":"")."
-                               ",3);
-                       }
-               }
-       }
-
-       /**
-        * Prints form for updating localconf.php or updates localconf.php depending on $cmd
-        * 
-        * @param       string          $cmd    If "get_form" it outputs the form. Default is to write "localconf.php" based on input in ->INSTALL[localconf.php] array and flag ->setLocalconf
-        * @return      [type]          ...
-        */
-       function setupGeneral($cmd="")  {
-               switch($cmd)    {
-                       case "get_form":
-                                       // Database:                            
-                               $out='
-                               <table border=0 cellpadding=0 cellspacing=0>
-                               <form action="'.$this->action.'" method="POST">';
-                               
-                               $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>":""));
-                               $out.=$this->wrapInCells("Password:", '<input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_password]" value="'.htmlspecialchars(TYPO3_db_password).'">');
-                               $out.=$this->wrapInCells("Host:", '<input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_host]" value="'.htmlspecialchars(TYPO3_db_host).'">');
-                               if ($this->config_array["mysqlConnect"])        {
-                                       $dbArr = $this->getDatabaseList();
-                                       reset($dbArr);
-                                       $options="";
-                                       $dbIncluded=0;
-                                       while(list(,$dbname)=each($dbArr))      {
-                                               $options.='<option value="'.htmlspecialchars($dbname).'"'.($dbname==TYPO3_db?' selected':'').'>'.htmlspecialchars($dbname).'</option>';
-                                               if ($dbname==TYPO3_db)  $dbIncluded=1;
-                                       }
-                                       if (!$dbIncluded && TYPO3_db)   {
-                                               $options.='<option value="'.htmlspecialchars(TYPO3_db).'" selected>'.htmlspecialchars(TYPO3_db).' (NO ACCESS!)</option>';
-                                       }
-                                       $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="">';
-                               } else {
-                                       $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).'">';
-                               }
-                               $out.=$this->wrapInCells("", "<BR>");
-                               $out.=$this->wrapInCells("Database:", $theCode);
-                               $out.=$this->wrapInCells("", "<BR>");
-
-                               if ($this->mode!="123") {
-                                       $out.=$this->wrapInCells("Site name:", '<input type="text" name="TYPO3_INSTALL[localconf.php][sitename]" value="'.htmlspecialchars($GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"]).'">');
-                                       $out.=$this->wrapInCells("", "<BR>");
-       
-                                               // Other
-                                       $fA = $this->setupGeneralCalculate();
-       //                              debug($fA);
-                                       if (is_array($fA["disable_exec_function"]))     {
-                                               $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"]));
-                                       } 
-                                       if (is_array($fA["gdlib"]))     {
-                                               $out.=$this->wrapInCells("[GFX][gdlib]=", $this->getFormElement($fA["gdlib"], $fA["gdlib"], 'TYPO3_INSTALL[localconf.php][gdlib]', $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib"]));
-                                               if (is_array($fA["gdlib_png"]) && $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib"])  {
-                                                       $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"]));
-                                               } 
-                                       } 
-                                       if (is_array($fA["im"]))        {
-                                               $out.=$this->wrapInCells("[GFX][im]=", $this->getFormElement($fA["im"], $fA["im"], 'TYPO3_INSTALL[localconf.php][im]', $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im"]));
-                                               $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"]));
-                                               if ($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im"])   {
-                                                       if (is_array($fA["im_path"]))   {
-                                                               $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"]));
-                                                       } 
-                                                       if (is_array($fA["im_path_lzw"]))       {
-                                                               $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"]));
-                                                       } 
-                                               }                                       
-                                       } 
-                               }                               
-
-                                       
-                               $out.=$this->wrapInCells("", '<BR><input type="submit" value="Update localconf.php"><BR>
-                               <strong>NOTICE: </strong>By clicking this button, localconf.php is updated with new values for the parameters listed above!');
-                               $out.='
-                               </form>
-                               </table>';
-                       break;
-                       default:
-                               if (is_array($this->INSTALL["localconf.php"]))          {
-                                       $lines = $this->writeToLocalconf_control();
-                                               
-                                               // New database?
-#debug($this->INSTALL);
-                                       if (trim($this->INSTALL["localconf.php"]["NEW_DATABASE_NAME"])) {
-                                               $newdbname=trim($this->INSTALL["localconf.php"]["NEW_DATABASE_NAME"]);
-                                               if (!ereg("[^[:alnum:]_]",$newdbname))  {
-                                                       if ($result = @mysql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))     {
-                                                               if (mysql_create_db($newdbname))        {
-                                                                       $this->INSTALL["localconf.php"]["typo_db"]=$newdbname;
-                                                                       $this->messages[]= "Database '".$newdbname."' created";
-                                                               } else $this->messages[]= "Could not create database '".$newdbname."' (...not created)";
-                                                       } else $this->messages[]= "Could not connect to database when creating database '".$newdbname."' (...not created)";
-                                               } else $this->messages[]= "The NEW database name '".$newdbname."' was not alphanumeric, a-zA-Z0-9_ (...not created)";
-                                       }
-#debug($this->messages)                ;
-                                               // Parsing values
-                                       reset($this->INSTALL["localconf.php"]);
-                                       while(list($key,$value)=each($this->INSTALL["localconf.php"]))          {
-                                               switch((string)$key)    {
-                                                       case "typo_db_username":
-                                                               if (!ereg("[^[:alnum:]_]",$value) && strlen($value)<50) {
-                                                                       if (strcmp(TYPO3_db_username,$value))           $this->setValueInLocalconfFile($lines, '$typo_db_username', $value);
-                                                               } else $this->messages[]= "Username '".$value."' was not alphanumeric, a-zA-Z0-9_, or longer than 50 chars (...not saved)";
-                                                       break;
-                                                       case "typo_db_password":
-                                                               if (!ereg("[^[:alnum:]_]",$value) && strlen($value)<50) {
-                                                                       if (strcmp(TYPO3_db_password,$value))           $this->setValueInLocalconfFile($lines, '$typo_db_password', $value);
-                                                               } else $this->messages[]= "Password '".$value."' was not alphanumeric, a-zA-Z0-9_, or longer than 50 chars (...not saved)";
-                                                       break;
-                                                       case "typo_db_host":
-                                                               if (!ereg("[^[:alnum:]_\.-]",$value) && strlen($value)<50)      {
-                                                                       if (strcmp(TYPO3_db_host,$value))               $this->setValueInLocalconfFile($lines, '$typo_db_host', $value);
-                                                               } else $this->messages[]= "Host '".$value."' was not alphanumeric, a-zA-Z0-9_-., or longer than 50 chars (...not saved)";
-                                                       break;
-                                                       case "typo_db":
-                                                               if (!ereg("[^[:alnum:]_]",$value) && strlen($value)<50) {
-                                                                       if (strcmp(TYPO3_db,$value))            $this->setValueInLocalconfFile($lines, '$typo_db', $value);
-                                                               } else $this->messages[]= "Database '".$value."' was not alphanumeric, a-zA-Z0-9_, or longer than 50 chars (...not saved)";
-                                                       break;
-                                                       case "disable_exec_function":
-                                                               if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["BE"]["disable_exec_function"],$value))  $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["BE"]["disable_exec_function"]', $value?1:0);
-                                                       break;
-                                                       case "sitename":
-                                                               if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"],$value))      $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["SYS"]["sitename"]', $value);
-                                                       break;
-                                                       case "im_combine_filename":
-                                                               if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_combine_filename"],$value))   $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["GFX"]["im_combine_filename"]', $value);
-                                                       break;
-                                                       case "gdlib":
-                                                       case "gdlib_png":
-                                                       case "im":
-                                                               if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["GFX"][$key],$value))    $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["GFX"]["'.$key.'"]', $value?1:0);
-                                                       break;
-                                                       case "im_path":
-                                                               list($value,$version) = explode("|",$value);
-                                                               if (!ereg("[[:space:]]",$value,$reg) && strlen($value)<100)     {
-                                                                       if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["GFX"][$key],$value))    {
-                                                                               $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["GFX"]["'.$key.'"]', $value);
-                                                                       }
-                                                                       $value_ext = (doubleval($version)<5)?0:1;
-                                                                       if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_version_5"],$value_ext))      {
-                                                                               $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["GFX"]["im_version_5"]', $value_ext);
-                                                                       }
-                                                               } else $this->messages[]= "Path '".$value."' contains spaces or is longer than 100 chars (...not saved)";
-                                                       break;
-                                                       case "im_path_lzw":
-                                                               list($value) = explode("|",$value);
-                                                               if (!ereg("[[:space:]]",$value) && strlen($value)<100)  {
-                                                                       if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["GFX"][$key],$value))    $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["GFX"]["'.$key.'"]', $value);
-                                                               } else $this->messages[]= "Path '".$value."' contains spaces or is longer than 100 chars (...not saved)";
-                                                       break;
-                                               }
-                                               
-                                               
-                                       }
-                                       
-                                       if (count($this->messages))     {
-#                                              echo "<H3>ERRORS</H3>";
-#                                              debug($this->messages);
-                                       }
-                                       $this->writeToLocalconf_control($lines);
-                               }
-                       break;
-               }
-               return $out;
-       }
-
-       /**
-        * [Describe function...]
-        * 
-        * @param       [type]          $lines: ...
-        * @param       [type]          $dontOutputContent: ...
-        * @return      [type]          ...
-        */
-       function writeToLocalconf_control($lines="",$dontOutputContent=0)       {
-               $this->writeToLocalconf_dat["file"] = PATH_typo3conf."localconf.php";
-               if (!$this->allowUpdateLocalConf)       {
-                       die("->allowUpdateLocalConf flag in the install object is not set and therefore 'localconf.php' cannot be altered.");
-               }
-               if (!@is_writeable($this->writeToLocalconf_dat["file"]))        {
-                       die($this->writeToLocalconf_dat["file"]." is not writeable!");
-               }
-               if (!is_array($lines))  {
-                               // Getting configuration
-                       $lines = explode(chr(10),trim(t3lib_div::getUrl($this->writeToLocalconf_dat["file"])));
-                       $this->writeToLocalconf_dat["endLine"]=array_pop($lines);
-       
-                       $updatedLine=array_pop($lines);
-                       $this->writeToLocalconf_dat["updatedText"] = "// Updated by ".$this->updateIdentity." ";
-                       if (!strstr($updatedLine, $this->writeToLocalconf_dat["updatedText"]))  {
-                               array_push($lines,$updatedLine);
-                       }
-                       return $lines;
-               } else {
-                               // Setting configuration
-                       $updatedLine=$this->writeToLocalconf_dat["updatedText"].date("d-m-Y H:i:s");
-                       array_push($lines,$updatedLine);
-                       array_push($lines,$this->writeToLocalconf_dat["endLine"]);
-                       //debug($lines);
-                       if ($this->setLocalconf)        {
-                               t3lib_div::writeFile($this->writeToLocalconf_dat["file"],implode($lines,chr(10)));
-                               if (!$dontOutputContent)        {
-                                       $this->messages[]= "Configuration written to typo3conf/localconf.php";
-       
-                                       $content = $this->fw("<BR><BR>".implode($this->messages,"<HR>").'<BR><BR><a href="'.$this->action.'">Click to continue...</a>');
-                                       $this->outputExitBasedOnStep($content);
-                               }
-                       } else {
-                               if (!$dontOutputContent)        {
-                                       $content = $this->fw('<strong>Writing to \'localconf.php\':</strong><BR><BR>No values were changed, so nothing is updated!<BR><BR><a href="'.$this->action.'">Click to continue...</a>');
-                                       $this->outputExitBasedOnStep("<BR>".$content);
-                               }
-                       }
-               }
-       }
-
-       /**
-        * [Describe function...]
-        * 
-        * @param       [type]          $content: ...
-        * @return      [type]          ...
-        */
-       function outputExitBasedOnStep($content)        {
-               if ($this->step)        {
-                       Header("Location: ".t3lib_div::locationHeaderUrl($this->action));
-               } else {
-                       echo $this->outputWrapper($content);
-               }
-               exit;
-       }
-
-       /**
-        * [Describe function...]
-        * 
-        * @param       [type]          $string: ...
-        * @return      [type]          ...
-        */
-       function checkForBadString($string)     {
-//             if (ereg("[".chr(10).chr(13)."\$\"\\]|//",$string)){
-               if (ereg("[".chr(10).chr(13)."]",$string)){
-                       return 0;
-               } else return 1;
-       }
-       
-       /**
-        * This functions takes an array with lines from localconf.php, finds a variable and inserts the new value.
-        * 
-        * @param       array           $lime_array     the localconf.php file exploded into an array by linebreaks.
-        * @param       string          $variable       The variable name to find and substitute. This string must match the first part of a trimmed line in the line-array. Matching is done backwards so the last appearing line will be substituted.
-        * @param       string          $value          Is the value to be insert for the variable
-        * @return      [type]          ...
-        */
-       function setValueInLocalconfFile(&$line_array, $variable, $value)       {
-               $value = stripslashes($value);
-               if (!$this->checkForBadString($value))  return 0;
-               $found=0;
-               $commentKey = "## ";
-               $inArray = in_array($commentKey.$this->localconf_editPointToken,$line_array);
-               $tokenSet = ($this->localconf_editPointToken && !$inArray);             // Flag is set if the token should be set but is not yet...
-               $stopAtToken = ($this->localconf_editPointToken && $inArray);
-               
-               $comment = ' Modified or inserted by '.$this->updateIdentity.'.';
-               if (!$this->localconf_addLinesOnly && !$tokenSet)       {
-                       $line_array = array_reverse($line_array);
-                       reset($line_array);
-                       while(list($k,$v)=each($line_array))    {
-                               $v2=trim($v);
-                               if ($stopAtToken && !strcmp($v2,$commentKey.$this->localconf_editPointToken))   break;          // If stopAtToken and token found, break out of the loop..
-                               if (!strcmp(substr($v2,0,strlen($variable." ")),$variable." ")) {
-                                       $mainparts = explode($variable,$v,2);
-                                       if (count($mainparts)==2)       {       // should ALWAYS be....
-                                               $subparts = explode("//",$mainparts[1],2);
-                                               $line_array[$k] = $mainparts[0].$variable." = '".$this->slashValueForSingleDashes($value)."';       ".("//".$comment.str_replace($comment,"",$subparts[1]));
-                                               $found=1;
-                                               break;
-                                       }
-                               }
-                       }
-                       $line_array = array_reverse($line_array);
-               }
-               if (!$found)    {
-                       if ($tokenSet)          {
-                               $line_array[] = $commentKey.$this->localconf_editPointToken;
-                               $line_array[] = "";
-                       }
-//                     $line_array[] = $variable.' = "'.addslashes($value).'"; // '.$comment;
-                       $line_array[] = $variable." = '".$this->slashValueForSingleDashes($value)."';   // ".$comment;
-               }
-               $this->messages[]= $variable." = '".htmlspecialchars($value)."'";
-               $this->setLocalconf=1;
-//             debug($line_array);
-       }
-
-       /**
-        * [Describe function...]
-        * 
-        * @param       [type]          $value: ...
-        * @return      [type]          ...
-        */
-       function slashValueForSingleDashes($value)      {
-               return str_replace("'","\'",str_replace('\\','\\\\',$value));
-       }
-
-       /**
-        * This appends something to value in the input array based on $type. Private.
-        * 
-        * @param       [type]          $arr: ...
-        * @param       [type]          $type: ...
-        * @return      [type]          ...
-        */
-       function setLabelValueArray($arr,$type) {
-               reset($arr);
-               while(list($k,$v)=each($arr))   {
-                       switch($type)   {
-                               case 0: // value, im
-                                       $arr[$k].="|".$this->config_array["im_versions"][$v]["convert"];
-                               break;
-                               case 1: // labels, im
-                                       $arr[$k].=$this->config_array["im_versions"][$v]["convert"] ? " (".$this->config_array["im_versions"][$v]["convert"].($this->config_array["im_versions"][$v]["gif_capability"]?", ".$this->config_array["im_versions"][$v]["gif_capability"]:"").")" : "";
-                               break;
-                               case 2: // labels, gd
-                                       $arr[$k].=" (".($v==1?"PNG":"GIF").")";
-                               break;
-                       }
-               }
-               return $arr;
-       }
-
-       /**
-        * Returns a form-element for the localconf.php update form
-        * 
-        * @param       [type]          $labels: ...
-        * @param       [type]          $values: ...
-        * @param       [type]          $fieldName: ...
-        * @param       [type]          $default: ...
-        * @param       [type]          $msg: ...
-        * @return      [type]          ...
-        */
-       function getFormElement($labels,$values,$fieldName,$default,$msg="")    {
-               $out.='<strong>'.htmlspecialchars(current($labels)).'</strong><BR>current value is '.htmlspecialchars($default).($msg?"<BR>".$msg:"");
-               if (count($labels)>1)           {
-                       reset($labels);
-                       while(list($k,$v)=each($labels))        {
-                               list($cleanV) =explode("|",$values[$k]);
-                               $options.='<option value="'.htmlspecialchars($values[$k]).'"'.(!strcmp($default,$cleanV)?" selected":"").'>'.htmlspecialchars($v).'</option>';
-                       }
-                       $out.='<BR><select name="'.$fieldName.'">'.$options.'</select>';
-               } else {
-                       $out.='<input type="hidden" name="'.$fieldName.'" value="'.htmlspecialchars(current($values)).'">';
-               }
-               return $out."<BR>";
-       }
-
-       /**
-        * Returns the list of available databases (with access-check based on username/password)
-        * 
-        * @return      [type]          ...
-        */
-       function getDatabaseList()      {
-               $dbArr=array();
-               if ($result = @mysql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))     {
-                       $db_list = mysql_list_dbs();
-                       while ($row = mysql_fetch_object($db_list)) {
-                               if (mysql_select_db($row->Database))    {
-                                       $dbArr[]=$row->Database;
-                               }
-                       }
-               }                       
-               return $dbArr;
-       }
-
-       /**
-        * Calculates the suggested setup that should be written to localconf.php
-        * 
-        * If safe_mode
-        * - disable_exec_function = 1
-        * - im = 0
-        * 
-        * if PNG/GIF/GD
-        * - disable gdlib if nothing
-        *      - select png/gif if only one of them is available, else PNG/GIF selector, defaulting to GIF
-        * - (safe_mode is on)
-        *      - im_path (default to 4.2.9, preferable with LZW)               im_ver5-flag is set based on im_path being 4.2.9 or 5+
-        *      - im_path_lzw (default to LZW version, pref. 4.2.9)
-        * 
-        * @return      [type]          ...
-        */
-       function setupGeneralCalculate()        {
-               $formArray["disable_exec_function"]=array(0);
-               $formArray["im_path"]=array("");
-               $formArray["im_path_lzw"]=array("");
-               $formArray["im_combine_filename"]=array("");
-               $formArray["im"]=array(1);
-               $formArray["gdlib"]=array(1);
-               if ($this->config_array["gd"] && ($this->config_array["gd_gif"] || $this->config_array["gd_png"]))      {
-                       if ($this->config_array["gd_gif"] && !$this->config_array["gd_png"])    {
-                               $formArray["gdlib_png"]=array(0);
-                       } elseif (!$this->config_array["gd_gif"] && $this->config_array["gd_png"])      {
-                               $formArray["gdlib_png"]=array(1);
-                       } else {
-                               $formArray["gdlib_png"]=array(0,1);
-                       }
-               } else {
-                       $formArray["gdlib"]=array(0);
-               }
-               if ($this->config_array["safemode"])    {
-                       $formArray["disable_exec_function"]=array(1);
-               }
-               if ($this->config_array["im"])  {
-                       $formArray["im"]=array(1);
-                       $LZW_found=0;
-                       $found=0;
-                       reset($this->config_array["im_versions"]);
-                       $totalArr=array();
-                       while(list($path,$dat)=each($this->config_array["im_versions"]))        {
-                               if (count($dat)>=3)     {
-                                       if (doubleval($dat["convert"])<5)       {
-                                               if ($dat["gif_capability"]=="LZW")      {
-                                                       $formArray["im_path"]=array($path);
-                                                       $found=2;
-                                               } elseif ($found<2)     {
-                                                       $formArray["im_path"]=array($path);
-                                                       $found=1;
-                                               }
-                                       } elseif (!$found)      {
-                                               $formArray["im_path"]=array($path);
-                                               $found=1;
-                                       }
-                               }
-                               if ($dat["gif_capability"]=="LZW")      {
-                                       if (doubleval($dat["convert"])<5)       {
-                                               $formArray["im_path_lzw"]=array($path);
-                                               $LZW_found=1;
-                                       } elseif (!$LZW_found) {
-                                               $formArray["im_path_lzw"]=array($path);
-                                               $LZW_found=1;
-                                       }
-                               } elseif ($dat["gif_capability"]=="RLE" && !$LZW_found) {
-                                       $formArray["im_path_lzw"]=array($path);
-                               }
-                               $totalArr[]=$path;
-                       }
-                       $formArray["im_path"]=array_unique(array_merge($formArray["im_path"],$totalArr));
-                       $formArray["im_path_lzw"]=array_unique(array_merge($formArray["im_path_lzw"],$totalArr));
-                       $formArray["im_combine_filename"]=array($this->config_array["im_combine_filename"]);
-               } else {
-                       $formArray["im"]=array(0);
-               }
-               return $formArray;
-       }
-
-       /**
-        * Returns the part of phpinfo() output that tells about GD library (HTML-code)
-        * 
-        * @return      [type]          ...
-        */
-       function getGDPartOfPhpinfo()   {
-               ob_start();
-               phpinfo();
-               $contents = ob_get_contents(); 
-               ob_end_clean();
-               $start_string = $this->getGD_start_string;
-               $end_string = $this->getGD_end_string;
-               list(,$gdpart_tmp) = explode($start_string,$contents,2);
-               list($gdpart) = explode($end_string,$start_string.$gdpart_tmp,2);
-               $gdpart.=$end_string;
-               return $gdpart;
-       }
-
-       /**
-        * Returns true if TTF lib is install according to phpinfo(). If $phpinfo supply as parameter that string is searched instead.
-        * 
-        * @param       [type]          $phpinfo: ...
-        * @return      [type]          ...
-        */
-       function isTTF($phpinfo="")     {
-/*             $phpinfo = $phpinfo?$phpinfo:$this->getGDPartOfPhpinfo();
-               if (stristr($phpinfo, $this->getTTF_string))    return 1;
-               if (stristr($phpinfo, $this->getTTF_string_alt))        return 1;
-               */
-               
-               if (!function_exists("imagettftext"))   return 0;       // Return right away if imageTTFtext does not exist.
-               
-                       // try, print truetype font:
-               $im = @imagecreate (300, 50);
-               $background_color = imagecolorallocate ($im, 255, 255, 55);
-               $text_color = imagecolorallocate ($im, 233, 14, 91);
-
-               $test = @imagettftext($im, t3lib_div::freetypeDpiComp(20), 0, 10, 20, $text_color, PATH_t3lib."/fonts/verdana.ttf", "Testing Truetype support");
-               if (t3lib_div::GPvar("testingTrueTypeSupport")) {
-                       if ($this->isGIF())     {
-                               header ("Content-type: image/gif");
-                               imagegif ($im);
-                       } else {
-                               header ("Content-type: image/png");
-                               imagepng ($im);
-                       }
-                       exit;
-               }
-               return is_array($test)?1:0;
-       }
-
-       
-       
-       
-       
-       
-       
-       
-       
-       
-       
-       /*****************************************
-        *
-        * ABOUT the isXXX functions.
-        *
-        * I had a very real experience that these checks DID NOT fail eg PNG support if it didn't exist! 
-        * 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. 
-        * And if THAT succeeds also, then we can be certain of the support!
-        */
-       
-       /**
-        * @return      [type]          ...
-        */
-       function isGD() {
-               if (function_exists("imagecreate"))     {
-                       if (@imagecreate (50, 100))     return 1;
-               }
-       }
-
-       /**
-        * [Describe function...]
-        * 
-        * @return      [type]          ...
-        */
-       function isGIF()        {
-               if (function_exists("imagecreatefromgif") && function_exists("imagegif") && ($this->ImageTypes() & IMG_GIF))    {       // If GIF-functions exists, also do a real test of them:
-                       $im = @imagecreatefromgif(t3lib_extMgm::extPath("install")."imgs/jesus.gif");
-                       return $im?1:0;
-               }
-       }
-
-       /**
-        * [Describe function...]
-        * 
-        * @return      [type]          ...
-        */
-       function isJPG()        {
-               if (function_exists("imagecreatefromjpeg") && function_exists("imagejpeg") && ($this->ImageTypes() & IMG_JPG))  {
-                       return 1;
-               }
-       }
-
-       /**
-        * [Describe function...]
-        * 
-        * @return      [type]          ...
-        */
-       function isPNG()        {
-               if (function_exists("imagecreatefrompng") && function_exists("imagepng") && ($this->ImageTypes() & IMG_PNG))    {       
-                       $im = imagecreatefrompng(t3lib_extMgm::extPath("install")."imgs/jesus.png");
-                       return $im?1:0;
-               }
-       }
-
-       /**
-        * [Describe function...]
-        * 
-        * @return      [type]          ...
-        */
-       function ImageTypes()   {
-               if (phpversion()!="4.1.2")      {
-                       return imagetypes();
-               } else return IMG_GIF+IMG_JPG+IMG_PNG; // all...
-       }
-
-       /**
-        * Returns general information about GDlib
-        * 
-        * @return      [type]          ...
-        */
-       function getGDSoftwareInfo()    {
-               return trim("
-               You can get GDLib in the PNG version from ".$this->linkIt("http://www.boutell.com/gd/")." or you can get the patched GIF version from ".$this->linkIt("http://www.typo3.com/?software").".<BR>FreeType is for download at ".$this->linkIt("http://www.freetype.org/")."</a>.
-               If you're using a Windows server, you'll be happy to know that all this is compiled into a PHP4-distribution for download at ".$this->linkIt("http://www.php4win.de/")."</a>.
-               ");
-       }
-
-       /**
-        * Returns general information about configuration of TYPO3.
-        * 
-        * @return      [type]          ...
-        */
-       function generallyAboutConfiguration()  {
-               $out='
-               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.
-               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.
-               See this page for '.$this->linkIt("http://www.typo3.com/index.php/Server_software_and/1051/0/","more information about system requirements.").'
-               ';
-               return trim($out);
-       }
-
-
-
-       
-       
-       
-       
-       
-       
-       
-       
-       
-       
-       /**********************
-        *
-        * IMAGE processing
-        *
-        **********************/
-
-       /**
-        * jesus.TIF:   IBM/LZW
-        * jesus.GIF:   Save for web, 32 colors
-        * jesus.JPG:   Save for web, 30 quality
-        * jesus.PNG:   Save for web, PNG-24
-        * jesus.tga    24 bit TGA file
-        * jesus.pcx    
-        * jesus.bmp    24 bit BMP file
-        * jesus_ps6.PDF:       PDF w/layers and vector data
-        * typo3logo.ai:        Illustrator 8 file
-        * pdf_from_imagemagick.PDF     PDF-file made by Acrobat Distiller from InDesign PS-file
-        * 
-        * 
-        * Imagemagick
-        * - Read formats
-        * - Write png, gif, jpg
-        * 
-        * Problems may arise from the use of safe_mode (eg. png)
-        * In safemode you will automatically execute the program convert in the safe_mode_exec_path no matter what other path you specify
-        * check fileexist before anything...
-        * 
-        * - compare gif size
-        * - scaling (by stdgraphic)
-        * - combining (by stdgraphic)
-        * 
-        * GDlib: 
-        * - create from:....
-        * - ttf text
-        * 
-        * From TypoScript: (GD only, GD+IM, IM)
-        * 
-        * @return      [type]          ...
-        */
-       function checkTheImageProcessing()      {
-               $this->message("Image Processing","What is it?","
-               TYPO3 is known for its ability to process images on the server.
-               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).
-               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).
-               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.
-               
-               In order to do this, TYPO3 uses two sets of tools:
-               
-               <B>ImageMagick:</B>
-               For conversion of non-web formats to webformats, combining images with alpha-masks, performing image-effects like blurring and sharpening.
-               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).
-               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).
-               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])
-               ImageMagick homepage is at ".$this->linkIt("http://www.imagemagick.org/")."
-               
-               <B>GDLib:</B>
-               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.
-               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.
-               ".$this->getGDSoftwareInfo()."
-               
-               You can disable all image processing options in TYPO3 ([GFX][image_processing]=0), but that would seriously disable TYPO3.
-               ");
-               
-               $this->message("Image Processing","Verifying the image processing capabilities of your server","
-               This page performs image processing and displays the result. It's a thorough check that everything you've configured is working correctly.
-               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.
-
-               The image to the right is the reference image (how it should be) and to the left the image made by your server. 
-               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.
-               
-               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.
-               ");             
-               
-//             debug($this->config_array);
-               $im_path = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path"];
-               $im_path_version = $this->config_array["im_versions"][$im_path]["convert"];
-               $im_path_lzw = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path_lzw"];
-               $im_path_lzw_version = $this->config_array["im_versions"][$im_path_lzw]["convert"];
-               $msg = "
-               ImageMagick enabled: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im"]."</strong>
-               ImageMagick path: <strong>".$im_path."</strong> (".$im_path_version.")
-               ImageMagick path/LZW: <strong>".$im_path_lzw."</strong>  (".$im_path_lzw_version.")
-               Version 5 flag: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_version_5"]."</strong>
-
-               GDLib enabled: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib"]."</strong>
-               GDLib using PNG: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib_png"]."</strong>
-               GDLib 2 enabled: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib_2"]."</strong>
-               IM5 effects enabled: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_v5effects"]."</strong> (Blurring/Sharpening with IM 5+)
-               Freetype DPI: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["TTFdpi"]."</strong> (Should be 96 for Freetype 2)
-               Mask invert: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_imvMaskState"]."</strong> (Should be set for some IM versions approx. 5.4+)
-
-               File Formats: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"]."</strong>
-               ";
-               if (($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_version_5"]?true:false) != (doubleval($im_path_version)>=5))        {
-                       $msg.="Warning: Mismatch between the version of ImageMagick (".$im_path_version.") and the configuration of [GFX][im_version_5] (".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_version_5"].")";
-                       $etype=2;
-               } else $etype=1;
-               
-               $this->message("Image Processing","Current configuration",$msg,$etype); 
-               
-
-               
-               
-               if (!$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["image_processing"])    {
-                       $this->message("Image Processing","Image Processing disabled!","
-                               Image Processing is disabled by the config flag <nobr>[GFX][image_processing]</nobr> set to false (zero)
-                       ",2);
-                       echo $this->outputWrapper($this->printAll());
-                       return;
-               } 
-               if (!$this->config_array["dir_typo3temp"])      {
-                       $this->message("Image Processing","typo3temp/ not writeable!","
-                               You must make typo3temp/ write enabled before you can proceed with this test.
-                       ",2);
-                       echo $this->outputWrapper($this->printAll());
-                       return;
-               } 
-
-
-               
-               $msg='<a name="testmenu"></a>Click each of these links in turn to test a topic. <B>Please be aware that each test may take several seconds!</B>:
-               
-               '.$this->imagemenu();
-               $this->message("Image Processing","Testmenu",$msg,"");  
-
-       
-               $this->messageFunc_nl2br=0;
-               $parseStart = microtime();
-               $imageProc = t3lib_div::makeInstance("t3lib_stdGraphic");
-               $imageProc->init();
-               $imageProc->tempPath=$this->typo3temp_path;
-               $imageProc->dontCheckForExistingTempFile=1;
-//             $imageProc->filenamePrefix="install_".($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_version_5"]?"v5":"");
-               $imageProc->filenamePrefix="install_";  
-               $imageProc->dontCompress=1;
-               $imageProc->alternativeOutputKey="TYPO3_INSTALL_SCRIPT";
-               $imageProc->noFramePrepended=$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_noFramePrepended"];
-               
-               // Very temporary!!!
-               $imageProc->dontUnlinkTempFiles=0;
-               
-               
-               $imActive = ($this->config_array["im"] && $im_path);
-               $gdActive = ($this->config_array["gd"] && $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib"]);
-
-               switch($this->INSTALL["images_type"])   {
-                       case "read":
-                               $refParseTime="5600";   // 4.2.9
-                               $refParseTime="3300";   // 5.2.3
-                               $headCode = "Reading and converting images";
-                               $this->message($headCode,"Supported file formats","
-                               This verifies that your ImageMagick installation is able to read the nine default file formats; JPG, GIF, PNG, TIF, BMP, PCX, TGA, PDF, AI.
-                               The tool 'identify' will be used to read the pixeldimensions of non-web formats.
-                               The tool 'convert' is used to read the image and write a temporary JPG-file
-                               ");
-
-                               if ($imActive)  {
-                                               // Reading formats - writing JPG
-                       
-                                       $extArr = explode(",","jpg,gif,png,tif,bmp,pcx,tga");
-                                       while(list(,$ext)=each($extArr))        {
-                                               if ($this->isExtensionEnabled($ext, $headCode, "Read ".strtoupper($ext)))       {
-                                                       $imageProc->IM_commands=array();
-                                                       $theFile = t3lib_extMgm::extPath("install")."imgs/jesus.".$ext;
-                                                       if (!@is_file($theFile))        die("Error: ".$theFile." was not a file");
-
-                                                       $imageProc->imageMagickConvert_forceFileNameBody="read_".$ext;
-                                                       $fileInfo = $imageProc->imageMagickConvert($theFile,"jpg","","","","","",1);
-                                                       $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
-                                                       $this->message($headCode,"Read ".strtoupper($ext),$result[0],$result[1]);
-                                               }
-                                       }
-                       
-                                       if ($this->isExtensionEnabled("pdf", $headCode, "Read PDF"))    {
-                                               $imageProc->IM_commands=array();
-                                               $theFile = t3lib_extMgm::extPath("install")."imgs/pdf_from_imagemagick.pdf";
-                                               if (!@is_file($theFile))        die("Error: ".$theFile." was not a file");
-
-                                               $imageProc->imageMagickConvert_forceFileNameBody="read_pdf";
-                                               $fileInfo = $imageProc->imageMagickConvert($theFile,"jpg","170","","","","",1);
-                                               $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
-                                               $this->message($headCode,"Read PDF",$result[0],$result[1]);
-                                       }
-                                       if ($this->isExtensionEnabled("ai", $headCode, "Read AI"))      {
-                                               $imageProc->IM_commands=array();
-                                               $theFile = t3lib_extMgm::extPath("install")."imgs/typo3logotype.ai";
-                                               if (!@is_file($theFile))        die("Error: ".$theFile." was not a file");
-
-                                               $imageProc->imageMagickConvert_forceFileNameBody="read_ai";
-                                               $fileInfo = $imageProc->imageMagickConvert($theFile,"jpg","170","","","","",1);
-                                               $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
-                                               $this->message($headCode,"Read AI",$result[0],$result[1]);
-                                       }                       
-                               } else {
-                                       $this->message($headCode,"Test skipped","
-                                       Use of ImageMagick has been disabled in the configuration.
-                                       Refer to section 'Basic Configuration' to change or review you configuration settings
-                                       ",2);
-                               }
-                       break;          
-                       case "write":
-                               $refParseTime="300";
-               
-                                       // Writingformats - writing JPG
-                               $headCode = "Writing images";
-                               $this->message($headCode,"Writing GIF and PNG","
-                               This verifies that ImageMagick is able to write GIF and PNG files.
-                               The GIF-file is attempted compressed with LZW by the t3lib_div::gif_compress() function.
-                               ");
-                       
-                               if ($imActive)  {
-                                               // Writing GIF
-                                       $imageProc->IM_commands=array();
-                                       $theFile = t3lib_extMgm::extPath("install")."imgs/jesus.gif";
-                                       if (!@is_file($theFile))        die("Error: ".$theFile." was not a file");
-
-                                       $imageProc->imageMagickConvert_forceFileNameBody="write_gif";
-                                       $fileInfo = $imageProc->imageMagickConvert($theFile,"gif","","","","","",1);
-                                       if ($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gif_compress"]) {
-                                               clearstatcache();
-                                               $prevSize=t3lib_div::formatSize(@filesize($fileInfo[3]));
-                                               $returnCode = t3lib_div::gif_compress($fileInfo[3],"");
-                                               clearstatcache();
-                                               $curSize=t3lib_div::formatSize(@filesize($fileInfo[3]));
-                                               $note = array("Note on gif_compress() function:","The 'gif_compress' method used was '".$returnCode."'.<BR>Previous filesize: ".$prevSize.". Current filesize:".$curSize);
-                                       } else  $note=array("Note on gif_compress() function:","<em>Not used! Disabled by [GFX][gif_compress]</em>");
-                                       $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands, $note);
-                                       $this->message($headCode,"Write GIF",$result[0],$result[1]);
-                                       
-                                       
-                                               // Writing PNG
-                                       $imageProc->IM_commands=array();
-                                       $theFile = t3lib_extMgm::extPath("install")."imgs/jesus.gif";
-
-                                       $imageProc->imageMagickConvert_forceFileNameBody="write_png";
-                                       $fileInfo = $imageProc->imageMagickConvert($theFile,"png","","","","","",1);
-                                       $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
-                                       $this->message($headCode,"Write PNG",$result[0],$result[1]);
-                               } else {
-                                       $this->message($headCode,"Test skipped","
-                                       Use of ImageMagick has been disabled in the configuration.
-                                       Refer to section 'Basic Configuration' to change or review you configuration settings
-                                       ",2);
-                               }
-                       break;          
-                       case "scaling":
-                               $refParseTime="650";
-               
-                                       // Scaling
-                               $headCode = "Scaling images";
-                               $this->message($headCode,"Scaling transparent images","
-                               This shows how ImageMagick reacts when scaling transparent GIF and PNG files.
-                               ");
-                               
-                               if ($imActive)  {
-                                               // Scaling transparent image
-                                       $imageProc->IM_commands=array();
-                                       $theFile = t3lib_extMgm::extPath("install")."imgs/jesus2_transp.gif";
-                                       if (!@is_file($theFile))        die("Error: ".$theFile." was not a file");
-
-                                       $imageProc->imageMagickConvert_forceFileNameBody="scale_gif";
-                                       $fileInfo = $imageProc->imageMagickConvert($theFile,"gif","150","","","","",1);
-                                       if ($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gif_compress"]) {
-                                               clearstatcache();
-                                               $prevSize=t3lib_div::formatSize(@filesize($fileInfo[3]));
-                                               $returnCode = t3lib_div::gif_compress($fileInfo[3],"");
-                                               clearstatcache();
-                                               $curSize=t3lib_div::formatSize(@filesize($fileInfo[3]));
-                                               $note = array("Note on gif_compress() function:","The 'gif_compress' method used was '".$returnCode."'.<BR>Previous filesize: ".$prevSize.". Current filesize:".$curSize);
-                                       } else $note=array("Note on gif_compress() function:","<em>Not used! Disabled by [GFX][gif_compress]</em>");
-                                       $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands,$note);
-                                       $this->message($headCode,"GIF to GIF, 150 pixels wide",$result[0],$result[1]);
-                       
-                                       $imageProc->IM_commands=array();
-                                       $theFile = t3lib_extMgm::extPath("install")."imgs/jesus2_transp.png";
-                                       if (!@is_file($theFile))        die("Error: ".$theFile." was not a file");
-
-                                       $imageProc->imageMagickConvert_forceFileNameBody="scale_png";
-                                       $fileInfo = $imageProc->imageMagickConvert($theFile,"png","150","","","","",1);
-                                       $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
-                                       $this->message($headCode,"PNG to PNG, 150 pixels wide",$result[0],$result[1]);
-                       
-                                       $imageProc->IM_commands=array();
-                                       $theFile = t3lib_extMgm::extPath("install")."imgs/jesus2_transp.gif";
-                                       if (!@is_file($theFile))        die("Error: ".$theFile." was not a file");
-                                       $imageProc->imageMagickConvert_forceFileNameBody="scale_jpg";
-                                       $fileInfo = $imageProc->imageMagickConvert($theFile,"jpg","150","","","","",1);
-                                       $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
-                                       $this->message($headCode,"GIF to JPG, 150 pixels wide",$result[0],$result[1]);
-                               } else {
-                                       $this->message($headCode,"Test skipped","
-                                       Use of ImageMagick has been disabled in the configuration.
-                                       Refer to section 'Basic Configuration' to change or review you configuration settings
-                                       ",2);
-                               }
-                       break;          
-                       case "combining":
-                               $refParseTime="150";    // 4.2.9
-                               $refParseTime="250";    // 5.2.3
-                                                                       // Combine
-                               $headCode = "Combining images";
-                               $this->message($headCode,"Combining images","
-                               This verifies that the ImageMagick tool, 'combine'/'composite', is able to combine two images through a grayscale mask.<BR>
-                               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)
-                               ");
-               
-                               if ($imActive)  {
-                                       $imageProc->IM_commands=array();
-                                       $input = t3lib_extMgm::extPath("install")."imgs/greenback.gif";
-                                       $overlay = t3lib_extMgm::extPath("install")."imgs/jesus.jpg";
-                                       $mask = t3lib_extMgm::extPath("install")."imgs/blackwhite_mask.gif";
-                                               if (!@is_file($input))  die("Error: ".$input." was not a file");
-                                               if (!@is_file($overlay))        die("Error: ".$overlay." was not a file");
-                                               if (!@is_file($mask))   die("Error: ".$mask." was not a file");
-
-                                       $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5($imageProc->alternativeOutputKey."combine1").".jpg";
-                                       $imageProc->combineExec($input,$overlay,$mask,$output);
-                                       $fileInfo = $imageProc->getImageDimensions($output);
-                                       $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
-                                       $this->message($headCode,"Combine using a GIF mask with only black and white",$result[0],$result[1]);
-                       
-                                       // Combine
-                                       $imageProc->IM_commands=array();
-                                       $input = t3lib_extMgm::extPath("install")."imgs/combine_back.jpg";
-                                       $overlay = t3lib_extMgm::extPath("install")."imgs/jesus.jpg";
-                                       $mask = t3lib_extMgm::extPath("install")."imgs/combine_mask.jpg";
-                                               if (!@is_file($input))  die("Error: ".$input." was not a file");
-                                               if (!@is_file($overlay))        die("Error: ".$overlay." was not a file");
-                                               if (!@is_file($mask))   die("Error: ".$mask." was not a file");
-                                       $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5($imageProc->alternativeOutputKey."combine2").".jpg";
-                                       $imageProc->combineExec($input,$overlay,$mask,$output);
-                                       $fileInfo = $imageProc->getImageDimensions($output);
-                                       $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
-                                       $this->message($headCode,"Combine using a JPG mask with graylevels",$result[0],$result[1]);
-                               } else {
-                                       $this->message($headCode,"Test skipped","
-                                       Use of ImageMagick has been disabled in the configuration.
-                                       Refer to section 'Basic Configuration' to change or review you configuration settings
-                                       ",2);
-                               }
-                       break;          
-                       case "gdlib":
-                               $refParseTime="1800";   // GIF / 4.2.9 / LZW (5.2.3)
-                               $refParseTime="2700";   // PNG / 4.2.9 / LZW (5.2.3)
-                               $refParseTime="1600";   // GIF / 5.2.3 / LZW (5.2.3)
-                                       // GDLibrary
-                               $headCode = "GDLib";
-                               $this->message($headCode,"Testing GDLib","
-                               This verifies that the GDLib installation works properly.
-                               ");
-               
-               
-                               if ($gdActive)  {
-                                       // GD with box
-                                       $imageProc->IM_commands=array();
-                                       $im = imageCreate(170,136);
-                                       ImageColorAllocate ($im, 0, 0, 0);
-                                       $workArea=array(0,0,170,136);
-                                       $conf=array(
-                                               "dimensions" => "10,50,150,36",
-                                               "color" => "olive"
-                                       );
-                                       $imageProc->makeBox($im,$conf,$workArea);
-                                       $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5("GDbox").".".$imageProc->gifExtension;
-                                       $imageProc->ImageGif ($im,$output);
-                                       $fileInfo = $imageProc->getImageDimensions($output);
-                                       $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
-                                       $this->message($headCode,"Create simple image",$result[0],$result[1]);
-                       
-                       
-                                       // GD from image with box
-                                       $imageProc->IM_commands=array();
-                                       $input = t3lib_extMgm::extPath("install")."imgs/jesus.".$imageProc->gifExtension;
-                                               if (!@is_file($input))  die("Error: ".$input." was not a file");
-                                       $im = $imageProc->imageCreateFromGif($input);
-                                       $workArea=array(0,0,170,136);
-                                       $conf=array();
-                                       $conf["dimensions"]="10,50,150,36";
-                                       $conf["color"]="olive";
-                                       $imageProc->makeBox($im,$conf,$workArea);
-                                       $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5("GDfromImage+box").".".$imageProc->gifExtension;
-                                       $imageProc->ImageGif ($im,$output);
-                                       $fileInfo = $imageProc->getImageDimensions($output);
-                                       $GDWithBox_filesize = @filesize($output);
-                                       $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
-                                       $this->message($headCode,"Create image from file",$result[0],$result[1]);
-                       
-                       
-                                       // GD with text
-                                       $imageProc->IM_commands=array();
-                                       $im = imageCreate(170,136);
-                                       ImageColorAllocate ($im, 128,128,150);
-                                       $workArea=array(0,0,170,136);
-                                       $conf=array(
-                                               "iterations" => 1,
-                                               "angle" => 0,
-                                               "antiAlias" => 1,
-                                               "text" => "HELLO WORLD",
-                                               "fontColor" => "#003366",
-                                               "fontSize" => 18,
-                                               "fontFile" => $this->backPath."t3lib/fonts/verdana.ttf",
-                                               "offset" => "17,40"
-                                       );
-                                       $conf["BBOX"] = $imageProc->calcBBox($conf);
-                                       $imageProc->makeText($im,$conf,$workArea);
-                       
-                                       $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5("GDwithText").".".$imageProc->gifExtension;
-                                       $imageProc->ImageGif ($im,$output);
-                                       $fileInfo = $imageProc->getImageDimensions($output);
-                                       $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
-                                       $this->message($headCode,"Render text with TrueType font",$result[0],$result[1]);
-               
-                                       if ($imActive)  {
-                                                       // extension: GD with text, niceText
-                                               $conf["offset"] = "17,65";
-                                               $conf["niceText"] = 1;
-                                               $imageProc->makeText($im,$conf,$workArea);
-                               
-                                               $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5("GDwithText-niceText").".".$imageProc->gifExtension;
-                                               $imageProc->ImageGif ($im,$output);
-                                               $fileInfo = $imageProc->getImageDimensions($output);
-                                               $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'."));
-                                               $this->message($headCode,"Render text with TrueType font using 'niceText' option",
-                                                       "(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>".
-                                                       $result[0],$result[1]);
-                                       } else {
-                                               $this->message($headCode,"Render text with TrueType font using 'niceText' option","
-                                               <strong>Test is skipped!</strong><BR><BR>
-                                               
-                                               Use of ImageMagick has been disabled in the configuration. ImageMagick is needed to generate text with the niceText option.
-                                               Refer to section 'Basic Configuration' to change or review you configuration settings
-                                               ",2);
-                                       }
-                                       
-                                       if ($imActive)  {
-                                                       // extension: GD with text, niceText AND shadow
-                                               $conf["offset"] = "17,90";
-                                               $conf["niceText"] = 1;
-                                               $conf["shadow."] = array(
-                                                       "offset"=>"2,2",
-                                                       "blur" => $imageProc->V5_EFFECTS?"20":"90",
-                                                       "opacity" => "50",
-                                                       "color" => "black"
-                                               );
-                                               $imageProc->makeShadow($im,$conf["shadow."],$workArea,$conf);
-                                               $imageProc->makeText($im,$conf,$workArea);
-                               
-                                               $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5("GDwithText-niceText-shadow").".".$imageProc->gifExtension;
-                                               $imageProc->ImageGif ($im,$output);
-                                               $fileInfo = $imageProc->getImageDimensions($output);
-                                               $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."));
-                                               $this->message($headCode,"Render 'niceText' with a shadow under",
-                                                       "(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>".
-                                                       $result[0],$result[1]);
-                                       } else {
-                                               $this->message($headCode,"Render 'niceText' with a shadow under","
-                                               <strong>Test is skipped!</strong><BR><BR>
-                                               
-                                               Use of ImageMagick has been disabled in the configuration. ImageMagick is needed to generate shadows.
-                                               Refer to section 'Basic Configuration' to change or review you configuration settings
-                                               ",2);
-                                       }
-                                       
-                                       if ($imageProc->gifExtension=="gif")    {
-                                               $buffer=20;
-                                               $assess = "This assessment is based on the filesize from 'Create image from file' test, which were ".$GDWithBox_filesize." bytes";
-                                               $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!";
-                                               if ($GDWithBox_filesize<8784+$buffer)   {
-                                                       $msg="<strong>Your GDLib appears to have LZW compression!</strong><BR>
-                                                               This assessment is based on the filesize from 'Create image from file' test, which were ".$GDWithBox_filesize." bytes.<BR>
-                                                               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>
-                                                               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)
-                                                               ";
-                                               } elseif ($GDWithBox_filesize>19000)    {
-                                                       $msg="<strong>Your GDLib appears to have no compression at all!</strong><BR>
-                                                               ".$assess."<br>".$goodNews;
-                                               } else {
-                                                       $msg="Your GDLib appears to have RLE compression<BR>
-                                                               ".$assess."<br>".$goodNews;
-                                               }
-                                               $this->message($headCode,"GIF compressing in GDLib","
-                                               ".$msg."
-                                               ",1);
-                                       }
-                                       
-                               } else {
-                                       $this->message($headCode,"Test skipped","
-                                       Use of GDLib has been disabled in the configuration.
-                                       Refer to section 'Basic Configuration' to change or review you configuration settings
-                                       ",2);
-                               }
-                       break;
-               }               
-
-               if ($this->INSTALL["images_type"])      {
-                       // End info
-                       if ($this->fatalError)  {
-                               $this->message("Info","Errors","
-                               It seems that you had some fatal errors in this test. Please make sure that your ImageMagick and GDLib settings are correct. 
-                               Refer to the 'Basic Configuration' section for more information and debugging of your settings.
-                               ");
-                       }
-
-                       $parseStop = microtime();
-                       $parseMS = t3lib_div::convertMicrotime($parseStop)-t3lib_div::convertMicrotime($parseStart);
-                       $this->message("Info","Parsetime",$parseMS." ms");
-               }       
-               echo $this->outputWrapper($this->printAll());
-       }
-
-       /**
-        * [Describe function...]
-        * 
-        * @param       [type]          $ext: ...
-        * @param       [type]          $headCode: ...
-        * @param       [type]          $short: ...
-        * @return      [type]          ...
-        */
-       function isExtensionEnabled($ext, $headCode, $short)    {
-               if (!t3lib_div::inList($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"],$ext))       {
-                       $this->message($headCode,$short,"Skipped - extension not in the list of allowed extensions ([GFX][imagefile_ext]).",1);
-               } else {
-                       return 1;
-               }
-       }
-
-       /**
-        * [Describe function...]
-        * 
-        * @param       [type]          $imageFile: ...
-        * @param       [type]          $IMcommands: ...
-        * @param       [type]          $note: ...
-        * @return      [type]          ...
-        */
-       function displayTwinImage ($imageFile, $IMcommands=array(), $note="")   {
-               $ex_rows="";
-               $errorLevels=array(-1);
-               if ($imageFile) {
-                       $verifyFile = t3lib_extMgm::extPath("install")."verify_imgs/".basename($imageFile);
-                       $destImg = @getImageSize($imageFile);
-                       $destImgCode ='<img src="'.$this->backPath.'../typo3temp/'.basename($imageFile).'" '.$destImg[2].'>';
-                       $verifyImg = @getImageSize($verifyFile);
-                       $verifyImgCode = '<img src="'.$this->backPath.t3lib_extMgm::extRelPath("install").'verify_imgs/'.basename($verifyFile).'" '.$verifyImg[2].'>';
-                       if (!$verifyImg)        {
-                               $gifVersion=1;
-                               $verifyFile_alt = substr($verifyFile,0,-3)."gif";
-                               $verifyImg = @getImageSize($verifyFile_alt);
-                               if ($verifyImg) {
-                                       $verifyImgCode = '<img src="'.$this->backPath.'t3lib/install/verify_imgs/'.basename($verifyFile_alt).'" '.$verifyImg[2].'>';
-                                       $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>';
-                               } else {
-                                       $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>';
-                               }
-                       }
-                       
-                       clearstatcache();
-                       $destImg["filesize"] = @filesize($imageFile);
-                       clearstatcache();
-                       $verifyImg["filesize"] = @filesize($verifyFile);
-                       
-                       $ex_rows.='<tr>';
-                       $ex_rows.='<td>'.$destImgCode.'</td>';
-                       $ex_rows.='<td><img src=clear.gif width=30 height=1></td>';
-                       $ex_rows.='<td>'.$verifyImgCode.'</td>';
-                       $ex_rows.='</tr>';
-       
-                       $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");
-       
-                       if ($destImg["filesize"]!=$verifyImg["filesize"])       {
-                               if (intval($destImg["filesize"]) && abs(($verifyImg["filesize"]/$destImg["filesize"])-1) < 0.05)        {
-//                                     debug(abs(($verifyImg["filesize"]/$destImg["filesize"])-1));
-                                       $ex_rows.=$this->getTwinImageMessage("File size is a bit different from reference", $destImg["filesize"], $verifyImg["filesize"]);
-                                       $errorLevels[]=1;
-                               } else {
-                                       $ex_rows.=$this->getTwinImageMessage("File size is very different from reference", $destImg["filesize"], $verifyImg["filesize"]);
-                                       $errorLevels[]=2;
-                               }
-                       }
-                       if ($destImg[0]!=$verifyImg[0] || $destImg[1]!=$verifyImg[1])   {
-                               $ex_rows.=$this->getTwinImageMessage("Pixel dimension are not equal!");
-                               $errorLevels[]=2;
-                       }
-                       if ($note)      {
-                               $ex_rows.=$this->getTwinImageMessage($note[0],$note[1]);
-                       }
-                       if ($this->dumpImCommands && count($IMcommands))        {
-                               $ex_rows.=$this->getTwinImageMessage("ImageMagick commands executed:",$this->formatImCmds($IMcommands));
-                       }
-               } else {
-                       $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));
-                       $errorLevels[]=3;
-               }                       
-               $out='<table border=0 cellpadding=0 cellspacing=0 align=center width=300>'.$ex_rows.'</table>';
-               
-               return array($out,max($errorLevels));
-       }
-
-       /**
-        * [Describe function...]
-        * 
-        * @param       [type]          $message: ...
-        * @param       [type]          $label_1: ...
-        * @param       [type]          $label_2: ...
-        * @return      [type]          ...
-        */
-       function getTwinImageMessage($message, $label_1="", $label_2="")        {
-               if ($message)   $out.='<tr><td colspan=3><strong>'.$this->fw($message).'</strong></td></tr>';
-               if ($label_1 && !$label_2)      {
-                       $out.='<tr><td colspan=3>'.$this->fw($label_1).'</td></tr>';
-               } elseif ($label_1 || $label_2) {
-                       $out.='<tr><td>'.$this->fw($label_1).'</td><td></td><td>'.$this->fw($label_2).'</td></tr>';
-               }
-               return $out;
-       }
-
-       /**
-        * [Describe function...]
-        * 
-        * @param       [type]          $arr: ...
-        * @return      [type]          ...
-        */
-       function formatImCmds($arr)     {
-               $out=array();
-               if (is_array($arr))     {
-                       reset($arr);
-                       while(list($k,$v)=each($arr))   {
-                               $out[]=$v[1];
-                               if ($v[2])      $out[]="   RETURNED: ".$v[2];
-                       }
-               }
-               if (count($out))        {
-                       $col = t3lib_div::intInRange(count($out),2,10);
-                       $outputStr = '<textarea cols=40 rows='.$col.' wrap="off">'.htmlspecialchars(implode($out,chr(10))).'</textarea>';
-                       return '<form action="">'.$outputStr.'</form>';
-               };
-       }
-
-       /**
-        * [Describe function...]
-        * 
-        * @return      [type]          ...
-        */
-       function imagemenu()    {
-               $menuitems = array(
-                       "read" => "Reading image formats",
-                       "write" => "Writing GIF and PNG",
-                       "scaling" => "Scaling images",
-                       "combining" => "Combining images",
-                       "gdlib" => "GD library functions"
-               );
-               reset($menuitems);
-               $c=0;
-               $out=array();
-               while(list($k,$v)=each($menuitems))     {
-                       $bgColor = ($this->INSTALL["images_type"]==$k ? ' bgColor="#ABBBB4"' : ' bgColor="#F4F0E8"');
-                       $c++;
-                       $out[]='<tr><td'.$bgColor.'><a href="'.$this->action.'&TYPO3_INSTALL[images_type]='.$k.'#testmenu">'.$this->fw($c.': '.$v).'</a></td></tr>';
-               }
-               
-               $code = '<table border=0 cellpadding=0 cellspacing=1>'.implode($out,"").'</table>';
-               $code = '<table border=0 cellpadding=0 cellspacing=0 bgColor="#ABBBB4"><tr><td>'.$code.'</td></tr></table>';
-               return '<div align="center">'.$code.'</div>';
-       }
-       
-       
-       
-       
-       
-       
-       
-       
-       
-       
-       
-       
-       /**********************
-        *
-        * DATABASE analysing
-        *
-        **********************/
-       
-       /**
-        * @return      [type]          ...
-        */
-       function checkTheDatabase()     {
-               if (!$this->config_array["mysqlConnect"])       {
-                       $this->message("Database Analyser","Your database connection failed","
-                               Please go to the 'Basic Configuration' section and correct this problem first.
-                       ",2);
-                       echo $this->outputWrapper($this->printAll());
-                       return;
-               } 
-               if ($this->config_array["no_database"]) {
-                       $this->message("Database Analyser","No database selected","
-                               Please go to the 'Basic Configuration' section and correct this problem first.
-                       ",2);
-                       echo $this->outputWrapper($this->printAll());
-                       return;
-               } 
-
-                       // Getting current tables
-               $whichTables=$this->getListOfTables();
-
-
-                       // Getting number of static_template records
-               if ($whichTables["static_template"])    {
-                       $res_static = mysql(TYPO3_db,"SELECT count(*) FROM static_template");
-                       list($static_template_count) = mysql_fetch_assoc($res_static);
-               }
-               $static_template_count=intval($static_template_count);
-
-               $headCode ="Database Analyser";
-               $this->message($headCode,"What is it?","
-                       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.
-               ",0);
-
-               $cInfo="
-                       Username: <strong>".TYPO3_db_username."</strong>
-                       Password: <strong>".TYPO3_db_password."</strong>
-                       Host: <strong>".TYPO3_db_host."</strong>
-               ";
-               $this->message($headCode, "Connected to MySQL successfully","
-               ".trim($cInfo)."
-               ",-1,1);
-               $this->message($headCode, "Database","
-                       <strong>".TYPO3_db."</strong> is selected as database. 
-                       Has <strong>".count($whichTables)."</strong> tables.
-               ",-1,1);
-
-
-               // Menu         
-
-               $this->messageFunc_nl2br = 0;
-               
-               $sql_files = array_merge(
-                       t3lib_div::getFilesInDir(PATH_typo3conf,"sql",1,1),
-#                      t3lib_div::getFilesInDir(PATH_t3lib."stddb/","sql",1,1),
-                       array()
-               );
-               
-               $action_type = $this->INSTALL["database_type"];
-               $actionParts = explode("|",$action_type);
-               if (count($actionParts)<2)      {
-                       $action_type="";
-               }
-
-               $out='';
-
-
-                       $out.='<tr>
-                               <td nowrap><strong>'.$this->fw('Update required tables').'</strong></td>
-                               <td'.($action_type=="cmpFile|CURRENT_TABLES"?' bgColor="#D9D5C9"':'').'>'.$this->fw('<a href="'.$this->action.'&TYPO3_INSTALL[database_type]=cmpFile|CURRENT_TABLES#bottom"><strong>COMPARE</strong></a>').'</td>
-                               <td>'.$this->fw('&nbsp;').'</td>
-                               <td>'.$this->fw('&nbsp;').'</td>
-                       </tr>';
-
-                       $out.='<tr>
-                               <td nowrap><strong>'.$this->fw('Dump static data').'</strong></td>
-                               <td>'.$this->fw('&nbsp;').'</td>
-                               <td nowrap'.($action_type=="import|CURRENT_STATIC"?' bgColor="#D9D5C9"':'').'>'.$this->fw('<a href="'.$this->action.'&TYPO3_INSTALL[database_type]=import|CURRENT_STATIC#bottom"><strong>IMPORT</strong></a>').'</td>
-                               <td>'.$this->fw('&nbsp;').'</td>
-                       </tr>';
-
-                       $out.='<tr>
-                               <td colspan=4>&nbsp;</td>
-                       </tr>';
-
-                       
-
-
-               reset($sql_files);
-               $directJump="";
-               while(list($k,$file)=each($sql_files))  {
-                       if ($this->mode=="123" && !count($whichTables) && strstr($file,"_testsite"))    {
-                               $directJump = $this->action.'&TYPO3_INSTALL[database_type]=import|'.rawurlencode($file);
-                       }
-                       $lf=t3lib_div::testInt($k);
-                       $fShortName = substr($file,strlen(PATH_site));
-/*                     $spec1 = (!count($whichTables) && $fShortName==TYPO3_mainDir."t3lib/install/tables_".str_replace(".","",$GLOBALS["TYPO_VERSION"]).".sql" ? " <font color=#000066>(1)</font>" : "");
-                       $spec2 = (count($whichTables) && !$static_template_count && $fShortName==TYPO3_mainDir."t3lib/install/static_template_".str_replace(".","",$GLOBALS["TYPO_VERSION"])."+adt.sql" ? " <font color=#000066>(2)</font>" : "");
-                       */
-                       $out.='<tr>
-                               <td nowrap>'.$this->fw($fShortName." (".t3lib_div::formatSize(filesize($file)).")").'</td>
-                               <td'.($action_type=="cmpFile|".$file?' bgColor="#D9D5C9"':'').'>'.$this->fw('<a href="'.$this->action.'&TYPO3_INSTALL[database_type]=cmpFile|'.rawurlencode($file).'#bottom"><strong>COMPARE</strong></a>').'</td>
-                               <td nowrap'.($action_type=="import|".$file?' bgColor="#D9D5C9"':'').'>'.$this->fw('<a href="'.$this->action.'&TYPO3_INSTALL[database_type]=import|'.rawurlencode($file).'#bottom"><strong>IMPORT'.$spec1.$spec2.'</strong></a>').'</td>
-                               <td nowrap'.($action_type=="view|".$file?' bgColor="#D9D5C9"':'').'>'.$this->fw('<a href="'.$this->action.'&TYPO3_INSTALL[database_type]=view|'.rawurlencode($file).'#bottom"><strong>VIEW'.$spec1.$spec2.'</strong></a>').'</td>
-                       </tr>';
-               }
-                       // TCA
-               $out.='<tr>
-                       <td></td>
-                       <td colspan=3'.($action_type=="cmpTCA|"?' bgColor="#D9D5C9"':'').'><strong>'.$this->fw('<a href="'.$this->action.'&TYPO3_INSTALL[database_type]=cmpTCA|#bottom">Compare with $TCA</a>').'</strong></td>
-               </tr>';
-               $out.='<tr>
-                       <td></td>
-                       <td colspan=3'.($action_type=="adminUser|"?' bgColor="#D9D5C9"':'').'><strong>'.$this->fw('<a href="'.$this->action.'&TYPO3_INSTALL[database_type]=adminUser|#bottom">Create "admin" user</a>').'</strong></td>
-               </tr>';
-               $out.='<tr>
-                       <td></td>
-                       <td colspan=3'.($action_type=="UC|"?' bgColor="#D9D5C9"':'').'><strong>'.$this->fw('<a href="'.$this->action.'&TYPO3_INSTALL[database_type]=UC|#bottom">Reset user preferences</a>').'</strong></td>
-               </tr>';
-               $out.='<tr>
-                       <td></td>
-                       <td colspan=3'.($action_type=="cache|"?' bgColor="#D9D5C9"':'').'><strong>'.$this->fw('<a href="'.$this->action.'&TYPO3_INSTALL[database_type]=cache|#bottom">Clear tables</a>').'</strong></td>
-               </tr>';
-
-               $theForm='<table border=0 cellpadding=2 cellspacing=2>'.$out.'</table>';
-               $theForm.='<a name="bottom"></a>';
-
-               if ($directJump)        {
-                       if (!$action_type)      {
-                               $this->message($headCode, "Menu",'
-                               <script language="javascript" type="text/javascript">
-                               document.location = "'.$directJump.'";
-                               </script>',0,1);
-                       }
-               } else {
-                       $this->message($headCode, "Menu","
-                       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>
-                       <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>
-                       <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>
-                       <strong>VIEW:</strong> Shows the content of the SQL-file, limiting characters on a single line to a reader-friendly amount.<BR><BR>
-                       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.
-       <br>
-                       <BR>
-                       ".$theForm."
-                       ",0,1);
-               }
-               
-               
-       // Install user
-       // clear uc
-               if ($action_type)       {
-                       switch($actionParts[0]) {
-                               case "cmpFile":
-                                       $tblFileContent="";
-                                       if (!strcmp($actionParts[1],"CURRENT_TABLES")) {
-                                               $tblFileContent = t3lib_div::getUrl(PATH_t3lib."stddb/tables.sql");
-
-                                               reset($GLOBALS["TYPO3_LOADED_EXT"]);
-                                               while(list(,$loadedExtConf)=each($GLOBALS["TYPO3_LOADED_EXT"])) {
-                                                       if (is_array($loadedExtConf) && $loadedExtConf["ext_tables.sql"])       {
-                                                               $tblFileContent.= chr(10).chr(10).chr(10).chr(10).t3lib_div::getUrl($loadedExtConf["ext_tables.sql"]);
-                                                       }
-                                               }
-//debug(array($tblFileContent));
-                                       } elseif (@is_file($actionParts[1]))    {
-                                               $tblFileContent = t3lib_div::getUrl($actionParts[1]);
-                                       }
-                                       if ($tblFileContent)    {
-                                               $fileContent = implode(
-                                                       $this->getStatementArray($tblFileContent,1,"^CREATE TABLE "),
-                                                       chr(10)
-                                               );
-                                               $FDfile = $this->getFieldDefinitions_sqlContent($fileContent);
-                                               if (!count($FDfile))    {
-                                                       die ("Error: There were no 'CREATE TABLE' definitions in the provided file");
-                                               }
-
-                                                       // Updating database...
-                                               if (is_array($this->INSTALL["database_update"]))        {
-                                                       $FDdb = $this->getFieldDefinitions_database(TYPO3_db);
-                                                       $diff = $this->getDatabaseExtra($FDfile, $FDdb);
-                                                       $update_statements = $this->getUpdateSuggestions($diff);
-                                                       $diff = $this->getDatabaseExtra($FDdb, $FDfile);
-                                                       $remove_statements = $this->getUpdateSuggestions($diff,"remove");
-
-                                                       $this->preformUpdateQueries($update_statements["add"],$this->INSTALL["database_update"]);
-                                                       $this->preformUpdateQueries($update_statements["change"],$this->INSTALL["database_update"]);
-                                                       $this->preformUpdateQueries($remove_statements["change"],$this->INSTALL["database_update"]);
-                                                       $this->preformUpdateQueries($remove_statements["drop"],$this->INSTALL["database_update"]);
-
-                                                       $this->preformUpdateQueries($update_statements["create_table"],$this->INSTALL["database_update"]);
-                                                       $this->preformUpdateQueries($remove_statements["change_table"],$this->INSTALL["database_update"]);
-                                                       $this->preformUpdateQueries($remove_statements["drop_table"],$this->INSTALL["database_update"]);
-                                               }
-                                               
-                                                       // Init again / first time depending...
-                                               $FDdb = $this->getFieldDefinitions_database(TYPO3_db);
-                                               $diff = $this->getDatabaseExtra($FDfile, $FDdb);
-                                               $update_statements = $this->getUpdateSuggestions($diff);
-                                               $diff = $this->getDatabaseExtra($FDdb, $FDfile);
-                                               $remove_statements = $this->getUpdateSuggestions($diff,"remove");
-                                               $tLabel = "Update database tables and fields";
-                                               
-                                               if ($remove_statements || $update_statements)   {
-                                                       $formContent = $this->generateUpdateDatabaseForm("get_form",$update_statements,$remove_statements,$action_type);
-                                                       $this->message($tLabel,"Table and field definitions should be updated","
-                                                       There seems to be a number of differencies between the database and the selected SQL-file.
-                                                       Please select which statements you want to execute in order to update your database:<BR><BR>
-                                                       ".$formContent."
-                                                       ",2);
-                                               } else {
-                                                       $formContent = $this->generateUpdateDatabaseForm("get_form",$update_statements,$remove_statements,$action_type);
-                                                       $this->message($tLabel,"Table and field definitions are OK.","
-                                                       The tables and fields in the current database corresponds perfectly to the database in the selected SQL-file.
-                                                       ",-1);
-                                               }
-                                       }
-                               break;
-                               case "cmpTCA":
-                                       $this->includeTCA();
-                                       $this->mysqlVersion = "3.23";   // Set this previously to calling the function below in order to make the rendering right for the comparison.
-                                       $FDdb = $this->getFieldDefinitions_database(TYPO3_db);
-
-                                               // Displaying configured fields which are not in the database
-                                       $tLabel="Tables and fields in \$TCA, but not in database";
-                                       $cmpTCA_DB = $this->compareTCAandDatabase($GLOBALS["TCA"],$FDdb);
-                                       if (!count($cmpTCA_DB["extra"]))        {
-                                               $this->message($tLabel,"Table and field definitions OK","
-                                               All fields and tables configured in $TCA appeared to exist in the database as well
-                                               ",-1);
-                                       } else {
-                                               $this->message($tLabel,"Invalid table and field definitions in \$TCA!","
-                                               There are some tables and/or fields configured in the \$TCA array which does not exist in the database!
-                                               This will most likely cause you trouble with the TYPO3 backend interface!
-                                               ",3);
-                                               while(list($tableName, $conf)=each($cmpTCA_DB["extra"]))        {
-                                                       $this->message($tLabel, $tableName,$this->displayFields($conf["fields"],0,"Suggested database field:"),2);
-                                               }
-                                       }
-                                       
-                                               // Displaying tables that are not setup in 
-                                       $cmpDB_TCA = $this->compareDatabaseAndTCA($FDdb,$GLOBALS["TCA"]);
-                                       $excludeTables="be_sessions,fe_session_data,fe_sessions";
-                                       if (TYPO3_OS=="WIN")    {$excludeTables = strtolower($excludeTables);}
-                                       $excludeFields = array(
-                                               "be_users" => "uc,lastlogin,usergroup_cached_list",
-                                               "fe_users" => "uc,lastlogin,fe_cruser_id",
-                                               "pages" => "SYS_LASTCHANGED",
-                                               "sys_dmail" => "mailContent",
-                                               "tt_board" => "doublePostCheck",
-                                               "tt_guest" => "doublePostCheck",
-                                               "tt_products" => "ordered"
-                                       );
-                                       $tCount=0;
-                                       $fCount=0;
-                                       $tLabel="Tables from database, but not in \$TCA";
-                                       $fLabel="Fields from database, but not in \$TCA";
-                                       $this->message($tLabel);
-                                       if (is_array($cmpDB_TCA['extra']))      {
-                                               while(list($tableName, $conf)=each($cmpDB_TCA['extra']))        {
-                                                       if (!t3lib_div::inList($excludeTables,$tableName) 
-                                                                       && substr($tableName,0,4)!="sys_" 
-                                                                       && substr($tableName,-3)!="_mm" 
-                                                                       && substr($tableName,0,6)!="index_" 
-                                                                       && substr($tableName,0,6)!="cache_")    {
-                                                               if ($conf["whole_table"])       {
-                                                                       $this->message($tLabel, $tableName,$this->displayFields($conf["fields"]),1);
-                                                                       $tCount++;
-                                                               } else {
-                                                                       list($theContent, $fC)  = $this->displaySuggestions($conf["fields"],$excludeFields[$tableName]);
-                                                                       $fCount+=$fC;
-                                                                       if ($fC)        $this->message($fLabel, $tableName,$theContent,1);
-                                                               }       
-                                                       }
-                                               }
-                                       }
-                                       if (!$tCount)   {
-                                               $this->message($tLabel,"Correct number of tables in the database","
-                                               There are no extra tables in the database compared to the configured tables in the \$TCA array.
-                                               ",-1);
-                                       } else {
-                                               $this->message($tLabel,"Extra tables in the database","
-                                               There are some tables in the database which are not configured in the \$TCA array. 
-                                               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.
-                                               ",2);
-                                       }
-
-                                       if (!$fCount)   {
-                                               $this->message($fLabel,"Correct number of fields in the database","
-                                               There are no additional fields in the database tables compared to the configured fields in the \$TCA array.
-                                               ",-1);
-                                       } else {
-                                               $this->message($fLabel,"Extra fields in the database","
-                                               There are some additional fields the database tables which are not configured in the \$TCA array. 
-                                               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.
-                                               ",2);
-                                       }
-                                       
-                                               // Displaying actual and suggested field database defitions
-                                       if (is_array($cmpTCA_DB["matching"]))   {
-                                               $tLabel="Comparison between database and \$TCA";
-                                       
-                                               $this->message($tLabel,"Actual and suggested field definitions","
-                                               This table shows you the suggested field definitions which are calculated based on the configuration in \$TCA. 
-                                               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.
-                                               ",0);
-                                               while(list($tableName, $conf)=each($cmpTCA_DB["matching"]))     {
-                                                       $this->message($tLabel, $tableName,$this->displayFieldComp($conf["fields"], $FDdb[$tableName]["fields"]),1);
-                                               }
-                                       }
-                               break;
-                               case "import":
-                                       $mode123Imported=0;
-                                       $tblFileContent="";
-                                       if (!strcmp($actionParts[1],"CURRENT_STATIC")) {
-                                               reset($GLOBALS["TYPO3_LOADED_EXT"]);
-                                               while(list(,$loadedExtConf)=each($GLOBALS["TYPO3_LOADED_EXT"])) {
-                                                       if (is_array($loadedExtConf) && $loadedExtConf["ext_tables_static+adt.sql"])    {
-                                                               $tblFileContent.= chr(10).chr(10).chr(10).chr(10).t3lib_div::getUrl($loadedExtConf["ext_tables_static+adt.sql"]);
-                                                       }
-                                               }
-                                       } elseif (@is_file($actionParts[1]))    {
-                                               $tblFileContent = t3lib_div::getUrl($actionParts[1]);
-                                       }
-                                       if ($tblFileContent)    {
-                                               $tLabel="Import SQL dump";
-                                                       // Getting statement array from
-                                               $statements = $this->getStatementArray($tblFileContent,1);
-                                               list($statements_table, $insertCount) = $this->getCreateTables($statements,1);
-
-                                                       // Updating database...
-                                               if ($this->INSTALL["database_import_all"])      {
-                                                       reset($statements);
-                                                       $r=0;
-                                                       while(list($k,$v)=each($statements))    {
-                                                               $res=mysql(TYPO3_db, $v);
-                                                               $err =mysql_error();
-                                                               if ($err)       echo $err."<BR>";
-                                                               $r++;
-                                                       }
-                                                       $this->message($tLabel,"Imported ALL","
-                                                               Queries: ".$r."
-                                                       ",1,1);
-                                                       if (t3lib_div::GPvar("goto_step"))      {
-                                                               $this->action.="&step=".t3lib_div::GPvar("goto_step");
-                                                               Header("Location: ".t3lib_div::locationHeaderUrl($this->action));
-                                                               exit;
-                                                       }
-                                               } elseif (is_array($this->INSTALL["database_import"]))  {
-                                                               // Traverse the tables
-                                                       reset($this->INSTALL["database_import"]);
-                                                       while(list($table,$md5str)=each($this->INSTALL["database_import"]))     {
-                                                               if ($md5str==md5($statements_table[$table]))    {
-                                                                       $res=mysql(TYPO3_db, "DROP TABLE IF EXISTS ".$table);
-                                                                       $err =mysql_error();
-                                                                       if ($err)       echo $err."<BR>";
-                                                                       
-                                                                       $res=mysql(TYPO3_db, $statements_table[$table]);
-                                                                       $err =mysql_error();
-                                                                       if ($err)       echo $err."<BR>";
-
-                                                                       if ($insertCount[$table])       {
-                                                                               $statements_insert = $this->getTableInsertStatements($statements, $table);
-                                                                               reset($statements_insert);
-                                                                               while(list($k,$v)=each($statements_insert))     {
-                                                                                       $res=mysql(TYPO3_db, $v);
-                                                                                       $err =mysql_error();
-                                                                                       if ($err)       echo $err."<BR>";
-                                                                               }
-                                                                       }
-
-                                                                       $this->message($tLabel,"Imported '".$table."'","
-                                                                               Rows: ".$insertCount[$table]."
-                                                                       ",1,1);
-                                                               }
-                                                       }
-                                               }
-
-                                               $mode123Imported=$this->isBasicComplete($tLabel);
-
-                                               if (!$mode123Imported)  {
-                                                               // Re-Getting current tables - may have been changed during import
-                                                       $whichTables=$this->getListOfTables();
-       
-                                                       if (count($statements_table))   {
-                                                               reset($statements_table);
-                                                               $out='';
-                                                               while(list($table,$definition)=each($statements_table)) {
-                                                                       $exist=isset($whichTables[$table]);
-                                                                       $out.='<tr>
-                                                                               <td><input type="checkbox" name="TYPO3_INSTALL[database_import]['.$table.']"