typo3/sysext/install/mod/class.tx_install.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00145 require_once (PATH_t3lib.'class.t3lib_install.php');
00146 require_once (PATH_t3lib.'class.t3lib_stdgraphic.php');
00147 
00156 class tx_install extends t3lib_install {
00157         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()
00158         var $getGD_end_string = '</TABLE>';     // Used to identify the end of the GD section (found with getGD_start_string) in the output from phpinfo()
00159         var $getTTF_string = 'with TTF library';        // Used to identify whether TTF-lib is included with GD
00160         var $getTTF_string_alt = 'with freetype';       // Used to identify whether TTF-lib is included with GD
00161         var $action = "";               // The url that calls this script
00162         var $scriptSelf = "index.php";          // The url that calls this script
00163         var $fontTag2='<font face="verdana,sans-serif" size=2 color=black>';
00164         var $fontTag1='<font face="verdana,sans-serif" size=1 color=black>';
00165         var $updateIdentity = "TYPO3 Install Tool";
00166         var $headerStyle ='';
00167         var $contentBeforeTable="";
00168         var $setAllCheckBoxesByDefault=0;
00169 
00170         var $allowFileEditOutsite_typo3conf_dir=0;
00171 
00172         var $INSTALL =array();          // In constructor: is set to global GET/POST var TYPO3_INSTALL
00173         var $checkIMlzw = 0;            // If set, lzw capabilities of the available ImageMagick installs are check by actually writing a gif-file and comparing size
00174         var $checkIM = 0;                       // If set, ImageMagick is checked.
00175         var $dumpImCommands=1;                  // If set, the image Magick commands are always outputted in the image processing checker
00176         var $mode = ""; // If set to "123" then only most vital information is displayed.
00177         var $step = 0;  // If set to 1,2,3 or GO it signifies various functions.
00178 
00179         // internal
00180         var $passwordOK=0;                      // This is set, if the password check was ok. The function init() will exit if this is not set
00181         var $silent=1;                          // If set, the check routines don't add to the message-array
00182         var $messageFunc_nl2br=1;
00183         var $sections=array();          // Used to gather the message information.
00184         var $fatalError=0;                      // This is set if some error occured that will definitely prevent TYpo3 from running.
00185         var $sendNoCacheHeaders=1;
00186         var $config_array = array(      // Flags are set in this array if the options are available and checked ok.
00187                 "gd"=>0,
00188                 "gd_gif"=>0,
00189                 "gd_png"=>0,
00190                 "gd_jpg"=>0,
00191                 "freetype" => 0,
00192                 "safemode" => 0,
00193                 "dir_typo3temp" => 0,
00194                 "dir_temp" => 0,
00195                 "im_versions" => array(),
00196                 "im" => 0,
00197                 "sql.safe_mode_user" => "",
00198                 "mysqlConnect" => 0,
00199                 "no_database" => 0
00200         );
00201         var $typo3temp_path="";
00202 
00203         var $menuitems = array(
00204                 "config" => "Basic Configuration",
00205                 "database" => "Database Analyser",
00206                 "images" => "Image Processing",
00207                 "extConfig" => "All Configuration",
00208                 "typo3temp" => "typo3temp/",
00209                 "cleanup" => "Clean up database",
00210                 "phpinfo" => "phpinfo()",
00211                 "typo3conf_edit" => "Edit files in typo3conf/",
00212                 "about" => "About"
00213         );
00214         var $cookie_name = "Typo3InstallTool";
00215         var $JSmessage = '';
00216 
00217 
00218 
00219 
00220 
00221 
00227         function tx_install()   {
00228                 parent::t3lib_install();
00229 
00230                 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.");
00231 
00232                 if ($this->sendNoCacheHeaders)  {
00233                         header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
00234                         header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
00235                         header("Expires: 0");
00236                         header("Cache-Control: no-cache, must-revalidate");
00237                         header("Pragma: no-cache");
00238                 }
00239 
00240                         // ****************************
00241                         // Initializing incoming vars.
00242                         // ****************************
00243                 $this->INSTALL = t3lib_div::_GP("TYPO3_INSTALL");
00244                 $this->mode = t3lib_div::_GP("mode");
00245                 $this->step = t3lib_div::_GP("step");
00246                 if ($_GET["TYPO3_INSTALL"]["type"])     $this->INSTALL["type"] = $_GET["TYPO3_INSTALL"]["type"];
00247 
00248                 if ($this->step==3)     {
00249                         $this->INSTALL["type"]="database";
00250                 }
00251 
00252                 if ($this->mode=="123") {
00253                         $tempItems = $this->menuitems;
00254                         unset($this->menuitems);
00255                         $this->menuitems["config"] = $tempItems["config"];
00256                         $this->menuitems["database"] = $tempItems["database"];
00257                         if (!$this->INSTALL["type"] || !isset($this->menuitems[$this->INSTALL["type"]]))        $this->INSTALL["type"] = "config";
00258                 } else {
00259                         if (!$this->INSTALL["type"] || !isset($this->menuitems[$this->INSTALL["type"]]))        $this->INSTALL["type"] = "about";
00260                 }
00261 
00262                 $this->action = $this->scriptSelf."?TYPO3_INSTALL[type]=".$this->INSTALL["type"].($this->mode?"&mode=".rawurlencode($this->mode):"").($this->step?"&step=".rawurlencode($this->step):"");
00263                 $this->typo3temp_path = PATH_site."typo3temp/";
00264 
00265 
00266                         // ****************
00267                         // Check password
00268                         // ****************
00269                         // Getting a unique session key, used to encode the session-access cookie later...
00270                 $uKey = $_COOKIE[$this->cookie_name."_key"];
00271                 if (!$uKey)     {
00272                         $uKey = md5(uniqid(microtime()));
00273                         SetCookie($this->cookie_name."_key", $uKey, 0, "/");            // Cookie is set
00274 
00275                         $this->JSmessage='SECURITY:
00276 Make sure to protect the Install Tool with another password than "joh316".
00277 Better yet you can add a die() function call to typo3/install/index.php after usage.
00278 
00279 IF THE INSTALL TOOL CRASHES...
00280 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.
00281 Workaround: Open the file typo3/t3lib/class.t3lib_install.php, go to the line where the function "isPNG()" is defined and make it return "0" hardcoded. PNG is not checked anymore and the rest of the Install Tool will work as expected. The same has been known with the other image formats as well. You can use a similar method to bypass the testing if that is also a problem.
00282 On behalf of PHP we regret this inconvenience.
00283 
00284 BTW: This Install Tool will only work if cookies are accepted by your web browser. If this dialog pops up over and over again you didn\'t enable cookies.
00285 ';
00286 
00287                 }
00288                         // Check if the password from TYPO3_CONF_VARS combined with uKey matches the sKey cookie. If not, ask for password.
00289                 $sKey = $_COOKIE[$this->cookie_name];
00290 
00291                 if (md5($GLOBALS["TYPO3_CONF_VARS"]["BE"]["installToolPassword"]."|".$uKey) == $sKey || $this->checkPassword($uKey))    {
00292                         $this->passwordOK=1;
00293                 }
00294 
00295                 if ($GLOBALS["CLIENT"]["SYSTEM"]=="unix" && $GLOBALS["CLIENT"]["BROWSER"]=="konqu")     {
00296                         $this->fontTag2='<font face="verdana,sans-serif" size=4 color=black>';
00297                         $this->fontTag1='<font face="verdana,sans-serif" size=3 color=black>';
00298                 }
00299         }
00300 
00307         function checkPassword($uKey)   {
00308                 $p = t3lib_div::_GP("password");
00309 
00310                 if ($p && md5($p)==$GLOBALS["TYPO3_CONF_VARS"]["BE"]["installToolPassword"])    {
00311                         $sKey = md5($GLOBALS["TYPO3_CONF_VARS"]["BE"]["installToolPassword"]."|".$uKey);
00312                         SetCookie($this->cookie_name, $sKey, 0, "/");
00313 
00314                                 // Sending warning email
00315                         $wEmail = $GLOBALS["TYPO3_CONF_VARS"]["BE"]["warning_email_addr"];
00316                         if ($wEmail)    {
00317                                 $subject="Install Tool Login at '".$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"]."'";
00318                                 $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").")";
00319                                 mail($wEmail,
00320                                         $subject,
00321                                         $email_body,
00322                                         "From: TYPO3 Install Tool WARNING <>"
00323                                 );
00324                         }
00325                         return true;
00326                 } else {
00327                         $this->messageFunc_nl2br=0;
00328                         $this->silent=0;
00329                         $content = '<form action="'.$this->action.'" method="POST">
00330                         <input type="password" name="password"><BR>
00331                         <input type="submit" value="Log in"><br>
00332                         <br>
00333 
00334                         '.$this->fw('The Install Tool Password is <i>not</i> the admin password of TYPO3.<BR>
00335                                 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.'.
00336                                 ($p?"<BR><BR>The password you just tried has this md5-value: <BR><BR>".md5($p):"")
00337                                 ).'
00338                         </form>';
00339 
00340                         $this->message("Password", "Enter the Install Tool Password", $content,3);
00341                         echo $this->outputWrapper($this->printAll());
00342                                 // Bad password, send warning:
00343                         if ($p) {
00344                                 $wEmail = $GLOBALS["TYPO3_CONF_VARS"]["BE"]["warning_email_addr"];
00345                                 if ($wEmail)    {
00346                                         $subject="Install Tool Login ATTEMPT at '".$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"]."'";
00347                                         $email_body="There has been a Install Tool login attempt at TYPO3 site '".$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"]."' (".t3lib_div::getIndpEnv("HTTP_HOST").").
00348 Password tried was '".$p."'
00349 REMOTE_ADDR was '".t3lib_div::getIndpEnv("REMOTE_ADDR")."' (".t3lib_div::getIndpEnv("REMOTE_HOST").")";
00350                                         mail($wEmail,
00351                                                 $subject,
00352                                                 $email_body,
00353                                                 "From: TYPO3 Install Tool WARNING <>"
00354                                         );
00355                                 }
00356                         }
00357 
00358                         return false;
00359                 }
00360         }
00361 
00368         function init() {
00369                 if (!defined("PATH_typo3"))     exit;           // Must be called after inclusion of init.php (or from init.php)
00370                 if (!$this->passwordOK) exit;
00371 //              debug($_COOKIE);
00372 
00373                         // Setting stuff...
00374                 $this->check_mail();
00375                 $this->setupGeneral();
00376                 $this->generateConfigForm();
00377                 if (count($this->messages))     debug($this->messages);
00378 
00379                 if ($this->step)        {
00380                         echo $this->outputWrapper($this->stepOutput());
00381                 } else {
00382                                 // Menu...
00383                         switch($this->INSTALL["type"])  {
00384                                 case "images":
00385                                         $this->checkIM=1;
00386                                         $this->checkTheConfig();
00387                                         $this->silent=0;
00388                                         $this->checkTheImageProcessing();
00389                                 break;
00390                                 case "database":
00391                                         $this->checkTheConfig();
00392                                         $this->silent=0;
00393                                         $this->checkTheDatabase();
00394                                 break;
00395                                 case "config":
00396                                         $this->silent=0;
00397                                         $this->checkIM=1;
00398                                         $this->message("About configuration","How to configure TYPO3",$this->generallyAboutConfiguration());
00399                                         $this->checkTheConfig();
00400 
00401                                         $ext = "Write config to localconf.php";
00402                                         if ($this->fatalError)  {
00403                                                 if ($this->config_array["no_database"] || !$this->config_array["mysqlConnect"]) {
00404                                                         $this->message($ext, "Database not configured yet!", "
00405                                                                 You need to specify database username, password and host as one of the first things.
00406                                                                 Next you'll have to select a database to use with TYPO3.
00407                                                                 Use the form below:
00408                                                         ",2);
00409                                                 } else {
00410                                                         $this->message($ext, "Fatal error encountered!", "
00411                                                                 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!
00412                                                                 You should also check all warnings that may appear.
00413                                                         ",2);
00414                                                 }
00415                                         } elseif ($this->mode=="123") {
00416                                                 if (!$this->fatalError) {
00417                                                         $this->message($ext, "Basic configuration completed", '
00418                                                                 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.
00419 
00420                                                                 <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>
00421                                                         ',-1,1);
00422                                                 }
00423                                         }
00424                                         $this->message($ext, "Very Important: Changing Image Processing settings", "
00425                                                 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.
00426                                                 The problem is solved by <a href=\"".$this->setScriptName("typo3temp")."\">clearing the typo3temp/ folder</a>. Also make sure to clear the cache_pages table.
00427                                                 ",1,1);
00428                                         $this->message($ext, "Very Important: Changing Encryption Key setting", "
00429                                                 When you change the setting for the Encryption Key you <i>must</i> take into account that a change to this value might invalidate temporary information, URLs etc.
00430                                                 The problem is solved by <a href=\"".$this->setScriptName("typo3temp")."\">clearing the typo3temp/ folder</a>. Also make sure to clear the cache_pages table.
00431                                                 ",1,1);
00432                                         $this->message($ext, "Update localconf.php", "
00433                                                 This form updates the localconf.php file with the suggested values you see below. The values are based on the analysis above.
00434                                                 You can change the values in case you have alternatives to the suggested defaults.
00435                                                 By this final step you will configure TYPO3 for immediate use provided that you have no fatal errors left above."
00436                                                 .$this->setupGeneral("get_form"),0,1);
00437 
00438                                         echo $this->outputWrapper($this->printAll());
00439                         //              debug($this->config_array);
00440                                 break;
00441                                 case "extConfig":
00442                                         $this->silent=0;
00443 
00444                                         $this->generateConfigForm("get_form");
00445 
00446                                         $content = $this->printAll();
00447                                         $content = '<form action="'.$this->action.'" method="POST">'.$content.'<input type="submit" value="Write to localconf.php"><BR><BR>
00448                                         '.$this->fw("<strong>NOTICE: </strong>By clicking this button, localconf.php is updated with new values for the parameters listed above!<BR>").'
00449                                         </form>';
00450                                         echo $this->outputWrapper($content);
00451                                 break;
00452                                 case "typo3temp":
00453                                         $this->checkTheConfig();
00454                                         $this->silent=0;
00455                                         $this->typo3TempManager();
00456                                 break;
00457                                 case "cleanup":
00458                                         $this->checkTheConfig();
00459                                         $this->silent=0;
00460                                         $this->cleanupManager();
00461                                 break;
00462                                 case "phpinfo":
00463                                         $this->silent=0;
00464                                         $this->phpinformation();
00465                                 break;
00466                                 case "typo3conf_edit":
00467                                         $this->silent=0;
00468                                         $this->typo3conf_edit();
00469                                 break;
00470                                 case "about":
00471                                 default:
00472                                         $this->silent=0;
00473                                         $this->message("About", "Warning - very important!", $this->securityRisk().$this->alterPasswordForm(),2);
00474 
00475                                         $this->message("About", "Using this script", "
00476                                         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.
00477                                         There are three primary steps for you to take:
00478 
00479                                         <strong>1: Basic Configuration</strong>
00480                                         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.
00481                                         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.
00482                                         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.
00483 
00484                                         <strong>2: Database Analyser</strong>
00485                                         In this step you can either install a new database or update the database from any previous TYPO3 version.
00486                                         You can also get an overview of extra/missing fields/tables in the database compared to a raw sql-file.
00487                                         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.
00488 
00489                                         <strong>3: Image Processing</strong>
00490                                         This step is a visual guide to verify your configuration of the image processing software.
00491                                         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.
00492 
00493                                         <strong>4: All Configuration</strong>
00494                                         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.
00495 
00496                                         <strong>5: typo3temp/</strong>
00497                                         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.
00498                                         ");
00499 
00500                                         $this->message("About", "Why is this script stand-alone?", "
00501                                         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.
00502                                         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!
00503                                         ");
00504 
00505 
00506                                         $headCode="Header legend";
00507                                         $this->message($headCode, "Just information", "
00508                                         This is a simple message with some information about something.
00509                                         ");
00510                                         $this->message($headCode, "Check was successful", "
00511                                         Indicates that something was checked and returned an expected result.
00512                                         ",-1);
00513                                         $this->message($headCode, "Notice!", "
00514                                         Indicates that something is important to be aware of.
00515                                         This does <em>not</em> indicate an error.
00516                                         ",1);
00517                                         $this->message($headCode, "Warning!", "
00518                                         Indicates that something may very well cause trouble and you should definitely look into it before proceeding.
00519                                         This indicates a <em>potential</em> error.
00520                                         ",2);
00521                                         $this->message($headCode, "Error!", "
00522                                         Indicates that something is definitely wrong and that TYPO3 will most likely not perform as expected if this problem is not solved.
00523                                         This indicates an actual error.
00524                                         ",3);
00525 
00526                                         echo $this->outputWrapper($this->printAll());
00527                                 break;
00528                         }
00529                 }
00530         }
00531 
00537         function stepOutput()   {
00538                 $this->checkTheConfig();
00539                 $error_missingConnect='<br>
00540                         '.$this->fontTag2.'<img src="../t3lib/gfx/icon_fatalerror.gif" width=18 height=16 class="absmiddle">
00541                         There is no connection to the database!<br>
00542                         (Username: <i>'.TYPO3_db_username.'</i>, Password: <i>'.TYPO3_db_password.'</i>, Host: <i>'.TYPO3_db_host.'</i>).<BR>
00543                         <br>
00544                         <strong>Go to Step 1</strong> and enter a proper username/password!</font>
00545                         <br>
00546                         <br>
00547                 ';
00548                 $error_missingDB='<br>
00549                         '.$this->fontTag2.'<img src="../t3lib/gfx/icon_fatalerror.gif" width=18 height=16 class="absmiddle">
00550                         There is no access to the database (<i>'.TYPO3_db.'</i>)!<br>
00551                         <br>
00552                         <strong>Go to Step 2</strong> and select an accessible database!</font>
00553                         <br>
00554                         <br>
00555                 ';
00556 
00557                 $whichTables=$this->getListOfTables();
00558                 $dbInfo='
00559                                         <table border=0 cellpadding=1 cellspacing=0>
00560                                                 <tr>
00561                                                         <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>
00562                                                 </tr>
00563                                                 <tr>
00564                                                         <td valign="top" nowrap>'.$this->fontTag1.'Username:</font></td>
00565                                                         <td valign="top" nowrap><strong>'.$this->fontTag1.''.TYPO3_db_username.'</font></strong></td>
00566                                                 </tr>
00567                                                 <tr>
00568                                                         <td valign="top" nowrap>'.$this->fontTag1.'Password:</font></td>
00569                                                         <td valign="top" nowrap><strong>'.$this->fontTag1.''.TYPO3_db_password.'</font></strong></td>
00570                                                 </tr>
00571                                                 <tr>
00572                                                         <td valign="top" nowrap>'.$this->fontTag1.'Host:</font></td>
00573                                                         <td valign="top" nowrap><strong>'.$this->fontTag1.''.TYPO3_db_host.'</font></strong></td>
00574                                                 </tr>
00575                                                 <tr>
00576                                                         <td valign="top" nowrap>'.$this->fontTag1.'Database:</font></td>
00577                                                         <td valign="top" nowrap><strong>'.$this->fontTag1.''.TYPO3_db.'</font></strong></td>
00578                                                 </tr>
00579                                                 <tr>
00580                                                         <td valign="top" nowrap>'.$this->fontTag1.'# of tables:</font></td>
00581                                                         <td valign="top" nowrap><strong>'.$this->fontTag1.''.(count($whichTables)?'<font color=red>'.count($whichTables).'</font>':count($whichTables)).'</font></strong></td>
00582                                                 </tr>
00583                                         </table>
00584                 ';
00585                 $error_emptyDB='<br>
00586                         '.$this->fontTag2.'<img src="../t3lib/gfx/icon_fatalerror.gif" width=18 height=16 class="absmiddle">
00587                         The database is still empty. There are no tables!<br>
00588                         <br>
00589                         <strong>Go to Step 3</strong> and import a database!</font>
00590                         <br>
00591                         <br>
00592                 ';
00593 
00594                 switch(strtolower($this->step)) {
00595                         case 1:
00596                                 $msg='
00597 <br>
00598 <br>
00599                                         <table border=0>
00600                                            <form action="'.$this->action.'" method="POST">
00601                                                 <tr>
00602                                                         <td valign="top" nowrap><strong>
00603                                                            '.$this->fontTag2.'Username:</font></strong>
00604                                                         </td>
00605                                                         <td>    &nbsp;
00606                                                         </td>
00607                                                         <td valign="top">
00608                                                            '.$this->fontTag2.'
00609                                                            <input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_username]" value="'.TYPO3_db_username.'"></font><BR>
00610                                                         </td>
00611                                                 </tr>
00612                                                 <tr>
00613                                                         <td valign="top" nowrap><strong>
00614                                                            '.$this->fontTag2.'Password:</font></strong>
00615                                                         </td>
00616                                                         <td>    &nbsp;
00617                                                         </td>
00618                                                         <td valign="top">
00619                                                            '.$this->fontTag2.'
00620                                                            <input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_password]" value="'.TYPO3_db_password.'"></font><BR>
00621                                                         </td>
00622                                                 </tr>
00623                                                 <tr>
00624                                                         <td valign="top" nowrap><strong>
00625                                                            '.$this->fontTag2.'Host:</font></strong>
00626                                                         </td>
00627                                                         <td>    &nbsp;
00628                                                         </td>
00629                                                         <td valign="top">
00630                                                            '.$this->fontTag2.'
00631                                                            <input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_host]" value="'.(TYPO3_db_host?TYPO3_db_host:'localhost').'"></font><BR>
00632                                                         </td>
00633                                                 </tr>
00634                                                 <tr>
00635                                                         <td valign="top" nowrap><strong>
00636                                                            '.$this->fontTag1.'</font></strong>
00637                                                         </td>
00638                                                         <td>    &nbsp;
00639                                                         </td>
00640                                                         <td valign="top">
00641                                                            '.$this->fontTag1.'<BR>
00642                                                            <input type="hidden" name="step" value="2">
00643                                                            <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>
00644                                                         </td>
00645                                                 </tr>
00646                                            </form>
00647                                         </table>
00648 <br>
00649 <br>
00650                                 ';
00651                         break;
00652                         case 2:
00653                                 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))  {
00654                                         $dbArr = $this->getDatabaseList();
00655                                         reset($dbArr);
00656                                         $options="";
00657                                         $options.='<option value="">[ SELECT DATABASE ]</option>';
00658                                         $dbIncluded=0;
00659                                         while(list(,$dbname)=each($dbArr))      {
00660                                                 $options.='<option value="'.htmlspecialchars($dbname).'"'.($dbname==TYPO3_db?' selected':'').'>'.htmlspecialchars($dbname).'</option>';
00661                                                 if ($dbname==TYPO3_db)  $dbIncluded=1;
00662                                         }
00663                                         if (!$dbIncluded && TYPO3_db)   {
00664                                                 $options.='<option value="'.htmlspecialchars(TYPO3_db).'" selected>'.htmlspecialchars(TYPO3_db).' (NO ACCESS!)</option>';
00665                                         }
00666                                         $select='<select name="TYPO3_INSTALL[localconf.php][typo_db]">'.$options.'</select>';
00667                                         $msg='
00668 <br>
00669 <br>
00670                                         <table border=0>
00671                                            <form action="'.$this->action.'" method="POST">
00672                                                 <tr>
00673                                                         <td valign="top" nowrap><strong>
00674                                                            '.$this->fontTag2.'
00675                                                            You have two options:<br>
00676                                                            <br><br>
00677 
00678                                                            1: Select an existing <u>EMPTY</u> database:</font></strong>
00679                                                         </td>
00680                                                 </tr>
00681                                                 <tr>
00682                                                         <td valign="top">
00683                                                            '.$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>
00684                                                         </td>
00685                                                 </tr>
00686                                                 <tr>
00687                                                         <td valign="top" nowrap><br>
00688                                                         <br>
00689 <strong>
00690                                                            '.$this->fontTag2.'2: Create new database (recommended):</font></strong>
00691                                                         </td>
00692                                                 </tr>
00693                                                 <tr>
00694                                                         <td valign="top">
00695                                                            '.$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>
00696                                                         </td>
00697                                                 </tr>
00698                                                 <tr>
00699                                                         <td valign="top">                  <br>
00700 
00701                                                            '.$this->fontTag1.'<BR>
00702                                                            <input type="hidden" name="step" value="3">
00703                                                            <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>
00704                                                         </td>
00705                                                 </tr>
00706                                            </form>
00707                                         </table>
00708 <br>
00709 <br>
00710                                 ';
00711                                 } else {
00712                                         $msg=$error_missingConnect;
00713                                 }
00714                         break;
00715                         case 3:
00716                                 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))  {
00717                                         if ($GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db))      {
00718                                                 $sFiles = t3lib_div::getFilesInDir(PATH_typo3conf,"sql",1,1);
00719                                                 reset($sFiles);
00720                                                 $opt='';
00721                                                 while(list(,$f)=each($sFiles))  {
00722                                                         $opt.='<option value="import|'.htmlspecialchars($f).'">'.htmlspecialchars(basename($f)).'</option>';
00723                                                 }
00724 
00725 
00726                                                 $content='
00727                                                         '.$this->fontTag2.'Database dumps in typo3conf/ directory:</font><BR>
00728                                                         <input type="hidden" name="TYPO3_INSTALL[database_import_all]" value=1>
00729                                                    <input type="hidden" name="step" value="">
00730                                                    <input type="hidden" name="goto_step" value="go">
00731                                                         <select name="TYPO3_INSTALL[database_type]">'.$opt.'</select><BR>';
00732 
00733                                                 $content = $this->getUpdateDbFormWrap("import", $content, "Import database");
00734 
00735                                                 $msg='
00736                                                 <br>
00737                                                 '.$dbInfo.'<br>
00738                                                 <br>
00739                                                 '.$content.'
00740 
00741                                                 ';
00742 
00743                                         } else {
00744                                                 $msg=$error_missingDB;
00745                                         }
00746                                 } else {
00747                                         $msg=$error_missingConnect;
00748                                 }
00749                         break;
00750                         case "go":
00751                                 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))  {
00752                                         if ($GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db))      {
00753                                                 if (count($whichTables))        {
00754                                                         $msg='
00755                                                         <br>
00756                                                         '.$this->fontTag2.'
00757                                                         '.nl2br($this->messageBasicFinished()).'
00758                                                         <br>
00759                                                         <hr>
00760                                                         <div align="center"><strong><img src="../t3lib/gfx/icon_warning.gif" hspace=5 width=18 height=16 class="absmiddle">IMPORTANT</strong></div><br>
00761                                                         <font size=1>'.nl2br($this->securityRisk()).'
00762                                                         <br>
00763                                                         <strong>Enter <a href="'.$this->scriptSelf.'">"Normal" mode for the Install Tool</a> to change this!</strong><br>
00764 
00765                                                         </font>
00766                                                         </font><BR>
00767                                                         ';
00768                                                 } else {
00769                                                         $msg=$error_emptyDB;
00770                                                 }
00771                                         } else {
00772                                                 $msg=$error_missingDB;
00773                                         }
00774                                 } else {
00775                                         $msg=$error_missingConnect;
00776                                 }
00777                         break;
00778                         default:
00779                         break;
00780                 }
00781                 return $msg;
00782         }
00783 
00789         function checkTheConfig()       {
00790                         // Order important:
00791                 $this->checkDirs();
00792                 $this->checkConfiguration();
00793                 $this->checkExtensions();
00794 
00795                 if (TYPO3_OS=="WIN")    {
00796                         $paths=array($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path_lzw"], $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path"], "c:\\php\\imagemagick\\", 'c:\\apache\\ImageMagick\\');
00797                 } else {
00798                         $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/");
00799                 }
00800 
00801                 asort($paths);
00802                 if (ini_get("safe_mode"))       {
00803                         $paths=array(ini_get("safe_mode_exec_dir"),"/usr/local/php/bin/");
00804                 }
00805                 if ($this->INSTALL["checkIM"]["lzw"])   {
00806                         $this->checkIMlzw=1;
00807                 }
00808                 if ($this->INSTALL["checkIM"]["path"])  {
00809                         $paths[]=trim($this->INSTALL["checkIM"]["path"]);
00810                 }
00811                 if ($this->checkIM)     $this->checkImageMagick($paths);
00812                 $this->checkDatabase();
00813         }
00814 
00820         function typo3conf_edit()       {
00821                 $EDIT_path = PATH_typo3conf;    // default:
00822                 if ($this->allowFileEditOutsite_typo3conf_dir && $this->INSTALL["FILE"]["EDIT_path"])   {
00823                         if (t3lib_div::validPathStr($this->INSTALL["FILE"]["EDIT_path"]) && substr($this->INSTALL["FILE"]["EDIT_path"],-1)=="/")        {
00824                                 $tmp_path = PATH_site.$this->INSTALL["FILE"]["EDIT_path"];
00825                                 if (is_dir($tmp_path))  {
00826                                         $EDIT_path=$tmp_path;
00827                                 } else {debug("'".$tmp_path."' was not dir");}
00828                         } else {
00829                                 debug("BAD DIR_NAME (must be like t3lib/ or media/script/)");
00830                         }
00831                 }
00832 
00833                 $headCode = "Edit files in ".basename($EDIT_path)."/";
00834                 $this->contentBeforeTable="";
00835 
00836                 if ($this->INSTALL["SAVE_FILE"])        {
00837                         $save_to_file = $this->INSTALL["FILE"]["name"];
00838                         if (@is_file($save_to_file))    {
00839                                 $save_to_file_md5 = md5($save_to_file);
00840                                 if (isset($this->INSTALL["FILE"][$save_to_file_md5]) && t3lib_div::isFirstPartOfStr($save_to_file,$EDIT_path."") && substr($save_to_file,-1)!="~")      {
00841                                         $this->INSTALL["typo3conf_files"] = $save_to_file;
00842                                         $save_fileContent = $this->INSTALL["FILE"][$save_to_file_md5];
00843 
00844                                         if ($this->INSTALL["FILE"]["win_to_unix_br"])   {
00845                                                 $save_fileContent = str_replace(chr(13).chr(10),chr(10),$save_fileContent);
00846                                         }
00847                                         if ($this->INSTALL["FILE"]["backup"])   {
00848                                                 if (@is_file($save_to_file."~"))        unlink($save_to_file."~");
00849                                                 rename($save_to_file,$save_to_file."~");
00850                                                 $this->contentBeforeTable.='Backup written to <strong>'.$save_to_file.'~</strong><BR>';
00851                                         } else {
00852                                                 if (@is_file($save_to_file."~"))        {
00853                                                         unlink($save_to_file."~");
00854                                                         $this->contentBeforeTable.='Backup REMOVED! (<strong>'.$save_to_file.'~</strong>)<BR>';
00855                                                 }
00856                                         }
00857 
00858                                         t3lib_div::writeFile($save_to_file,$save_fileContent);
00859                                         $this->contentBeforeTable.='
00860                                                 File saved: <strong>'.$save_to_file.'</strong><BR>
00861                                                 MD5-sum: '.$this->INSTALL["FILE"]["prevMD5"].' (prev)<BR>
00862                                                 MD5-sum: '.md5($save_fileContent).' (new)<BR>
00863                                         ';
00864                                 }
00865                         }
00866                 }
00867 
00868 
00869                         // Filelist:
00870                 $typo3conf_files = t3lib_div::getFilesInDir($EDIT_path,"",1,1);
00871                 reset($typo3conf_files);
00872                 $lines=array();
00873                 $fileFound = 0;
00874                 while(list($k,$file)=each($typo3conf_files))    {
00875                         if ($this->INSTALL["typo3conf_files"] && !strcmp($this->INSTALL["typo3conf_files"],$file))      {
00876                                 $wrap=array('<strong><font color=navy>','</font></strong>');
00877                                 $fileFound = 1;
00878                         } else {$wrap=array();}
00879                         $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>';
00880                 }
00881                 $fileList='<table border=0 cellpadding=0 cellspacing=0>'.implode("",$lines).'</table>';
00882                 $fileList.="<BR>(".$EDIT_path.")";
00883 
00884                 if ($this->allowFileEditOutsite_typo3conf_dir)  {
00885                         $fileList.='<BR><form action="'.$this->action.'" method="POST">
00886                         '.PATH_site.'<input type="text" name="TYPO3_INSTALL[FILE][EDIT_path]" value="'.$this->INSTALL["FILE"]["EDIT_path"].'"><input type="submit" name="" value="Set">
00887                         </form>';
00888                 }
00889 
00890                 if ($fileFound && @is_file($this->INSTALL["typo3conf_files"]))  {
00891                         $this->headerStyle = '
00892                         <style type="text/css"><!--
00893                                 SELECT {font-family: Verdana,Arial,Helvetica,Sans-serif; font-size: 10px;}
00894                                 TEXTAREA  {font-family: Verdana,Arial,Helvetica,Sans-serif; font-size: 10px;}
00895                                 INPUT {font-family: Verdana,Arial,Helvetica,Sans-serif; font-size: 10px;}
00896                         //--></style>
00897                         ';
00898 
00899                         $fileContent = t3lib_div::getUrl($this->INSTALL["typo3conf_files"]);
00900                         $this->contentBeforeTable.= '<form action="'.$this->action.'" method="POST">
00901                                 '.(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">
00902                                 <BR>File: '.$this->INSTALL["typo3conf_files"].'
00903                                 <BR>MD5-sum: '.md5($fileContent).'
00904                                 <BR>
00905 
00906                                 <input type="hidden" name="TYPO3_INSTALL[FILE][name]" value="'.$this->INSTALL["typo3conf_files"].'">
00907                                 '.($this->allowFileEditOutsite_typo3conf_dir?'<input type="hidden" name="TYPO3_INSTALL[FILE][EDIT_path]" value="'.$this->INSTALL["FILE"]["EDIT_path"].'">':'').'
00908                                 <input type="hidden" name="TYPO3_INSTALL[FILE][prevMD5]" value="'.md5($fileContent).'">
00909                                 <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>
00910                                 <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>
00911                                 <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>
00912                                 '.
00913                         '</form>';
00914                 }
00915 
00916                 if ($this->contentBeforeTable)  {
00917                         $this->contentBeforeTable = $this->fw($this->contentBeforeTable);
00918                 }
00919 
00920                 $this->message($headCode,"Files in folder",$fileList);
00921 
00922                 echo $this->outputWrapper($this->printAll());
00923         }
00924 
00930         function phpinformation()       {
00931                 $headCode = "PHP information";
00932 
00933                 $sVar = t3lib_div::getIndpEnv("_ARRAY");
00934                 $sVar["CONST: PHP_OS"]=PHP_OS;
00935                 $sVar["CONST: TYPO3_OS"]=TYPO3_OS;
00936                 $sVar["CONST: PATH_thisScript"]=PATH_thisScript;
00937                 $sVar["CONST: php_sapi_name()"]=php_sapi_name();
00938                 $sVar[