Documentation TYPO3 par Ameos

class.tx_install.php

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


Généré par Le spécialiste TYPO3 avec  doxygen 1.4.6