Documentation TYPO3 par Ameos

class.tx_install.php

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


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