Documentation TYPO3 par Ameos

class.tx_install.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 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, "Update localconf.php", "
00429                                                 This form updates the localconf.php file with the suggested values you see below. The values are based on the analysis above.
00430                                                 You can change the values in case you have alternatives to the suggested defaults.
00431                                                 By this final step you will configure TYPO3 for immediate use provided that you have no fatal errors left above."
00432                                                 .$this->setupGeneral("get_form"),0,1);
00433 
00434                                         echo $this->outputWrapper($this->printAll());
00435                         //              debug($this->config_array);
00436                                 break;
00437                                 case "extConfig":
00438                                         $this->silent=0;
00439 
00440                                         $this->generateConfigForm("get_form");
00441 
00442                                         $content = $this->printAll();
00443                                         $content = '<form action="'.$this->action.'" method="POST">'.$content.'<input type="submit" value="Write to localconf.php"><BR><BR>
00444                                         '.$this->fw("<strong>NOTICE: </strong>By clicking this button, localconf.php is updated with new values for the parameters listed above!<BR>").'
00445                                         </form>';
00446                                         echo $this->outputWrapper($content);
00447                                 break;
00448                                 case "typo3temp":
00449                                         $this->checkTheConfig();
00450                                         $this->silent=0;
00451                                         $this->typo3TempManager();
00452                                 break;
00453                                 case "cleanup":
00454                                         $this->checkTheConfig();
00455                                         $this->silent=0;
00456                                         $this->cleanupManager();
00457                                 break;
00458                                 case "phpinfo":
00459                                         $this->silent=0;
00460                                         $this->phpinformation();
00461                                 break;
00462                                 case "typo3conf_edit":
00463                                         $this->silent=0;
00464                                         $this->typo3conf_edit();
00465                                 break;
00466                                 case "about":
00467                                 default:
00468                                         $this->silent=0;
00469                                         $this->message("About", "Warning - very important!", $this->securityRisk().$this->alterPasswordForm(),2);
00470 
00471                                         $this->message("About", "Using this script", "
00472                                         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.
00473                                         There are three primary steps for you to take:
00474 
00475                                         <strong>1: Basic Configuration</strong>
00476                                         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.
00477                                         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.
00478                                         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.
00479 
00480                                         <strong>2: Database Analyser</strong>
00481                                         In this step you can either install a new database or update the database from any previous TYPO3 version.
00482                                         You can also get an overview of extra/missing fields/tables in the database compared to a raw sql-file.
00483                                         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.
00484 
00485                                         <strong>3: Image Processing</strong>
00486                                         This step is a visual guide to verify your configuration of the image processing software.
00487                                         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.
00488 
00489                                         <strong>4: All Configuration</strong>
00490                                         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.
00491 
00492                                         <strong>5: typo3temp/</strong>
00493                                         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.
00494                                         ");
00495 
00496                                         $this->message("About", "Why is this script stand-alone?", "
00497                                         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.
00498                                         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!
00499                                         ");
00500 
00501 
00502                                         $headCode="Header legend";
00503                                         $this->message($headCode, "Just information", "
00504                                         This is a simple message with some information about something.
00505                                         ");
00506                                         $this->message($headCode, "Check was successful", "
00507                                         Indicates that something was checked and returned an expected result.
00508                                         ",-1);
00509                                         $this->message($headCode, "Notice!", "
00510                                         Indicates that something is important to be aware of.
00511                                         This does <em>not</em> indicate an error.
00512                                         ",1);
00513                                         $this->message($headCode, "Warning!", "
00514                                         Indicates that something may very well cause trouble and you should definitely look into it before proceeding.
00515                                         This indicates a <em>potential</em> error.
00516                                         ",2);
00517                                         $this->message($headCode, "Error!", "
00518                                         Indicates that something is definitely wrong and that TYPO3 will most likely not perform as expected if this problem is not solved.
00519                                         This indicates an actual error.
00520                                         ",3);
00521 
00522                                         echo $this->outputWrapper($this->printAll());
00523                                 break;
00524                         }
00525                 }
00526         }
00527 
00533         function stepOutput()   {
00534                 $this->checkTheConfig();
00535                 $error_missingConnect='<br>
00536                         '.$this->fontTag2.'<img src="../t3lib/gfx/icon_fatalerror.gif" width=18 height=16 class="absmiddle">
00537                         There is no connection to the database!<br>
00538                         (Username: <i>'.TYPO3_db_username.'</i>, Password: <i>'.TYPO3_db_password.'</i>, Host: <i>'.TYPO3_db_host.'</i>).<BR>
00539                         <br>
00540                         <strong>Go to Step 1</strong> and enter a proper username/password!</font>
00541                         <br>
00542                         <br>
00543                 ';
00544                 $error_missingDB='<br>
00545                         '.$this->fontTag2.'<img src="../t3lib/gfx/icon_fatalerror.gif" width=18 height=16 class="absmiddle">
00546                         There is no access to the database (<i>'.TYPO3_db.'</i>)!<br>
00547                         <br>
00548                         <strong>Go to Step 2</strong> and select an accessible database!</font>
00549                         <br>
00550                         <br>
00551                 ';
00552 
00553                 $whichTables=$this->getListOfTables();
00554                 $dbInfo='
00555                                         <table border=0 cellpadding=1 cellspacing=0>
00556                                                 <tr>
00557                                                         <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>
00558                                                 </tr>
00559                                                 <tr>
00560                                                         <td valign="top" nowrap>'.$this->fontTag1.'Username:</font></td>
00561                                                         <td valign="top" nowrap><strong>'.$this->fontTag1.''.TYPO3_db_username.'</font></strong></td>
00562                                                 </tr>
00563                                                 <tr>
00564                                                         <td valign="top" nowrap>'.$this->fontTag1.'Password:</font></td>
00565                                                         <td valign="top" nowrap><strong>'.$this->fontTag1.''.TYPO3_db_password.'</font></strong></td>
00566                                                 </tr>
00567                                                 <tr>
00568                                                         <td valign="top" nowrap>'.$this->fontTag1.'Host:</font></td>
00569                                                         <td valign="top" nowrap><strong>'.$this->fontTag1.''.TYPO3_db_host.'</font></strong></td>
00570                                                 </tr>
00571                                                 <tr>
00572                                                         <td valign="top" nowrap>'.$this->fontTag1.'Database:</font></td>
00573                                                         <td valign="top" nowrap><strong>'.$this->fontTag1.''.TYPO3_db.'</font></strong></td>
00574                                                 </tr>
00575                                                 <tr>
00576                                                         <td valign="top" nowrap>'.$this->fontTag1.'# of tables:</font></td>
00577                                                         <td valign="top" nowrap><strong>'.$this->fontTag1.''.(count($whichTables)?'<font color=red>'.count($whichTables).'</font>':count($whichTables)).'</font></strong></td>
00578                                                 </tr>
00579                                         </table>
00580                 ';
00581                 $error_emptyDB='<br>
00582                         '.$this->fontTag2.'<img src="../t3lib/gfx/icon_fatalerror.gif" width=18 height=16 class="absmiddle">
00583                         The database is still empty. There are no tables!<br>
00584                         <br>
00585                         <strong>Go to Step 3</strong> and import a database!</font>
00586                         <br>
00587                         <br>
00588                 ';
00589 
00590                 switch(strtolower($this->step)) {
00591                         case 1:
00592                                 $msg='
00593 <br>
00594 <br>
00595                                         <table border=0>
00596                                            <form action="'.$this->action.'" method="POST">
00597                                                 <tr>
00598                                                         <td valign="top" nowrap><strong>
00599                                                            '.$this->fontTag2.'Username:</font></strong>
00600                                                         </td>
00601                                                         <td>    &nbsp;
00602                                                         </td>
00603                                                         <td valign="top">
00604                                                            '.$this->fontTag2.'
00605                                                            <input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_username]" value="'.TYPO3_db_username.'"></font><BR>
00606                                                         </td>
00607                                                 </tr>
00608                                                 <tr>
00609                                                         <td valign="top" nowrap><strong>
00610                                                            '.$this->fontTag2.'Password:</font></strong>
00611                                                         </td>
00612                                                         <td>    &nbsp;
00613                                                         </td>
00614                                                         <td valign="top">
00615                                                            '.$this->fontTag2.'
00616                                                            <input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_password]" value="'.TYPO3_db_password.'"></font><BR>
00617                                                         </td>
00618                                                 </tr>
00619                                                 <tr>
00620                                                         <td valign="top" nowrap><strong>
00621                                                            '.$this->fontTag2.'Host:</font></strong>
00622                                                         </td>
00623                                                         <td>    &nbsp;
00624                                                         </td>
00625                                                         <td valign="top">
00626                                                            '.$this->fontTag2.'
00627                                                            <input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_host]" value="'.(TYPO3_db_host?TYPO3_db_host:'localhost').'"></font><BR>
00628                                                         </td>
00629                                                 </tr>
00630                                                 <tr>
00631                                                         <td valign="top" nowrap><strong>
00632                                                            '.$this->fontTag1.'</font></strong>
00633                                                         </td>
00634                                                         <td>    &nbsp;
00635                                                         </td>
00636                                                         <td valign="top">
00637                                                            '.$this->fontTag1.'<BR>
00638                                                            <input type="hidden" name="step" value="2">
00639                                                            <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>
00640                                                         </td>
00641                                                 </tr>
00642                                            </form>
00643                                         </table>
00644 <br>
00645 <br>
00646                                 ';
00647                         break;
00648                         case 2:
00649                                 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))  {
00650                                         $dbArr = $this->getDatabaseList();
00651                                         reset($dbArr);
00652                                         $options="";
00653                                         $options.='<option value="">[ SELECT DATABASE ]</option>';
00654                                         $dbIncluded=0;
00655                                         while(list(,$dbname)=each($dbArr))      {
00656                                                 $options.='<option value="'.htmlspecialchars($dbname).'"'.($dbname==TYPO3_db?' selected':'').'>'.htmlspecialchars($dbname).'</option>';
00657                                                 if ($dbname==TYPO3_db)  $dbIncluded=1;
00658                                         }
00659                                         if (!$dbIncluded && TYPO3_db)   {
00660                                                 $options.='<option value="'.htmlspecialchars(TYPO3_db).'" selected>'.htmlspecialchars(TYPO3_db).' (NO ACCESS!)</option>';
00661                                         }
00662                                         $select='<select name="TYPO3_INSTALL[localconf.php][typo_db]">'.$options.'</select>';
00663                                         $msg='
00664 <br>
00665 <br>
00666                                         <table border=0>
00667                                            <form action="'.$this->action.'" method="POST">
00668                                                 <tr>
00669                                                         <td valign="top" nowrap><strong>
00670                                                            '.$this->fontTag2.'
00671                                                            You have two options:<br>
00672                                                            <br><br>
00673 
00674                                                            1: Select an existing <u>EMPTY</u> database:</font></strong>
00675                                                         </td>
00676                                                 </tr>
00677                                                 <tr>
00678                                                         <td valign="top">
00679                                                            '.$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>
00680                                                         </td>
00681                                                 </tr>
00682                                                 <tr>
00683                                                         <td valign="top" nowrap><br>
00684                                                         <br>
00685 <strong>
00686                                                            '.$this->fontTag2.'2: Create new database (recommended):</font></strong>
00687                                                         </td>
00688                                                 </tr>
00689                                                 <tr>
00690                                                         <td valign="top">
00691                                                            '.$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>
00692                                                         </td>
00693                                                 </tr>
00694                                                 <tr>
00695                                                         <td valign="top">                  <br>
00696 
00697                                                            '.$this->fontTag1.'<BR>
00698                                                            <input type="hidden" name="step" value="3">
00699                                                            <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>
00700                                                         </td>
00701                                                 </tr>
00702                                            </form>
00703                                         </table>
00704 <br>
00705 <br>
00706                                 ';
00707                                 } else {
00708                                         $msg=$error_missingConnect;
00709                                 }
00710                         break;
00711                         case 3:
00712                                 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))  {
00713                                         if ($GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db))      {
00714                                                 $sFiles = t3lib_div::getFilesInDir(PATH_typo3conf,"sql",1,1);
00715                                                 reset($sFiles);
00716                                                 $opt='';
00717                                                 while(list(,$f)=each($sFiles))  {
00718                                                         $opt.='<option value="import|'.htmlspecialchars($f).'">'.htmlspecialchars(basename($f)).'</option>';
00719                                                 }
00720 
00721 
00722                                                 $content='
00723                                                         '.$this->fontTag2.'Database dumps in typo3conf/ directory:</font><BR>
00724                                                         <input type="hidden" name="TYPO3_INSTALL[database_import_all]" value=1>
00725                                                    <input type="hidden" name="step" value="">
00726                                                    <input type="hidden" name="goto_step" value="go">
00727                                                         <select name="TYPO3_INSTALL[database_type]">'.$opt.'</select><BR>';
00728 
00729                                                 $content = $this->getUpdateDbFormWrap("import", $content, "Import database");
00730 
00731                                                 $msg='
00732                                                 <br>
00733                                                 '.$dbInfo.'<br>
00734                                                 <br>
00735                                                 '.$content.'
00736 
00737                                                 ';
00738 
00739                                         } else {
00740                                                 $msg=$error_missingDB;
00741                                         }
00742                                 } else {
00743                                         $msg=$error_missingConnect;
00744                                 }
00745                         break;
00746                         case "go":
00747                                 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))  {
00748                                         if ($GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db))      {
00749                                                 if (count($whichTables))        {
00750                                                         $msg='
00751                                                         <br>
00752                                                         '.$this->fontTag2.'
00753                                                         '.nl2br($this->messageBasicFinished()).'
00754                                                         <br>
00755                                                         <hr>
00756                                                         <div align="center"><strong><img src="../t3lib/gfx/icon_warning.gif" hspace=5 width=18 height=16 class="absmiddle">IMPORTANT</strong></div><br>
00757                                                         <font size=1>'.nl2br($this->securityRisk()).'
00758                                                         <br>
00759                                                         <strong>Enter <a href="'.$this->scriptSelf.'">"Normal" mode for the Install Tool</a> to change this!</strong><br>
00760 
00761                                                         </font>
00762                                                         </font><BR>
00763                                                         ';
00764                                                 } else {
00765                                                         $msg=$error_emptyDB;
00766                                                 }
00767                                         } else {
00768                                                 $msg=$error_missingDB;
00769                                         }
00770                                 } else {
00771                                         $msg=$error_missingConnect;
00772                                 }
00773                         break;
00774                         default:
00775                         break;
00776                 }
00777                 return $msg;
00778         }
00779 
00785         function checkTheConfig()       {
00786                         // Order important:
00787                 $this->checkDirs();
00788                 $this->checkConfiguration();
00789                 $this->checkExtensions();
00790 
00791                 if (TYPO3_OS=="WIN")    {
00792                         $paths=array($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path_lzw"], $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path"], "c:\\php\\imagemagick\\", 'c:\\apache\\ImageMagick\\');
00793                 } else {
00794                         $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/");
00795                 }
00796 
00797                 asort($paths);
00798                 if (ini_get("safe_mode"))       {
00799                         $paths=array(ini_get("safe_mode_exec_dir"),"/usr/local/php/bin/");
00800                 }
00801                 if ($this->INSTALL["checkIM"]["lzw"])   {
00802                         $this->checkIMlzw=1;
00803                 }
00804                 if ($this->INSTALL["checkIM"]["path"])  {
00805                         $paths[]=trim($this->INSTALL["checkIM"]["path"]);
00806                 }
00807                 if ($this->checkIM)     $this->checkImageMagick($paths);
00808                 $this->checkDatabase();
00809         }
00810 
00816         function typo3conf_edit()       {
00817                 $EDIT_path = PATH_typo3conf;    // default:
00818                 if ($this->allowFileEditOutsite_typo3conf_dir && $this->INSTALL["FILE"]["EDIT_path"])   {
00819                         if (t3lib_div::validPathStr($this->INSTALL["FILE"]["EDIT_path"]) && substr($this->INSTALL["FILE"]["EDIT_path"],-1)=="/")        {
00820                                 $tmp_path = PATH_site.$this->INSTALL["FILE"]["EDIT_path"];
00821                                 if (is_dir($tmp_path))  {
00822                                         $EDIT_path=$tmp_path;
00823                                 } else {debug("'".$tmp_path."' was not dir");}
00824                         } else {
00825                                 debug("BAD DIR_NAME (must be like t3lib/ or media/script/)");
00826                         }
00827                 }
00828 
00829                 $headCode = "Edit files in ".basename($EDIT_path)."/";
00830                 $this->contentBeforeTable="";
00831 
00832                 if ($this->INSTALL["SAVE_FILE"])        {
00833                         $save_to_file = $this->INSTALL["FILE"]["name"];
00834                         if (@is_file($save_to_file))    {
00835                                 $save_to_file_md5 = md5($save_to_file);
00836                                 if (isset($this->INSTALL["FILE"][$save_to_file_md5]) && t3lib_div::isFirstPartOfStr($save_to_file,$EDIT_path."") && substr($save_to_file,-1)!="~")      {
00837                                         $this->INSTALL["typo3conf_files"] = $save_to_file;
00838                                         $save_fileContent = $this->INSTALL["FILE"][$save_to_file_md5];
00839 
00840                                         if ($this->INSTALL["FILE"]["win_to_unix_br"])   {
00841                                                 $save_fileContent = str_replace(chr(13).chr(10),chr(10),$save_fileContent);
00842                                         }
00843                                         if ($this->INSTALL["FILE"]["backup"])   {
00844                                                 if (@is_file($save_to_file."~"))        unlink($save_to_file."~");
00845                                                 rename($save_to_file,$save_to_file."~");
00846                                                 $this->contentBeforeTable.='Backup written to <strong>'.$save_to_file.'~</strong><BR>';
00847                                         } else {
00848                                                 if (@is_file($save_to_file."~"))        {
00849                                                         unlink($save_to_file."~");
00850                                                         $this->contentBeforeTable.='Backup REMOVED! (<strong>'.$save_to_file.'~</strong>)<BR>';
00851                                                 }
00852                                         }
00853 
00854                                         t3lib_div::writeFile($save_to_file,$save_fileContent);
00855                                         $this->contentBeforeTable.='
00856                                                 File saved: <strong>'.$save_to_file.'</strong><BR>
00857                                                 MD5-sum: '.$this->INSTALL["FILE"]["prevMD5"].' (prev)<BR>
00858                                                 MD5-sum: '.md5($save_fileContent).' (new)<BR>
00859                                         ';
00860                                 }
00861                         }
00862                 }
00863 
00864 
00865                         // Filelist:
00866                 $typo3conf_files = t3lib_div::getFilesInDir($EDIT_path,"",1,1);
00867                 reset($typo3conf_files);
00868                 $lines=array();
00869                 $fileFound = 0;
00870                 while(list($k,$file)=each($typo3conf_files))    {
00871                         if ($this->INSTALL["typo3conf_files"] && !strcmp($this->INSTALL["typo3conf_files"],$file))      {
00872                                 $wrap=array('<strong><font color=navy>','</font></strong>');
00873                                 $fileFound = 1;
00874                         } else {$wrap=array();}
00875                         $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>';
00876                 }
00877                 $fileList='<table border=0 cellpadding=0 cellspacing=0>'.implode("",$lines).'</table>';
00878                 $fileList.="<BR>(".$EDIT_path.")";
00879 
00880                 if ($this->allowFileEditOutsite_typo3conf_dir)  {
00881                         $fileList.='<BR><form action="'.$this->action.'" method="POST">
00882                         '.PATH_site.'<input type="text" name="TYPO3_INSTALL[FILE][EDIT_path]" value="'.$this->INSTALL["FILE"]["EDIT_path"].'"><input type="submit" name="" value="Set">
00883                         </form>';
00884                 }
00885 
00886                 if ($fileFound && @is_file($this->INSTALL["typo3conf_files"]))  {
00887                         $this->headerStyle = '
00888                         <style type="text/css"><!--
00889                                 SELECT {font-family: Verdana,Arial,Helvetica,Sans-serif; font-size: 10px;}
00890                                 TEXTAREA  {font-family: Verdana,Arial,Helvetica,Sans-serif; font-size: 10px;}
00891                                 INPUT {font-family: Verdana,Arial,Helvetica,Sans-serif; font-size: 10px;}
00892                         //--></style>
00893                         ';
00894 
00895                         $fileContent = t3lib_div::getUrl($this->INSTALL["typo3conf_files"]);
00896                         $this->contentBeforeTable.= '<form action="'.$this->action.'" method="POST">
00897                                 '.(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">
00898                                 <BR>File: '.$this->INSTALL["typo3conf_files"].'
00899                                 <BR>MD5-sum: '.md5($fileContent).'
00900                                 <BR>
00901 
00902                                 <input type="hidden" name="TYPO3_INSTALL[FILE][name]" value="'.$this->INSTALL["typo3conf_files"].'">
00903                                 '.($this->allowFileEditOutsite_typo3conf_dir?'<input type="hidden" name="TYPO3_INSTALL[FILE][EDIT_path]" value="'.$this->INSTALL["FILE"]["EDIT_path"].'">':'').'
00904                                 <input type="hidden" name="TYPO3_INSTALL[FILE][prevMD5]" value="'.md5($fileContent).'">
00905                                 <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>
00906                                 <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>
00907                                 <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>
00908                                 '.
00909                         '</form>';
00910                 }
00911 
00912                 if ($this->contentBeforeTable)  {
00913                         $this->contentBeforeTable = $this->fw($this->contentBeforeTable);
00914                 }
00915 
00916                 $this->message($headCode,"Files in folder",$fileList);
00917 
00918                 echo $this->outputWrapper($this->printAll());
00919         }
00920 
00926         function phpinformation()       {
00927                 $headCode = "PHP information";
00928 
00929                 $sVar = t3lib_div::getIndpEnv("_ARRAY");
00930                 $sVar["CONST: PHP_OS"]=PHP_OS;
00931                 $sVar["CONST: TYPO3_OS"]=TYPO3_OS;
00932                 $sVar["CONST: PATH_thisScript"]=PATH_thisScript;
00933                 $sVar["CONST: php_sapi_name()"]=php_sapi_name();
00934                 $sVar["OTHER: TYPO3_VERSION"]=$GLOBALS["TYPO_VERSION"];
00935                 $sVar["OTHER: PHP_VERSION"]=phpversion();
00936                 $sVar["imagecreatefromgif()"]=function_exists("imagecreatefromgif");
00937                 $sVar["imagecreatefrompng()"]=function_exists("imagecreatefrompng");
00938                 $sVar["imagecreatefromjpeg()"]=function_exists("imagecreatefromjpeg");
00939                 $sVar["imagegif()"]=function_exists("imagegif");
00940                 $sVar["imagepng()"]=function_exists("imagepng");
00941                 $sVar["imagejpeg()"]=function_exists("imagejpeg");
00942                 $sVar["imagettftext()"]=function_exists("imagettftext");
00943                 $sVar["OTHER: IMAGE_TYPES"]=imagetypes();
00944                 $sVar["OTHER: memory_limit"]=ini_get("memory_limit");
00945 
00946                 $gE_keys = explode(",","SERVER_PORT,SERVER_SOFTWARE,GATEWAY_INTERFACE,SCRIPT_NAME,PATH_TRANSLATED");
00947                 while(list(,$k)=each($gE_keys)) {
00948                         $sVar["SERVER: ".$k]=$_SERVER[$k];
00949                 }
00950 
00951                 $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");
00952                 while(list(,$k)=each($gE_keys)) {
00953                         $sVar["T3CV_GFX: ".$k]=$GLOBALS["TYPO3_CONF_VARS"]["GFX"][$k];
00954                 }
00955 
00956                 $debugInfo=array();
00957                 $debugInfo[]="### DEBUG SYSTEM INFORMATION - START ###";
00958                 reset($sVar);
00959                 while(list($kkk,$vvv)=each($sVar))      {
00960                         $debugInfo[]=str_pad(substr($kkk,0,20),20).": ".$vvv;
00961                 }
00962                 $debugInfo[]="### DEBUG SYSTEM INFORMATION - END ###";
00963 
00964                 $buf=$this->messageFunc_nl2br;
00965                 $this->messageFunc_nl2br=0;
00966                 $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>
00967                 <form action=""><textarea rows="10" '.$this->formWidthText(80,"","off").' wrap="OFF">'.t3lib_div::formatForTextarea(implode(chr(10),$debugInfo)).'</textarea></form>');
00968                 $this->messageFunc_nl2br=$buf;
00969 
00970                 $getEnvArray = array();
00971                 $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");
00972                 while(list(,$k)=each($gE_keys)) {
00973                         $getEnvArray[$k] = getenv($k);
00974                 }
00975                 $this->message($headCode,"t3lib_div::getIndpEnv()",t3lib_div::view_array(t3lib_div::getIndpEnv("_ARRAY")));
00976                 $this->message($headCode,"getenv()",t3lib_div::view_array($getEnvArray));
00977                 $this->message($headCode,"_ENV",t3lib_div::view_array($_ENV));
00978                 $this->message($headCode,"_SERVER",t3lib_div::view_array($_SERVER));
00979                 $this->message($headCode,"_COOKIE",t3lib_div::view_array($_COOKIE));
00980                 $this->message($headCode,"_GET",t3lib_div::view_array($_GET));
00981 
00982                 ob_start();
00983                 phpinfo();
00984                 $contents = explode("<body>",ob_get_contents());
00985                 ob_end_clean();
00986                 $contents = explode("</body>",$contents[1]);
00987 
00988                 $this->message($headCode,"phpinfo()",$contents[0]);
00989 
00990 
00991 
00992 $this->headerStyle = '
00993 <style type="text/css"><!--
00994 a { text-decoration: none; }
00995 a:hover { text-decoration: underline; }
00996 h1 { font-family: verdana,arial, helvetica, sans-serif; font-size: 14pt; font-weight: bold;}
00997 h2 { font-family: verdana,arial, helvetica, sans-serif; font-size: 12pt; font-weight: bold;}
00998 body, td { font-family: verdana,arial, helvetica, sans-serif; font-size: 10pt; }
00999 th { font-family: verdana,arial, helvetica, sans-serif; font-size: 10pt; font-weight: bold; }
01000 //--></style>
01001 ';
01002 
01003                 echo $this->outputWrapper($this->printAll());
01004         }
01005 
01006 
01007 
01008 
01009 
01010 
01011 
01012 
01013 
01014 
01015 
01016 
01017 
01018         /*******************************
01019          *
01020          * typo3temp/ manager
01021          *
01022          *******************************/
01023 
01029         function typo3TempManager()     {
01030                 $headCode = "typo3temp/ directory";
01031                 $this->message($headCode,"What is it?","
01032                 TYPO3 uses this directory for temporary files, mainly processed and cached images.
01033                 The filenames are very cryptic; They are unique representations of the file properties made by md5-hashing a serialized array with information.
01034                 Anyway this directory may contain many thousand files and a lot of them may be of no use anymore.
01035 
01036                 With this test you can delete the files in this folder. When you do that, you should also clear the cache database tables afterwards.
01037                 ");
01038 
01039                 if (!$this->config_array["dir_typo3temp"])      {
01040                         $this->message("typo3temp/ directory","typo3temp/ not writable!","
01041                                 You must make typo3temp/ write enabled before you can proceed with this test.
01042                         ",2);
01043                         echo $this->outputWrapper($this->printAll());
01044                         return;
01045                 }
01046 
01047                         // Run through files
01048                 $fileCounter = 0;
01049                 $deleteCounter = 0;
01050                 $criteriaMatch = 0;
01051                 $tmap=array("day"=>1, "week"=>7, "month"=>30);
01052                 $tt = $this->INSTALL["typo3temp_delete"];
01053                 $subdir = $this->INSTALL["typo3temp_subdir"];
01054                 if (strlen($subdir) && !ereg('^[[:alnum:]_]+/$',$subdir))       die('subdir "'.$subdir.'" was not allowed!');
01055                 $action = $this->INSTALL["typo3temp_action"];
01056                 $d = @dir($this->typo3temp_path.$subdir);
01057                 if (is_object($d))      {
01058                         while($entry=$d->read()) {
01059                                 $theFile = $this->typo3temp_path.$subdir.$entry;
01060                                 if (@is_file($theFile)) {
01061                                         $ok = 0;
01062                                         $fileCounter++;
01063                                         if ($tt)        {
01064                                                 if (t3lib_div::testInt($tt))    {
01065                                                         if (filesize($theFile) > $tt*1024)      $ok=1;
01066                                                 } else {
01067                                                         if (fileatime($theFile) < time()-(intval($tmap[$tt])*60*60*24)) $ok=1;
01068                                                 }
01069                                         } else {
01070                                                 $ok = 1;
01071                                         }
01072                                         if ($ok)        {
01073                                                 $hashPart=substr(basename($theFile),-14,10);
01074                                                 if (!ereg("[^a-f0-9]",$hashPart) || substr($theFile,-6)==='.cache' || substr($theFile,-4)==='.tbl' || substr(basename($theFile),0,8)==='install_')      {               // This is a kind of check that the file being deleted has a 10 char hash in it
01075                                                         if ($action && $deleteCounter<$action)  {
01076                                                                 $deleteCounter++;
01077                                                                 unlink($theFile);
01078                                                         } else {
01079                                                                 $criteriaMatch++;
01080                                                         }
01081                                                 }
01082                                         }
01083                                 }
01084                         }
01085                         $d->close();
01086                 }
01087 
01088                         // Find sub-dirs:
01089                 $subdirRegistry = array(''=>'');
01090                 $d = @dir($this->typo3temp_path);
01091                 if (is_object($d))      {
01092                         while($entry=$d->read()) {
01093                                 $theFile = $entry;
01094                                 if (@is_dir($this->typo3temp_path.$theFile) && $theFile!='..' && $theFile!='.') {
01095                                         $subdirRegistry[$theFile.'/'] = $theFile.'/ (Files: '.count(t3lib_div::getFilesInDir($this->typo3temp_path.$theFile)).')';
01096                                 }
01097                         }
01098                 }
01099 
01100                 $deleteType=array(
01101                         "0" => "All",
01102                         "day" => "Last access more than a day ago",
01103                         "week" => "Last access more than a week ago",
01104                         "month" => "Last access more than a month ago",
01105                         "10" => "Filesize greater than 10 kb",
01106                         "50" => "Filesize greater than 50 kb",
01107                         "100" => "Filesize greater than 100 kb"
01108                 );
01109 
01110                 $actionType=array(
01111                         "0" => "Don't delete, just display statistics",
01112                         "100" => "Delete 100",
01113                         "500" => "Delete 500",
01114                         "1000" => "Delete 1000"
01115                 );
01116 
01117                 $content='<select name="TYPO3_INSTALL[typo3temp_delete]">'.$this->getSelectorOptions($deleteType,$tt).'</select>
01118                 <br>
01119 Number of files at a time:
01120                 <select name="TYPO3_INSTALL[typo3temp_action]">'.$this->getSelectorOptions($actionType).'</select>
01121 
01122 From sub-directory:
01123                 <select name="TYPO3_INSTALL[typo3temp_subdir]">'.$this->getSelectorOptions($subdirRegistry, $this->INSTALL["typo3temp_subdir"]).'</select>
01124                 ';
01125 
01126                 $form = '<form action="'.$this->action.'" method="POST">'.$content.'
01127 
01128                 <input type="submit" value="Execute">
01129                 </form>
01130                 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.';
01131 
01132                 $this->message($headCode,"Statistics","
01133                 Number of temporary files: <strong>".($fileCounter-$deleteCounter)."</strong>
01134                 Number matching '".htmlspecialchars($deleteType[$tt])."': <strong>".$criteriaMatch."</strong>
01135                 Number deleted: <strong>".$deleteCounter."</strong>
01136                 <BR>
01137                 ".$form,1);
01138 
01139                 echo $this->outputWrapper($this->printAll());
01140         }
01141 
01149         function getSelectorOptions($deleteType,$tt="") {
01150                 $out="";
01151                 if (is_array($deleteType))      {
01152                         reset($deleteType);
01153                         while(list($v,$l)=each($deleteType))    {
01154                                 $out.='<option value="'.htmlspecialchars($v).'"'.(!strcmp($v,$tt)?" selected":"").'>'.htmlspecialchars($l).'</option>';
01155                         }
01156                 }
01157                 return $out;
01158         }
01159 
01160 
01161 
01162 
01163 
01164 
01165 
01166 
01167 
01168         /*******************************
01169          *
01170          * cleanup manager
01171          *
01172          *******************************/
01173 
01181         function cleanupManager()       {
01182                 $headCode = "Clean up database";
01183                 $this->message($headCode,"What is it?","
01184                 This function will become a general clean up manager for various tables used by TYPO3. By now you can only empty the cache which is used for storing image sizes of all pictures used in TYPO3.
01185 
01186                 <strong>Clear cached image sizes</strong>
01187                 Clears the cache used for memorizing sizes of all images used in your website. This information is cached in order to gain performance and will be stored each time a new image is being displayed in the frontend.
01188 
01189                 You should <em>Clear All Cache</em> in the backend after clearing this cache.
01190                 ");
01191 
01192                 $tables = $this->getListOfTables();
01193                 $action = $this->INSTALL['cleanup_type'];
01194 
01195                 if (($action == 'cache_imagesizes' || $action == 'all') && isset ($tables['cache_imagesizes'])) {
01196                         $GLOBALS['TYPO3_DB']->exec_DELETEquery ('cache_imagesizes','1');
01197                 }
01198 
01199                 $cleanupType = array (
01200                         "all" => "Clean up everything",
01201                 );
01202 
01203                         // Get cache_imagesizes info
01204                 if (isset ($tables['cache_imagesizes'])) {
01205                         $cleanupType["cache_imagesizes"] = "Clear cached image sizes only";
01206                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_imagesizes', '');
01207                         $resArr = $GLOBALS['TYPO3_DB']->sql_fetch_assoc ($res);
01208                         $cachedImageSizesCounter = intval ($resArr['count(*)']);
01209                 } else {
01210                         $this->message($headCode,"Table cache_imagesizes does not exist!","
01211                                 The table cache_imagesizes was not found. Please check your database settings in Basic Configuration and compare your table definition with the Database Analyzer.
01212                         ",2);
01213                         $cachedImageSizesCounter = 'unknown';
01214                 }
01215 
01216                 $content = '<select name="TYPO3_INSTALL[cleanup_type]">'.$this->getSelectorOptions($cleanupType,$tt).'</select> ';
01217                 $form = '<form action="'.$this->action.'" method="POST">'.$content.'<input type="submit" value="Execute"></form>';
01218                 $this->message($headCode,"Statistics","
01219                         Number cached image sizes: <strong>".$cachedImageSizesCounter."</strong><br>
01220                 ".$form,1);
01221 
01222                 echo $this->outputWrapper($this->printAll());
01223         }
01224 
01225 
01226 
01227 
01228 
01229 
01230 
01231 
01232 
01233 
01234 
01235 
01236 
01237         /*******************************
01238          *
01239          * CONFIGURATION FORM
01240          *
01241          ********************************/
01242 
01249         function generateConfigForm($type="")   {
01250                 switch($type)   {
01251                         case "get_form":
01252                                 $default_config_content = t3lib_div::getUrl(PATH_t3lib."config_default.php");
01253                                 $commentArr = $this->getDefaultConfigArrayComments($default_config_content);
01254 /*
01255                                 $localconf_content = t3lib_div::getUrl(PATH_typo3conf."localconf.php");
01256                                 $commentArr2 = $this->getConfigArrayComments($localconf_content);
01257                                 debug($commentArr2);
01258 */
01259                                 reset($GLOBALS["TYPO3_CONF_VARS"]);
01260                                 $this->messageFunc_nl2br=0;
01261                                 while(list($k,$va)=each($GLOBALS["TYPO3_CONF_VARS"]))   {
01262                                         $ext="[".$k."]";
01263                                         $this->message($ext, '$TYPO3_CONF_VARS["'.$k.'"]',$commentArr[0][$k],1);
01264                                         while(list($vk,$value)=each($va))       {
01265                                                 if (!is_array($value) && $this->checkForBadString($value))      {
01266                                                         $k2="[".$vk."]";
01267                                                         $description = trim($commentArr[1][$k][$vk]);
01268                                                         $msg=$description."<BR><BR><em>".$ext.$k2." = ".htmlspecialchars(t3lib_div::fixed_lgd($value,60))."</em><BR>";
01269 
01270                                                         if (strstr($value,chr(10)))     {
01271                                                                                 // Never used at this point:
01272                                                                 $form='<textarea name="TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']" cols=40 rows=5 wrap="off">'.htmlspecialchars($value).'</textarea>';
01273                                                         } elseif (eregi("^boolean",$description)) {
01274                                                                 $form='<input type="hidden" name="TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']" value="0">';
01275                                                                 $form.='<input type="checkbox" name="TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']"'.($value?" checked":"").' value="'.($value&&strcmp($value,"0")?htmlspecialchars($value):1).'">';
01276                                                         } else {
01277                                                                 $form='<input type="text" size=40 name="TYPO3_INSTALL[extConfig]['.$k.']['.$vk.']" value="'.htmlspecialchars($value).'">';
01278                                                         }
01279                                                         $this->message($ext, $k2,$msg.$form);
01280                                                 }
01281                                         }
01282                                 }
01283                         break;
01284                         default:
01285                                 if (is_array($this->INSTALL["extConfig"]))              {
01286                                         reset($this->INSTALL["extConfig"]);
01287                                         $lines = $this->writeToLocalconf_control();
01288                                         while(list($k,$va)=each($this->INSTALL["extConfig"]))   {
01289                                                 if (is_array($GLOBALS["TYPO3_CONF_VARS"][$k]))  {
01290                                                         while(list($vk,$value)=each($va))       {
01291                                                                 if (isset($GLOBALS["TYPO3_CONF_VARS"][$k][$vk]))        {
01292                                                                         $doit=1;
01293                                                                         if ($k=="BE" && $vk=="installToolPassword")     {
01294                                                                                 if ($value)     {
01295                                                                                         if (isset($_POST["installToolPassword_check"]) && (!t3lib_div::_GP("installToolPassword_check") || strcmp(t3lib_div::_GP("installToolPassword_check"),$value))) {
01296                                                                                                 $doit=0;
01297                                                                                                 debug("ERROR: The two passwords did not match! The password was not changed.");
01298                                                                                         }
01299                                                                                         if (t3lib_div::_GP("installToolPassword_md5"))  $value =md5($value);
01300                                                                                 } else $doit=0;
01301                                                                         }
01302                                                                         if ($doit && strcmp($GLOBALS["TYPO3_CONF_VARS"][$k][$vk],$value))       $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["'.$k.'"]["'.$vk.'"]', $value);
01303                                                                 }
01304                                                         }
01305                                                 }
01306                                         }
01307                                         $this->writeToLocalconf_control($lines);
01308                                 }
01309                         break;
01310                 }
01311         }
01312 
01321         function getDefaultConfigArrayComments($string,$mainArray=array(),$commentArray=array())        {
01322                 $lines = explode(chr(10),$string);
01323                 $in=0;
01324                 $mainKey="";
01325                 while(list(,$lc)=each($lines))  {
01326                         $lc = trim($lc);
01327                         if ($in) {
01328                                 if (!strcmp($lc,");"))  {
01329                                         $in=0;
01330                                 } else {
01331                                         if (eregi('["\']([[:alnum:]_-]*)["\'][[:space:]]*=>(.*)',$lc,$reg))     {
01332                                                 list(,$theComment)=explode("//",$reg[2],2);
01333                                                 if (substr(strtolower(trim($reg[2])),0,5)=="array" && !strcmp($reg[1],strtoupper($reg[1])))     {
01334                                                         $mainKey=trim($reg[1]);
01335                                                         $mainArray[$mainKey]=trim($theComment);
01336                                                 } elseif ($mainKey) {
01337                                                         $commentArray[$mainKey][$reg[1]]=trim($theComment);
01338                                                 }
01339                                         } else {
01340                                                 //debug($lc,1);
01341                                         }
01342                                 }
01343                         }
01344                         if (!strcmp($lc,'$TYPO3_CONF_VARS = Array('))   {
01345                                 $in=1;
01346                         }
01347                 }
01348                 return array($mainArray,$commentArray);
01349         }
01350 
01351 
01352 
01353 
01354 
01355 
01356 
01357 
01358 
01359 
01360 
01361 
01362 
01363         /*******************************
01364          *
01365          * CHECK CONFIGURATION FUNCTIONS
01366          *
01367          *******************************/
01368 
01374         function checkConfiguration()   {
01375                 $ext="php.ini configuration checked";
01376                 $this->message($ext);
01377 
01378                         // *****************
01379                         // Incoming values:
01380                         // *****************
01381 /*
01382                 if (!ini_get("track_vars"))     {
01383                         $this->message($ext, "Tracking Vars not set","
01384                                 <i>track_vars=".ini_get("track_vars")."</i>
01385                                 Tracking vars are essential for almost any PHP-application.
01386                                 The fact that the value is not set may not impose a problem, because it's always set in version 4.03+ of PHP.
01387                         ",1);
01388                 } else $this->message($ext, "Tracking Vars enabled","",-1);
01389 */
01390 /*
01391                 if (!ini_get("allow_url_fopen"))        {
01392                         $this->message($ext, "fopen() not allowed to open URL's","
01393                                 <i>allow_url_fopen=".ini_get("allow_url_fopen")."</i>
01394                                 allow_url_fopen should be enabled if you want TYPO3 to connect to the online TYPO3 Extension Repository.
01395                         ",2);
01396                 } else $this->message($ext, "fopen() allowed to open URL's","",-1);
01397 */
01398 
01399                         // Includepath
01400                 $incPaths = t3lib_div::trimExplode(TYPO3_OS=="WIN"?";":":", ini_get("include_path"));
01401                 if (!in_array(".",$incPaths))   {
01402                         $this->message($ext, "Current dir (./) is not in include path!","
01403                                 <i>include_path=".ini_get("include_path")."</i>
01404                                 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.
01405                         ",1);
01406                 } else $this->message($ext, "Current dir in include path","",-1);
01407 
01408 /*
01409                 if (!ini_get("register_globals"))       {
01410                         $this->message($ext, "Register globals disabled","
01411                                 <i>register_globals=".ini_get("register_globals")."</i>
01412                                 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.
01413                                 You should always use the function t3lib_div::_GP(\"<i>[the_var_name_from_GET_or_POST]</i>\") to retrieve values passed to your script from outside.
01414                         ",1);
01415                 } else $this->message($ext, "Register globals enabled","You should always use the function t3lib_div::_GP(\"<i>[the_var_name_from_GET_or_POST]</i>\") to retrieve values passed to your script from outside.",1);
01416                 if (!ini_get("magic_quotes_gpc"))       {
01417                         $this->message($ext, "magic_quotes_gpc","
01418                                 <i>magic_quotes_gpc=".ini_get("magic_quotes_gpc")."</i>
01419                                 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.
01420                         ",1);
01421                 } else $this->message($ext, "magic_quotes_gpc","<i>magic_quotes_gpc=".ini_get("magic_quotes_gpc")."</i>",-1);
01422                 if (ini_get("magic_quotes_runtime"))    {
01423                         $this->message($ext, "Magic Quotes Runtime is enabled","
01424                                 <i>magic_quotes_runtime=".ini_get("magic_quotes_runtime")."</i>
01425                                 TYPO3 is depending on this option NOT being enabled!
01426                         ",3);
01427                 } else $this->message($ext, "magic_quotes_runtime","<i>magic_quotes_runtime=".ini_get("magic_quotes_runtime")."</i>",-1);
01428                 if (ini_get("gpc_order")!="GPC")        {
01429                         $this->message($ext, "GPC order non-standard","
01430                                 <i>gpc_order=".ini_get("gpc_order")."</i>
01431                                 The order of GET, POST and COOKIE vars are non-standard. The value should be \"GPC\".
01432                         ",2);
01433                 } else $this->message($ext, "GPC order","",-1);
01434 */
01435                         // *****************
01436                         // File uploads
01437                         // *****************
01438                 if (!ini_get("file_uploads"))   {
01439                         $this->message($ext, "File uploads not allowed","
01440                                 <i>file_uploads=".ini_get("file_uploads")."</i>
01441                                 TYPO3 uses the ability to upload files from the browser in various cases.
01442                                 As long as this flag is disabled, you'll not be able to upload files.
01443                                 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!
01444                                 However if you cannot enable fileupload for some reason alternatively you change the default form encoding value with \$TYPO3_CONF_VARS[SYS][form_enctype].
01445                         ",3);
01446                 } else $this->message($ext, "File uploads allowed","",-1);
01447                 $upload_max_filesize = $this->convertByteSize(ini_get("upload_max_filesize"));
01448                 if ($upload_max_filesize<10000*1024)    {
01449                         $this->message($ext, "Max Upload filesize too small?","
01450                                 <i>upload_max_filesize=".ini_get("upload_max_filesize")."</i>
01451                                 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]).
01452                                 Your current value is below this, so at this point, PHP sets the limits for uploaded filesizes and not TYPO3.
01453                                 <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.
01454                         ",1);
01455                 }
01456 
01457                         // *****************
01458                         // Memory and functions
01459                         // *****************
01460                 $memory_limit_value = $this->convertByteSize(ini_get("memory_limit"));
01461                 if ($memory_limit_value&&$memory_limit_value<16*1024*1024)      {
01462                         $this->message($ext, "Memory Limit below 16 MB","
01463                                 <i>memory_limit=".ini_get("memory_limit")."</i>
01464                                 Your system is configured to enforce a memory limit of PHP scripts lower than 16 MB. The Extension Manager needs to include more PHP-classes than will fit into this memory space. There is nothing else to do than raise the limit. To be safe, ask the system administrator of the webserver to raise the limit to over 25 MB.
01465                         ",3);
01466                 } elseif(!$memory_limit_value) {
01467                         $this->message($ext, "Memory Limit","<i>No Memory Limit in effect.</i>",-1);
01468                 } else $this->message($ext, "Memory Limit","<i>memory_limit=".ini_get("memory_limit")."</i>",-1);
01469                 if (ini_get("max_execution_time")<30)   {
01470                         $this->message($ext, "Max Execution Time below default 30 seconds","
01471                                 <i>max_execution_time=".ini_get("max_execution_time")."</i>
01472                                 May impose problems if too low.
01473                         ",1);
01474                 } else $this->message($ext, "Max Execution Time","<i>max_execution_time=".ini_get("max_execution_time")."</i>",-1);
01475                 if (ini_get("disable_functions"))       {
01476                         $this->message($ext, "Functions disabled!","
01477                                 <i>disable_functions=".ini_get("disable_functions")."</i>
01478                                 The above list of functions are disabled. If TYPO3 use any of these there might be trouble.
01479                                 TYPO3 is designed to use the default set of PHP4.0.6+ functions plus the functions from GDLib.
01480                                 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.
01481                         ",2);
01482                 } else $this->message($ext, "Functions disabled: none","",-1);
01483                 if (!ini_get("sendmail_path"))  {
01484                         $this->message($ext, "Sendmail path not defined!","
01485                                 <i>sendmail_path=".ini_get("sendmail_path")."</i>
01486                                 This may be critical to TYPO3's use of the mail() function. Please be sure that the mail() function in your php-installation works!
01487                         ".$this->check_mail("get_form"),1);
01488                 } else {
01489                         list($prg) = explode(" ",ini_get("sendmail_path"));
01490                         if (TYPO3_OS=='WIN')    {
01491                                 $this->message($ext, "Sendmail program not searched for on Windows","",1);
01492                         } else {
01493                                 if (!@is_executable($prg))      {
01494                                         $this->message($ext, "Sendmail program not found or not executable?","
01495                                                 <i>sendmail_path=".ini_get("sendmail_path")."</i>
01496                                                 This may be critical to TYPO3's use of the mail() function. Please be sure that the mail() function in your php-installation works!
01497                                         ".$this->check_mail("get_form"),1);
01498                                 } else {
01499                                         $this->message($ext, "Sendmail OK","
01500                                                 <i>sendmail_path=".ini_get("sendmail_path")."</i>
01501                                                 You may check the mail() function by entering your emailaddress here:
01502                                         ".$this->check_mail("get_form"),-1);
01503                                 }
01504                         }
01505                 }
01506 
01507                         // *****************
01508                         // Safe mode related
01509                         // *****************
01510                 if (ini_get("safe_mode"))       {
01511                         $this->message($ext, "Safe mode turned on","
01512                                 <i>safe_mode=".ini_get("safe_mode")."</i>
01513                                 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.
01514                                 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/\".
01515                                 If you use safe_mode with TYPO3, you should disable use of external programs ([BE][disable_exec_function]=1).
01516                                 In safe mode you must ensure that all the php-scripts and upload folders are owned by the same user.
01517 
01518                                         <i>safe_mode_exec_dir=".ini_get("safe_mode_exec_dir")."</i>
01519                                         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)
01520 
01521 
01522                                         <strong>Example of safe_mode settings:</strong>
01523                                         Set this in the php.ini file:
01524 
01525                                         ; Safe Mode
01526                                         safe_mode               =       On
01527                                         safe_mode_exec_dir      = /usr/bin/
01528 
01529                                         ...and the ImageMagick '/usr/bin/convert' will be executable.
01530                                         The last slash is important (..../) and you can only specify one directory.
01531 
01532                                         <strong>Notice: </strong>
01533                                         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.
01534                                         Paths to ImageMagick are defined in localconf.php and may be something else than /usr/bin/, but this is default for ImageMagick 5+
01535 
01536 
01537                         ",2);
01538                         if (ini_get("doc_root"))        {
01539                                 $this->message($ext, "doc_root set","
01540                                         <i>doc_root=".ini_get("doc_root")."</i>
01541                                         PHP cannot execute scripts outside this directory. If that is a problem is please correct it.
01542                                 ",1);
01543                         }
01544                         $this->config_array["safemode"]=1;
01545                 } else $this->message($ext, "safe_mode: off","",-1);
01546                 if (ini_get("sql.safe_mode"))   {
01547                         $this->message($ext, "sql.safe_mode is enabled","
01548                                 <i>sql.safe_mode=".ini_get("sql.safe_mode")."</i>
01549                                 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")."
01550                                 The owner of the current file is: <strong>".get_current_user ()."</strong>
01551                         ",1);
01552                         $this->config_array["sql.safe_mode_user"] = get_current_user();
01553                 } else $this->message($ext, "sql.safe_mode: off","",-1);
01554                 if (ini_get("open_basedir"))    {
01555                         $this->message($ext, "open_basedir set","
01556                                 <i>open_basedir=".ini_get("open_basedir")."</i>
01557                                 This restricts TYPO3 to open and include files only in this path. Please make sure that this does not prevent TYPO3 from running.
01558                                 <strong>Notice (UNIX):</strong> Before checking a path according to open_basedir, PHP resolves all symbolic links.
01559                         ",1);
01560 //      ????                    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.
01561                 } else $this->message($ext, "open_basedir: off","",-1);
01562 
01563         }
01564 
01571         function check_mail($cmd="")    {
01572                 switch($cmd)    {
01573                         case "get_form":
01574                                 $out='
01575                                 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.
01576                                 <form action="'.$this->action.'" method="POST"><input type="text" name="TYPO3_INSTALL[check_mail]">
01577                                         <input type="submit" value="Send test mail"></form>';
01578                         break;
01579                         default:
01580                                 if (trim($this->INSTALL["check_mail"])) {
01581                                         mail(trim($this->INSTALL["check_mail"]), "TEST SUBJECT", "TEST CONTENT", "From: test@test.test");
01582                                         $this->messages[]= "MAIL WAS SENT TO: ".$this->INSTALL["check_mail"];
01583                                 }
01584                         break;
01585                 }
01586                 return $out;
01587         }
01588 
01594         function checkExtensions()      {
01595                 $ext = "GDLib";
01596                 $this->message($ext);
01597 
01598                 $software_info=1;
01599                 if (extension_loaded("gd") && $this->isGD())    {
01600                         $this->config_array["gd"]=1;
01601                         $this->message($ext, "GDLib found","",-1);
01602                         if ($this->isPNG()) {
01603                                 $this->config_array["gd_png"]=1;
01604                                 $this->message($ext, "PNG supported","",-1);
01605                         }
01606                         if ($this->isGIF()) {
01607                                 $this->config_array["gd_gif"]=1;
01608                                 $this->message($ext, "GIF supported","",-1);
01609                         }
01610                         if ($this->isJPG()) {
01611                                 $this->config_array["gd_jpg"]=1;
01612                                 $this->message($ext, "JPG supported (not used by TYPO3)","");
01613                         }
01614                         if (!$this->config_array["gd_gif"] && !$this->config_array["gd_png"])   {
01615                                 $this->message($ext, "PNG or GIF not supported", nl2br(trim("
01616                                         Your GDLib supports either GIF nor PNG. It must support either one of them.
01617                                 ")), 2);
01618                         } else {
01619                                 $msg=array();
01620                                 if ($this->config_array["gd_gif"] && $this->config_array["gd_png"])             {
01621                                         $msg[0]="You can choose between generating GIF or PNG files, as your GDLib supports both.";
01622                                 }
01623                                 if ($this->config_array["gd_gif"])              {
01624                                         $msg[10]="You should watch out for the generated size of the GIF-files because some versions of the GD library do not compress them with LZW, but RLE and ImageMagick is subsequently used to compress with LZW. But in the case of ImageMagick failing this task (eg. not being compiled with LZW which is the case with some versions) you'll end up with GIF-filesizes all too big!
01625                                         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.";
01626                                 }
01627                                 if ($this->config_array["gd_png"])              {
01628                                         $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.";
01629                                 }
01630                                 $this->message($ext, "GIF / PNG issues", nl2br(trim(implode($msg,chr(10)))), 1);
01631                         }
01632                         if (!$this->isTTF())    {
01633                                 $this->message($ext, "FreeType is apparently not installed", "
01634                                         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'.
01635                                 ", 2);
01636                         } else {
01637                                 $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);
01638                                 $this->config_array["freetype"]=1;
01639                         }
01640                 } else {
01641                         $this->message($ext, "GDLib not found", "
01642                                 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.
01643                                 GDLib is also used in the TYPO3 Backend (TBE) to generate record icons and new module tabs.
01644                                 It's highly recommended to install this library. Remember to compile GD with FreeType which is also required.
01645                                 If you choose not to install GDLib, you can disable it in the configuration with [GFX][gdlib]=0;.
01646                         ", 2);
01647                 }
01648                 $this->message($ext, "GDLib software information", nl2br(trim($this->getGDSoftwareInfo())));
01649         }
01650 
01656         function checkDirs()    {
01657                 // Check typo3/temp/
01658                 $ext="Directories";
01659                 $this->message($ext);
01660 
01661                 $uniqueName = md5(uniqid(microtime()));
01662 
01663                         // The requirement level (the integer value, ie. the second value of the value array) has the following meanings:
01664                         // -1 = not required, but if it exists may be writable or not
01665                         //  0 = not required, if it exists the dir should be writable
01666                         //  1 = required, don't has to be writable
01667                         //  2 = required, has to be writable
01668 
01669                 $checkWrite=array(
01670                         "typo3temp/" => array("The folder is used by both the frontend (FE) and backend interface (TBE) for image manipulated files.",2,"dir_typo3temp"),
01671 #                       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"),
01672                         "typo3conf/" => array("This directory contains the local configuration files of your website. TYPO3 must be able to write to these configuration files during setup and when the Extension Manager (EM) installs extensions.",2),
01673                         "typo3conf/ext/" => array("Location for local extensions. Must be writable if the Extension Manager is supposed to install extensions for this website.",0),
01674                         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),
01675                         "uploads/" => array("Location for uploaded files from RTE + in the subdirs for tables.",2),
01676                         "uploads/pics/" => array("Typical location for uploaded files (images especially).",0),
01677                         "uploads/media/" => array("Typical location for uploaded files (non-images especially).",0),
01678                         "uploads/tf/" => array("Typical location for uploaded files (TS template resources).",0),
01679                         "fileadmin/" => array("Location for local files such as templates, independent uploads etc.",-1),
01680                         "fileadmin/_temp_/" => array("Typical temporary location for default upload of files by administrators.",0),
01681                 );
01682 
01683                 reset($checkWrite);
01684                 while(list($relpath,$descr)=each($checkWrite))  {
01685                         // Check typo3temp/
01686                         $general_message = $descr[0];
01687                         if (!@is_dir(PATH_site.$relpath))       {
01688                                 if ($descr[1])  {       // required...
01689                                         $this->message($ext, $relpath." directory does not exist","
01690                                         <em>Full path: ".PATH_site.$relpath."</em>
01691                                         ".$general_message."
01692 
01693                                         This error should not occur as ".$relpath." must always be accessible in the root of a TYPO3 website.
01694                                         ",3);
01695                                 } else {
01696                                         if ($descr[1] == 0) {
01697                                                 $msg = 'This directory does not necessarily have to exist but if it does it must be writable.';
01698                                         } else {
01699                                                 $msg = 'This directory does not necessarily have to exist and if it does it can be writable or not.';
01700                                         }
01701                                         $this->message($ext, $relpath." directory does not exist","
01702                                         <em>Full path: ".PATH_site.$relpath."</em>
01703                                         ".$general_message."
01704 
01705                                         ".$msg."
01706                                         ",2);
01707                                 }
01708                         } else {
01709                                 $file = PATH_site.$relpath.$uniqueName;
01710                                 @touch($file);
01711                                 if (@is_file($file))    {
01712                                         unlink($file);
01713                                         if ($descr[2])  { $this->config_array[$descr[2]]=1; }
01714                                         $this->message($ext, $relpath." writable","",-1);
01715                                 } else {
01716                                         $severity = ($descr[1]==2 || $descr[1]==0) ? 3 : 2;
01717                                         if ($descr[1] == 0 || $descr[1] == 2) {
01718                                                 $msg = "The directory ".$relpath." must be writable!";
01719                                         } elseif ($descr[1] == -1 || $descr[1] == 1) {
01720                                                 $msg = "The directory ".$relpath." does not neccesarily have to be writable.";
01721                                         }
01722                                         $this->message($ext, $relpath." directory not writable","
01723                                         <em>Full path: ".$file."</em>
01724                                         ".$general_message."
01725 
01726                                         Tried to write this file (with touch()) but didn't succeed.
01727                                         ".$msg."
01728                                         ",$severity);
01729                                 }
01730                         }
01731                 }
01732         }
01733 
01742         function checkImageMagick($paths)       {
01743                 $ext="Check Image Magick";
01744                 $this->message($ext);
01745 
01746                 $paths = array_unique($paths);
01747 
01748                 $programs = explode(",","convert,combine,composite,identify");  // Added composite (substitution for combine in newer versions?)
01749                 $isExt = TYPO3_OS=="WIN" ? ".exe" : "";
01750                 $this->config_array["im_combine_filename"]="combine";
01751                 reset($paths);
01752                 while(list($k,$v)=each($paths)) {
01753                         reset($programs);
01754                         if (!ereg('[\\\/]$',$v)) $v.='/';
01755                         while(list(,$filename)=each($programs)) {
01756                                 if (ini_get("open_basedir")||(@file_exists($v)&& @is_file($v.$filename.$isExt))) {
01757                                         if($this->_checkImageMagick_getVersion($v.$filename.$isExt) > 0 ) {
01758                                                 $index[$v][$filename]=$this->_checkImageMagick_getVersion($v.$filename.$isExt);
01759                                         }
01760                                 }
01761                         }
01762                         if (count($index[$v])>=3)       {$this->config_array["im"]=1;}
01763 
01764                         if ($index[$v]["composite"] && !$index[$v]["combine"])  {
01765                                 $this->config_array["im_combine_filename"]="composite";
01766                         } elseif (!$index[$v]["composite"] && $index[$v]["combine"]) {
01767                                 $this->config_array["im_combine_filename"]="combine";
01768                         }
01769 
01770                         if (isset($index[$v]["convert"]) && $this->checkIMlzw)  {
01771                                 $index[$v]["gif_capability"] = "".$this->_checkImageMagickGifCapability($v);
01772                         }
01773                 }
01774                 $this->config_array["im_versions"]=$index;
01775                 if (!$this->config_array["im"]) {
01776                         $this->message($ext, "No ImageMagick install available","
01777                         It seems that there is no adequate ImageMagick installation available at the checked locations (".implode($paths, ", ").")
01778                         An 'adequate' installation for requires 'convert', 'combine'/'composite' and 'identify' to be available
01779                         ",2);
01780                 } else {
01781                         $theCode="";
01782                         reset($this->config_array["im_versions"]);
01783                         while(list($p,$v)=each($this->config_array["im_versions"]))     {
01784                                 $ka=array();
01785                                 reset($v);
01786                                 while(list($ka[])=each($v)){}
01787                                 $theCode.='<tr><td>'.$this->fw($p).'</td><td>'.$this->fw(implode($ka,"<BR>")).'</td><td>'.$this->fw(implode($v,"<BR>")).'</td></tr>';
01788                         }
01789                         $this->message($ext, "Available ImageMagick installations:",'<table border=1 cellpadding=2 cellspacing=2>'.$theCode.'</table>',-1);
01790                 }
01791                 $this->message($ext, "Search for ImageMagick:",'
01792                         <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.
01793 
01794                                 Check this path for ImageMagick installation:
01795                                 <input type="text" name="TYPO3_INSTALL[checkIM][path]" value="'.htmlspecialchars($this->INSTALL["checkIM"]["path"]).'">
01796                                 (Eg. "D:\wwwroot\im537\ImageMagick\" for windows or "/usr/bin/" for Unix)<br>
01797 
01798                                 <input type="submit" value="Send">
01799                         </form>
01800                 ',0);
01801 
01802         }
01803 
01810         function _checkImageMagickGifCapability($file)  {
01811                 if ($this->config_array["dir_typo3temp"])       {               //  && !$this->config_array["safemode"]
01812                         $path = $this->typo3temp_path;
01813                         $uniqueName = md5(uniqid(microtime()));
01814                         $dest = $path.$uniqueName.".gif";
01815                         $src = PATH_t3lib."gfx/typo3logo.gif";
01816                         if (@is_file($src) && !strstr($src," ") && !strstr($dest," "))  {
01817                                 $cmd = $file.'convert '.$src.' '.$dest;
01818                                 exec($cmd);
01819                         } else die("No t3lib/gfx/typo3logo.gif file!");
01820                         $out="";
01821                         if (@is_file($dest))    {
01822                                 $new_info = @getimagesize($dest);
01823                                 clearstatcache();
01824                                 $new_size = filesize($dest);
01825                                 $src_info = @getimagesize($src);
01826                                 clearstatcache();
01827                                 $src_size = @filesize($src);
01828 
01829                                 if ($new_info[0]!=$src_info[0] || $new_info[1]!=$src_info[1] || !$new_size || !$src_size)       {
01830                                         $out="error";
01831                                 } else {
01832                                         if ($new_size/$src_size > 4) {  // NONE-LZW ratio was 5.5 in test
01833                                                 $out="NONE";
01834                                         } elseif ($new_size/$src_size > 1.5) {  // NONE-RLE ratio was not tested
01835                                                 $out="RLE";
01836                                         } else {
01837                                                 $out="LZW";
01838                                         }
01839                                 }
01840                                 unlink($dest);
01841                         }
01842                         return $out;
01843                 }
01844         }
01845 
01852         function _checkImageMagick_getVersion($file)    {
01853                 exec($file, $retVal);
01854                 $string = $retVal[0];
01855                 list(,$ver) = explode("ImageMagick", $string);
01856                 list($ver) = explode(" ",trim($ver));
01857                 return trim($ver);
01858         }
01859 
01865         function checkDatabase()                {
01866                 $ext="Check database";
01867                 $this->message($ext);
01868 
01869                 if (!extension_loaded("mysql")) {
01870                         $this->message($ext, "MySQL not available","
01871                                 PHP does not feature MySQL support (which is pretty unusual).
01872                         ",2);
01873                 } else {
01874                         $cInfo="
01875                                 Username: <strong>".TYPO3_db_username."</strong>
01876                                 Password: <strong>".TYPO3_db_password."</strong>
01877                                 Host: <strong>".TYPO3_db_host."</strong>
01878                         ";
01879                         if (!TYPO3_db_host || !TYPO3_db_username)       {
01880                                 $this->message($ext, "Username, password or host not set","
01881                                         You may need to enter data for these values:
01882                                         ".trim($cInfo)."
01883 
01884                                         Use the form below.
01885                                 ",2);
01886                         }
01887                         if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))  {
01888                                 $this->message($ext, "Connected to SQL database successfully","
01889                                 ".trim($cInfo)."
01890                                 ",-1,1);
01891                                 $this->config_array["mysqlConnect"]=1;
01892                                 if (!TYPO3_db)  {
01893                                         $this->message($ext, "No database selected","
01894                                                 Currently you have no database selected.
01895                                                 Please select one or create a new database.
01896                                         ",3);
01897                                         $this->config_array["no_database"]=1;
01898                                 } elseif (!$GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db))  {
01899                                         $this->message($ext, "Database","
01900                                                 '".TYPO3_db."' could not be selected as database!
01901                                                 Please select another one or create a new database.
01902                                         ",3,1);
01903                                         $this->config_array["no_database"]=1;
01904                                 } else  {
01905                                         $this->message($ext, "Database","
01906                                                 <strong>".TYPO3_db."</strong> is selected as database.
01907                                         ",1,1);
01908                                 }
01909                         } else {
01910                                 $this->message($ext, "Could not connect to SQL database!","
01911                                 Connecting to SQL database failed with these settings:
01912                                 ".trim($cInfo)."
01913 
01914                                 Make sure you're using the correct set of data.".($this->config_array["sql.safe_mode_user"]? "
01915                                 <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"]."'":"")."
01916                                 ",3);
01917                         }
01918                 }
01919         }
01920 
01927         function setupGeneral($cmd="")  {
01928                 switch($cmd)    {
01929                         case "get_form":
01930                                         // Database:
01931                                 $out='
01932                                 <table border=0 cellpadding=0 cellspacing=0>
01933                                 <form action="'.$this->action.'" method="POST">';
01934 
01935                                 $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>":""));
01936                                 $out.=$this->wrapInCells("Password:", '<input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_password]" value="'.htmlspecialchars(TYPO3_db_password).'">');
01937                                 $out.=$this->wrapInCells("Host:", '<input type="text" name="TYPO3_INSTALL[localconf.php][typo_db_host]" value="'.htmlspecialchars(TYPO3_db_host).'">');
01938                                 if ($this->config_array["mysqlConnect"])        {
01939                                         $dbArr = $this->getDatabaseList();
01940                                         reset($dbArr);
01941                                         $options="";
01942                                         $dbIncluded=0;
01943                                         while(list(,$dbname)=each($dbArr))      {
01944                                                 $options.='<option value="'.htmlspecialchars($dbname).'"'.($dbname==TYPO3_db?' selected':'').'>'.htmlspecialchars($dbname).'</option>';
01945                                                 if ($dbname==TYPO3_db)  $dbIncluded=1;
01946                                         }
01947                                         if (!$dbIncluded && TYPO3_db)   {
01948                                                 $options.='<option value="'.htmlspecialchars(TYPO3_db).'" selected>'.htmlspecialchars(TYPO3_db).' (NO ACCESS!)</option>';
01949                                         }
01950                                         $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="">';
01951                                 } else {
01952                                         $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).'">';
01953                                 }
01954                                 $out.=$this->wrapInCells("", "<BR>");
01955                                 $out.=$this->wrapInCells("Database:", $theCode);
01956                                 $out.=$this->wrapInCells("", "<BR>");
01957 
01958                                 if ($this->mode!="123") {
01959                                         $out.=$this->wrapInCells("Site name:", '<input type="text" name="TYPO3_INSTALL[localconf.php][sitename]" value="'.htmlspecialchars($GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"]).'">');
01960                                         $out.=$this->wrapInCells("", "<BR>");
01961 
01962                                                 // Other
01963                                         $fA = $this->setupGeneralCalculate();
01964         //                              debug($fA);
01965                                         if (is_array($fA["disable_exec_function"]))     {
01966                                                 $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"]));
01967                                         }
01968                                         if (is_array($fA["gdlib"]))     {
01969                                                 $out.=$this->wrapInCells("[GFX][gdlib]=", $this->getFormElement($fA["gdlib"], $fA["gdlib"], 'TYPO3_INSTALL[localconf.php][gdlib]', $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib"]));
01970                                                 if (is_array($fA["gdlib_png"]) && $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib"])  {
01971                                                         $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"]));
01972                                                 }
01973                                         }
01974                                         if (is_array($fA["im"]))        {
01975                                                 $out.=$this->wrapInCells("[GFX][im]=", $this->getFormElement($fA["im"], $fA["im"], 'TYPO3_INSTALL[localconf.php][im]', $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im"]));
01976                                                 $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"]));
01977                                                 if ($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im"])   {
01978                                                         if (is_array($fA["im_path"]))   {
01979                                                                 $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"]));
01980                                                         }
01981                                                         if (is_array($fA["im_path_lzw"]))       {
01982                                                                 $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"]));
01983                                                         }
01984                                                 }
01985                                         }
01986                                 }
01987 
01988 
01989                                 $out.=$this->wrapInCells("", '<BR><input type="submit" value="Update localconf.php"><BR>
01990                                 <strong>NOTICE: </strong>By clicking this button, localconf.php is updated with new values for the parameters listed above!');
01991                                 $out.='
01992                                 </form>
01993                                 </table>';
01994                         break;
01995                         default:
01996                                 if (is_array($this->INSTALL["localconf.php"]))          {
01997                                         $errorMessages=array();
01998                                         $lines = $this->writeToLocalconf_control();
01999 
02000                                                 // New database?
02001 #debug($this->INSTALL);
02002                                         if (trim($this->INSTALL["localconf.php"]["NEW_DATABASE_NAME"])) {
02003                                                 $newdbname=trim($this->INSTALL["localconf.php"]["NEW_DATABASE_NAME"]);
02004                                                 if (!ereg("[^[:alnum:]_-]",$newdbname)) {
02005                                                         if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))  {
02006                                                                 if ($GLOBALS['TYPO3_DB']->admin_query('CREATE DATABASE '.$newdbname)) {
02007                                                                         $this->INSTALL["localconf.php"]["typo_db"] = $newdbname;
02008                                                                         $this->messages[]= "Database '".$newdbname."' created";
02009                                                                 } else $this->messages[]= $errorMessages[] = "Could not create database '".$newdbname."' (...not created)";
02010                                                         } else $this->messages[]= $errorMessages[] = "Could not connect to database when creating database '".$newdbname."' (...not created)";
02011                                                 } else $this->messages[]= $errorMessages[] = "The NEW database name '".$newdbname."' was not alphanumeric, a-zA-Z0-9_- (...not created)";
02012                                         }
02013 #debug($this->messages)         ;
02014                                                 // Parsing values
02015                                         reset($this->INSTALL["localconf.php"]);
02016                                         while(list($key,$value)=each($this->INSTALL["localconf.php"]))          {
02017                                                 switch((string)$key)    {
02018                                                         case "typo_db_username":
02019                                                                 if (strlen($value)<50)  {
02020                                                                         if (strcmp(TYPO3_db_username,$value))           $this->setValueInLocalconfFile($lines, '$typo_db_username', trim($value));
02021                                                                 } else $this->messages[]= $errorMessages[] = "Username '".$value."' was longer than 50 chars (...not saved)";
02022                                                         break;
02023                                                         case "typo_db_password":
02024                                                                 if (strlen($value)<50)  {
02025                                                                         if (strcmp(TYPO3_db_password,$value))           $this->setValueInLocalconfFile($lines, '$typo_db_password',  trim($value));
02026                                                                 } else $this->messages[]= $errorMessages[] = "Password '".$value."' was longer than 50 chars (...not saved)";
02027                                                         break;
02028                                                         case "typo_db_host":
02029                                                                 if (!ereg("[^[:alnum:]_\.-]",$value) && strlen($value)<50)      {
02030                                                                         if (strcmp(TYPO3_db_host,$value))               $this->setValueInLocalconfFile($lines, '$typo_db_host', $value);
02031                                                                 } else $this->messages[]= $errorMessages[] = "Host '".$value."' was not alphanumeric, a-zA-Z0-9_-., or longer than 50 chars (...not saved)";
02032                                                         break;
02033                                                         case "typo_db":
02034                                                                 if (strlen($value)<50)  {
02035                                                                         if (strcmp(TYPO3_db,$value))            $this->setValueInLocalconfFile($lines, '$typo_db',  trim($value));
02036                                                                 } else $this->messages[]= $errorMessages[] = "Database name '".$value."' was longer than 50 chars (...not saved)";
02037                                                         break;
02038                                                         case "disable_exec_function":
02039                                                                 if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["BE"]["disable_exec_function"],$value))  $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["BE"]["disable_exec_function"]', $value?1:0);
02040                                                         break;
02041                                                         case "sitename":
02042                                                                 if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"],$value))      $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["SYS"]["sitename"]', $value);
02043                                                         break;
02044                                                         case "im_combine_filename":
02045                                                                 if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_combine_filename"],$value))   $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["GFX"]["im_combine_filename"]', $value);
02046                                                         break;
02047                                                         case "gdlib":
02048                                                         case "gdlib_png":
02049                                                         case "im":
02050                                                                 if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["GFX"][$key],$value))    $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["GFX"]["'.$key.'"]', $value?1:0);
02051                                                         break;
02052                                                         case "im_path":
02053                                                                 list($value,$version) = explode("|",$value);
02054                                                                 if (!ereg("[[:space:]]",$value,$reg) && strlen($value)<100)     {
02055                                                                         if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["GFX"][$key],$value))    {
02056                                                                                 $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["GFX"]["'.$key.'"]', $value);
02057                                                                         }
02058                                                                         $value_ext = (doubleval($version)<5)?0:1;
02059                                                                         if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_version_5"],$value_ext))      {
02060                                                                                 $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["GFX"]["im_version_5"]', $value_ext);
02061                                                                         }
02062                                                                 } else $this->messages[]= $errorMessages[] = "Path '".$value."' contains spaces or is longer than 100 chars (...not saved)";
02063                                                         break;
02064                                                         case "im_path_lzw":
02065                                                                 list($value) = explode("|",$value);
02066                                                                 if (!ereg("[[:space:]]",$value) && strlen($value)<100)  {
02067                                                                         if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["GFX"][$key],$value))    $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["GFX"]["'.$key.'"]', $value);
02068                                                                 } else $this->messages[]= $errorMessages[] = "Path '".$value."' contains spaces or is longer than 100 chars (...not saved)";
02069                                                         break;
02070                                                 }
02071 
02072 
02073                                         }
02074 
02075                                         if (count($errorMessages))      {
02076                                                 echo "<H3>ERRORS</H3>";
02077                                                 echo t3lib_div::view_array($errorMessages);
02078                                                 echo 'Click the browsers "Back" button to reenter the values.';
02079                                                 exit;
02080                                         }
02081                                         $this->writeToLocalconf_control($lines);
02082                                 }
02083                         break;
02084                 }
02085                 return $out;
02086         }
02087 
02094         function writeToLocalconf_control($lines="")    {
02095                 $returnVal = parent::writeToLocalconf_control($lines);
02096 
02097                 switch($returnVal)      {
02098                         case 'continue':
02099                                 $content = "<BR><BR>".implode($this->messages,"<HR>").'<BR><BR><a href="'.$this->action.'">Click to continue...</a>';
02100                                 $this->outputExitBasedOnStep($content);
02101                         break;
02102                         case 'nochange':
02103                                 $content = '<strong>Writing to \'localconf.php\':</strong><BR><BR>No values were changed, so nothing is updated!<BR><BR><a href="'.$this->action.'">Click to continue...</a>';
02104                                 $this->outputExitBasedOnStep("<BR>".$content);
02105                         break;
02106                 }
02107 
02108                 return $returnVal;
02109         }
02110 
02117         function outputExitBasedOnStep($content)        {
02118                 if ($this->step)        {
02119                         Header("Location: ".t3lib_div::locationHeaderUrl($this->action));
02120                 } else {
02121                         echo $this->outputWrapper($content);
02122                 }
02123                 exit;
02124         }
02125 
02133         function setLabelValueArray($arr,$type) {
02134                 reset($arr);
02135                 while(list($k,$v)=each($arr))   {
02136                         switch($type)   {
02137                                 case 0: // value, im
02138                                         $arr[$k].="|".$this->config_array["im_versions"][$v]["convert"];
02139                                 break;
02140                                 case 1: // labels, im
02141                                         $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"]:"").")" : "";
02142                                 break;
02143                                 case 2: // labels, gd
02144                                         $arr[$k].=" (".($v==1?"PNG":"GIF").")";
02145                                 break;
02146                         }
02147                 }
02148                 return $arr;
02149         }
02150 
02161         function getFormElement($labels,$values,$fieldName,$default,$msg="")    {
02162                 $out.='<strong>'.htmlspecialchars(current($labels)).'</strong><BR>current value is '.htmlspecialchars($default).($msg?"<BR>".$msg:"");
02163                 if (count($labels)>1)           {
02164                         reset($labels);
02165                         while(list($k,$v)=each($labels))        {
02166                                 list($cleanV) =explode("|",$values[$k]);
02167                                 $options.='<option value="'.htmlspecialchars($values[$k]).'"'.(!strcmp($default,$cleanV)?" selected":"").'>'.htmlspecialchars($v).'</option>';
02168                         }
02169                         $out.='<BR><select name="'.$fieldName.'">'.$options.'</select>';
02170                 } else {
02171                         $out.='<input type="hidden" name="'.$fieldName.'" value="'.htmlspecialchars(current($values)).'">';
02172                 }
02173                 return $out."<BR>";
02174         }
02175 
02181         function getDatabaseList()      {
02182                 $dbArr=array();
02183                 if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password))  {
02184                         $dbArr = $GLOBALS['TYPO3_DB']->admin_get_dbs();
02185                 }
02186                 return $dbArr;
02187         }
02188 
02205         function setupGeneralCalculate()        {
02206                 $formArray["disable_exec_function"]=array(0);
02207                 $formArray["im_path"]=array("");
02208                 $formArray["im_path_lzw"]=array("");
02209                 $formArray["im_combine_filename"]=array("");
02210                 $formArray["im"]=array(1);
02211                 $formArray["gdlib"]=array(1);
02212                 if ($this->config_array["gd"] && ($this->config_array["gd_gif"] || $this->config_array["gd_png"]))      {
02213                         if ($this->config_array["gd_gif"] && !$this->config_array["gd_png"])    {
02214                                 $formArray["gdlib_png"]=array(0);
02215                         } elseif (!$this->config_array["gd_gif"] && $this->config_array["gd_png"])      {
02216                                 $formArray["gdlib_png"]=array(1);
02217                         } else {
02218                                 $formArray["gdlib_png"]=array(0,1);
02219                         }
02220                 } else {
02221                         $formArray["gdlib"]=array(0);
02222                 }
02223                 if ($this->config_array["safemode"])    {
02224                         $formArray["disable_exec_function"]=array(1);
02225                 }
02226                 if ($this->config_array["im"])  {
02227                         $formArray["im"]=array(1);
02228                         $LZW_found=0;
02229                         $found=0;
02230                         reset($this->config_array["im_versions"]);
02231                         $totalArr=array();
02232                         while(list($path,$dat)=each($this->config_array["im_versions"]))        {
02233                                 if (count($dat)>=3)     {
02234                                         if (doubleval($dat["convert"])<5)       {
02235                                                 if ($dat["gif_capability"]=="LZW")      {
02236                                                         $formArray["im_path"]=array($path);
02237                                                         $found=2;
02238                                                 } elseif ($found<2)     {
02239                                                         $formArray["im_path"]=array($path);
02240                                                         $found=1;
02241                                                 }
02242                                         } elseif (!$found)      {
02243                                                 $formArray["im_path"]=array($path);
02244                                                 $found=1;
02245                                         }
02246                                 }
02247                                 if ($dat["gif_capability"]=="LZW")      {
02248                                         if (doubleval($dat["convert"])<5)       {
02249                                                 $formArray["im_path_lzw"]=array($path);
02250                                                 $LZW_found=1;
02251                                         } elseif (!$LZW_found) {
02252                                                 $formArray["im_path_lzw"]=array($path);
02253                                                 $LZW_found=1;
02254                                         }
02255                                 } elseif ($dat["gif_capability"]=="RLE" && !$LZW_found) {
02256                                         $formArray["im_path_lzw"]=array($path);
02257                                 }
02258                                 $totalArr[]=$path;
02259                         }
02260                         $formArray["im_path"]=array_unique(array_merge($formArray["im_path"],$totalArr));
02261                         $formArray["im_path_lzw"]=array_unique(array_merge($formArray["im_path_lzw"],$totalArr));
02262                         $formArray["im_combine_filename"]=array($this->config_array["im_combine_filename"]);
02263                 } else {
02264                         $formArray["im"]=array(0);
02265                 }
02266                 return $formArray;
02267         }
02268 
02274         function getGDPartOfPhpinfo()   {
02275                 ob_start();
02276                 phpinfo();
02277                 $contents = ob_get_contents();
02278                 ob_end_clean();
02279                 $start_string = $this->getGD_start_string;
02280                 $end_string = $this->getGD_end_string;
02281                 list(,$gdpart_tmp) = explode($start_string,$contents,2);
02282                 list($gdpart) = explode($end_string,$start_string.$gdpart_tmp,2);
02283                 $gdpart.=$end_string;
02284                 return $gdpart;
02285         }
02286 
02293         function isTTF($phpinfo="")     {
02294 /*              $phpinfo = $phpinfo?$phpinfo:$this->getGDPartOfPhpinfo();
02295                 if (stristr($phpinfo, $this->getTTF_string))    return 1;
02296                 if (stristr($phpinfo, $this->getTTF_string_alt))        return 1;
02297                 */
02298 
02299                 if (!function_exists("imagettftext"))   return 0;       // Return right away if imageTTFtext does not exist.
02300 
02301                         // try, print truetype font:
02302                 $im = @imagecreate (300, 50);
02303                 $background_color = imagecolorallocate ($im, 255, 255, 55);
02304                 $text_color = imagecolorallocate ($im, 233, 14, 91);
02305 
02306                 $test = @imagettftext($im, t3lib_div::freetypeDpiComp(20), 0, 10, 20, $text_color, PATH_t3lib."/fonts/verdana.ttf", "Testing Truetype support");
02307                 if (t3lib_div::_GP("testingTrueTypeSupport"))   {
02308                         if ($this->isGIF())     {
02309                                 header ("Content-type: image/gif");
02310                                 imagegif ($im);
02311                         } else {
02312                                 header ("Content-type: image/png");
02313                                 imagepng ($im);
02314                         }
02315                         exit;
02316                 }
02317                 return is_array($test)?1:0;
02318         }
02319 
02320 
02321 
02322 
02323 
02324 
02325 
02326 
02327 
02328 
02329 
02330         /*****************************************
02331          *
02332          * ABOUT the isXXX functions.
02333          *
02334          * I had a very real experience that these checks DID NOT fail eg PNG support if it didn't exist!
02335          * 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.
02336          * And if THAT succeeds also, then we can be certain of the support!
02337          */
02338 
02342         function isGD() {
02343                 if (function_exists("imagecreate"))     {
02344                         if (@imagecreate (50, 100))     return 1;
02345                 }
02346         }
02347 
02353         function isGIF()        {
02354                 if (function_exists("imagecreatefromgif") && function_exists("imagegif") && ($this->ImageTypes() & IMG_GIF))    {       // If GIF-functions exists, also do a real test of them:
02355                         $im = @imagecreatefromgif(t3lib_extMgm::extPath("install")."imgs/jesus.gif");
02356                         return $im?1:0;
02357                 }
02358         }
02359 
02365         function isJPG()        {
02366                 if (function_exists("imagecreatefromjpeg") && function_exists("imagejpeg") && ($this->ImageTypes() & IMG_JPG))  {
02367                         return 1;
02368                 }
02369         }
02370 
02376         function isPNG()        {
02377                 if (function_exists("imagecreatefrompng") && function_exists("imagepng") && ($this->ImageTypes() & IMG_PNG))    {
02378                         $im = imagecreatefrompng(t3lib_extMgm::extPath("install")."imgs/jesus.png");
02379                         return $im?1:0;
02380                 }
02381         }
02382 
02388         function ImageTypes()   {
02389                 if (phpversion()!="4.1.2")      {
02390                         return imagetypes();
02391                 } else return IMG_GIF+IMG_JPG+IMG_PNG; // all...
02392         }
02393 
02399         function getGDSoftwareInfo()    {
02400                 return trim("
02401                 You can get GDLib in the PNG version from ".$this->linkIt("http://www.boutell.com/gd/").".<BR>FreeType is for download at ".$this->linkIt("http://www.freetype.org/")."</a>.
02402                 Generally, software for TYPO3 is found at ".$this->linkIt("http://typo3.sunsite.dk/software/")." and packages listed at ".$this->linkIt("http://typo3.org/1274.0.html").".
02403                 ");
02404         }
02405 
02411         function generallyAboutConfiguration()  {
02412                 $out='
02413                 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.
02414                 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.
02415                 See this page for '.$this->linkIt("http://typo3.org/1275.0.html","more information about system requirements.").'
02416                 ';
02417                 return trim($out);
02418         }
02419 
02420 
02421 
02422 
02423 
02424 
02425 
02426 
02427 
02428 
02429 
02430 
02431 
02432         /**********************
02433          *
02434          * IMAGE processing
02435          *
02436          **********************/
02437 
02471         function checkTheImageProcessing()      {
02472                 $this->message("Image Processing","What is it?","
02473                 TYPO3 is known for its ability to process images on the server.
02474                 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).
02475                 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).
02476                 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.
02477 
02478                 In order to do this, TYPO3 uses two sets of tools:
02479 
02480                 <B>ImageMagick:</B>
02481                 For conversion of non-web formats to webformats, combining images with alpha-masks, performing image-effects like blurring and sharpening.
02482                 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).
02483                 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).
02484                 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])
02485                 ImageMagick homepage is at ".$this->linkIt("http://www.imagemagick.org/")."
02486 
02487                 <B>GDLib:</B>
02488                 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.
02489                 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.
02490                 ".$this->getGDSoftwareInfo()."
02491 
02492                 You can disable all image processing options in TYPO3 ([GFX][image_processing]=0), but that would seriously disable TYPO3.
02493                 ");
02494 
02495                 $this->message("Image Processing","Verifying the image processing capabilities of your server","
02496                 This page performs image processing and displays the result. It's a thorough check that everything you've configured is working correctly.
02497                 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.
02498 
02499                 The image to the right is the reference image (how it should be) and to the left the image made by your server.
02500                 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.
02501 
02502                 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.
02503                 ");
02504 
02505 //              debug($this->config_array);
02506                 $im_path = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path"];
02507                 $im_path_version = $this->config_array["im_versions"][$im_path]["convert"];
02508                 $im_path_lzw = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path_lzw"];
02509                 $im_path_lzw_version = $this->config_array["im_versions"][$im_path_lzw]["convert"];
02510                 $msg = "
02511                 ImageMagick enabled: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im"]."</strong>
02512                 ImageMagick path: <strong>".$im_path."</strong> (".$im_path_version.")
02513                 ImageMagick path/LZW: <strong>".$im_path_lzw."</strong>  (".$im_path_lzw_version.")
02514                 Version 5 flag: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_version_5"]."</strong>
02515 
02516                 GDLib enabled: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib"]."</strong>
02517                 GDLib using PNG: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib_png"]."</strong>
02518                 GDLib 2 enabled: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib_2"]."</strong>
02519                 IM5 effects enabled: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_v5effects"]."</strong> (Blurring/Sharpening with IM 5+)
02520                 Freetype DPI: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["TTFdpi"]."</strong> (Should be 96 for Freetype 2)
02521                 Mask invert: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_imvMaskState"]."</strong> (Should be set for some IM versions approx. 5.4+)
02522 
02523                 File Formats: <strong>".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"]."</strong>
02524                 ";
02525                 if (($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_version_5"]?true:false) != (doubleval($im_path_version)>=5))        {
02526                         $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"].")";
02527                         $etype=2;
02528                 } else $etype=1;
02529 
02530                 $this->message("Image Processing","Current configuration",$msg,$etype);
02531 
02532 
02533 
02534 
02535                 if (!$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["image_processing"])    {
02536                         $this->message("Image Processing","Image Processing disabled!","
02537                                 Image Processing is disabled by the config flag <nobr>[GFX][image_processing]</nobr> set to false (zero)
02538                         ",2);
02539                         echo $this->outputWrapper($this->printAll());
02540                         return;
02541                 }
02542                 if (!$this->config_array["dir_typo3temp"])      {
02543                         $this->message("Image Processing","typo3temp/ not writable!","
02544                                 You must make typo3temp/ write enabled before you can proceed with this test.
02545                         ",2);
02546                         echo $this->outputWrapper($this->printAll());
02547                         return;
02548                 }
02549 
02550 
02551 
02552                 $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>:
02553 
02554                 '.$this->imagemenu();
02555                 $this->message("Image Processing","Testmenu",$msg,"");
02556 
02557 
02558                 $this->messageFunc_nl2br=0;
02559                 $parseStart = microtime();
02560                 $imageProc = t3lib_div::makeInstance("t3lib_stdGraphic");
02561                 $imageProc->init();
02562                 $imageProc->tempPath = $this->typo3temp_path;
02563                 $imageProc->dontCheckForExistingTempFile=1;
02564 //              $imageProc->filenamePrefix="install_".($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_version_5"]?"v5":"");
02565                 $imageProc->filenamePrefix="install_";
02566                 $imageProc->dontCompress=1;
02567                 $imageProc->alternativeOutputKey="TYPO3_INSTALL_SCRIPT";
02568                 $imageProc->noFramePrepended=$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_noFramePrepended"];
02569 
02570                 // Very temporary!!!
02571                 $imageProc->dontUnlinkTempFiles=0;
02572 
02573 
02574                 $imActive = ($this->config_array["im"] && $im_path);
02575                 $gdActive = ($this->config_array["gd"] && $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib"]);
02576 
02577                 switch($this->INSTALL["images_type"])   {
02578                         case "read":
02579                                 $refParseTime="5600";   // 4.2.9
02580                                 $refParseTime="3300";   // 5.2.3
02581                                 $headCode = "Reading and converting images";
02582                                 $this->message($headCode,"Supported file formats","
02583                                 This verifies that your ImageMagick installation is able to read the nine default file formats; JPG, GIF, PNG, TIF, BMP, PCX, TGA, PDF, AI.
02584                                 The tool 'identify' will be used to read the pixeldimensions of non-web formats.
02585                                 The tool 'convert' is used to read the image and write a temporary JPG-file
02586                                 ");
02587 
02588                                 if ($imActive)  {
02589                                                 // Reading formats - writing JPG
02590 
02591                                         $extArr = explode(",","jpg,gif,png,tif,bmp,pcx,tga");
02592                                         while(list(,$ext)=each($extArr))        {
02593                                                 if ($this->isExtensionEnabled($ext, $headCode, "Read ".strtoupper($ext)))       {
02594                                                         $imageProc->IM_commands=array();
02595                                                         $theFile = t3lib_extMgm::extPath("install")."imgs/jesus.".$ext;
02596                                                         if (!@is_file($theFile))        die("Error: ".$theFile." was not a file");
02597 
02598                                                         $imageProc->imageMagickConvert_forceFileNameBody="read_".$ext;
02599                                                         $fileInfo = $imageProc->imageMagickConvert($theFile,"jpg","","","","","",1);
02600                                                         $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
02601                                                         $this->message($headCode,"Read ".strtoupper($ext),$result[0],$result[1]);
02602                                                 }
02603                                         }
02604 
02605                                         if ($this->isExtensionEnabled("pdf", $headCode, "Read PDF"))    {
02606                                                 $imageProc->IM_commands=array();
02607                                                 $theFile = t3lib_extMgm::extPath("install")."imgs/pdf_from_imagemagick.pdf";
02608                                                 if (!@is_file($theFile))        die("Error: ".$theFile." was not a file");
02609 
02610                                                 $imageProc->imageMagickConvert_forceFileNameBody="read_pdf";
02611                                                 $fileInfo = $imageProc->imageMagickConvert($theFile,"jpg","170","","","","",1);
02612                                                 $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
02613                                                 $this->message($headCode,"Read PDF",$result[0],$result[1]);
02614                                         }
02615                                         if ($this->isExtensionEnabled("ai", $headCode, "Read AI"))      {
02616                                                 $imageProc->IM_commands=array();
02617                                                 $theFile = t3lib_extMgm::extPath("install")."imgs/typo3logotype.ai";
02618                                                 if (!@is_file($theFile))        die("Error: ".$theFile." was not a file");
02619 
02620                                                 $imageProc->imageMagickConvert_forceFileNameBody="read_ai";
02621                                                 $fileInfo = $imageProc->imageMagickConvert($theFile,"jpg","170","","","","",1);
02622                                                 $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
02623                                                 $this->message($headCode,"Read AI",$result[0],$result[1]);
02624                                         }
02625                                 } else {
02626                                         $this->message($headCode,"Test skipped","
02627                                         Use of ImageMagick has been disabled in the configuration.
02628                                         Refer to section 'Basic Configuration' to change or review you configuration settings
02629                                         ",2);
02630                                 }
02631                         break;
02632                         case "write":
02633                                 $refParseTime="300";
02634 
02635                                         // Writingformats - writing JPG
02636                                 $headCode = "Writing images";
02637                                 $this->message($headCode,"Writing GIF and PNG","
02638                                 This verifies that ImageMagick is able to write GIF and PNG files.
02639                                 The GIF-file is attempted compressed with LZW by the t3lib_div::gif_compress() function.
02640                                 ");
02641 
02642                                 if ($imActive)  {
02643                                                 // Writing GIF
02644                                         $imageProc->IM_commands=array();
02645                                         $theFile = t3lib_extMgm::extPath("install")."imgs/jesus.gif";
02646                                         if (!@is_file($theFile))        die("Error: ".$theFile." was not a file");
02647 
02648                                         $imageProc->imageMagickConvert_forceFileNameBody="write_gif";
02649                                         $fileInfo = $imageProc->imageMagickConvert($theFile,"gif","","","","","",1);
02650                                         if ($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gif_compress"]) {
02651                                                 clearstatcache();
02652                                                 $prevSize=t3lib_div::formatSize(@filesize($fileInfo[3]));
02653                                                 $returnCode = t3lib_div::gif_compress($fileInfo[3],"");
02654                                                 clearstatcache();
02655                                                 $curSize=t3lib_div::formatSize(@filesize($fileInfo[3]));
02656                                                 $note = array("Note on gif_compress() function:","The 'gif_compress' method used was '".$returnCode."'.<BR>Previous filesize: ".$prevSize.". Current filesize:".$curSize);
02657                                         } else  $note=array("Note on gif_compress() function:","<em>Not used! Disabled by [GFX][gif_compress]</em>");
02658                                         $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands, $note);
02659                                         $this->message($headCode,"Write GIF",$result[0],$result[1]);
02660 
02661 
02662                                                 // Writing PNG
02663                                         $imageProc->IM_commands=array();
02664                                         $theFile = t3lib_extMgm::extPath("install")."imgs/jesus.gif";
02665 
02666                                         $imageProc->imageMagickConvert_forceFileNameBody="write_png";
02667                                         $fileInfo = $imageProc->imageMagickConvert($theFile,"png","","","","","",1);
02668                                         $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
02669                                         $this->message($headCode,"Write PNG",$result[0],$result[1]);
02670                                 } else {
02671                                         $this->message($headCode,"Test skipped","
02672                                         Use of ImageMagick has been disabled in the configuration.
02673                                         Refer to section 'Basic Configuration' to change or review you configuration settings
02674                                         ",2);
02675                                 }
02676                         break;
02677                         case "scaling":
02678                                 $refParseTime="650";
02679 
02680                                         // Scaling
02681                                 $headCode = "Scaling images";
02682                                 $this->message($headCode,"Scaling transparent images","
02683                                 This shows how ImageMagick reacts when scaling transparent GIF and PNG files.
02684                                 ");
02685 
02686                                 if ($imActive)  {
02687                                                 // Scaling transparent image
02688                                         $imageProc->IM_commands=array();
02689                                         $theFile = t3lib_extMgm::extPath("install")."imgs/jesus2_transp.gif";
02690                                         if (!@is_file($theFile))        die("Error: ".$theFile." was not a file");
02691 
02692                                         $imageProc->imageMagickConvert_forceFileNameBody="scale_gif";
02693                                         $fileInfo = $imageProc->imageMagickConvert($theFile,"gif","150","","","","",1);
02694                                         if ($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gif_compress"]) {
02695                                                 clearstatcache();
02696                                                 $prevSize=t3lib_div::formatSize(@filesize($fileInfo[3]));
02697                                                 $returnCode = t3lib_div::gif_compress($fileInfo[3],"");
02698                                                 clearstatcache();
02699                                                 $curSize=t3lib_div::formatSize(@filesize($fileInfo[3]));
02700                                                 $note = array("Note on gif_compress() function:","The 'gif_compress' method used was '".$returnCode."'.<BR>Previous filesize: ".$prevSize.". Current filesize:".$curSize);
02701                                         } else $note=array("Note on gif_compress() function:","<em>Not used! Disabled by [GFX][gif_compress]</em>");
02702                                         $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands,$note);
02703                                         $this->message($headCode,"GIF to GIF, 150 pixels wide",$result[0],$result[1]);
02704 
02705                                         $imageProc->IM_commands=array();
02706                                         $theFile = t3lib_extMgm::extPath("install")."imgs/jesus2_transp.png";
02707                                         if (!@is_file($theFile))        die("Error: ".$theFile." was not a file");
02708 
02709                                         $imageProc->imageMagickConvert_forceFileNameBody="scale_png";
02710                                         $fileInfo = $imageProc->imageMagickConvert($theFile,"png","150","","","","",1);
02711                                         $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
02712                                         $this->message($headCode,"PNG to PNG, 150 pixels wide",$result[0],$result[1]);
02713 
02714                                         $imageProc->IM_commands=array();
02715                                         $theFile = t3lib_extMgm::extPath("install")."imgs/jesus2_transp.gif";
02716                                         if (!@is_file($theFile))        die("Error: ".$theFile." was not a file");
02717                                         $imageProc->imageMagickConvert_forceFileNameBody="scale_jpg";
02718                                         $fileInfo = $imageProc->imageMagickConvert($theFile,"jpg","150","","","","",1);
02719                                         $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
02720                                         $this->message($headCode,"GIF to JPG, 150 pixels wide",$result[0],$result[1]);
02721                                 } else {
02722                                         $this->message($headCode,"Test skipped","
02723                                         Use of ImageMagick has been disabled in the configuration.
02724                                         Refer to section 'Basic Configuration' to change or review you configuration settings
02725                                         ",2);
02726                                 }
02727                         break;
02728                         case "combining":
02729                                 $refParseTime="150";    // 4.2.9
02730                                 $refParseTime="250";    // 5.2.3
02731                                                                         // Combine
02732                                 $headCode = "Combining images";
02733                                 $this->message($headCode,"Combining images","
02734                                 This verifies that the ImageMagick tool, 'combine'/'composite', is able to combine two images through a grayscale mask.<BR>
02735                                 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)
02736                                 ");
02737 
02738                                 if ($imActive)  {
02739                                         $imageProc->IM_commands=array();
02740                                         $input = t3lib_extMgm::extPath("install")."imgs/greenback.gif";
02741                                         $overlay = t3lib_extMgm::extPath("install")."imgs/jesus.jpg";
02742                                         $mask = t3lib_extMgm::extPath("install")."imgs/blackwhite_mask.gif";
02743                                                 if (!@is_file($input))  die("Error: ".$input." was not a file");
02744                                                 if (!@is_file($overlay))        die("Error: ".$overlay." was not a file");
02745                                                 if (!@is_file($mask))   die("Error: ".$mask." was not a file");
02746 
02747                                         $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5($imageProc->alternativeOutputKey."combine1").".jpg";
02748                                         $imageProc->combineExec($input,$overlay,$mask,$output);
02749                                         $fileInfo = $imageProc->getImageDimensions($output);
02750                                         $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
02751                                         $this->message($headCode,"Combine using a GIF mask with only black and white",$result[0],$result[1]);
02752 
02753                                         // Combine
02754                                         $imageProc->IM_commands=array();
02755                                         $input = t3lib_extMgm::extPath("install")."imgs/combine_back.jpg";
02756                                         $overlay = t3lib_extMgm::extPath("install")."imgs/jesus.jpg";
02757                                         $mask = t3lib_extMgm::extPath("install")."imgs/combine_mask.jpg";
02758                                                 if (!@is_file($input))  die("Error: ".$input." was not a file");
02759                                                 if (!@is_file($overlay))        die("Error: ".$overlay." was not a file");
02760                                                 if (!@is_file($mask))   die("Error: ".$mask." was not a file");
02761                                         $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5($imageProc->alternativeOutputKey."combine2").".jpg";
02762                                         $imageProc->combineExec($input,$overlay,$mask,$output);
02763                                         $fileInfo = $imageProc->getImageDimensions($output);
02764                                         $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
02765                                         $this->message($headCode,"Combine using a JPG mask with graylevels",$result[0],$result[1]);
02766                                 } else {
02767                                         $this->message($headCode,"Test skipped","
02768                                         Use of ImageMagick has been disabled in the configuration.
02769                                         Refer to section 'Basic Configuration' to change or review you configuration settings
02770                                         ",2);
02771                                 }
02772                         break;
02773                         case "gdlib":
02774                                 $refParseTime="1800";   // GIF / 4.2.9 / LZW (5.2.3)
02775                                 $refParseTime="2700";   // PNG / 4.2.9 / LZW (5.2.3)
02776                                 $refParseTime="1600";   // GIF / 5.2.3 / LZW (5.2.3)
02777                                         // GDLibrary
02778                                 $headCode = "GDLib";
02779                                 $this->message($headCode,"Testing GDLib","
02780                                 This verifies that the GDLib installation works properly.
02781                                 ");
02782 
02783 
02784                                 if ($gdActive)  {
02785                                         // GD with box
02786                                         $imageProc->IM_commands=array();
02787                                         $im = imageCreate(170,136);
02788                                         ImageColorAllocate ($im, 0, 0, 0);
02789                                         $workArea=array(0,0,170,136);
02790                                         $conf=array(
02791                                                 "dimensions" => "10,50,150,36",
02792                                                 "color" => "olive"
02793                                         );
02794                                         $imageProc->makeBox($im,$conf,$workArea);
02795                                         $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5("GDbox").".".$imageProc->gifExtension;
02796                                         $imageProc->ImageGif ($im,$output);
02797                                         $fileInfo = $imageProc->getImageDimensions($output);
02798                                         $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
02799                                         $this->message($headCode,"Create simple image",$result[0],$result[1]);
02800 
02801 
02802                                         // GD from image with box
02803                                         $imageProc->IM_commands=array();
02804                                         $input = t3lib_extMgm::extPath("install")."imgs/jesus.".$imageProc->gifExtension;
02805                                                 if (!@is_file($input))  die("Error: ".$input." was not a file");
02806                                         $im = $imageProc->imageCreateFromGif($input);
02807                                         $workArea=array(0,0,170,136);
02808                                         $conf=array();
02809                                         $conf["dimensions"]="10,50,150,36";
02810                                         $conf["color"]="olive";
02811                                         $imageProc->makeBox($im,$conf,$workArea);
02812                                         $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5("GDfromImage+box").".".$imageProc->gifExtension;
02813                                         $imageProc->ImageGif ($im,$output);
02814                                         $fileInfo = $imageProc->getImageDimensions($output);
02815                                         $GDWithBox_filesize = @filesize($output);
02816                                         $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
02817                                         $this->message($headCode,"Create image from file",$result[0],$result[1]);
02818 
02819 
02820                                         // GD with text
02821                                         $imageProc->IM_commands=array();
02822                                         $im = imageCreate(170,136);
02823                                         ImageColorAllocate ($im, 128,128,150);
02824                                         $workArea=array(0,0,170,136);
02825                                         $conf=array(
02826                                                 "iterations" => 1,
02827                                                 "angle" => 0,
02828                                                 "antiAlias" => 1,
02829                                                 "text" => "HELLO WORLD",
02830                                                 "fontColor" => "#003366",
02831                                                 "fontSize" => 18,
02832                                                 "fontFile" => $this->backPath."t3lib/fonts/verdana.ttf",
02833                                                 "offset" => "17,40"
02834                                         );
02835                                         $conf["BBOX"] = $imageProc->calcBBox($conf);
02836                                         $imageProc->makeText($im,$conf,$workArea);
02837 
02838                                         $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5("GDwithText").".".$imageProc->gifExtension;
02839                                         $imageProc->ImageGif ($im,$output);
02840                                         $fileInfo = $imageProc->getImageDimensions($output);
02841                                         $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands);
02842                                         $this->message($headCode,"Render text with TrueType font",$result[0],$result[1]);
02843 
02844                                         if ($imActive)  {
02845                                                         // extension: GD with text, niceText
02846                                                 $conf["offset"] = "17,65";
02847                                                 $conf["niceText"] = 1;
02848                                                 $imageProc->makeText($im,$conf,$workArea);
02849 
02850                                                 $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5("GDwithText-niceText").".".$imageProc->gifExtension;
02851                                                 $imageProc->ImageGif ($im,$output);
02852                                                 $fileInfo = $imageProc->getImageDimensions($output);
02853                                                 $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'."));
02854                                                 $this->message($headCode,"Render text with TrueType font using 'niceText' option",
02855                                                         "(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>".
02856                                                         $result[0],$result[1]);
02857                                         } else {
02858                                                 $this->message($headCode,"Render text with TrueType font using 'niceText' option","
02859                                                 <strong>Test is skipped!</strong><BR><BR>
02860 
02861                                                 Use of ImageMagick has been disabled in the configuration. ImageMagick is needed to generate text with the niceText option.
02862                                                 Refer to section 'Basic Configuration' to change or review you configuration settings
02863                                                 ",2);
02864                                         }
02865 
02866                                         if ($imActive)  {
02867                                                         // extension: GD with text, niceText AND shadow
02868                                                 $conf["offset"] = "17,90";
02869                                                 $conf["niceText"] = 1;
02870                                                 $conf["shadow."] = array(
02871                                                         "offset"=>"2,2",
02872                                                         "blur" => $imageProc->V5_EFFECTS?"20":"90",
02873                                                         "opacity" => "50",
02874                                                         "color" => "black"
02875                                                 );
02876                                                 $imageProc->makeShadow($im,$conf["shadow."],$workArea,$conf);
02877                                                 $imageProc->makeText($im,$conf,$workArea);
02878 
02879                                                 $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5("GDwithText-niceText-shadow").".".$imageProc->gifExtension;
02880                                                 $imageProc->ImageGif ($im,$output);
02881                                                 $fileInfo = $imageProc->getImageDimensions($output);
02882                                                 $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."));
02883                                                 $this->message($headCode,"Render 'niceText' with a shadow under",
02884                                                         "(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>".
02885                                                         $result[0],$result[1]);
02886                                         } else {
02887                                                 $this->message($headCode,"Render 'niceText' with a shadow under","
02888                                                 <strong>Test is skipped!</strong><BR><BR>
02889 
02890                                                 Use of ImageMagick has been disabled in the configuration. ImageMagick is needed to generate shadows.
02891                                                 Refer to section 'Basic Configuration' to change or review you configuration settings
02892                                                 ",2);
02893                                         }
02894 
02895                                         if ($imageProc->gifExtension=="gif")    {
02896                                                 $buffer=20;
02897                                                 $assess = "This assessment is based on the filesize from 'Create image from file' test, which were ".$GDWithBox_filesize." bytes";
02898                                                 $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!";
02899                                                 if ($GDWithBox_filesize<8784+$buffer)   {
02900                                                         $msg="<strong>Your GDLib appears to have LZW compression!</strong><BR>
02901                                                                 This assessment is based on the filesize from 'Create image from file' test, which were ".$GDWithBox_filesize." bytes.<BR>
02902                                                                 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>
02903                                                                 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)
02904                                                                 ";
02905                                                 } elseif ($GDWithBox_filesize>19000)    {
02906                                                         $msg="<strong>Your GDLib appears to have no compression at all!</strong><BR>
02907                                                                 ".$assess."<br>".$goodNews;
02908                                                 } else {
02909                                                         $msg="Your GDLib appears to have RLE compression<BR>
02910                                                                 ".$assess."<br>".$goodNews;
02911                                                 }
02912                                                 $this->message($headCode,"GIF compressing in GDLib","
02913                                                 ".$msg."
02914                                                 ",1);
02915                                         }
02916 
02917                                 } else {
02918                                         $this->message($headCode,"Test skipped","
02919                                         Use of GDLib has been disabled in the configuration.
02920                                         Refer to section 'Basic Configuration' to change or review you configuration settings
02921                                         ",2);
02922                                 }
02923                         break;
02924                 }
02925 
02926                 if ($this->INSTALL["images_type"])      {
02927                         // End info
02928                         if ($this->fatalError)  {
02929                                 $this->message("Info","Errors","
02930                                 It seems that you had some fatal errors in this test. Please make sure that your ImageMagick and GDLib settings are correct.
02931                                 Refer to the 'Basic Configuration' section for more information and debugging of your settings.
02932                                 ");
02933                         }
02934 
02935                         $parseStop = microtime();
02936                         $parseMS = t3lib_div::convertMicrotime($parseStop)-t3lib_div::convertMicrotime($parseStart);
02937                         $this->message("Info","Parsetime",$parseMS." ms");
02938                 }
02939                 echo $this->outputWrapper($this->printAll());
02940         }
02941 
02950         function isExtensionEnabled($ext, $headCode, $short)    {
02951                 if (!t3lib_div::inList($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"],$ext))       {
02952                         $this->message($headCode,$short,"Skipped - extension not in the list of allowed extensions ([GFX][imagefile_ext]).",1);
02953                 } else {
02954                         return 1;
02955                 }
02956         }
02957 
02966         function displayTwinImage ($imageFile, $IMcommands=array(), $note="")   {
02967                 $ex_rows="";
02968                 $errorLevels=array(-1);
02969                 if ($imageFile) {
02970                         $verifyFile = t3lib_extMgm::extPath("install")."verify_imgs/".basename($imageFile);
02971 #debug(array($imageFile,$this->backPath.'../'.substr($imageFile,strlen(PATH_site))),1);
02972                         $destImg = @getImageSize($imageFile);
02973                         $destImgCode ='<img src="'.$this->backPath.'../'.substr($imageFile,strlen(PATH_site)).'" '.$destImg[3].'>';
02974                         $verifyImg = @getImageSize($verifyFile);
02975                         $verifyImgCode = '<img src="'.$this->backPath.t3lib_extMgm::extRelPath("install").'verify_imgs/'.basename($verifyFile).'" '.$verifyImg[3].'>';
02976                         if (!$verifyImg)        {
02977                                 $gifVersion=1;
02978                                 $verifyFile_alt = substr($verifyFile,0,-3)."gif";
02979                                 $verifyImg = @getImageSize($verifyFile_alt);
02980                                 if ($verifyImg) {
02981                                         $verifyImgCode = '<img src="'.$this->backPath.'t3lib/install/verify_imgs/'.basename($verifyFile_alt).'" '.$verifyImg[3].'>';
02982                                         $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>';
02983                                 } else {
02984                                         $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>';
02985                                 }
02986                         }
02987 
02988                         clearstatcache();
02989                         $destImg["filesize"] = @filesize($imageFile);
02990                         clearstatcache();
02991                         $verifyImg["filesize"] = @filesize($verifyFile);
02992 
02993                         $ex_rows.='<tr>';
02994                         $ex_rows.='<td>'.$destImgCode.'</td>';
02995                         $ex_rows.='<td><img src=clear.gif width=30 height=1></td>';
02996                         $ex_rows.='<td>'.$verifyImgCode.'</td>';
02997                         $ex_rows.='</tr>';
02998 
02999                         $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");
03000 
03001                         if ($destImg["filesize"]!=$verifyImg["filesize"])       {
03002                                 if (intval($destImg["filesize"]) && abs(($verifyImg["filesize"]/$destImg["filesize"])-1) < 0.05)        {
03003 //                                      debug(abs(($verifyImg["filesize"]/$destImg["filesize"])-1));
03004                                         $ex_rows.=$this->getTwinImageMessage("File size is a bit different from reference", $destImg["filesize"], $verifyImg["filesize"]);
03005                                         $errorLevels[]=1;
03006                                 } else {
03007                                         $ex_rows.=$this->getTwinImageMessage("File size is very different from reference", $destImg["filesize"], $verifyImg["filesize"]);
03008                                         $errorLevels[]=2;
03009                                 }
03010                         }
03011                         if ($destImg[0]!=$verifyImg[0] || $destImg[1]!=$verifyImg[1])   {
03012                                 $ex_rows.=$this->getTwinImageMessage("Pixel dimension are not equal!");
03013                                 $errorLevels[]=2;
03014                         }
03015                         if ($note)      {
03016                                 $ex_rows.=$this->getTwinImageMessage($note[0],$note[1]);
03017                         }
03018                         if ($this->dumpImCommands && count($IMcommands))        {
03019                                 $ex_rows.=$this->getTwinImageMessage("ImageMagick commands executed:",$this->formatImCmds($IMcommands));
03020                         }
03021                 } else {
03022                         $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));
03023                         $errorLevels[]=3;
03024                 }
03025                 $out='<table border=0 cellpadding=0 cellspacing=0 align=center width=300>'.$ex_rows.'</table>';
03026 
03027                 return array($out,max($errorLevels));
03028         }
03029 
03038         function getTwinImageMessage($message, $label_1="", $label_2="")        {
03039                 if ($message)   $out.='<tr><td colspan=3><strong>'.$this->fw($message).'</strong></td></tr>';
03040                 if ($label_1 && !$label_2)      {
03041                         $out.='<tr><td colspan=3>'.$this->fw($label_1).'</td></tr>';
03042                 } elseif ($label_1 || $label_2) {
03043                         $out.='<tr><td>'.$this->fw($label_1).'</td><td></td><td>'.$this->fw($label_2).'</td></tr>';
03044                 }
03045                 return $out;
03046         }
03047 
03054         function formatImCmds($arr)     {
03055                 $out=array();
03056                 if (is_array($arr))     {
03057                         reset($arr);
03058                         while(list($k,$v)=each($arr))   {
03059                                 $out[]=$v[1];
03060                                 if ($v[2])      $out[]="   RETURNED: ".$v[2];
03061                         }
03062                 }
03063                 if (count($out))        {
03064                         $col = t3lib_div::intInRange(count($out),2,10);
03065                         $outputStr = '<textarea cols=40 rows='.$col.' wrap="off">'.htmlspecialchars(implode($out,chr(10))).'</textarea>';
03066                         return '<form action="">'.$outputStr.'</form>';
03067                 };
03068         }
03069 
03075         function imagemenu()    {
03076                 $menuitems = array(
03077                         "read" => "Reading image formats",
03078                         "write" => "Writing GIF and PNG",
03079                         "scaling" => "Scaling images",
03080                         "combining" => "Combining images",
03081                         "gdlib" => "GD library functions"
03082                 );
03083                 reset($menuitems);
03084                 $c=0;
03085                 $out=array();
03086                 while(list($k,$v)=each($menuitems))     {
03087                         $bgColor = ($this->INSTALL["images_type"]==$k ? ' bgColor="#ABBBB4"' : ' bgColor="#F4F0E8"');
03088                         $c++;
03089                         $out[]='<tr><td'.$bgColor.'><a href="'.$this->action.'&TYPO3_INSTALL[images_type]='.$k.'#testmenu">'.$this->fw($c.': '.$v).'</a></td></tr>';
03090                 }
03091 
03092                 $code = '<table border=0 cellpadding=0 cellspacing=1>'.implode($out,"").'</table>';
03093                 $code = '<table border=0 cellpadding=0 cellspacing=0 bgColor="#ABBBB4"><tr><td>'.$code.'</td></tr></table>';
03094                 return '<div align="center">'.$code.'</div>';
03095         }
03096 
03097 
03098 
03099 
03100 
03101 
03102 
03103 
03104 
03105 
03106 
03107 
03108         /**********************
03109          *
03110          * DATABASE analysing
03111          *
03112          **********************/
03113 
03117         function checkTheDatabase()     {
03118                 if (!$this->config_array["mysqlConnect"])       {
03119                         $this->message("Database Analyser","Your database connection failed","
03120                                 Please go to the 'Basic Configuration' section and correct this problem first.
03121                         ",2);
03122                         echo $this->outputWrapper($this->printAll());
03123                         return;
03124                 }
03125                 if ($this->config_array["no_database"]) {
03126                         $this->message("Database Analyser","No database selected","
03127                                 Please go to the 'Basic Configuration' section and correct this problem first.
03128                         ",2);
03129                         echo $this->outputWrapper($this->printAll());
03130                         return;
03131                 }
03132 
03133                         // Getting current tables
03134                 $whichTables=$this->getListOfTables();
03135 
03136 
03137                         // Getting number of static_template records
03138                 if ($whichTables["static_template"])    {
03139                         $res_static = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'static_template', '');
03140                         list($static_template_count) = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res_static);
03141                 }
03142                 $static_template_count=intval($static_template_count);
03143 
03144                 $headCode ="Database Analyser";
03145                 $this->message($headCode,"What is it?","
03146                         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.
03147                 ",0);
03148 
03149                 $cInfo="
03150                         Username: <strong>".TYPO3_db_username."</strong>
03151                         Password: <strong>".TYPO3_db_password."</strong>
03152                         Host: <strong>".TYPO3_db_host."</strong>
03153                 ";
03154                 $this->message($headCode, "Connected to SQL database successfully","
03155                 ".trim($cInfo)."
03156                 ",-1,1);
03157                 $this->message($headCode, "Database","
03158                         <strong>".TYPO3_db."</strong> is selected as database.
03159                         Has <strong>".count($whichTables)."</strong> tables.
03160                 ",-1,1);
03161 
03162 
03163                 // Menu
03164 
03165                 $this->messageFunc_nl2br = 0;
03166 
03167                 $sql_files = array_merge(
03168                         t3lib_div::getFilesInDir(PATH_typo3conf,"sql",1,1),
03169 #                       t3lib_div::getFilesInDir(PATH_t3lib."stddb/","sql",1,1),
03170                         array()
03171                 );
03172 
03173                 $action_type = $this->INSTALL["database_type"];
03174                 $actionParts = explode("|",$action_type);
03175                 if (count($actionParts)<2)      {
03176                         $action_type="";
03177                 }
03178 
03179                 $out='';
03180 
03181 
03182                         $out.='<tr>
03183                                 <td nowrap><strong>'.$this->fw('Update required tables').'</strong></td>
03184                                 <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>
03185                                 <td>'.$this->fw('&nbsp;').'</td>
03186                                 <td>'.$this->fw('&nbsp;').'</td>
03187                         </tr>';
03188 
03189                         $out.='<tr>
03190                                 <td nowrap><strong>'.$this->fw('Dump static data').'</strong></td>
03191                                 <td>'.$this->fw('&nbsp;').'</td>
03192                                 <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>
03193                                 <td>'.$this->fw('&nbsp;').'</td>
03194                         </tr>';
03195 
03196                         $out.='<tr>
03197                                 <td colspan=4>&nbsp;</td>
03198                         </tr>';
03199 
03200 
03201 
03202 
03203                 reset($sql_files);
03204                 $directJump="";
03205                 while(list($k,$file)=each($sql_files))  {
03206                         if ($this->mode=="123" && !count($whichTables) && strstr($file,"_testsite"))    {
03207                                 $directJump = $this->action.'&TYPO3_INSTALL[database_type]=import|'.rawurlencode($file);
03208                         }
03209                         $lf=t3lib_div::testInt($k);
03210                         $fShortName = substr($file,strlen(PATH_site));
03211 /*                      $spec1 = (!count($whichTables) && $fShortName==TYPO3_mainDir."t3lib/install/tables_".str_replace(".","",$GLOBALS["TYPO_VERSION"]).".sql" ? " <font color=#000066>(1)</font>" : "");
03212                         $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>" : "");
03213                         */
03214                         $out.='<tr>
03215                                 <td nowrap>'.$this->fw($fShortName." (".t3lib_div::formatSize(filesize($file)).")").'</td>
03216                                 <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>
03217                                 <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>
03218                                 <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>
03219                         </tr>';
03220                 }
03221                         // TCA
03222                 $out.='<tr>
03223                         <td></td>
03224                         <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>
03225                 </tr>';
03226                 $out.='<tr>
03227                         <td></td>
03228                         <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>
03229                 </tr>';
03230                 $out.='<tr>
03231                         <td></td>
03232                         <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>
03233                 </tr>';
03234                 $out.='<tr>
03235                         <td></td>
03236                         <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>
03237                 </tr>';
03238 
03239                 $theForm='<table border=0 cellpadding=2 cellspacing=2>'.$out.'</table>';
03240                 $theForm.='<a name="bottom"></a>';
03241 
03242                 if ($directJump)        {
03243                         if (!$action_type)      {
03244                                 $this->message($headCode, "Menu",'
03245                                 <script language="javascript" type="text/javascript">
03246                                 document.location = "'.$directJump.'";
03247                                 </script>',0,1);
03248                         }
03249                 } else {
03250                         $this->message($headCode, "Menu","
03251                         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>
03252                         <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>
03253                         <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>
03254                         <strong>VIEW:</strong> Shows the content of the SQL-file, limiting characters on a single line to a reader-friendly amount.<BR><BR>
03255                         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.
03256         <br>
03257                         <BR>
03258                         ".$theForm."
03259                         ",0,1);
03260                 }
03261 
03262 
03263         // Install user
03264         // clear uc
03265                 if ($action_type)       {
03266                         switch($actionParts[0]) {
03267                                 case "cmpFile":
03268                                         $tblFileContent="";
03269                                         if (!strcmp($actionParts[1],"CURRENT_TABLES")) {
03270                                                 $tblFileContent = t3lib_div::getUrl(PATH_t3lib."stddb/tables.sql");
03271 
03272                                                 reset($GLOBALS["TYPO3_LOADED_EXT"]);
03273                                                 while(list(,$loadedExtConf)=each($GLOBALS["TYPO3_LOADED_EXT"])) {
03274                                                         if (is_array($loadedExtConf) && $loadedExtConf["ext_tables.sql"])       {
03275                                                                 $tblFileContent.= chr(10).chr(10).chr(10).chr(10).t3lib_div::getUrl($loadedExtConf["ext_tables.sql"]);
03276                                                         }
03277                                                 }
03278 #debug(array($tblFileContent));
03279                                         } elseif (@is_file($actionParts[1]))    {
03280                                                 $tblFileContent = t3lib_div::getUrl($actionParts[1]);
03281                                         }
03282                                         if ($tblFileContent)    {
03283                                                 $fileContent = implode(
03284                                                         $this->getStatementArray($tblFileContent,1,"^CREATE TABLE "),
03285                                                         chr(10)
03286                                                 );
03287                                                 $FDfile = $this->getFieldDefinitions_sqlContent($fileContent);
03288                                                 if (!count($FDfile))    {
03289                                                         die ("Error: There were no 'CREATE TABLE' definitions in the provided file");
03290                                                 }
03291 
03292                                                         // Updating database...
03293                                                 if (is_array($this->INSTALL["database_update"]))        {
03294                                                         $FDdb = $this->getFieldDefinitions_database();
03295                                                         $diff = $this->getDatabaseExtra($FDfile, $FDdb);
03296                                                         $update_statements = $this->getUpdateSuggestions($diff);
03297                                                         $diff = $this->getDatabaseExtra($FDdb, $FDfile);
03298                                                         $remove_statements = $this->getUpdateSuggestions($diff,"remove");
03299 
03300                                                         $this->performUpdateQueries($update_statements["add"],$this->INSTALL["database_update"]);
03301                                                         $this->performUpdateQueries($update_statements["change"],$this->INSTALL["database_update"]);
03302                                                         $this->performUpdateQueries($remove_statements["change"],$this->INSTALL["database_update"]);
03303                                                         $this->performUpdateQueries($remove_statements["drop"],$this->INSTALL["database_update"]);
03304 
03305                                                         $this->performUpdateQueries($update_statements["create_table"],$this->INSTALL["database_update"]);
03306                                                         $this->performUpdateQueries($remove_statements["change_table"],$this->INSTALL["database_update"]);
03307                                                         $this->performUpdateQueries($remove_statements["drop_table"],$this->INSTALL["database_update"]);
03308                                                 }
03309 
03310                                                         // Init again / first time depending...
03311                                                 $FDdb = $this->getFieldDefinitions_database();
03312                                                 $diff = $this->getDatabaseExtra($FDfile, $FDdb);
03313                                                 $update_statements = $this->getUpdateSuggestions($diff);
03314                                                 $diff = $this->getDatabaseExtra($FDdb, $FDfile);
03315                                                 $remove_statements = $this->getUpdateSuggestions($diff,"remove");
03316                                                 $tLabel = "Update database tables and fields";
03317 
03318                                                 if ($remove_statements || $update_statements)   {
03319                                                         $formContent = $this->generateUpdateDatabaseForm("get_form",$update_statements,$remove_statements,$action_type);
03320                                                         $this->message($tLabel,"Table and field definitions should be updated","
03321                                                         There seems to be a number of differencies between the database and the selected SQL-file.
03322                                                         Please select which statements you want to execute in order to update your database:<BR><BR>
03323                                                         ".$formContent."
03324                                                         ",2);
03325                                                 } else {
03326                                                         $formContent = $this->generateUpdateDatabaseForm("get_form",$update_statements,$remove_statements,$action_type);
03327                                                         $this->message($tLabel,"Table and field definitions are OK.","
03328                                                         The tables and fields in the current database corresponds perfectly to the database in the selected SQL-file.
03329                                                         ",-1);
03330                                                 }
03331                                         }
03332                                 break;
03333                                 case "cmpTCA":
03334                                         $this->includeTCA();
03335                                         $this->mysqlVersion = "3.23";   // Set this previously to calling the function below in order to make the rendering right for the comparison.
03336                                         $FDdb = $this->getFieldDefinitions_database();
03337 
03338                                                 // Displaying configured fields which are not in the database
03339                                         $tLabel="Tables and fields in \$TCA, but not in database";
03340                                         $cmpTCA_DB = $this->compareTCAandDatabase($GLOBALS["TCA"],$FDdb);
03341                                         if (!count($cmpTCA_DB["extra"]))        {
03342                                                 $this->message($tLabel,"Table and field definitions OK","
03343                                                 All fields and tables configured in $TCA appeared to exist in the database as well
03344                                                 ",-1);
03345                                         } else {
03346                                                 $this->message($tLabel,"Invalid table and field definitions in \$TCA!","
03347                                                 There are some tables and/or fields configured in the \$TCA array which does not exist in the database!
03348                                                 This will most likely cause you trouble with the TYPO3 backend interface!
03349                                                 ",3);
03350                                                 while(list($tableName, $conf)=each($cmpTCA_DB["extra"]))        {
03351                                                         $this->message($tLabel, $tableName,$this->displayFields($conf["fields"],0,"Suggested database field:"),2);
03352                                                 }
03353                                         }
03354 
03355                                                 // Displaying tables that are not setup in
03356                                         $cmpDB_TCA = $this->compareDatabaseAndTCA($FDdb,$GLOBALS["TCA"]);
03357                                         $excludeTables="be_sessions,fe_session_data,fe_sessions";
03358                                         if (TYPO3_OS=="WIN")    {$excludeTables = strtolower($excludeTables);}
03359                                         $excludeFields = array(
03360                                                 "be_users" => "uc,lastlogin,usergroup_cached_list",
03361                                                 "fe_users" => "uc,lastlogin,fe_cruser_id",
03362                                                 "pages" => "SYS_LASTCHANGED",
03363                                                 "sys_dmail" => "mailContent",
03364                                                 "tt_board" => "doublePostCheck",
03365                                                 "tt_guest" => "doublePostCheck",
03366                                                 "tt_products" => "ordered"
03367                                         );
03368                                         $tCount=0;
03369                                         $fCount=0;
03370                                         $tLabel="Tables from database, but not in \$TCA";
03371                                         $fLabel="Fields from database, but not in \$TCA";
03372                                         $this->message($tLabel);
03373                                         if (is_array($cmpDB_TCA['extra']))      {
03374                                                 while(list($tableName, $conf)=each($cmpDB_TCA['extra']))        {
03375                                                         if (!t3lib_div::inList($excludeTables,$tableName)
03376                                                                         && substr($tableName,0,4)!="sys_"
03377                                                                         && substr($tableName,-3)!="_mm"
03378                                                                         && substr($tableName,0,6)!="index_"
03379                                                                         && substr($tableName,0,6)!="cache_")    {
03380                                                                 if ($conf["whole_table"])       {
03381                                                                         $this->message($tLabel, $tableName,$this->displayFields($conf["fields"]),1);
03382                                                                         $tCount++;
03383                                                                 } else {
03384                                                                         list($theContent, $fC)  = $this->displaySuggestions($conf["fields"],$excludeFields[$tableName]);
03385                                                                         $fCount+=$fC;
03386                                                                         if ($fC)        $this->message($fLabel, $tableName,$theContent,1);
03387                                                                 }
03388                                                         }
03389                                                 }
03390                                         }
03391                                         if (!$tCount)   {
03392                                                 $this->message($tLabel,"Correct number of tables in the database","
03393                                                 There are no extra tables in the database compared to the configured tables in the \$TCA array.
03394                                                 ",-1);
03395                                         } else {
03396                                                 $this->message($tLabel,"Extra tables in the database","
03397                                                 There are some tables in the database which are not configured in the \$TCA array.
03398                                                 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.
03399                                                 ",2);
03400                                         }
03401 
03402                                         if (!$fCount)   {
03403                                                 $this->message($fLabel,"Correct number of fields in the database","
03404                                                 There are no additional fields in the database tables compared to the configured fields in the \$TCA array.
03405                                                 ",-1);
03406                                         } else {
03407                                                 $this->message($fLabel,"Extra fields in the database","
03408                                                 There are some additional fields the database tables which are not configured in the \$TCA array.
03409                                                 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.
03410                                                 ",2);
03411                                         }
03412 
03413                                                 // Displaying actual and suggested field database defitions
03414                                         if (is_array($cmpTCA_DB["matching"]))   {
03415                                                 $tLabel="Comparison between database and \$TCA";
03416 
03417                                                 $this->message($tLabel,"Actual and suggested field definitions","
03418                                                 This table shows you the suggested field definitions which are calculated based on the configuration in \$TCA.
03419                                                 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.
03420                                                 ",0);
03421                                                 while(list($tableName, $conf)=each($cmpTCA_DB["matching"]))     {
03422                                                         $this->message($tLabel, $tableName,$this->displayFieldComp($conf["fields"], $FDdb[$tableName]["fields"]),1);
03423                                                 }
03424                                         }
03425                                 break;
03426                                 case "import":
03427                                         $mode123Imported=0;
03428                                         $tblFileContent="";
03429                                         if (!strcmp($actionParts[1],"CURRENT_STATIC")) {
03430                                                 reset($GLOBALS["TYPO3_LOADED_EXT"]);
03431                                                 while(list(,$loadedExtConf)=each($GLOBALS["TYPO3_LOADED_EXT"])) {
03432                                                         if (is_array($loadedExtConf) && $loadedExtConf["ext_tables_static+adt.sql"])    {
03433                                                                 $tblFileContent.= chr(10).chr(10).chr(10).chr(10).t3lib_div::getUrl($loadedExtConf["ext_tables_static+adt.sql"]);
03434                                                         }
03435                                                 }
03436                                         } elseif (@is_file($actionParts[1]))    {
03437                                                 $tblFileContent = t3lib_div::getUrl($actionParts[1]);
03438                                         }
03439                                         if ($tblFileContent)    {
03440                                                 $tLabel="Import SQL dump";
03441                                                         // Getting statement array from
03442                                                 $statements = $this->getStatementArray($tblFileContent,1);
03443                                                 list($statements_table, $insertCount) = $this->getCreateTables($statements,1);
03444 
03445                                                         // Updating database...
03446                                                 if ($this->INSTALL["database_import_all"])      {
03447                                                         reset($statements);
03448                                                         $r=0;
03449                                                         while(list($k,$v)=each($statements))    {
03450                                                                 $res = $GLOBALS['TYPO3_DB']->admin_query($v);
03451                                                                 $r++;
03452                                                         }
03453                                                         $this->message($tLabel,"Imported ALL","
03454                                                                 Queries: ".$r."
03455                                                         ",1,1);
03456                                                         if (t3lib_div::_GP("goto_step"))        {
03457                                                                 $this->action.="&step=".t3lib_div::_GP("goto_step");
03458                                                                 Header("Location: ".t3lib_div::locationHeaderUrl($this->action));
03459                                                                 exit;
03460                                                         }
03461                                                 } elseif (is_array($this->INSTALL["database_import"]))  {
03462                                                                 // Traverse the tables
03463                                                         reset($this->INSTALL["database_import"]);
03464                                                         while(list($table,$md5str)=each($this->INSTALL["database_import"]))     {
03465                                                                 if ($md5str==md5($statements_table[$table]))    {
03466                                                                         $res = $GLOBALS['TYPO3_DB']->admin_query("DROP TABLE IF EXISTS ".$table);
03467                                                                         $res = $GLOBALS['TYPO3_DB']->admin_query($statements_table[$table]);
03468 
03469                                                                         if ($insertCount[$table])       {
03470                                                                                 $statements_insert = $this->getTableInsertStatements($statements, $table);
03471                                                                                 reset($statements_insert);
03472                                                                                 while(list($k,$v)=each($statements_insert))     {
03473                                                                                         $res = $GLOBALS['TYPO3_DB']->admin_query($v);
03474                                                                                 }
03475                                                                         }
03476 
03477                                                                         $this->message($tLabel,"Imported '".$table."'","
03478                                                                                 Rows: ".$insertCount[$table]."
03479                                                                         ",1,1);
03480                                                                 }
03481                                                         }
03482                                                 }
03483 
03484                                                 $mode123Imported=$this->isBasicComplete($tLabel);
03485 
03486                                                 if (!$mode123Imported)  {
03487                                                                 // Re-Getting current tables - may have been changed during import
03488                                                         $whichTables=$this->getListOfTables();
03489 
03490                                                         if (count($statements_table))   {
03491                                                                 reset($statements_table);
03492                                                                 $out='';
03493                                                                 while(list($table,$definition)=each($statements_table)) {
03494                                                                         $exist=isset($whichTables[$table]);
03495                                                                         $out.='<tr>
03496                                                                                 <td><input type="checkbox" name="TYPO3_INSTALL[database_import]['.$table.']" value="'.md5($definition).'"></td>
03497                                                                                 <td><strong>'.$this->fw($table).'</strong></td>
03498                                                                                 <td><img src=clear.gif width=10 height=1></td>
03499                                                                                 <td nowrap>'.$this->fw($insertCount[$table]?"Rows: ".$insertCount[$table]:"").'</td>
03500                                                                                 <td><img src=clear.gif width=10 height=1></td>
03501                                                                                 <td nowrap>'.($exist?'<img src="'.$this->backPath.'t3lib/gfx/icon_warning.gif" width=18 height=16 align=top>'.$this->fw("Table exists!"):'').'</td>
03502                                                                                 </tr>';
03503                                                                 }
03504 
03505                                                                 $content ='';
03506                                                                 if ($this->mode!="123") {
03507                                                                         $content.='<table border=0 cellpadding=0 cellspacing=0>'.$out.'</table>
03508                                                                         <HR>
03509                                                                         ';
03510                                                                 }
03511                                                                 $content.='<input type="checkbox" name="TYPO3_INSTALL[database_import_all]" value="1"'.($this->mode=="123"||t3lib_div::_GP("presetWholeTable")?" checked":"").'>'.$this->fw("Import the whole file '".basename($actionParts[1])."' directly (ignores selections above):").'<BR>
03512 
03513                                                                 ';
03514                                                                 $form = $this->getUpdateDbFormWrap($action_type, $content);
03515                                                                 $this->message($tLabel,"Select tables to import","
03516                                                                 This is an overview of the CREATE TABLE definitions in the SQL file.
03517                                                                 Select which tables you want to dump to the database.
03518                                                                 Any table you choose dump to the database is dropped from the database first, so you'll loose all data in existing tables.
03519                                                                 ".$form,1,1);
03520                                                         } else {
03521                                                                 $this->message($tLabel,"No tables","
03522                                                                 There seems to be no CREATE TABLE definitions in the SQL file.
03523                                                                 This tool is intelligently creating one table at a time and not just dumping the whole content of the file uncritically. That's why there must be defined tables in the SQL file.
03524                                                                 ",3,1);
03525                                                         }
03526                                                 }
03527                                         }
03528                                 break;
03529                                 case "view":
03530                                         if (@is_file($actionParts[1]))  {
03531                                                 $tLabel="Import SQL dump";
03532                                                         // Getting statement array from
03533                                                 $sqlContent = t3lib_div::getUrl($actionParts[1]);
03534                                                 $statements = $this->getStatementArray($sqlContent,1);
03535                                                 $maxL=1000;
03536                                                 $strLen = strlen($sqlContent);
03537                                                 $maxlen = 200+($maxL-t3lib_div::intInRange(($strLen-20000)/100,0,$maxL));
03538 //                                              debug($maxlen);
03539                                                 if (count($statements)) {
03540                                                         reset($statements);
03541                                                         $out='';
03542                                                         while(list(,$statement)=each($statements))      {
03543                                                                 $out.=nl2br(htmlspecialchars(t3lib_div::fixed_lgd($statement,$maxlen)).chr(10).chr(10));
03544                                                         }
03545                                                 }
03546                                                 $this->message($tLabel,"Content of ".basename($actionParts[1]),$out,1);
03547                                         }
03548                                 break;
03549                                 case "adminUser":
03550                                         if ($whichTables["be_users"])   {
03551                                                 if (is_array($this->INSTALL["database_adminUser"]))     {
03552                                                         $username = ereg_replace("[^[:alnum:]_-]","",trim($this->INSTALL["database_adminUser"]["username"]));
03553                                                         $username = str_replace(" ","_",$username);
03554                                                         $pass = trim($this->INSTALL["database_adminUser"]["password"]);
03555                                                         if ($username && $pass) {
03556                                                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'be_users', 'username="'.$GLOBALS['TYPO3_DB']->quoteStr($username, 'be_users').'"');
03557                                                                 if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res))  {
03558 
03559                                                                         $insertFields = array(
03560                                                                                 'username' => $username,
03561                                                                                 'password' => md5($pass),
03562                                                                                 'admin' => 1,
03563                                                                                 'uc' => '',
03564                                                                                 'fileoper_perms' => 7,
03565                                                                                 'tstamp' => time(),
03566                                                                                 'crdate' => time()
03567                                                                         );
03568 
03569                                                                         $GLOBALS['TYPO3_DB']->exec_INSERTquery('be_users', $insertFields);
03570 
03571                                                                         $this->isBasicComplete($headCode);
03572 
03573                                                                         $this->message($headCode,"User created",'
03574                                                                         Username: <strong>'.htmlspecialchars($username).'</strong><BR>
03575                                                                         Password: <strong>'.htmlspecialchars($pass).'</strong><BR>'
03576                                                                         ,1,1);
03577                                                                 } else {
03578                                                                         $this->message($headCode,"Username not unique!",'
03579                                                                         The username, <strong>'.htmlspecialchars($username).'</strong>, was not unique.',2,1);
03580                                                                 }
03581                                                         }
03582                                                 }
03583                                                 $content = '
03584                                                 <input type="text" name="TYPO3_INSTALL[database_adminUser][username]"> username - unique, no space, lowercase<BR>
03585                                                 <input type="text" name="TYPO3_INSTALL[database_adminUser][password]"> password
03586                                                 ';
03587                                                 $form = $this->getUpdateDbFormWrap($action_type, $content);
03588                                                 $this->message($headCode,"Create admin user","
03589                                                 Enter username and password for a new admin user.<BR>
03590                                                 You should use this function only if there are no admin users in the database, for instance if this is a blank database.<BR>
03591                                                 After you've created the user, log in and add the rest of the user information, like email and real name.<BR>
03592                                                 <BR>
03593                                                 ".$form."
03594                                                 ",0,1);
03595                                         } else {
03596                                                 $this->message($headCode,"Required table not in database","
03597                                                 'be_users' must be a table in the database!
03598                                                 ",3,1);
03599                                         }
03600                                 break;
03601                                 case "UC":
03602                                         if ($whichTables["be_users"])   {
03603                                                 if (!strcmp($this->INSTALL["database_UC"],1))   {
03604                                                         $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_users', '', array('uc' => ''));
03605                                                         $this->message($headCode,"Clearing be_users.uc",'Done.',1);
03606                                                 }
03607                                                 $content = '
03608                                                 <input type="checkbox" name="TYPO3_INSTALL[database_UC]" value=1 checked> Clear be_users preferences ("uc" field)
03609                                                 ';
03610                                                 $form = $this->getUpdateDbFormWrap($action_type, $content);
03611                                                 $this->message($headCode,"Clear user preferences","
03612                                                 If you press this button all backend users from the tables be_users will have their user preferences cleared (field 'uc' set to an empty string).<BR>
03613                                                 This may come in handy in rare cases where that configuration may be corrupt.<BR>
03614                                                 Clearing this will clear all user settings from the 'Setup' module.<BR>
03615                                                 <BR>
03616                                                 ".$form);
03617                                         } else {
03618                                                 $this->message($headCode,"Required table not in database","
03619                                                 'be_users' must be a table in the database!
03620                                                 ",3);
03621                                         }
03622                                 break;
03623                                 case "cache":
03624                                         $tableListArr = explode(",","cache_pages,cache_pagesection,cache_hash,--div--,sys_log,sys_history,--div--,be_sessions,fe_sessions,fe_session_data".
03625                                                 (t3lib_extMgm::isLoaded("indexed_search") ? ",--div--,index_words,index_rel,index_phash,index_grlist,index_section,index_fulltext" : "").
03626                                                 (t3lib_extMgm::isLoaded("tt_products") ? ",--div--,sys_products_orders,sys_products_orders_mm_tt_products" : "").
03627                                                 (t3lib_extMgm::isLoaded("direct_mail") ? ",--div--,sys_dmail_maillog" : "").
03628                                                 (t3lib_extMgm::isLoaded("sys_stat") ? ",--div--,sys_stat" : "")
03629                                         );
03630 
03631                                         if (is_array($this->INSTALL["database_clearcache"]))    {
03632                                                 $qList=array();
03633                                                 reset($tableListArr);
03634                                                 while(list(,$table)=each($tableListArr))        {
03635                                                         if ($table!="--div--")  {
03636                                                                 $table_c = TYPO3_OS=="WIN" ? strtolower($table) : $table;
03637                                                                 if ($this->INSTALL["database_clearcache"][$table] && $whichTables[$table_c])    {
03638                                                                         $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, '');
03639                                                                         $qList[] = $table;
03640                                                                 }
03641                                                         }
03642                                                 }
03643                                                 if (count($qList))      {
03644                                                         $this->message($headCode,"Clearing cache",'
03645                                                         The following tables were emptied:<BR><BR>
03646                                                         '.implode($qList,"<BR>")
03647                                                         ,1);
03648                                                 }
03649                                         }
03650                                                 // Count entries and make checkboxes
03651                                         $labelArr = array(
03652                                                 "cache_pages" => "Pages",
03653                                                 "cache_pagesection" => "TS template related information",
03654                                                 "cache_hash" => "Multipurpose md5-hash cache",
03655                                                 "sys_log" => "Backend action logging",
03656                                                 "sys_stat" => "Page hit statistics",
03657                                                 "sys_history" => "Addendum to the sys_log which tracks ALL changes to content through TCE. May become huge by time. Is used for rollback (undo) and the WorkFlow engine.",
03658                                                 "be_sessions" => "Backend User sessions",
03659                                                 "fe_sessions" => "Frontend User sessions",
03660                                                 "fe_session_data" => "Frontend User sessions data",
03661                                                 "sys_dmail_maillog" => "Direct Mail log",
03662                                                 "sys_products_orders" => "tt_product orders",
03663                                                 "sys_products_orders_mm_tt_products" => "relations between tt_products and sys_products_orders"
03664                                         );
03665 
03666                                         $checkBoxes=array();
03667                                         $countEntries=array();
03668                                         reset($tableListArr);
03669                                         while(list(,$table)=each($tableListArr))        {
03670                                                 if ($table!="--div--")  {
03671                                                         $table_c = TYPO3_OS=="WIN" ? strtolower($table) : $table;
03672                                                         if ($whichTables[$table_c])     {
03673                                                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, '');
03674                                                                 list($countEntries[$table]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
03675                                                                         // Checkboxes:
03676                                                                 $checkBoxes[]= '<input type="checkbox" name="TYPO3_INSTALL[database_clearcache]['.$table.']" value="1"'.($this->INSTALL["database_clearcache"][$table]||$_GET["PRESET"]["database_clearcache"][$table]?" checked":"").'> <strong>'.$table.'</strong> ('.$countEntries[$table].' rows) - '.$labelArr[$table];
03677                                                         }
03678                                                 } else {
03679                                                                 $checkBoxes[]=  '<HR>';
03680                                                 }
03681                                         }
03682 
03683                                         $content = implode("<BR>",$checkBoxes)."<BR><BR>";
03684 
03685                                         $form = $this->getUpdateDbFormWrap($action_type, $content);
03686                                         $this->message($headCode,"Clear out selected tables",'
03687                                         Pressing this button will delete all records from the selected tables.<BR>
03688                                         <BR>
03689                                         '.$form.'
03690                                         ');
03691                                 break;
03692                         }
03693                 }
03694 
03695                 echo $this->outputWrapper($this->printAll());
03696         }
03697 
03703         function isBackendAdminUser() {
03704                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'be_users', 'admin');
03705                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
03706                 return current($row);
03707         }
03708 
03714         function isStaticTemplates()    {
03715                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'static_template', '');
03716                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
03717                 return current($row);
03718         }
03719 
03726         function isBasicComplete($tLabel)       {
03727                 if ($this->mode=="123") {
03728                         $tables = $this->getListOfTables();
03729 
03730                         if (count($tables))     {
03731                                 $beuser = $this->isBackendAdminUser();
03732                                 $static = $this->isStaticTemplates();
03733                         }
03734                         if (count($tables) && $beuser && $static)       {
03735                                 $mode123Imported=1;
03736                                 $this->message($tLabel,"Basic Installation Completed",nl2br($this->messageBasicFinished()),-1,1);
03737                                 $this->message($tLabel,"Security Risk!",nl2br($this->securityRisk().$this->alterPasswordForm()),2,1);
03738                         } else {
03739                                 $this->message($tLabel,"Still missing something?",nl2br("
03740                                 You may be missing one of these points before your TYPO3 installation is complete:
03741 
03742                                 ".(count($tables)?"":"- You haven't imported any tables yet.
03743                                 ")
03744                                 .($static?"":"- You haven't imported the static_template table.
03745                                 ")
03746                                 .($beuser?"":"- You haven't created an admin-user yet.
03747                                 ")
03748                                 ."
03749 
03750                                 You you're about to import a database with a complete site in it, these three points should be met.
03751                                 "),-1,1);
03752                         }
03753                 }
03754                 return $mode123Imported;
03755         }
03756 
03766         function generateUpdateDatabaseForm($type, $arr_update, $arr_remove, $action_type)      {
03767                 switch($type)   {
03768                         case "get_form":
03769                                 $content="";
03770                                 $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_update["add"],"Add fields");
03771                                 $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_update["change"],"Changing fields",1,0,$arr_update["change_currentValue"]);
03772                                 $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_remove["change"],"Remove unused fields (rename with prefix)",$this->setAllCheckBoxesByDefault,1);
03773                                 $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_remove["drop"],"Drop fields (really!)",$this->setAllCheckBoxesByDefault);
03774 
03775                                 $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_update["create_table"],"Add tables");
03776                                 $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_remove["change_table"],"Removing tables (rename with prefix)",$this->setAllCheckBoxesByDefault,1,$arr_remove["tables_count"],1);
03777                                 $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_remove["drop_table"],"Drop tables (really!)",$this->setAllCheckBoxesByDefault,0,$arr_remove["tables_count"],1);
03778 
03779                                 $form = $this->getUpdateDbFormWrap($action_type, $content);
03780                                 return $form;
03781                         break;
03782                         default:
03783 
03784                         break;
03785                 }
03786         }
03787 
03796         function getUpdateDbFormWrap($action_type, $content, $label="Write to database")        {
03797                 $form = '<form action="'.$this->action.'#bottom" method="POST"><input type="hidden" name="TYPO3_INSTALL[database_type]" value="'.htmlspecialchars($action_type).'">'.$content.'<BR><input type="submit" value="'.$label.'">';
03798                 return $form;
03799         }
03800 
03809         function displayFields($arr, $pre=0, $label="") {
03810                 $out="";
03811                 $out.='<tr><td bgcolor="#9BA1A8" align=center><strong>'.$this->fw("Field name:").'</strong></td><td bgcolor="#9BA1A8" align=center><strong>'.$this->fw($label?$label:"Info:").'</strong></td></tr>';
03812                 if (is_array($arr))     {
03813                         reset($arr);
03814                         while(list($fieldname, $fieldContent)=each($arr))       {
03815                                 if ($pre)       {
03816                                         $fieldContent = '<pre>'.trim($fieldContent).'</pre>';
03817                                 } else {
03818                                         $fieldContent = $this->fw($fieldContent);
03819                                 }
03820                                 $out.='<tr><td bgcolor="#ABBBB4">'.$this->fw($fieldname).'</td><td bgcolor="#ABBBB4">'.$fieldContent.'</td></tr>';
03821                         }
03822                 }
03823                 $out= '<table border=0 cellpadding=0 cellspacing=0>'.$out.'</table>';
03824                 return $out;
03825         }
03826 
03834         function displayFieldComp($arr, $arr_db)        {
03835                 $out="";
03836                 $out.='<tr><td bgcolor="#9BA1A8" align=center><strong>'.$this->fw("Field name:").'</strong></td>
03837                         <td bgcolor="#9BA1A8" align=center><strong>'.$this->fw("Suggested value from \$TCA:").'</strong></td>
03838                         <td bgcolor="#9BA1A8" align=center><strong>'.$this->fw("Actual value from database:").'</strong></td>
03839                         </tr>';
03840                 if (is_array($arr))     {
03841                         reset($arr);
03842                         while(list($fieldname, $fieldContent)=each($arr))       {
03843                                         // This tries to equalize the types tinyint and int
03844                                 $str1 = $fieldContent;
03845                                 $str2 = trim($arr_db[$fieldname]);
03846                                 $str1 = str_replace("tinyint(3)","tinyint(4)",$str1);
03847                                 $str2 = str_replace("tinyint(3)","tinyint(4)",$str2);
03848                                 $str1 = str_replace("int(10)","int(11)",$str1);
03849                                 $str2 = str_replace("int(10)","int(11)",$str2);
03850                                         // Compare:
03851                                 if (strcmp($str1,$str2))        {
03852                                         $bgColor=' bgcolor="#ABBBB4"';
03853                                 } else {
03854                                         $bgColor=' bgcolor="#D9D5C9"';
03855                                 }
03856                                 $fieldContent = $this->fw($fieldContent);
03857                                 $fieldContent_db = $this->fw($arr_db[$fieldname]);
03858                                 $out.='<tr>
03859                                         <td bgcolor="#D9D5C9">'.$this->fw($fieldname).'</td>
03860                                         <td'.$bgColor.'>'.$fieldContent.'</td>
03861                                         <td'.$bgColor.'>'.$fieldContent_db.'</td>
03862                                         </tr>';
03863                         }
03864                 }
03865                 $out= '<table border=0 cellpadding=2 cellspacing=2>'.$out.'</table>';
03866                 return $out;
03867         }
03868 
03876         function displaySuggestions($arr, $excludeList="")      {
03877                 $out="";
03878                 $out.='<tr><td bgcolor="#9BA1A8" align=center><strong>'.$this->fw("Field name:").'</strong></td><td bgcolor="#9BA1A8" align=center><strong>'.$this->fw("Info / Suggestion for the field:").'</strong></td></tr>';
03879                 $fC=0;
03880                 if (is_array($arr))     {
03881                         reset($arr);
03882                         while(list($fieldname, $fieldContent)=each($arr))       {
03883                                 if (!t3lib_div::inList($excludeList,$fieldname) && substr($fieldname,0,strlen($this->deletedPrefixKey))!=$this->deletedPrefixKey && substr($fieldname,-1)!=".") {
03884                                         $fieldContent = $this->fw($fieldContent);
03885                                         if ($arr[$fieldname."."])       {
03886                                                 $fieldContent.= '<HR>';
03887                                                 $fieldContent.= '<pre>'.trim($arr[$fieldname."."]).'</pre>';
03888                                         }
03889                                         $out.='<tr><td bgcolor="#ABBBB4">'.$this->fw($fieldname).'</td><td bgcolor="#ABBBB4">'.$fieldContent.'</td></tr>';
03890                                         $fC++;
03891                                 }
03892                         }
03893                 }
03894                 $out= '<table border=0 cellpadding=2 cellspacing=2>'.$out.'</table>';
03895                 return array($out,$fC);
03896         }
03897 
03906         function compareDatabaseAndTCA($FDsrc, $TCA, $onlyFields=0)     {
03907                 $extraArr=array();
03908                 if (is_array($FDsrc))   {
03909                         reset($FDsrc);
03910                         while(list($table,$info)=each($FDsrc))  {
03911                                 if (!isset($TCA[$table]))       {
03912                                         if (!$onlyFields)       {
03913                                                 $extraArr[$table]=$info;                // If the table was not in the FDcomp-array, the result array is loaded with that table.
03914                                                 $extraArr[$table]["whole_table"]=1;
03915                                                 unset($extraArr[$table]["keys"]);
03916                                         }
03917                                 } else {
03918                                         $theKey="fields";
03919                                         $excludeListArr=array();
03920                                         if (is_array($TCA[$table]["ctrl"]["enablecolumns"]))    $excludeListArr[]=$TCA[$table]["ctrl"]["enablecolumns"];
03921                                         $excludeListArr[]=$TCA[$table]["ctrl"]["tstamp"];
03922                                         $excludeListArr[]=$TCA[$table]["ctrl"]["sortby"];
03923                                         $excludeListArr[]=$TCA[$table]["ctrl"]["delete"];
03924                                         $excludeListArr[]=$TCA[$table]["ctrl"]["cruser_id"];
03925                                         $excludeListArr[]=$TCA[$table]["ctrl"]["crdate"];
03926                                         $excludeListArr[]="uid";
03927                                         $excludeListArr[]="pid";
03928                                         if ($table=="pages")    {
03929                                                 $excludeListArr[]="perms_userid";
03930                                                 $excludeListArr[]="perms_groupid";
03931                                                 $excludeListArr[]="perms_user";
03932                                                 $excludeListArr[]="perms_group";
03933                                                 $excludeListArr[]="perms_everybody";
03934                                         }
03935                                         if ($table=="sys_dmail")        {
03936                                                 $excludeListArr[]="scheduled";
03937                                                 $excludeListArr[]="scheduled_begin";
03938                                                 $excludeListArr[]="scheduled_end";
03939                                                 $excludeListArr[]="query_info";
03940                                         }
03941 
03942                                         if (is_array($info[$theKey]))   {
03943                                                 reset($info[$theKey]);
03944                                                 while(list($fieldN,$fieldC)=each($info[$theKey]))       {
03945                                                         if (!isset($TCA[$table]["columns"][$fieldN]) && !in_array($fieldN,$excludeListArr))     {
03946                                                                 $extraArr[$table][$theKey][$fieldN] = $info["fields"][$fieldN];
03947                                                                 $extraArr[$table][$theKey][$fieldN."."]=$this->suggestTCAFieldDefinition($fieldN,$fieldC);
03948                                                         }
03949                                                 }
03950                                         }
03951                                 }
03952                         }
03953                 }
03954                 return array("extra"=>$extraArr);
03955         }
03956 
03964         function compareTCAandDatabase($TCA, $FDcomp)   {
03965                 $extraArr=array();
03966                 $matchingArr=array();
03967                 if (is_array($TCA))     {
03968                         reset($TCA);
03969                         while(list($table)=each($TCA))  {
03970                                 $info=$TCA[$table];
03971                                 if (!isset($FDcomp[$table]))    {
03972 //                                      $extraArr[$table]=$info;                // If the table was not in the FDcomp-array, the result array is loaded with that table.
03973                                         $extraArr[$table]["whole_table"]=1;
03974                                 } else {
03975                                         reset($info["columns"]);
03976                                         while(list($fieldN,$fieldC)=each($info["columns"]))     {
03977                                                 $fieldDef = $this->suggestFieldDefinition($fieldC);
03978                                                 if (!is_array($fieldDef))       {
03979                                                         if (!isset($FDcomp[$table]["fields"][$fieldN])) {
03980                                                                 $extraArr[$table]["fields"][$fieldN]=$fieldDef;
03981                                                         } else {
03982                                                                 $matchingArr[$table]["fields"][$fieldN]=$fieldDef;
03983                                                         }
03984                                                 }
03985                                         }
03986                                 }
03987                         }
03988                 }
03989                 return array("extra"=>$extraArr, "matching"=>$matchingArr);
03990         }
03991 
03998         function suggestFieldDefinition($fieldInfo)     {
03999                 $out="";
04000                 switch($fieldInfo["config"]["type"])    {
04001                         case "input":
04002                                 if (ereg("date|time|int|year",$fieldInfo["config"]["eval"]))    {
04003                                         $us=ereg("date|time",$fieldInfo["config"]["eval"]) ? " unsigned" : "";
04004                                         $out = "int(11)".$us." NOT NULL default '0'";
04005                                 } else {
04006                                         $max = intval($fieldInfo["config"]["max"]);
04007                                         if ($max>0 && $max<200) {
04008                                                 $out = "varchar(".$max.") NOT NULL default ''";
04009                                         } else {
04010                                                 $out = "tinytext NOT NULL";
04011                                         }
04012                                 }
04013                         break;
04014                         case "text":
04015                                 $out = "text NOT NULL";
04016                         break;
04017                         case "check":
04018                                 if (is_array($fieldInfo["config"]["items"]) && count($fieldInfo["config"]["items"])>8)  {
04019                                         $out = "int(11) unsigned NOT NULL default '0'";
04020                                 } else {
04021                                         $out = "tinyint(3) unsigned NOT NULL default '0'";
04022                                 }
04023                         break;
04024                         case "radio":
04025                                 if (is_array($fieldInfo["config"]["items"]))    {
04026                                         $out = $this->getItemArrayType($fieldInfo["config"]["items"]);
04027                                 } else {
04028                                         $out = "ERROR: Radiobox did not have items!";
04029                                 }
04030                         break;
04031                         case "group":
04032                                 if ($fieldInfo["config"]["internal_type"]=="db")        {
04033                                         $max = t3lib_div::intInRange($fieldInfo["config"]["maxitems"],1,10000);
04034                                         if (count(explode(",",$fieldInfo["config"]["allowed"]))>1)      {
04035                                                 $len = $max*(10+1+5+1);         // Tablenames are 10, "_" 1, uid's 5, comma 1
04036                                                 $out=$this->getItemBlobSize($len);
04037                                         } elseif ($max<=1) {
04038                                                 $out = "int(11) unsigned NOT NULL default '0'";
04039                                         } else {
04040                                                 $len = $max*(5+1);              // uid's 5, comma 1
04041                                                 $out=$this->getItemBlobSize($len);
04042                                         }
04043                                 }
04044                                 if ($fieldInfo["config"]["internal_type"]=="file")      {
04045                                         $max = t3lib_div::intInRange($fieldInfo["config"]["maxitems"],1,10000);
04046                                         $len = $max*(30+1);             // Filenames is 30+ chars....
04047                                         $out=$this->getItemBlobSize($len);
04048                                 }
04049                         break;
04050                         case "select":
04051                                 $max = t3lib_div::intInRange($fieldInfo["config"]["maxitems"],1,10000);
04052                                 if ($max<=1)    {
04053                                         if ($fieldInfo["config"]["foreign_table"])      {
04054                                                 $out = "int(11) unsigned NOT NULL default '0'";
04055                                         } else {
04056                                                 $out = $this->getItemArrayType($fieldInfo["config"]["items"]);
04057                                         }
04058                                 } else {
04059                                                 // five chars (special=10) + comma:
04060                                         $len = $max*(($fieldInfo["config"]["special"]?10:5)+1);
04061                                         $out=$this->getItemBlobSize($len);
04062                                 }
04063                         break;
04064                         default:
04065                         break;
04066                 }
04067                 return $out?$out:$fieldInfo;
04068         }
04069 
04076         function getItemArrayType($arr) {
04077                 if (is_array($arr))     {
04078                         reset($arr);
04079                         $type[]=0;
04080                         $intSize[]=0;
04081                         while(list(,$item)=each($arr))  {
04082                                 if (!t3lib_div::testInt($item[1]) && $item[1]!="--div--")       {
04083                                         $type[]=strlen($item[1]);
04084                                 } else {
04085                                         $intSize[]=$item[1];
04086                                 }
04087                         }
04088                         $us = min($intSize)>=0 ? " unsigned" : "";
04089                         if (max($type)>0)       {
04090                                 $out = "varchar(".max($type).") NOT NULL default ''";
04091                         } elseif (max($intSize)>(!$us?127:255)) {
04092                                 $out = "int(11)".$us." NOT NULL default '0'";
04093                         } else {
04094                                 $out = "tinyint(3)".$us." NOT NULL default '0'";
04095                         }
04096                 }
04097                 return $out;
04098         }
04099 
04106         function getItemBlobSize($len)  {
04107                 return ($len>255 ? "tiny" : "")."blob NOT NULL";
04108         }
04109 
04117         function suggestTCAFieldDefinition($fieldName,$fieldInfo)       {
04118                 list($type,$len) = split(" |\(|\)",$fieldInfo,3);
04119                 switch($type)   {
04120                         case "int":
04121 $out='
04122 "'.$fieldName.'" => Array (
04123         "label" => "'.strtoupper($fieldName).':",
04124         "exclude" => 0,
04125         "config" => Array (
04126                 "type" => "input",
04127                 "size" => "8",
04128                 "max" => "20",
04129                 "eval" => "date",
04130                 "default" => "0",
04131                 "checkbox" => "0"
04132         )
04133 ),
04134 
04135 ----- OR -----
04136 
04137 "'.$fieldName.'" => Array (
04138         "label" => "'.strtoupper($fieldName).':",
04139         "exclude" => 0,
04140         "config" => Array (
04141                 "type" => "select",
04142                 "items" => Array (
04143                         Array("[nothing]", 0),
04144                         Array("Extra choice! Only negative values here.", -1),
04145                         Array("__Divider:__", "--div--")
04146                 ),
04147                 "foreign_table" => "[some_table_name]"
04148         )
04149 ),';
04150                         break;
04151                         case "varchar":
04152                                 if ($len>10)    {
04153                                         $out='
04154 "'.$fieldName.'" => Array (
04155         "label" => "'.strtoupper($fieldName).':",
04156         "exclude" => 0,
04157         "config" => Array (
04158                 "type" => "input",
04159                 "size" => "8",
04160                 "max" => "'.$len.'",
04161                 "eval" => "trim",
04162                 "default" => ""
04163         )
04164 ),';
04165                                 } else {
04166                                         $out='
04167 "'.$fieldName.'" => Array (
04168         "label" => "'.strtoupper($fieldName).':",
04169         "exclude" => 0,
04170         "config" => Array (
04171                 "type" => "select",
04172                 "items" => Array (
04173                         Array("Item number 1", "key1"),
04174                         Array("Item number 2", "key2"),
04175                         Array("-----", "--div--"),
04176                         Array("Item number 3", "key3")
04177                 ),
04178                 "default" => "1"
04179         )
04180 ),';
04181                                 }
04182                         break;
04183                         case "tinyint":
04184                                         $out='
04185 "'.$fieldName.'" => Array (
04186         "label" => "'.strtoupper($fieldName).':",
04187         "exclude" => 0,
04188         "config" => Array (
04189                 "type" => "select",
04190                 "items" => Array (
04191                         Array("Item number 1", "1"),
04192                         Array("Item number 2", "2"),
04193                         Array("-----", "--div--"),
04194                         Array("Item number 3", "3")
04195                 ),
04196                 "default" => "1"
04197         )
04198 ),
04199 
04200 ----- OR -----
04201 
04202 "'.$fieldName.'" => Array (
04203         "label" => "'.strtoupper($fieldName).':",
04204         "exclude" => 0,
04205         "config" => Array (
04206                 "type" => "check",
04207                 "default" => "1"
04208         )
04209 ),';
04210                         break;
04211                         case "tinytext":
04212 $out='
04213 "'.$fieldName.'" => Array (
04214         "label" => "'.strtoupper($fieldName).':",
04215         "exclude" => 0,
04216         "config" => Array (
04217                 "type" => "input",
04218                 "size" => "40",
04219                 "max" => "255",
04220                 "eval" => "",
04221                 "default" => ""
04222         )
04223 ),';
04224                         break;
04225                         case "text":
04226                         case "mediumtext":
04227 $out='
04228 "'.$fieldName.'" => Array (
04229         "label" => "'.strtoupper($fieldName).':",
04230         "config" => Array (
04231                 "type" => "text",
04232                 "cols" => "48",
04233                 "rows" => "5"
04234         )
04235 ),';
04236                         break;
04237                         default:
04238                                 $out='
04239 "'.$fieldName.'" => Array (
04240         "label" => "'.strtoupper($fieldName).':",
04241         "exclude" => 0,
04242         "config" => Array (
04243                 "type" => "input",
04244                 "size" => "30",
04245                 "max" => "",
04246                 "eval" => "",
04247                 "default" => ""
04248         )
04249 ),';
04250                         break;
04251                 }
04252                 return $out?$out:$fieldInfo;
04253         }
04254 
04260         function includeTCA()   {
04261                 global $TCA;
04262 
04263                 include (TYPO3_tables_script ? PATH_typo3conf.TYPO3_tables_script : PATH_t3lib."stddb/tables.php");
04264 
04265                         // Extension additions
04266                 if ($GLOBALS["TYPO3_LOADED_EXT"]["_CACHEFILE"]) {
04267                         include(PATH_typo3conf.$GLOBALS["TYPO3_LOADED_EXT"]["_CACHEFILE"]."_ext_tables.php");
04268                 } else {
04269                         include(PATH_t3lib."stddb/load_ext_tables.php");
04270                 }
04271 
04272                 if (TYPO3_extTableDef_script)   {
04273                         include (PATH_typo3conf.TYPO3_extTableDef_script);
04274                 }
04275 
04276                 reset($TCA);
04277                 while(list($table)=each($TCA))  {
04278                         t3lib_div::loadTCA($table);
04279                 }
04280         }
04281 
04282 
04283 
04284 
04285 
04286 
04287 
04288 
04289         /**********************
04290          *
04291          * GENERAL FUNCTIONS
04292          *
04293          **********************/
04294 
04302         function linkIt($url,$link="")  {
04303                 return '<a href="'.$url.'" target="_blank">'.($link?$link:$url).'</a>';
04304         }
04305 
04309         function message($head, $short_string="", $long_string="", $type=0, $force=0)   {               // type: -1=OK sign, 0=message, 1=notification, 2=warning , 3=error
04310                 if (!$force && $this->mode=="123" && $type<2)   {return;}       // Return directly if mode-123 is enabled.
04311 
04312                 if ($type==3)   {$this->fatalError=1;}
04313                 if ($this->messageFunc_nl2br)   {
04314                         $long_string = nl2br(trim($long_string));
04315                 } else {
04316                         $long_string = trim($long_string);
04317                 }
04318                 if (!$this->silent)     $this->printSection($head, $short_string, $long_string, $type);
04319         }
04320 
04330         function printSection($head, $short_string, $long_string, $type)        {
04331                 $icon="";
04332 
04333                 $bgCol =' bgcolor=#D9D5C9';
04334                 switch($type)   {
04335                         case "3":
04336                                 $bgCol =' bgcolor=red';
04337                                 $icon = 't3lib/gfx/icon_fatalerror.gif';
04338                         break;
04339                         case "2":
04340 //                              $bgCol =' bgcolor=#9BA1A8';
04341                                 $icon = 't3lib/gfx/icon_warning.gif';
04342                         break;
04343                         case "1":
04344 //                              $bgCol =' bgcolor=#ABBBB4';
04345                                 $icon = 't3lib/gfx/icon_note.gif';
04346                         break;
04347                         case "-1":
04348 //                              $bgCol =' bgcolor=yellow';
04349                                 $icon = 't3lib/gfx/icon_ok.gif';
04350                         break;
04351                         default:
04352                                 $bgCol =' bgcolor='.t3lib_div::modifyHTMLcolor("#ABBBB4",+40,+30,+40);
04353                         break;
04354                 }
04355                 if (!trim($short_string))       {
04356                         $this->sections[$head][]="";
04357                 } else {
04358                         $this->sections[$head][]='
04359                         <tr><td'.$bgCol.' nowrap>'.($icon?'<img src="'.$this->backPath.$icon.'" width=18 height=16 align=top>':'').'<strong>'.$this->fw($short_string).'</strong></td></tr>'.(trim($long_string)?'
04360                         <tr><td>'.$this->fw($long_string).'<BR><BR></td></tr>' : '');
04361                 }
04362         }
04363 
04371         function fw($str,$size=1)       {
04372                 if ($GLOBALS["CLIENT"]["SYSTEM"]=="unix" && $GLOBALS["CLIENT"]["BROWSER"]=="konqu")     {
04373                         return '<font face="sans-serif" size='.($size+2).' color=black>'.$str.'</font>';
04374                 }
04375                 return '<font face="verdana,sans-serif" size='.$size.' color=black>'.$str.'</font>';
04376         }
04377 
04384         function fwheader($str) {
04385                 return '<div align=center><strong>'.$this->fw($str,3).'</strong></div>';
04386         }
04387 
04395         function wrapInCells($label,$content)   {
04396                 return '<tr><td valign=top nowrap><strong>'.$this->fw($label).'</strong></td><td>&nbsp;</td><td valign=top>'.$this->fw($content).'<BR></td></tr>';
04397         }
04398 
04404         function printAll()     {
04405                 reset($this->sections);
04406                 $out="";
04407                 while(list($header,$valArray)=each($this->sections))    {
04408                         $out.='
04409                         <tr><td>&nbsp;</td></tr>
04410                         <tr><td><strong><div align="center">'.$this->fw($header.":",2).'</div></strong></td></tr>
04411                         ';
04412                         $out.=implode($valArray,chr(10));
04413                 }
04414                 return '<table border=0 cellpadding=2 cellspacing=2>'.$out.'</table>';
04415         }
04416 
04423         function outputWrapper($content)        {
04424                 $out='
04425 <html>
04426 
04427 
04428 <STYLE TYPE="text/css">
04429 <!--
04430 A:link {text-decoration: none}
04431 A:visited {text-decoration: none}
04432 A:active {text-decoration: none}
04433 A:hover {color: #000066}
04434 -->
04435 </STYLE>
04436 '.$this->headerStyle.'
04437         <head>
04438                 <title>TYPO3 Install Tool</title>
04439                 '.($this->JSmessage?'
04440 <script language="javascript" type="text/javascript">alert(unescape(\''.rawurlencode($this->JSmessage).'\'));</script>
04441 
04442                 ':'').'
04443         </head>
04444         <body bgcolor="white" alink="maroon" link="maroon" vlink="maroon">'.$this->contentBeforeTable.'
04445                 <div align="center">
04446                 <table border=0 cellspacing=0 cellpadding=0 width=333 bgcolor="white">
04447                 <tr>
04448                         <td><img src="'.$this->backPath.'t3lib/gfx/typo3logo.gif" width=333 height=43 vspace=10 hspace=50></td>
04449                 </tr>
04450                 <tr>
04451                         <td bgcolor="black">
04452                                 <table width="100%" border=0 cellspacing=1 cellpadding=10>
04453                                         <tr>
04454                                                 <td bgcolor=#F4F0E8>
04455                                                 <font face="verdana,sans-serif" size=4 color=black><strong><div align="center">TYPO3 '.$GLOBALS["TYPO_VERSION"].' Install Tool</div></strong></font>
04456                                                 <font face="verdana,sans-serif" size=2 color=navy><strong><div align="center">Site: '.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"].'</div></strong></font><br>
04457 
04458 '.($this->step?$this->stepHeader():$this->menu()).$content.'<HR>'.$this->note123().$this->endNotes().'
04459                                                 </td>
04460                                         </tr>
04461                                 </table>
04462                         </td>
04463                 </tr>
04464                 </table>
04465                 </div>
04466         </body>
04467 </html>';
04468                 return $out;
04469         }
04470 
04476         function menu() {
04477                 if (!$this->passwordOK) return;
04478 
04479                 reset($this->menuitems);
04480                 $c=0;
04481                 $out=array();
04482                 while(list($k,$v)=each($this->menuitems))       {
04483                         $bgColor = ($this->INSTALL["type"]==$k ? ' bgColor="#ABBBB4"' : ' bgColor="#F4F0E8"');
04484                         $c++;
04485                         $out[]='<tr><td'.$bgColor.'><a href="'.$this->scriptSelf.'?TYPO3_INSTALL[type]='.$k.($this->mode?"&mode=".rawurlencode($this->mode):"").'">'.$this->fw($c.': '.$v).'</a></td></tr>';
04486                 }
04487 
04488                 $code = '<table border=0 cellpadding=0 cellspacing=1>'.implode($out,chr(10)).'</table>';
04489                 $code = '<table border=0 cellpadding=0 cellspacing=0 bgColor="#ABBBB4"><tr><td>'.$code.'</td></tr></table>';
04490                 return '<div align="center">'.$code.'</div>';
04491         }
04492 
04498         function stepHeader()   {
04499                 $msg1='Type in your database parameters here:';
04500                 $msg2='Database';
04501                 $msg3='Import the database sql-file';
04502                 $msg4='You\'re done!';
04503                 $out='<img src="../t3lib/gfx/123_'.$this->step.'.png" width="402" height="73" border="0" alt="" usemap="#id123_print_Map">
04504 <MAP NAME="id123_print_Map">
04505 <AREA title="'.$msg4.'" SHAPE="poly" ALT="" COORDS="299,35, 303,19, 313,9, 335,5, 366,6, 379,11, 388,21, 392,35, 390,47, 381,58, 376,64, 359,67, 320,66, 307,60, 302,51, 300,44" HREF="'.$this->scriptSelf.'?mode='.$this->mode.'&step=go">
04506 <AREA title="'.$msg3.'" SHAPE="circle" ALT="" COORDS="234,36,32" HREF="'.$this->scriptSelf.'?mode='.$this->mode.'&step=3">
04507 <AREA title="'.$msg2.'" SHAPE="circle" ALT="" COORDS="136,37,30" HREF="'.$this->scriptSelf.'?mode='.$this->mode.'&step=2">
04508 <AREA title="'.$msg1.'" SHAPE="circle" ALT="" COORDS="40,36,29" HREF="'.$this->scriptSelf.'?mode='.$this->mode.'&step=1">
04509 </MAP>
04510 
04511 
04512                 <BR>';
04513                 $msg="";
04514                 switch(strtolower($this->step)) {
04515                         case 1:
04516                                 $msg=$msg1;
04517                         break;
04518                         case 2:
04519                                 $msg=$msg2;
04520                         break;
04521                         case 3:
04522                                 $msg=$msg3;
04523                         break;
04524                         case "go":
04525                                 $msg=$msg4;
04526                         break;
04527                         default:
04528                         break;
04529                 }
04530                 $out.='<BR><div align="center"><strong>'.$this->fw($msg,2).'</strong></div>';
04531 
04532                 return $out;
04533         }
04534 
04540         function note123()      {
04541                 if ($this->mode=="123") {
04542                         $c='<table border=0 cellpadding=0 cellspacing=0 width=100%>
04543                                 <tr><td bgcolor=#D9D5C9 nowrap><img src="../t3lib/gfx/icon_note.gif" width=18 height=16 align=top><strong>'.$this->fontTag1.'NOTICE: Install Tool is running in \'123\' mode. <a href="'.$this->scriptSelf.'">Click here to disable.</a></font></strong></td></tr>
04544                         </table>';
04545                         return $c;
04546                 }
04547         }
04548 
04554         function endNotes()     {
04555                 if ($this->mode!="123" && $this->passwordOK)    {
04556                         $c.="OS detected: <strong>".(TYPO3_OS=="WIN"?"WIN":"UNIX")."</strong><BR>";
04557                         $c.="UNIX/CGI detected: <strong>".(php_sapi_name()=="cgi" ? "YES" : "NO")."</strong><BR>";
04558                         $c.="PATH_thisScript: <strong>".PATH_thisScript."</strong><BR>";
04559                         $c.="<BR>";
04560                         $c.="<a href='../index.php' target='install_backend'>Backend admin in new window.</a><BR>";
04561                         $c.="<a href='../../index.php' target='install_frontend'>Frontend website in new window.</a><BR>";
04562 
04563                         return $this->fw($c);
04564                 }
04565         }
04566 
04573         function convertByteSize($bytes)        {
04574                 if (stristr($bytes,"m"))        {
04575                         $bytes=doubleval($bytes)*1024*1024;
04576                 } elseif (stristr($bytes,"k"))  {
04577                         $bytes=doubleval($bytes)*1024;
04578                 }
04579                 return $bytes;
04580         }
04581 
04587         function securityRisk() {
04588                 $c="This script is a <strong>great danger to the security of TYPO3</strong> if you don't secure it somehow.
04589                         We suggest one of the following:
04590 
04591                         - change the password as defined by the md5-hash in TYPO3_CONF_VARS[BE][installToolPassword].
04592                         - delete the folder 'typo3/install/' with this script in or just insert an 'exit;' line in the script-file there.
04593                         - password protect the 'typo3/install/' folder, eg. with a .htaccess file
04594 
04595                         The TYPO3_CONF_VARS[BE][installToolPassword] is always active, but choosing one of the other options will improve security and is recommended highly.
04596                 ";
04597                 return $c;
04598         }
04599 
04605         function alterPasswordForm()    {
04606                         $content = '<form action="'.$this->scriptSelf.'?TYPO3_INSTALL[type]=extConfig" method="POST">
04607                         Enter new password:
04608                         <input type="password" name="TYPO3_INSTALL[extConfig][BE][installToolPassword]"><BR>Enter again:
04609                         <input type="password" name="installToolPassword_check">
04610                         <input type="hidden" name="installToolPassword_md5" value=1>
04611                         <input type="submit" value="Set new password"><br>
04612                         </form>';
04613                         return $content;
04614         }
04615 
04621         function messageBasicFinished() {
04622                 $msg ="
04623                                 Apparently you have completed the basic setup of the TYPO3 database.
04624                                 Now you can choose between these options:
04625 
04626                                 - <a href='../../index.php'><strong>Go to the frontend pages</strong></a>
04627 
04628                                 - <a href='../index.php?u=admin&p=password'><strong>Go to the backend login</strong></a>
04629                                  (username may be: <i>admin</i>, password may be: <i>password</i>.)
04630 
04631                                 - <a href='".$this->scriptSelf."'><strong>Continue to configure TYPO3</strong></a> (Recommended).
04632                                  This will let you analyse and verify that everything in your PHP installation is alright. Also if you want to configure TYPO3 to use all the cool features, you <em>must</em> dig into the this!
04633                                 ";
04634                 return $msg;
04635         }
04636 
04643         function setScriptName($type)   {
04644                 $value = $this->scriptSelf."?TYPO3_INSTALL[type]=".$type.($this->mode?"&mode=".rawurlencode($this->mode):"").($this->step?"&step=".rawurlencode($this->step):"");
04645                 return $value;
04646         }
04647 
04656         function formWidth($size=48,$textarea=0,$styleOverride="") {
04657                         // Input or text-field attribute (size or cols)
04658                 $wAttrib = $textarea?"cols":"size";
04659                 if (!$GLOBALS["CLIENT"]["FORMSTYLE"])   {       // If not setting the width by style-attribute
04660                         $size = ceil($size*1);
04661                         $retVal = ' '.$wAttrib.'="'.$size.'"';
04662                 } else {        // Setting width by style-attribute. "cols" MUST be avoided with NN6+
04663                         $pixels = ceil($size*10);
04664                         $retVal = $styleOverride ? ' style="'.$styleOverride.'"' : ' style="width:'.$pixels.'px;"';
04665                 }
04666                 return $retVal;
04667         }
04668 
04677         function formWidthText($size=48,$styleOverride="",$wrap="") {
04678                 $wTags = $this->formWidth($size,1,$styleOverride);
04679                         // Netscape 6+ seems to have this ODD problem where there WILL ALWAYS be wrapping with the cols-attribute set and NEVER without the col-attribute...
04680                 if (strtolower(trim($wrap))!="off" && $GLOBALS["CLIENT"]["BROWSER"]=="net" && $GLOBALS["CLIENT"]["VERSION"]>=5) {
04681                         $wTags.=' cols="'.$size.'"';
04682                 }
04683                 return $wTags;
04684         }
04685 }
04686 
04687 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/install/mod/class.tx_install.php'])    {
04688         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/install/mod/class.tx_install.php']);
04689 }
04690 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6