*/ /** * [CLASS/FUNCTION INDEX of SCRIPT] * * * * 154: class tx_install extends t3lib_install * 225: function tx_install() * 303: function checkPassword($uKey) * 364: function init() * 529: function stepOutput() * 781: function checkTheConfig() * 812: function typo3conf_edit() * 922: function phpinformation() * * SECTION: typo3temp/ manager * 1025: function typo3TempManager() * 1126: function getSelectorOptions($deleteType,$tt="") * * SECTION: cleanup manager * 1158: function cleanupManager() * * SECTION: CONFIGURATION FORM * 1226: function generateConfigForm($type="") * 1298: function getDefaultConfigArrayComments($string,$mainArray=array(),$commentArray=array()) * * SECTION: CHECK CONFIGURATION FUNCTIONS * 1351: function checkConfiguration() * 1546: function check_mail($cmd="") * 1569: function checkExtensions() * 1632: function checkDirs() * 1718: function checkImageMagick($paths) * 1785: function _checkImageMagickGifCapability($file) * 1827: function _checkImageMagick_getVersion($file) * 1840: function checkDatabase() * 1902: function setupGeneral($cmd="") * 2069: function writeToLocalconf_control($lines="") * 2092: function outputExitBasedOnStep($content) * 2108: function setLabelValueArray($arr,$type) * 2136: function getFormElement($labels,$values,$fieldName,$default,$msg="") * 2156: function getDatabaseList() * 2180: function setupGeneralCalculate() * 2249: function getGDPartOfPhpinfo() * 2268: function isTTF($phpinfo="") * * SECTION: ABOUT the isXXX functions. * 2317: function isGD() * 2328: function isGIF() * 2340: function isJPG() * 2351: function isPNG() * 2363: function ImageTypes() * 2374: function getGDSoftwareInfo() * 2386: function generallyAboutConfiguration() * * SECTION: IMAGE processing * 2446: function checkTheImageProcessing() * 2925: function isExtensionEnabled($ext, $headCode, $short) * 2941: function displayTwinImage ($imageFile, $IMcommands=array(), $note="") * 3012: function getTwinImageMessage($message, $label_1="", $label_2="") * 3028: function formatImCmds($arr) * 3049: function imagemenu() * * SECTION: DATABASE analysing * 3091: function checkTheDatabase() * 3677: function isBackendAdminUser() * 3688: function isStaticTemplates() * 3700: function isBasicComplete($tLabel) * 3740: function generateUpdateDatabaseForm($type, $arr_update, $arr_remove, $action_type) * 3770: function getUpdateDbFormWrap($action_type, $content, $label="Write to database") * 3783: function displayFields($arr, $pre=0, $label="") * 3808: function displayFieldComp($arr, $arr_db) * 3850: function displaySuggestions($arr, $excludeList="") * 3880: function compareDatabaseAndTCA($FDsrc, $TCA, $onlyFields=0) * 3938: function compareTCAandDatabase($TCA, $FDcomp) * 3972: function suggestFieldDefinition($fieldInfo) * 4050: function getItemArrayType($arr) * 4080: function getItemBlobSize($len) * 4091: function suggestTCAFieldDefinition($fieldName,$fieldInfo) * 4234: function includeTCA() * * SECTION: GENERAL FUNCTIONS * 4276: function linkIt($url,$link="") * 4304: function printSection($head, $short_string, $long_string, $type) * 4345: function fw($str,$size=1) * 4358: function fwheader($str) * 4369: function wrapInCells($label,$content) * 4378: function printAll() * 4397: function outputWrapper($content) * 4450: function menu() * 4472: function stepHeader() * 4514: function note123() * 4528: function endNotes() * 4547: function convertByteSize($bytes) * 4561: function securityRisk() * 4579: function alterPasswordForm() * 4595: function messageBasicFinished() * 4617: function setScriptName($type) * 4630: function formWidth($size=48,$textarea=0,$styleOverride="") * 4651: function formWidthText($size=48,$styleOverride="",$wrap="") * * TOTAL FUNCTIONS: 76 * (This index is automatically created/updated by the extension "extdeveval") * */ require_once (PATH_t3lib.'class.t3lib_install.php'); require_once (PATH_t3lib.'class.t3lib_stdgraphic.php'); /** * Install Tool module * * @author Kasper Skaarhoj * @package TYPO3 * @subpackage tx_install */ class tx_install extends t3lib_install { var $getGD_start_string='

gd

'; // Used to identify the GD section in the output from phpinfo() var $getGD_end_string = ''; // Used to identify the end of the GD section (found with getGD_start_string) in the output from phpinfo() var $getTTF_string = 'with TTF library'; // Used to identify whether TTF-lib is included with GD var $getTTF_string_alt = 'with freetype'; // Used to identify whether TTF-lib is included with GD var $action = ""; // The url that calls this script var $scriptSelf = "index.php"; // The url that calls this script var $fontTag2=''; var $fontTag1=''; var $updateIdentity = "TYPO3 Install Tool"; var $headerStyle =''; var $contentBeforeTable=""; var $setAllCheckBoxesByDefault=0; var $allowFileEditOutsite_typo3conf_dir=0; var $INSTALL =array(); // In constructor: is set to global GET/POST var TYPO3_INSTALL var $checkIMlzw = 0; // If set, lzw capabilities of the available ImageMagick installs are check by actually writing a gif-file and comparing size var $checkIM = 0; // If set, ImageMagick is checked. var $dumpImCommands=1; // If set, the image Magick commands are always outputted in the image processing checker var $mode = ""; // If set to "123" then only most vital information is displayed. var $step = 0; // If set to 1,2,3 or GO it signifies various functions. // internal var $passwordOK=0; // This is set, if the password check was ok. The function init() will exit if this is not set var $silent=1; // If set, the check routines don't add to the message-array var $messageFunc_nl2br=1; var $sections=array(); // Used to gather the message information. var $fatalError=0; // This is set if some error occured that will definitely prevent TYpo3 from running. var $sendNoCacheHeaders=1; var $config_array = array( // Flags are set in this array if the options are available and checked ok. "gd"=>0, "gd_gif"=>0, "gd_png"=>0, "gd_jpg"=>0, "freetype" => 0, "safemode" => 0, "dir_typo3temp" => 0, "dir_temp" => 0, "im_versions" => array(), "im" => 0, "sql.safe_mode_user" => "", "mysqlConnect" => 0, "no_database" => 0 ); var $typo3temp_path=""; var $menuitems = array( "config" => "Basic Configuration", "database" => "Database Analyser", "images" => "Image Processing", "extConfig" => "All Configuration", "typo3temp" => "typo3temp/", "cleanup" => "Clean up database", "phpinfo" => "phpinfo()", "typo3conf_edit" => "Edit files in typo3conf/", "about" => "About" ); var $cookie_name = "Typo3InstallTool"; var $JSmessage = ''; /** * Constructor * * @return [type] ... */ function tx_install() { if (!$GLOBALS["TYPO3_CONF_VARS"]["BE"]["installToolPassword"]) die("Install Tool deactivated.
You must enable it by setting a password in typo3conf/localconf.php. If you insert the line below, the password will be 'joh316':

\$TYPO3_CONF_VARS[\"BE\"][\"installToolPassword\"] = \"bacb98acf97e0b6112b1d1b650b84971\";

See the document 'installing_upgrading_32b1.pdf' for more info."); if ($this->sendNoCacheHeaders) { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Expires: 0"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); } // **************************** // Initializing incoming vars. // **************************** $this->INSTALL = t3lib_div::_GP("TYPO3_INSTALL"); $this->mode = t3lib_div::_GP("mode"); $this->step = t3lib_div::_GP("step"); if ($GLOBALS["HTTP_GET_VARS"]["TYPO3_INSTALL"]["type"]) $this->INSTALL["type"] = $GLOBALS["HTTP_GET_VARS"]["TYPO3_INSTALL"]["type"]; if ($this->step==3) { $this->INSTALL["type"]="database"; } if ($this->mode=="123") { $tempItems = $this->menuitems; unset($this->menuitems); $this->menuitems["config"] = $tempItems["config"]; $this->menuitems["database"] = $tempItems["database"]; if (!$this->INSTALL["type"] || !isset($this->menuitems[$this->INSTALL["type"]])) $this->INSTALL["type"] = "config"; } else { if (!$this->INSTALL["type"] || !isset($this->menuitems[$this->INSTALL["type"]])) $this->INSTALL["type"] = "about"; } $this->action = $this->scriptSelf."?TYPO3_INSTALL[type]=".$this->INSTALL["type"].($this->mode?"&mode=".rawurlencode($this->mode):"").($this->step?"&step=".rawurlencode($this->step):""); $this->typo3temp_path = PATH_site."typo3temp/"; // **************** // Check password // **************** // Getting a unique session key, used to encode the session-access cookie later... $uKey = $GLOBALS["HTTP_COOKIE_VARS"][$this->cookie_name."_key"]; if (!$uKey) { $uKey = md5(uniqid(microtime())); SetCookie($this->cookie_name."_key", $uKey, 0, "/"); // Cookie is set $this->JSmessage='SECURITY: Make sure to protect the Install Tool with another password than "joh316". Better yet you can add a die() function call to typo3/install/index.php after usage. IF THE INSTALL TOOL CRASHES... The Install Tool is checking PHPs support for image formats. However certain versions of PHP (fx. 4.3.0 with bundled GD) will crash when trying to read the PNG test file. If this happens you will see a blank screen or error message. Workaround: Open the file typo3/t3lib/class.t3lib_install.php, go to 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. On behalf of PHP we regret this inconvenience. 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. '; } // Check if the password from TYPO3_CONF_VARS combined with uKey matches the sKey cookie. If not, ask for password. $sKey = $GLOBALS["HTTP_COOKIE_VARS"][$this->cookie_name]; if (md5($GLOBALS["TYPO3_CONF_VARS"]["BE"]["installToolPassword"]."|".$uKey) == $sKey || $this->checkPassword($uKey)) { $this->passwordOK=1; } if ($GLOBALS["CLIENT"]["SYSTEM"]=="unix" && $GLOBALS["CLIENT"]["BROWSER"]=="konqu") { $this->fontTag2=''; $this->fontTag1=''; } } /** * Returns true if submitted password is ok. Else displays a form in which to enter password. * * @param [type] $uKey: ... * @return [type] ... */ function checkPassword($uKey) { $p = t3lib_div::_GP("password"); if ($p && md5($p)==$GLOBALS["TYPO3_CONF_VARS"]["BE"]["installToolPassword"]) { $sKey = md5($GLOBALS["TYPO3_CONF_VARS"]["BE"]["installToolPassword"]."|".$uKey); SetCookie($this->cookie_name, $sKey, 0, "/"); // Sending warning email $wEmail = $GLOBALS["TYPO3_CONF_VARS"]["BE"]["warning_email_addr"]; if ($wEmail) { $subject="Install Tool Login at '".$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"]."'"; $email_body="There has been a Install Tool login at TYPO3 site '".$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"]."' (".t3lib_div::getIndpEnv("HTTP_HOST").") from remote address '".t3lib_div::getIndpEnv("REMOTE_ADDR")."' (".t3lib_div::getIndpEnv("REMOTE_HOST").")"; mail($wEmail, $subject, $email_body, "From: TYPO3 Install Tool WARNING <>" ); } return true; } else { $this->messageFunc_nl2br=0; $this->silent=0; $content = '



'.$this->fw('The Install Tool Password is not the admin password of TYPO3.
If you don\'t know the current password, you can set a new one by setting the value of $TYPO3_CONF_VARS["BE"]["installToolPassword"] in typo3conf/localconf.php to the md5() hash value of the password you desire.'. ($p?"

The password you just tried has this md5-value:

".md5($p):"") ).'
'; $this->message("Password", "Enter the Install Tool Password", $content,3); echo $this->outputWrapper($this->printAll()); // Bad password, send warning: if ($p) { $wEmail = $GLOBALS["TYPO3_CONF_VARS"]["BE"]["warning_email_addr"]; if ($wEmail) { $subject="Install Tool Login ATTEMPT at '".$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"]."'"; $email_body="There has been a Install Tool login attempt at TYPO3 site '".$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"]."' (".t3lib_div::getIndpEnv("HTTP_HOST")."). Password tried was '".$p."' REMOTE_ADDR was '".t3lib_div::getIndpEnv("REMOTE_ADDR")."' (".t3lib_div::getIndpEnv("REMOTE_HOST").")"; mail($wEmail, $subject, $email_body, "From: TYPO3 Install Tool WARNING <>" ); } } return false; } } /** * Calling function that checks system, IM, GD, dirs, database and lets you alter localconf.php * This method is called from init.php to start the install Tool. * * @return [type] ... */ function init() { if (!defined("PATH_typo3")) exit; // Must be called after inclusion of init.php (or from init.php) if (!$this->passwordOK) exit; // debug($GLOBALS["HTTP_COOKIE_VARS"]); // Setting stuff... $this->check_mail(); $this->setupGeneral(); $this->generateConfigForm(); if (count($this->messages)) debug($this->messages); if ($this->step) { echo $this->outputWrapper($this->stepOutput()); } else { // Menu... switch($this->INSTALL["type"]) { case "images": $this->checkIM=1; $this->checkTheConfig(); $this->silent=0; $this->checkTheImageProcessing(); break; case "database": $this->checkTheConfig(); $this->silent=0; $this->checkTheDatabase(); break; case "config": $this->silent=0; $this->checkIM=1; $this->message("About configuration","How to configure TYPO3",$this->generallyAboutConfiguration()); $this->checkTheConfig(); $ext = "Write config to localconf.php"; if ($this->fatalError) { if ($this->config_array["no_database"] || !$this->config_array["mysqlConnect"]) { $this->message($ext, "Database not configured yet!", " You need to specify database username, password and host as one of the first things. Next you'll have to select a database to use with TYPO3. Use the form below: ",2); } else { $this->message($ext, "Fatal error encountered!", " Somewhere above a fatal configuration problem is encountered. Please make sure that you've fixed this error before you submit the configuration. TYPO3 will not run if this problem is not fixed! You should also check all warnings that may appear. ",2); } } elseif ($this->mode=="123") { if (!$this->fatalError) { $this->message($ext, "Basic configuration completed", ' You have no fatal errors in your basic configuration. You may have warnings though. Please pay attention to them! However you may continue and install the database. Step 2: Click here to install the database. ',-1,1); } } $this->message($ext, "Very Important: Changing Image Processing settings", " When you change the settings for Image Processing you must take into account that old images may still be in typo3temp/ folder and prevent new files from being generated! This is especially important to know, if you're trying to set up image processing for the very first time. The problem is solved by setScriptName("typo3temp")."\">clearing the typo3temp/ folder. Also make sure to clear the cache_pages table. ",1,1); $this->message($ext, "Update localconf.php", " This form updates the localconf.php file with the suggested values you see below. The values are based on the analysis above. You can change the values in case you have alternatives to the suggested defaults. By this final step you will configure TYPO3 for immediate use provided that you have no fatal errors left above." .$this->setupGeneral("get_form"),0,1); echo $this->outputWrapper($this->printAll()); // debug($this->config_array); break; case "extConfig": $this->silent=0; $this->generateConfigForm("get_form"); $content = $this->printAll(); $content = '
'.$content.'

'.$this->fw("NOTICE: By clicking this button, localconf.php is updated with new values for the parameters listed above!
").'
'; echo $this->outputWrapper($content); break; case "typo3temp": $this->checkTheConfig(); $this->silent=0; $this->typo3TempManager(); break; case "cleanup": $this->checkTheConfig(); $this->silent=0; $this->cleanupManager(); break; case "phpinfo": $this->silent=0; $this->phpinformation(); break; case "typo3conf_edit": $this->silent=0; $this->typo3conf_edit(); break; case "about": default: $this->silent=0; $this->message("About", "Warning - very important!", $this->securityRisk().$this->alterPasswordForm(),2); $this->message("About", "Using this script", " Installing TYPO3 has always been a hot topic on the mailing list and forums. Therefore we've developed this tool which will help you through configuration and testing. There are three primary steps for you to take: 1: Basic Configuration In this step your PHP-configuration is checked. If there are any settings that will prevent TYPO3 from running correctly you'll get warnings and errors with a description of the problem. You'll have to enter a database username, password and hostname. Then you can choose to create a new database or select an existing one. Finally the image processing settings are entered and verified and you can choose to let the script update the configuration file, typo3conf/localconf.php with the suggested settings. 2: Database Analyser In this step you can either install a new database or update the database from any previous TYPO3 version. You can also get an overview of extra/missing fields/tables in the database compared to a raw sql-file. The database is also verified agains your 'tables.php' configuration (\$TCA) and you can even see suggestions to entries in \$TCA or new fields in the database. 3: Image Processing This step is a visual guide to verify your configuration of the image processing software. You'll be presented to a list of images that should all match in pairs. If some irregularity appears, you'll get a warning. Thus you're able to track an error before you'll discover it on your website. 4: All Configuration 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. 5: typo3temp/ Here you can manage the files in typo3temp/ folder in a simple manner. typo3temp/ contains temporary files, which may still be used by the website, but some may not. By searching for files with old access-dates, you can possibly manage to delete unused files rather than files still used. However if you delete a temporary file still in use, it's just regenerated as long as you make sure to clear the cache tables afterwards. "); $this->message("About", "Why is this script stand-alone?", " You would think that this script should rather be a module in the backend and access-controlled to only admin-users from the database. But that's not how it works. The reason is, that this script must not be depending on the success of the configuration of TYPO3 and whether or not there is a working database behind. Therefore the script is invoked from the backend init.php file, which allows access if the constant 'TYPO3_enterInstallScript' has been defined and is not false. That is and should be the case only when calling the script 'typo3/install/index.php' - this script! "); $headCode="Header legend"; $this->message($headCode, "Just information", " This is a simple message with some information about something. "); $this->message($headCode, "Check was successful", " Indicates that something was checked and returned an expected result. ",-1); $this->message($headCode, "Notice!", " Indicates that something is important to be aware of. This does not indicate an error. ",1); $this->message($headCode, "Warning!", " Indicates that something may very well cause trouble and you should definitely look into it before proceeding. This indicates a potential error. ",2); $this->message($headCode, "Error!", " Indicates that something is definitely wrong and that TYPO3 will most likely not perform as expected if this problem is not solved. This indicates an actual error. ",3); echo $this->outputWrapper($this->printAll()); break; } } } /** * Controls the step 1-2-3-go process * * @return [type] ... */ function stepOutput() { $this->checkTheConfig(); $error_missingConnect='
'.$this->fontTag2.' There is no connection to the database!
(Username: '.TYPO3_db_username.', Password: '.TYPO3_db_password.', Host: '.TYPO3_db_host.').

Go to Step 1 and enter a proper username/password!


'; $error_missingDB='
'.$this->fontTag2.' There is no access to the database ('.TYPO3_db.')!

Go to Step 2 and select an accessible database!


'; $whichTables=$this->getListOfTables(); $dbInfo='
'.$this->fontTag2.'Database summary:
'.$this->fontTag1.'Username: '.$this->fontTag1.''.TYPO3_db_username.'
'.$this->fontTag1.'Password: '.$this->fontTag1.''.TYPO3_db_password.'
'.$this->fontTag1.'Host: '.$this->fontTag1.''.TYPO3_db_host.'
'.$this->fontTag1.'Database: '.$this->fontTag1.''.TYPO3_db.'
'.$this->fontTag1.'# of tables: '.$this->fontTag1.''.(count($whichTables)?''.count($whichTables).'':count($whichTables)).'
'; $error_emptyDB='
'.$this->fontTag2.' The database is still empty. There are no tables!

Go to Step 3 and import a database!


'; switch(strtolower($this->step)) { case 1: $msg='

'.$this->fontTag2.'Username:   '.$this->fontTag2.'
'.$this->fontTag2.'Password:   '.$this->fontTag2.'
'.$this->fontTag2.'Host:   '.$this->fontTag2.'
'.$this->fontTag1.'   '.$this->fontTag1.'


NOTICE: By clicking this button, typo3conf/localconf.php is updated with new values for the parameters listed above!


'; break; case 2: if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { $dbArr = $this->getDatabaseList(); reset($dbArr); $options=""; $options.=''; $dbIncluded=0; while(list(,$dbname)=each($dbArr)) { $options.=''; if ($dbname==TYPO3_db) $dbIncluded=1; } if (!$dbIncluded && TYPO3_db) { $options.=''; } $select=''; $msg='

'.$this->fontTag2.' You have two options:


1: Select an existing EMPTY database:
'.$this->fontTag1.'Any existing tables which are used by TYPO3 will be overwritten in Step 3. So make sure this database is empty:
'.$select.'


'.$this->fontTag2.'2: Create new database (recommended):
'.$this->fontTag1.'Enter the desired name of the database here:


'.$this->fontTag1.'


NOTICE: By clicking this button, typo3conf/localconf.php is updated with new values for the parameters listed above!


'; } else { $msg=$error_missingConnect; } break; case 3: if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { if ($GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) { $sFiles = t3lib_div::getFilesInDir(PATH_typo3conf,"sql",1,1); reset($sFiles); $opt=''; while(list(,$f)=each($sFiles)) { $opt.=''; } $content=' '.$this->fontTag2.'Database dumps in typo3conf/ directory:


'; $content = $this->getUpdateDbFormWrap("import", $content, "Import database"); $msg='
'.$dbInfo.'

'.$content.' '; } else { $msg=$error_missingDB; } } else { $msg=$error_missingConnect; } break; case "go": if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { if ($GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) { if (count($whichTables)) { $msg='
'.$this->fontTag2.' '.nl2br($this->messageBasicFinished()).'

IMPORTANT

'.nl2br($this->securityRisk()).'
Enter "Normal" mode for the Install Tool to change this!

'; } else { $msg=$error_emptyDB; } } else { $msg=$error_missingDB; } } else { $msg=$error_missingConnect; } break; default: break; } return $msg; } /** * Calling the functions that checks the system * * @return [type] ... */ function checkTheConfig() { // Order important: $this->checkDirs(); $this->checkConfiguration(); $this->checkExtensions(); if (TYPO3_OS=="WIN") { $paths=array($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path_lzw"], $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path"], "c:\\php\\imagemagick\\", 'c:\\apache\\ImageMagick\\'); } else { $paths=array($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path_lzw"], $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path"], "/usr/local/bin/","/usr/bin/","/usr/X11R6/bin/"); } asort($paths); if (ini_get("safe_mode")) { $paths=array(ini_get("safe_mode_exec_dir"),"/usr/local/php/bin/"); } if ($this->INSTALL["checkIM"]["lzw"]) { $this->checkIMlzw=1; } if ($this->INSTALL["checkIM"]["path"]) { $paths[]=trim($this->INSTALL["checkIM"]["path"]); } if ($this->checkIM) $this->checkImageMagick($paths); $this->checkDatabase(); } /** * Editing files in typo3conf directory (or elsewhere if enabled) * * @return [type] ... */ function typo3conf_edit() { $EDIT_path = PATH_typo3conf; // default: if ($this->allowFileEditOutsite_typo3conf_dir && $this->INSTALL["FILE"]["EDIT_path"]) { if (t3lib_div::validPathStr($this->INSTALL["FILE"]["EDIT_path"]) && substr($this->INSTALL["FILE"]["EDIT_path"],-1)=="/") { $tmp_path = PATH_site.$this->INSTALL["FILE"]["EDIT_path"]; if (is_dir($tmp_path)) { $EDIT_path=$tmp_path; } else {debug("'".$tmp_path."' was not dir");} } else { debug("BAD DIR_NAME (must be like t3lib/ or media/script/)"); } } $headCode = "Edit files in ".basename($EDIT_path)."/"; $this->contentBeforeTable=""; if ($this->INSTALL["SAVE_FILE"]) { $save_to_file = $this->INSTALL["FILE"]["name"]; if (@is_file($save_to_file)) { $save_to_file_md5 = md5($save_to_file); if (isset($this->INSTALL["FILE"][$save_to_file_md5]) && t3lib_div::isFirstPartOfStr($save_to_file,$EDIT_path."") && substr($save_to_file,-1)!="~") { $this->INSTALL["typo3conf_files"] = $save_to_file; $save_fileContent = $this->INSTALL["FILE"][$save_to_file_md5]; if ($this->INSTALL["FILE"]["win_to_unix_br"]) { $save_fileContent = str_replace(chr(13).chr(10),chr(10),$save_fileContent); } if ($this->INSTALL["FILE"]["backup"]) { if (@is_file($save_to_file."~")) unlink($save_to_file."~"); rename($save_to_file,$save_to_file."~"); $this->contentBeforeTable.='Backup written to '.$save_to_file.'~
'; } else { if (@is_file($save_to_file."~")) { unlink($save_to_file."~"); $this->contentBeforeTable.='Backup REMOVED! ('.$save_to_file.'~)
'; } } t3lib_div::writeFile($save_to_file,$save_fileContent); $this->contentBeforeTable.=' File saved: '.$save_to_file.'
MD5-sum: '.$this->INSTALL["FILE"]["prevMD5"].' (prev)
MD5-sum: '.md5($save_fileContent).' (new)
'; } } } // Filelist: $typo3conf_files = t3lib_div::getFilesInDir($EDIT_path,"",1,1); reset($typo3conf_files); $lines=array(); $fileFound = 0; while(list($k,$file)=each($typo3conf_files)) { if ($this->INSTALL["typo3conf_files"] && !strcmp($this->INSTALL["typo3conf_files"],$file)) { $wrap=array('',''); $fileFound = 1; } else {$wrap=array();} $lines[]=''.$this->fw($wrap[0].basename($file).$wrap[1]."   ").''.$this->fw(t3lib_div::formatSize(filesize($file))).''; } $fileList=''.implode("",$lines).'
'; $fileList.="
(".$EDIT_path.")"; if ($this->allowFileEditOutsite_typo3conf_dir) { $fileList.='
'.PATH_site.'
'; } if ($fileFound && @is_file($this->INSTALL["typo3conf_files"])) { $this->headerStyle = ' '; $fileContent = t3lib_div::getUrl($this->INSTALL["typo3conf_files"]); $this->contentBeforeTable.= '
'.(substr($this->INSTALL["typo3conf_files"],-1)!="~"?' ':'').'
File: '.$this->INSTALL["typo3conf_files"].'
MD5-sum: '.md5($fileContent).'
'.($this->allowFileEditOutsite_typo3conf_dir?'':'').'
Convert windows linebreaks (13-10) to unix (10)
INSTALL["typo3conf_files"]."~") ? " CHECKED":"").'> Make backup copy (else remove any backup copy, prepended by "~")
'. '
'; } if ($this->contentBeforeTable) { $this->contentBeforeTable = $this->fw($this->contentBeforeTable); } $this->message($headCode,"Files in folder",$fileList); echo $this->outputWrapper($this->printAll()); } /** * Outputs system information * * @return [type] ... */ function phpinformation() { $headCode = "PHP information"; $sVar = t3lib_div::getIndpEnv("_ARRAY"); $sVar["CONST: PHP_OS"]=PHP_OS; $sVar["CONST: TYPO3_OS"]=TYPO3_OS; $sVar["CONST: PATH_thisScript"]=PATH_thisScript; $sVar["CONST: php_sapi_name()"]=php_sapi_name(); $sVar["OTHER: TYPO3_VERSION"]=$GLOBALS["TYPO_VERSION"]; $sVar["OTHER: PHP_VERSION"]=phpversion(); $sVar["imagecreatefromgif()"]=function_exists("imagecreatefromgif"); $sVar["imagecreatefrompng()"]=function_exists("imagecreatefrompng"); $sVar["imagecreatefromjpeg()"]=function_exists("imagecreatefromjpeg"); $sVar["imagegif()"]=function_exists("imagegif"); $sVar["imagepng()"]=function_exists("imagepng"); $sVar["imagejpeg()"]=function_exists("imagejpeg"); $sVar["imagettftext()"]=function_exists("imagettftext"); $sVar["OTHER: IMAGE_TYPES"]=imagetypes(); $sVar["OTHER: memory_limit"]=ini_get("memory_limit"); $gE_keys = explode(",","SERVER_PORT,SERVER_SOFTWARE,GATEWAY_INTERFACE,SCRIPT_NAME,PATH_TRANSLATED"); while(list(,$k)=each($gE_keys)) { $sVar["SERVER: ".$k]=$GLOBALS["HTTP_SERVER_VARS"][$k]; } $gE_keys = explode(",","image_processing,gdlib,gdlib_png,gdlib_2,im,im_path,im_path_lzw,im_version_5,im_negate_mask,im_imvMaskState,im_combine_filename"); while(list(,$k)=each($gE_keys)) { $sVar["T3CV_GFX: ".$k]=$GLOBALS["TYPO3_CONF_VARS"]["GFX"][$k]; } $debugInfo=array(); $debugInfo[]="### DEBUG SYSTEM INFORMATION - START ###"; reset($sVar); while(list($kkk,$vvv)=each($sVar)) { $debugInfo[]=str_pad(substr($kkk,0,20),20).": ".$vvv; } $debugInfo[]="### DEBUG SYSTEM INFORMATION - END ###"; $buf=$this->messageFunc_nl2br; $this->messageFunc_nl2br=0; $this->message($headCode,"DEBUG information",'Please copy/paste the information from this text field into an email or bug-report as "Debug System Information" whenever you wish to get support or report problems. This information helps others to check if your system has some obvious misconfiguration and you\'ll get your help faster!
'); $this->messageFunc_nl2br=$buf; $getEnvArray = array(); $gE_keys = explode(",","QUERY_STRING,HTTP_ACCEPT,HTTP_ACCEPT_ENCODING,HTTP_ACCEPT_LANGUAGE,HTTP_CONNECTION,HTTP_COOKIE,HTTP_HOST,HTTP_USER_AGENT,REMOTE_ADDR,REMOTE_HOST,REMOTE_PORT,SERVER_ADDR,SERVER_ADMIN,SERVER_NAME,SERVER_PORT,SERVER_SIGNATURE,SERVER_SOFTWARE,GATEWAY_INTERFACE,SERVER_PROTOCOL,REQUEST_METHOD,SCRIPT_NAME,PATH_TRANSLATED,HTTP_REFERER,PATH_INFO"); while(list(,$k)=each($gE_keys)) { $getEnvArray[$k] = getenv($k); } $this->message($headCode,"t3lib_div::getIndpEnv()",t3lib_div::view_array(t3lib_div::getIndpEnv("_ARRAY"))); $this->message($headCode,"getenv()",t3lib_div::view_array($getEnvArray)); $this->message($headCode,"HTTP_ENV_VARS",t3lib_div::view_array($GLOBALS["HTTP_ENV_VARS"])); $this->message($headCode,"HTTP_SERVER_VARS",t3lib_div::view_array($GLOBALS["HTTP_SERVER_VARS"])); $this->message($headCode,"HTTP_COOKIE_VARS",t3lib_div::view_array($GLOBALS["HTTP_COOKIE_VARS"])); $this->message($headCode,"HTTP_GET_VARS",t3lib_div::view_array($GLOBALS["HTTP_GET_VARS"])); ob_start(); phpinfo(); $contents = explode("",ob_get_contents()); ob_end_clean(); $contents = explode("",$contents[1]); $this->message($headCode,"phpinfo()",$contents[0]); $this->headerStyle = ' '; echo $this->outputWrapper($this->printAll()); } /******************************* * * typo3temp/ manager * *******************************/ /** * Provides a tool for deleting temporary files located in typo3temp/ * * @return string HTML output */ function typo3TempManager() { $headCode = "typo3temp/ directory"; $this->message($headCode,"What is it?"," TYPO3 uses this directory for temporary files, mainly processed and cached images. The filenames are very cryptic; They are unique representations of the file properties made by md5-hashing a serialized array with information. Anyway this directory may contain many thousand files and a lot of them may be of no use anymore. With this test you can delete the files in this folder. When you do that, you should also clear the cache database tables afterwards. "); if (!$this->config_array["dir_typo3temp"]) { $this->message("typo3temp/ directory","typo3temp/ not writeable!"," You must make typo3temp/ write enabled before you can proceed with this test. ",2); echo $this->outputWrapper($this->printAll()); return; } // Run through files $fileCounter=0; $deleteCounter=0; $criteriaMatch=0; $tmap=array("day"=>1,"week"=>7,"month"=>30); $tt=$this->INSTALL["typo3temp_delete"]; $action=$this->INSTALL["typo3temp_action"]; $d = @dir($this->typo3temp_path); if (is_object($d)) { while($entry=$d->read()) { $theFile = $this->typo3temp_path.$entry; if (@is_file($theFile)) { $ok=0; $fileCounter++; if ($tt) { if (t3lib_div::testInt($tt)) { if (filesize($theFile) > $tt*1024) $ok=1; } else { if (fileatime($theFile) < time()-(intval($tmap[$tt])*60*60*24)) $ok=1; } } else { $ok=1; } if ($ok) { $hashPart=substr(basename($theFile),-14,10); if (!ereg("[^a-f0-9]",$hashPart)) { // This is a kind of check that the file being deleted has a 10 char hash in it if ($action && $deleteCounter<$action) { $deleteCounter++; unlink($theFile); } else { $criteriaMatch++; } } } } } $d->close(); } $deleteType=array( "0" => "All", "day" => "Last access more than a day ago", "week" => "Last access more than a week ago", "month" => "Last access more than a month ago", "10" => "Filesize greater than 10 kb", "50" => "Filesize greater than 50 kb", "100" => "Filesize greater than 100 kb" ); $actionType=array( "0" => "Don't delete, just display statistics", "100" => "Delete 100", "500" => "Delete 500", "1000" => "Delete 1000" ); $content='
Number of files at a time: '; $form = '
'.$content.'
This tool will delete files only if the last 10 characters before the extension (3 chars+\'.\') are hexadecimal valid ciphers, which are lowercase a-f and 0-9.'; $this->message($headCode,"Statistics"," Number of temporary files: ".($fileCounter-$deleteCounter)." Number matching '".htmlspecialchars($deleteType[$tt])."': ".$criteriaMatch." Number deleted: ".$deleteCounter."
".$form,1); echo $this->outputWrapper($this->printAll()); } /** * [Describe function...] * * @param [type] $deleteType: ... * @param [type] $tt: ... * @return [type] ... */ function getSelectorOptions($deleteType,$tt="") { $out=""; if (is_array($deleteType)) { reset($deleteType); while(list($v,$l)=each($deleteType)) { $out.=''; } } return $out; } /******************************* * * cleanup manager * *******************************/ /** * Provides a tool cleaning up various tables in the database * * @return string HTML output * @author Robert Lemke * @todo Add more functionality ... */ function cleanupManager() { $headCode = "Clean up database"; $this->message($headCode,"What is it?"," 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. Clear cached image sizes 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. You should Clear All Cache in the backend after clearing this cache. "); $tables = $this->getListOfTables(); $action = $this->INSTALL['cleanup_type']; if (($action == 'cache_imagesizes' || $action == 'all') && isset ($tables['cache_imagesizes'])) { $GLOBALS['TYPO3_DB']->exec_DELETEquery ('cache_imagesizes','1'); } $cleanupType = array ( "all" => "Clean up everything", ); // Get cache_imagesizes info if (isset ($tables['cache_imagesizes'])) { $cleanupType["cache_imagesizes"] = "Clear cached image sizes only"; $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'cache_imagesizes', ''); $resArr = $GLOBALS['TYPO3_DB']->sql_fetch_assoc ($res); $cachedImageSizesCounter = intval ($resArr['count(*)']); } else { $this->message($headCode,"Table cache_imagesizes does not exist!"," The table cache_imagesizes was not found. Please check your database settings in Basic Configuration and compare your table definition with the Database Analyzer. ",2); $cachedImageSizesCounter = 'unknown'; } $content = ' '; $form = '
'.$content.'
'; $this->message($headCode,"Statistics"," Number cached image sizes: ".$cachedImageSizesCounter."
".$form,1); echo $this->outputWrapper($this->printAll()); } /******************************* * * CONFIGURATION FORM * ********************************/ /** * Creating the form for editing the TYPO3_CONF_VARS options. * * @param [type] $type: ... * @return [type] ... */ function generateConfigForm($type="") { switch($type) { case "get_form": $default_config_content = t3lib_div::getUrl(PATH_t3lib."config_default.php"); $commentArr = $this->getDefaultConfigArrayComments($default_config_content); /* $localconf_content = t3lib_div::getUrl(PATH_typo3conf."localconf.php"); $commentArr2 = $this->getConfigArrayComments($localconf_content); debug($commentArr2); */ reset($GLOBALS["TYPO3_CONF_VARS"]); $this->messageFunc_nl2br=0; while(list($k,$va)=each($GLOBALS["TYPO3_CONF_VARS"])) { $ext="[".$k."]"; $this->message($ext, '$TYPO3_CONF_VARS["'.$k.'"]',$commentArr[0][$k],1); while(list($vk,$value)=each($va)) { if (!is_array($value) && $this->checkForBadString($value)) { $k2="[".$vk."]"; $description = trim($commentArr[1][$k][$vk]); $msg=$description."

".$ext.$k2." = ".htmlspecialchars(t3lib_div::fixed_lgd($value,60))."
"; if (strstr($value,chr(10))) { // Never used at this point: $form=''; } elseif (eregi("^boolean",$description)) { $form=''; $form.=''; } else { $form=''; } $this->message($ext, $k2,$msg.$form); } } } break; default: if (is_array($this->INSTALL["extConfig"])) { reset($this->INSTALL["extConfig"]); $lines = $this->writeToLocalconf_control(); while(list($k,$va)=each($this->INSTALL["extConfig"])) { if (is_array($GLOBALS["TYPO3_CONF_VARS"][$k])) { while(list($vk,$value)=each($va)) { if (isset($GLOBALS["TYPO3_CONF_VARS"][$k][$vk])) { $doit=1; if ($k=="BE" && $vk=="installToolPassword") { if ($value) { if (isset($GLOBALS["HTTP_POST_VARS"]["installToolPassword_check"]) && (!t3lib_div::_GP("installToolPassword_check") || strcmp(t3lib_div::_GP("installToolPassword_check"),$value))) { $doit=0; debug("ERROR: The two passwords did not match! The password was not changed."); } if (t3lib_div::_GP("installToolPassword_md5")) $value =md5($value); } else $doit=0; } if ($doit && strcmp($GLOBALS["TYPO3_CONF_VARS"][$k][$vk],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["'.$k.'"]["'.$vk.'"]', $value); } } } } $this->writeToLocalconf_control($lines); } break; } } /** * [Describe function...] * * @param [type] $string: ... * @param [type] $mainArray: ... * @param [type] $commentArray: ... * @return [type] ... */ function getDefaultConfigArrayComments($string,$mainArray=array(),$commentArray=array()) { $lines = explode(chr(10),$string); $in=0; $mainKey=""; while(list(,$lc)=each($lines)) { $lc = trim($lc); if ($in) { if (!strcmp($lc,");")) { $in=0; } else { if (eregi('["\']([[:alnum:]_-]*)["\'][[:space:]]*=>(.*)',$lc,$reg)) { list(,$theComment)=explode("//",$reg[2],2); if (substr(strtolower(trim($reg[2])),0,5)=="array" && !strcmp($reg[1],strtoupper($reg[1]))) { $mainKey=trim($reg[1]); $mainArray[$mainKey]=trim($theComment); } elseif ($mainKey) { $commentArray[$mainKey][$reg[1]]=trim($theComment); } } else { //debug($lc,1); } } } if (!strcmp($lc,'$TYPO3_CONF_VARS = Array(')) { $in=1; } } return array($mainArray,$commentArray); } /******************************* * * CHECK CONFIGURATION FUNCTIONS * *******************************/ /** * Checking php.ini configuration and set appropriate messages and flags. * * @return [type] ... */ function checkConfiguration() { $ext="php.ini configuration checked"; $this->message($ext); // ***************** // Incoming values: // ***************** /* if (!ini_get("track_vars")) { $this->message($ext, "Tracking Vars not set"," track_vars=".ini_get("track_vars")." Tracking vars are essential for almost any PHP-application. The fact that the value is not set may not impose a problem, because it's always set in version 4.03+ of PHP. ",1); } else $this->message($ext, "Tracking Vars enabled","",-1); */ /* if (!ini_get("allow_url_fopen")) { $this->message($ext, "fopen() not allowed to open URL's"," allow_url_fopen=".ini_get("allow_url_fopen")." allow_url_fopen should be enabled if you want TYPO3 to connect to the online TYPO3 Extension Repository. ",2); } else $this->message($ext, "fopen() allowed to open URL's","",-1); */ // Includepath $incPaths = t3lib_div::trimExplode(TYPO3_OS=="WIN"?";":":", ini_get("include_path")); if (!in_array(".",$incPaths)) { $this->message($ext, "Current dir (./) is not in include path!"," include_path=".ini_get("include_path")." Normally the current path, '.', is included in the include_path of PHP. Although TYPO3 is made to work around this it is an unusual setting that may introduce problems. ",1); } else $this->message($ext, "Current dir in include path","",-1); /* if (!ini_get("register_globals")) { $this->message($ext, "Register globals disabled"," register_globals=".ini_get("register_globals")." Incoming values by GET or POST method are not registered as globals. TYPO3 is designed to cope with that - actually we encourage that setting - but you should be aware if your included PHP-scripts (or TypoScript configurations) are compatible with this setting. You should always use the function t3lib_div::_GP(\"[the_var_name_from_GET_or_POST]\") to retrieve values passed to your script from outside. ",1); } else $this->message($ext, "Register globals enabled","You should always use the function t3lib_div::_GP(\"[the_var_name_from_GET_or_POST]\") to retrieve values passed to your script from outside.",1); if (!ini_get("magic_quotes_gpc")) { $this->message($ext, "magic_quotes_gpc"," magic_quotes_gpc=".ini_get("magic_quotes_gpc")." Incoming \" and ' chars in values by GET or POST method are currently not escaped. TYPO3 is designed to cope with that but it may be on the expense of a minor performance loss, because all incoming values are addslashes()'ed. ",1); } else $this->message($ext, "magic_quotes_gpc","magic_quotes_gpc=".ini_get("magic_quotes_gpc")."",-1); if (ini_get("magic_quotes_runtime")) { $this->message($ext, "Magic Quotes Runtime is enabled"," magic_quotes_runtime=".ini_get("magic_quotes_runtime")." TYPO3 is depending on this option NOT being enabled! ",3); } else $this->message($ext, "magic_quotes_runtime","magic_quotes_runtime=".ini_get("magic_quotes_runtime")."",-1); if (ini_get("gpc_order")!="GPC") { $this->message($ext, "GPC order non-standard"," gpc_order=".ini_get("gpc_order")." The order of GET, POST and COOKIE vars are non-standard. The value should be \"GPC\". ",2); } else $this->message($ext, "GPC order","",-1); */ // ***************** // File uploads // ***************** if (!ini_get("file_uploads")) { $this->message($ext, "File uploads not allowed"," file_uploads=".ini_get("file_uploads")." TYPO3 uses the ability to upload files from the browser in various cases. As long as this flag is disabled, you'll not be able to upload files. But it doesn't end here, because not only are files not accepted by the server - ALL content in the forms are discarded and therefore nothing at all will be editable if you don't set this flag! However if you cannot enable fileupload for some reason alternatively you change the default form encoding value with \$TYPO3_CONF_VARS[SYS][form_enctype]. ",3); } else $this->message($ext, "File uploads allowed","",-1); $upload_max_filesize = $this->convertByteSize(ini_get("upload_max_filesize")); if ($upload_max_filesize<10000*1024) { $this->message($ext, "Max Upload filesize too small?"," upload_max_filesize=".ini_get("upload_max_filesize")." By default TYPO3 supports uploading, copying and moving files of sizes up to 10000 kb (10 MB) (You can alter the TYPO3 defaults by the config option TYPO3_CONF_VARS[BE][maxFileSize]). Your current value is below this, so at this point, PHP sets the limits for uploaded filesizes and not TYPO3. Notice: The limits for filesizes attached to database records are set in the tables.php configuration file (\$TCA) for each group/file field. ",1); } // ***************** // Memory and functions // ***************** $memory_limit_value = $this->convertByteSize(ini_get("memory_limit")); if ($memory_limit_value<16*1024*1024) { $this->message($ext, "Memory Limit below 16 MB"," memory_limit=".ini_get("memory_limit")." 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. ",3); } else $this->message($ext, "Memory Limit","memory_limit=".ini_get("memory_limit")."",-1); if (ini_get("max_execution_time")<30) { $this->message($ext, "Max Execution Time below default 30 seconds"," max_execution_time=".ini_get("max_execution_time")." May impose problems if too low. ",1); } else $this->message($ext, "Max Execution Time","max_execution_time=".ini_get("max_execution_time")."",-1); if (ini_get("disable_functions")) { $this->message($ext, "Functions disabled!"," disable_functions=".ini_get("disable_functions")." The above list of functions are disabled. If TYPO3 use any of these there might be trouble. TYPO3 is designed to use the default set of PHP4.0.6+ functions plus the functions from GDLib. Possibly these functions are disabled due to security risks and most likely the list would include a function like exec() which is use by TYPO3 to access ImageMagick. ",2); } else $this->message($ext, "Functions disabled: none","",-1); if (!ini_get("sendmail_path")) { $this->message($ext, "Sendmail path not defined!"," sendmail_path=".ini_get("sendmail_path")." This may be critical to TYPO3's use of the mail() function. Please be sure that the mail() function in your php-installation works! ".$this->check_mail("get_form"),1); } else { list($prg) = explode(" ",ini_get("sendmail_path")); if (TYPO3_OS=='WIN') { $this->message($ext, "Sendmail program not searched for on Windows","",1); } else { if (!@is_executable($prg)) { $this->message($ext, "Sendmail program not found or not executable?"," sendmail_path=".ini_get("sendmail_path")." This may be critical to TYPO3's use of the mail() function. Please be sure that the mail() function in your php-installation works! ".$this->check_mail("get_form"),1); } else { $this->message($ext, "Sendmail OK"," sendmail_path=".ini_get("sendmail_path")." You may check the mail() function by entering your emailaddress here: ".$this->check_mail("get_form"),-1); } } } // ***************** // Safe mode related // ***************** if (ini_get("safe_mode")) { $this->message($ext, "Safe mode turned on"," safe_mode=".ini_get("safe_mode")." 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 may be a problem in two areas: File administration and execution of external programs, in particular ImageMagick. If you just ignore this warning, you'll most likely find, that TYPO3 seems to work except from the image-generation. The problem in that case is that the external ImageMagick programs are not allowed to be executed from the regular paths like \"/usr/bin/\" or \"/usr/X11R6/bin/\". If you use safe_mode with TYPO3, you should disable use of external programs ([BE][disable_exec_function]=1). In safe mode you must ensure that all the php-scripts and upload folders are owned by the same user. safe_mode_exec_dir=".ini_get("safe_mode_exec_dir")." 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) Example of safe_mode settings: Set this in the php.ini file: ; Safe Mode safe_mode = On safe_mode_exec_dir = /usr/bin/ ...and the ImageMagick '/usr/bin/convert' will be executable. The last slash is important (..../) and you can only specify one directory. Notice: ImageMagick 4.2.9 is recommended and the binaries are normally installed by RPM in /usr/X11R6/bin or by compiling in /usr/local/bin. Please look in the \"Inside TYPO3\" pdf-document for extensive information about ImageMagick issues. Paths to ImageMagick are defined in localconf.php and may be something else than /usr/bin/, but this is default for ImageMagick 5+ ",2); if (ini_get("doc_root")) { $this->message($ext, "doc_root set"," doc_root=".ini_get("doc_root")." PHP cannot execute scripts outside this directory. If that is a problem is please correct it. ",1); } $this->config_array["safemode"]=1; } else $this->message($ext, "safe_mode: off","",-1); if (ini_get("sql.safe_mode")) { $this->message($ext, "sql.safe_mode is enabled"," sql.safe_mode=".ini_get("sql.safe_mode")." This means that you can only connect to the database with a username corresponding to the user of the webserver process or fileowner. Consult your ISP for information about this. Also see ".$this->linkIt("http://www.wrox.com/Consumer/Store/Books/2963/29632002.htm")." The owner of the current file is: ".get_current_user ()." ",1); $this->config_array["sql.safe_mode_user"] = get_current_user(); } else $this->message($ext, "sql.safe_mode: off","",-1); if (ini_get("open_basedir")) { $this->message($ext, "open_basedir set"," open_basedir=".ini_get("open_basedir")." This restricts TYPO3 to open and include files only in this path. Please make sure that this does not prevent TYPO3 from running. Notice (UNIX): Before checking a path according to open_basedir, PHP resolves all symbolic links. ",1); // ???? If this option was set falsely you probably didn't see this page in the first place, but this option may spoil this configuration test when checking for such as ImageMagick executables. } else $this->message($ext, "open_basedir: off","",-1); } /** * Check if php function mail() works * * @param string $cmd If "get_form" then a formfield for the mail-address is shown. If not, it's checked if "check_mail" was in the INSTALL array and if so a test mail is sent to the recipient given. * @return [type] ... */ function check_mail($cmd="") { switch($cmd) { case "get_form": $out=' You can check the mail() function by entering your email address here and press the button. You should then receive a testmail from test@test.test.
'; break; default: if (trim($this->INSTALL["check_mail"])) { mail(trim($this->INSTALL["check_mail"]), "TEST SUBJECT", "TEST CONTENT", "From: test@test.test"); $this->messages[]= "MAIL WAS SENT TO: ".$this->INSTALL["check_mail"]; } break; } return $out; } /** * Checking php extensions, specifically GDLib and Freetype * * @return [type] ... */ function checkExtensions() { $ext = "GDLib"; $this->message($ext); $software_info=1; if (extension_loaded("gd") && $this->isGD()) { $this->config_array["gd"]=1; $this->message($ext, "GDLib found","",-1); if ($this->isPNG()) { $this->config_array["gd_png"]=1; $this->message($ext, "PNG supported","",-1); } if ($this->isGIF()) { $this->config_array["gd_gif"]=1; $this->message($ext, "GIF supported","",-1); } if ($this->isJPG()) { $this->config_array["gd_jpg"]=1; $this->message($ext, "JPG supported (not used by TYPO3)",""); } if (!$this->config_array["gd_gif"] && !$this->config_array["gd_png"]) { $this->message($ext, "PNG or GIF not supported", nl2br(trim(" Your GDLib supports either GIF nor PNG. It must support either one of them. ")), 2); } else { $msg=array(); if ($this->config_array["gd_gif"] && $this->config_array["gd_png"]) { $msg[0]="You can choose between generating GIF or PNG files, as your GDLib supports both."; } if ($this->config_array["gd_gif"]) { $msg[10]="You should know that generating GIF files are covered by a UNISYS patent. Read more for details."; $msg[11]="In addition you should watch out for the generated size of the GIF-files because GDLib does not compress them with LZW, but RLE and ImageMagick is subsequently used to compress with LZW. But in the case of ImageMagick failing this task (eg. not being compiled with LZW which is the case with newer versions) you'll end up with GIF-filesizes all too big! This install tool tests what kinds of GIF compression are available in the ImageMagick installations by a physical test. You can also check it manually by opening a TYPO3 generated gif-file with Photoshop and save it in a new file. If the file sizes of the original and the new file are almost the same, you're having LZW compression and everything is fine."; } if ($this->config_array["gd_png"]) { $msg[20]="TYPO3 prefers the use of GIF-files and most likely your visitors on your website does too as not all browsers support PNG yet."; } $this->message($ext, "GIF / PNG issues", nl2br(trim(implode($msg,chr(10)))), 1); } if (!$this->isTTF()) { $this->message($ext, "FreeType is apparently not installed", " It looks like the FreeType library is not compiled into GDLib. This is required when TYPO3 uses GDLib and you'll most likely get errors like 'ImageTTFBBox is not a function' or 'ImageTTFText is not a function'. ", 2); } else { $this->message($ext, "FreeType Quick-test (".($this->isGIF()?"as GIF":"as PNG").")", '
(If the text is exceeding the image borders you are using Freetype 2 and need to set TYPO3_CONF_VARS[GFX][TTFdpi]=96.
If there is no image at all Freetype is most likely NOT available and you can just as well disable GDlib for TYPO3...)', -1); $this->config_array["freetype"]=1; } } else { $this->message($ext, "GDLib not found", " GDLib is required if you want to use the GIFBUILDER object in TypoScript. GIFBUILDER is in charge of all advanced image generation in TypoScript, including graphical menuitems. GDLib is also used in the TYPO3 Backend (TBE) to generate record icons and new module tabs. It's highly recommended to install this library. Remember to compile GD with FreeType which is also required. If you choose not to install GDLib, you can disable it in the configuration with [GFX][gdlib]=0;. ", 2); } $this->message($ext, "GDLib software information", nl2br(trim($this->getGDSoftwareInfo()))); } /** * Checking and testing that the required writable directories are writable. * * @return [type] ... */ function checkDirs() { // Check typo3/temp/ $ext="Directories"; $this->message($ext); $uniqueName = md5(uniqid(microtime())); // The requirement level (the integer value, ie. the second value of the value array) has the following meanings: // -1 = not required, but if it exists may be writeable or not // 0 = not required, if it exists the dir should be writeable // 1 = required, don't has to be writeable // 2 = required, has to be writeable $checkWrite=array( "typo3temp/" => array("The folder is used by both the frontend (FE) and backend interface (TBE) for image manipulated files.",2,"dir_typo3temp"), # TYPO3_mainDir."temp/" => array("The folder is used by the backend interface only (TBE) for icons, pane tabs and click-menu items. The directory is usually not empty in the distribution, but you should be able to clear it out and TYPO3 should generate new files automatically.",1,"dir_temp"), "typo3conf/" => array("This directory contains the local configuration files of your website. TYPO3 must be able to write to these configuration files during setup and when the Extension Manager (EM) installs extensions.",2), "typo3conf/ext/" => array("Location for local extensions. Must be writable if the Extension Manager is supposed to install extensions for this website.",0), TYPO3_mainDir."ext/" => array("Location for global extensions. Must be writable if the Extension Manager is supposed to install extensions globally in the source.",-1), "uploads/" => array("Location for uploaded files from RTE + in the subdirs for tables.",2), "uploads/pics/" => array("Typical location for uploaded files (images especially).",0), "uploads/media/" => array("Typical location for uploaded files (non-images especially).",0), "uploads/tf/" => array("Typical location for uploaded files (TS template resources).",0), "fileadmin/" => array("Location for local files such as templates, independent uploads etc.",-1), "fileadmin/_temp_/" => array("Typical temporary location for default upload of files by administrators.",0), ); reset($checkWrite); while(list($relpath,$descr)=each($checkWrite)) { // Check typo3temp/ $general_message = $descr[0]; if (!@is_dir(PATH_site.$relpath)) { if ($descr[1]) { // required... $this->message($ext, $relpath." directory does not exist"," Full path: ".PATH_site.$relpath." ".$general_message." This error should not occur as ".$relpath." must always be accessible in the root of a TYPO3 website. ",3); } else { if ($descr[1] == 0) { $msg = 'This directory does not necessarily have to exist but if it does it must be writable.'; } else { $msg = 'This directory does not necessarily have to exist and if it does it can be writable or not.'; } $this->message($ext, $relpath." directory does not exist"," Full path: ".PATH_site.$relpath." ".$general_message." ".$msg." ",2); } } else { $file = PATH_site.$relpath.$uniqueName; @touch($file); if (@is_file($file)) { unlink($file); if ($descr[2]) { $this->config_array[$descr[2]]=1; } $this->message($ext, $relpath." writeable","",-1); } else { $severity = ($descr[1]==2 || $descr[1]==0) ? 3 : 2; if ($descr[1] == 0 || $descr[1] == 2) { $msg = "The directory ".$relpath." must be writable!"; } elseif ($descr[1] == -1 || $descr[1] == 1) { $msg = "The directory ".$relpath." does not neccesarily have to be writable."; } $this->message($ext, $relpath." directory not writeable"," Full path: ".$file." ".$general_message." Tried to write this file (with touch()) but didn't succeed. ".$msg." ",$severity); } } } } /** * Checking for existing ImageMagick installs. * * This tries to find available ImageMagick installations and tries to find the version numbers by executing "convert" without parameters. If the ->checkIMlzw is set, LZW capabilities of the IM installs are check also. * * @param [type] $paths: ... * @return [type] ... */ function checkImageMagick($paths) { $ext="Check Image Magick"; $this->message($ext); $paths = array_unique($paths); $programs = explode(",","convert,combine,composite,identify"); // Added composite (substitution for combine in newer versions?) $isExt = TYPO3_OS=="WIN" ? ".exe" : ""; $this->config_array["im_combine_filename"]="combine"; reset($paths); while(list($k,$v)=each($paths)) { reset($programs); if (!ereg('[\\\/]$',$v)) $v.='/'; while(list(,$filename)=each($programs)) { if (ini_get("open_basedir")||(@file_exists($v)&& @is_file($v.$filename.$isExt))) { if($this->_checkImageMagick_getVersion($v.$filename.$isExt) > 0 ) { $index[$v][$filename]=$this->_checkImageMagick_getVersion($v.$filename.$isExt); } } } if (count($index[$v])>=3) {$this->config_array["im"]=1;} if ($index[$v]["composite"] && !$index[$v]["combine"]) { $this->config_array["im_combine_filename"]="composite"; } elseif (!$index[$v]["composite"] && $index[$v]["combine"]) { $this->config_array["im_combine_filename"]="combine"; } if (isset($index[$v]["convert"]) && $this->checkIMlzw) { $index[$v]["gif_capability"] = "".$this->_checkImageMagickGifCapability($v); } } $this->config_array["im_versions"]=$index; if (!$this->config_array["im"]) { $this->message($ext, "No ImageMagick install available"," It seems that there is no adequate ImageMagick installation available at the checked locations (".implode($paths, ", ").") An 'adequate' installation for requires 'convert', 'combine'/'composite' and 'identify' to be available ",2); } else { $theCode=""; reset($this->config_array["im_versions"]); while(list($p,$v)=each($this->config_array["im_versions"])) { $ka=array(); reset($v); while(list($ka[])=each($v)){} $theCode.=''.$this->fw($p).''.$this->fw(implode($ka,"
")).''.$this->fw(implode($v,"
")).''; } $this->message($ext, "Available ImageMagick installations:",''.$theCode.'
',-1); } $this->message($ext, "Search for ImageMagick:",'
'.$content.'INSTALL["checkIM"]["lzw"]?" checked":"").'> Check LZW capabilities. Check this path for ImageMagick installation: (Eg. "D:\wwwroot\im537\ImageMagick\" for windows or "/usr/bin/" for Unix)
',0); } /** * Checking GIF-compression capabilities of ImageMagick install * * @param [type] $file: ... * @return [type] ... */ function _checkImageMagickGifCapability($file) { if ($this->config_array["dir_typo3temp"]) { // && !$this->config_array["safemode"] $path = $this->typo3temp_path; $uniqueName = md5(uniqid(microtime())); $dest = $path.$uniqueName.".gif"; $src = PATH_t3lib."gfx/typo3logo.gif"; if (@is_file($src) && !strstr($src," ") && !strstr($dest," ")) { $cmd = $file.'convert '.$src.' '.$dest; exec($cmd); } else die("No t3lib/gfx/typo3logo.gif file!"); $out=""; if (@is_file($dest)) { $new_info = @getimagesize($dest); clearstatcache(); $new_size = filesize($dest); $src_info = @getimagesize($src); clearstatcache(); $src_size = @filesize($src); if ($new_info[0]!=$src_info[0] || $new_info[1]!=$src_info[1] || !$new_size || !$src_size) { $out="error"; } else { if ($new_size/$src_size > 4) { // NONE-LZW ratio was 5.5 in test $out="NONE"; } elseif ($new_size/$src_size > 1.5) { // NONE-RLE ratio was not tested $out="RLE"; } else { $out="LZW"; } } unlink($dest); } return $out; } } /** * Extracts the version number for imagemagick * * @param string $file This is the path to the convert-program to execute in order to find the version number * @return [type] ... */ function _checkImageMagick_getVersion($file) { exec($file, $retVal); $string = $retVal[0]; list(,$ver) = explode("ImageMagick", $string); list($ver) = explode(" ",trim($ver)); return trim($ver); } /** * Checks database username/password/host/database * * @return [type] ... */ function checkDatabase() { $ext="Check database"; $this->message($ext); if (!extension_loaded("mysql")) { $this->message($ext, "MySQL not available"," PHP does not feature MySQL support (which is pretty unusual). ",2); } else { $cInfo=" Username: ".TYPO3_db_username." Password: ".TYPO3_db_password." Host: ".TYPO3_db_host." "; if (!TYPO3_db_host || !TYPO3_db_username) { $this->message($ext, "Username, password or host not set"," You may need to enter data for these values: ".trim($cInfo)." Use the form below. ",2); } if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { $this->message($ext, "Connected to SQL database successfully"," ".trim($cInfo)." ",-1,1); $this->config_array["mysqlConnect"]=1; if (!TYPO3_db) { $this->message($ext, "No database selected"," Currently you have no database selected. Please select one or create a new database. ",3); $this->config_array["no_database"]=1; } elseif (!$GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db)) { $this->message($ext, "Database"," '".TYPO3_db."' could not be selected as database! Please select another one or create a new database. ",3,1); $this->config_array["no_database"]=1; } else { $this->message($ext, "Database"," ".TYPO3_db." is selected as database. ",1,1); } } else { $this->message($ext, "Could not connect to SQL database!"," Connecting to SQL database failed with these settings: ".trim($cInfo)." Make sure you're using the correct set of data.".($this->config_array["sql.safe_mode_user"]? " Notice: sql.safe_mode is turned on, so apparently your username to the database is the same as the scriptowner, which is '".$this->config_array["sql.safe_mode_user"]."'":"")." ",3); } } } /** * Prints form for updating localconf.php or updates localconf.php depending on $cmd * * @param string $cmd If "get_form" it outputs the form. Default is to write "localconf.php" based on input in ->INSTALL[localconf.php] array and flag ->setLocalconf * @return [type] ... */ function setupGeneral($cmd="") { switch($cmd) { case "get_form": // Database: $out=' '; $out.=$this->wrapInCells("Username:", 'config_array["sql.safe_mode_user"]:"")).'">'.($this->config_array["sql.safe_mode_user"]?"
sql.safe_mode_user: ".$this->config_array["sql.safe_mode_user"]."":"")); $out.=$this->wrapInCells("Password:", ''); $out.=$this->wrapInCells("Host:", ''); if ($this->config_array["mysqlConnect"]) { $dbArr = $this->getDatabaseList(); reset($dbArr); $options=""; $dbIncluded=0; while(list(,$dbname)=each($dbArr)) { $options.=''; if ($dbname==TYPO3_db) $dbIncluded=1; } if (!$dbIncluded && TYPO3_db) { $options.=''; } $theCode='
Create database? (Enter name):
'; } else { $theCode=''.htmlspecialchars(TYPO3_db).'
(Can only select database if username/password/host is correctly set first)'; } $out.=$this->wrapInCells("", "
"); $out.=$this->wrapInCells("Database:", $theCode); $out.=$this->wrapInCells("", "
"); if ($this->mode!="123") { $out.=$this->wrapInCells("Site name:", ''); $out.=$this->wrapInCells("", "
"); // Other $fA = $this->setupGeneralCalculate(); // debug($fA); if (is_array($fA["disable_exec_function"])) { $out.=$this->wrapInCells("[BE][disable_exec_function]=", $this->getFormElement($fA["disable_exec_function"], $fA["disable_exec_function"], 'TYPO3_INSTALL[localconf.php][disable_exec_function]', $GLOBALS["TYPO3_CONF_VARS"]["BE"]["disable_exec_function"])); } if (is_array($fA["gdlib"])) { $out.=$this->wrapInCells("[GFX][gdlib]=", $this->getFormElement($fA["gdlib"], $fA["gdlib"], 'TYPO3_INSTALL[localconf.php][gdlib]', $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib"])); if (is_array($fA["gdlib_png"]) && $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib"]) { $out.=$this->wrapInCells("[GFX][gdlib_png]=", $this->getFormElement($this->setLabelValueArray($fA["gdlib_png"],2), $fA["gdlib_png"], 'TYPO3_INSTALL[localconf.php][gdlib_png]', $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib_png"])); } } if (is_array($fA["im"])) { $out.=$this->wrapInCells("[GFX][im]=", $this->getFormElement($fA["im"], $fA["im"], 'TYPO3_INSTALL[localconf.php][im]', $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im"])); $out.=$this->wrapInCells("[GFX][im_combine_filename]=", $this->getFormElement($fA["im_combine_filename"], ($fA["im_combine_filename"]?$fA["im_combine_filename"]:"combine"), 'TYPO3_INSTALL[localconf.php][im_combine_filename]', $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_combine_filename"])); if ($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im"]) { if (is_array($fA["im_path"])) { $out.=$this->wrapInCells("[GFX][im_path]=", $this->getFormElement($this->setLabelValueArray($fA["im_path"],1), $this->setLabelValueArray($fA["im_path"],0), 'TYPO3_INSTALL[localconf.php][im_path]', $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path"])); } if (is_array($fA["im_path_lzw"])) { $out.=$this->wrapInCells("[GFX][im_path_lzw]=", $this->getFormElement($this->setLabelValueArray($fA["im_path_lzw"],1), $this->setLabelValueArray($fA["im_path_lzw"],0), 'TYPO3_INSTALL[localconf.php][im_path_lzw]', $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path_lzw"])); } } } } $out.=$this->wrapInCells("", '

NOTICE: By clicking this button, localconf.php is updated with new values for the parameters listed above!'); $out.='
'; break; default: if (is_array($this->INSTALL["localconf.php"])) { $errorMessages=array(); $lines = $this->writeToLocalconf_control(); // New database? #debug($this->INSTALL); if (trim($this->INSTALL["localconf.php"]["NEW_DATABASE_NAME"])) { $newdbname=trim($this->INSTALL["localconf.php"]["NEW_DATABASE_NAME"]); if (!ereg("[^[:alnum:]_]",$newdbname)) { if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { if ($GLOBALS['TYPO3_DB']->admin_query('CREATE DATABASE '.$newdbname)) { $this->INSTALL["localconf.php"]["typo_db"] = $newdbname; $this->messages[]= "Database '".$newdbname."' created"; } else $this->messages[]= $errorMessages[] = "Could not create database '".$newdbname."' (...not created)"; } else $this->messages[]= $errorMessages[] = "Could not connect to database when creating database '".$newdbname."' (...not created)"; } else $this->messages[]= $errorMessages[] = "The NEW database name '".$newdbname."' was not alphanumeric, a-zA-Z0-9_ (...not created)"; } #debug($this->messages) ; // Parsing values reset($this->INSTALL["localconf.php"]); while(list($key,$value)=each($this->INSTALL["localconf.php"])) { switch((string)$key) { case "typo_db_username": if (!ereg("[^[:alnum:]_\.-]",$value) && strlen($value)<50) { if (strcmp(TYPO3_db_username,$value)) $this->setValueInLocalconfFile($lines, '$typo_db_username', $value); } else $this->messages[]= $errorMessages[] = "Username '".$value."' was not alphanumeric, a-zA-Z0-9_-., or longer than 50 chars (...not saved)"; break; case "typo_db_password": if (!ereg("[^[:alnum:]_\.-]",$value) && strlen($value)<50) { if (strcmp(TYPO3_db_password,$value)) $this->setValueInLocalconfFile($lines, '$typo_db_password', $value); } else $this->messages[]= $errorMessages[] = "Password '".$value."' was not alphanumeric, a-zA-Z0-9_-., or longer than 50 chars (...not saved)"; break; case "typo_db_host": if (!ereg("[^[:alnum:]_\.-]",$value) && strlen($value)<50) { if (strcmp(TYPO3_db_host,$value)) $this->setValueInLocalconfFile($lines, '$typo_db_host', $value); } else $this->messages[]= $errorMessages[] = "Host '".$value."' was not alphanumeric, a-zA-Z0-9_-., or longer than 50 chars (...not saved)"; break; case "typo_db": if (!ereg("[^[:alnum:]_\.-]",$value) && strlen($value)<50) { if (strcmp(TYPO3_db,$value)) $this->setValueInLocalconfFile($lines, '$typo_db', $value); } else $this->messages[]= $errorMessages[] = "Database '".$value."' was not alphanumeric, a-zA-Z0-9_-., or longer than 50 chars (...not saved)"; break; case "disable_exec_function": if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["BE"]["disable_exec_function"],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["BE"]["disable_exec_function"]', $value?1:0); break; case "sitename": if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["SYS"]["sitename"]', $value); break; case "im_combine_filename": if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_combine_filename"],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["GFX"]["im_combine_filename"]', $value); break; case "gdlib": case "gdlib_png": case "im": if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["GFX"][$key],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["GFX"]["'.$key.'"]', $value?1:0); break; case "im_path": list($value,$version) = explode("|",$value); if (!ereg("[[:space:]]",$value,$reg) && strlen($value)<100) { if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["GFX"][$key],$value)) { $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["GFX"]["'.$key.'"]', $value); } $value_ext = (doubleval($version)<5)?0:1; if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_version_5"],$value_ext)) { $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["GFX"]["im_version_5"]', $value_ext); } } else $this->messages[]= $errorMessages[] = "Path '".$value."' contains spaces or is longer than 100 chars (...not saved)"; break; case "im_path_lzw": list($value) = explode("|",$value); if (!ereg("[[:space:]]",$value) && strlen($value)<100) { if (strcmp($GLOBALS["TYPO3_CONF_VARS"]["GFX"][$key],$value)) $this->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS["GFX"]["'.$key.'"]', $value); } else $this->messages[]= $errorMessages[] = "Path '".$value."' contains spaces or is longer than 100 chars (...not saved)"; break; } } if (count($errorMessages)) { echo "

ERRORS

"; echo t3lib_div::view_array($errorMessages); echo 'Click the browsers "Back" button to reenter the values.'; exit; } $this->writeToLocalconf_control($lines); } break; } return $out; } /** * [Describe function...] * * @param [type] $lines: ... * @return [type] ... */ function writeToLocalconf_control($lines="") { $returnVal = parent::writeToLocalconf_control($lines); switch($returnVal) { case 'continue': $content = "

".implode($this->messages,"
").'

Click to continue...'; $this->outputExitBasedOnStep($content); break; case 'nochange': $content = 'Writing to \'localconf.php\':

No values were changed, so nothing is updated!

Click to continue...'; $this->outputExitBasedOnStep("
".$content); break; } return $returnVal; } /** * [Describe function...] * * @param [type] $content: ... * @return [type] ... */ function outputExitBasedOnStep($content) { if ($this->step) { Header("Location: ".t3lib_div::locationHeaderUrl($this->action)); } else { echo $this->outputWrapper($content); } exit; } /** * This appends something to value in the input array based on $type. Private. * * @param [type] $arr: ... * @param [type] $type: ... * @return [type] ... */ function setLabelValueArray($arr,$type) { reset($arr); while(list($k,$v)=each($arr)) { switch($type) { case 0: // value, im $arr[$k].="|".$this->config_array["im_versions"][$v]["convert"]; break; case 1: // labels, im $arr[$k].=$this->config_array["im_versions"][$v]["convert"] ? " (".$this->config_array["im_versions"][$v]["convert"].($this->config_array["im_versions"][$v]["gif_capability"]?", ".$this->config_array["im_versions"][$v]["gif_capability"]:"").")" : ""; break; case 2: // labels, gd $arr[$k].=" (".($v==1?"PNG":"GIF").")"; break; } } return $arr; } /** * Returns a form-element for the localconf.php update form * * @param [type] $labels: ... * @param [type] $values: ... * @param [type] $fieldName: ... * @param [type] $default: ... * @param [type] $msg: ... * @return [type] ... */ function getFormElement($labels,$values,$fieldName,$default,$msg="") { $out.=''.htmlspecialchars(current($labels)).'
current value is '.htmlspecialchars($default).($msg?"
".$msg:""); if (count($labels)>1) { reset($labels); while(list($k,$v)=each($labels)) { list($cleanV) =explode("|",$values[$k]); $options.=''; } $out.='
'; } else { $out.=''; } return $out."
"; } /** * Returns the list of available databases (with access-check based on username/password) * * @return [type] ... */ function getDatabaseList() { $dbArr=array(); if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { $dbArr = $GLOBALS['TYPO3_DB']->admin_get_dbs(); } return $dbArr; } /** * Calculates the suggested setup that should be written to localconf.php * * If safe_mode * - disable_exec_function = 1 * - im = 0 * * if PNG/GIF/GD * - disable gdlib if nothing * - select png/gif if only one of them is available, else PNG/GIF selector, defaulting to GIF * - (safe_mode is on) * - im_path (default to 4.2.9, preferable with LZW) im_ver5-flag is set based on im_path being 4.2.9 or 5+ * - im_path_lzw (default to LZW version, pref. 4.2.9) * * @return [type] ... */ function setupGeneralCalculate() { $formArray["disable_exec_function"]=array(0); $formArray["im_path"]=array(""); $formArray["im_path_lzw"]=array(""); $formArray["im_combine_filename"]=array(""); $formArray["im"]=array(1); $formArray["gdlib"]=array(1); if ($this->config_array["gd"] && ($this->config_array["gd_gif"] || $this->config_array["gd_png"])) { if ($this->config_array["gd_gif"] && !$this->config_array["gd_png"]) { $formArray["gdlib_png"]=array(0); } elseif (!$this->config_array["gd_gif"] && $this->config_array["gd_png"]) { $formArray["gdlib_png"]=array(1); } else { $formArray["gdlib_png"]=array(0,1); } } else { $formArray["gdlib"]=array(0); } if ($this->config_array["safemode"]) { $formArray["disable_exec_function"]=array(1); } if ($this->config_array["im"]) { $formArray["im"]=array(1); $LZW_found=0; $found=0; reset($this->config_array["im_versions"]); $totalArr=array(); while(list($path,$dat)=each($this->config_array["im_versions"])) { if (count($dat)>=3) { if (doubleval($dat["convert"])<5) { if ($dat["gif_capability"]=="LZW") { $formArray["im_path"]=array($path); $found=2; } elseif ($found<2) { $formArray["im_path"]=array($path); $found=1; } } elseif (!$found) { $formArray["im_path"]=array($path); $found=1; } } if ($dat["gif_capability"]=="LZW") { if (doubleval($dat["convert"])<5) { $formArray["im_path_lzw"]=array($path); $LZW_found=1; } elseif (!$LZW_found) { $formArray["im_path_lzw"]=array($path); $LZW_found=1; } } elseif ($dat["gif_capability"]=="RLE" && !$LZW_found) { $formArray["im_path_lzw"]=array($path); } $totalArr[]=$path; } $formArray["im_path"]=array_unique(array_merge($formArray["im_path"],$totalArr)); $formArray["im_path_lzw"]=array_unique(array_merge($formArray["im_path_lzw"],$totalArr)); $formArray["im_combine_filename"]=array($this->config_array["im_combine_filename"]); } else { $formArray["im"]=array(0); } return $formArray; } /** * Returns the part of phpinfo() output that tells about GD library (HTML-code) * * @return [type] ... */ function getGDPartOfPhpinfo() { ob_start(); phpinfo(); $contents = ob_get_contents(); ob_end_clean(); $start_string = $this->getGD_start_string; $end_string = $this->getGD_end_string; list(,$gdpart_tmp) = explode($start_string,$contents,2); list($gdpart) = explode($end_string,$start_string.$gdpart_tmp,2); $gdpart.=$end_string; return $gdpart; } /** * Returns true if TTF lib is install according to phpinfo(). If $phpinfo supply as parameter that string is searched instead. * * @param [type] $phpinfo: ... * @return [type] ... */ function isTTF($phpinfo="") { /* $phpinfo = $phpinfo?$phpinfo:$this->getGDPartOfPhpinfo(); if (stristr($phpinfo, $this->getTTF_string)) return 1; if (stristr($phpinfo, $this->getTTF_string_alt)) return 1; */ if (!function_exists("imagettftext")) return 0; // Return right away if imageTTFtext does not exist. // try, print truetype font: $im = @imagecreate (300, 50); $background_color = imagecolorallocate ($im, 255, 255, 55); $text_color = imagecolorallocate ($im, 233, 14, 91); $test = @imagettftext($im, t3lib_div::freetypeDpiComp(20), 0, 10, 20, $text_color, PATH_t3lib."/fonts/verdana.ttf", "Testing Truetype support"); if (t3lib_div::_GP("testingTrueTypeSupport")) { if ($this->isGIF()) { header ("Content-type: image/gif"); imagegif ($im); } else { header ("Content-type: image/png"); imagepng ($im); } exit; } return is_array($test)?1:0; } /***************************************** * * ABOUT the isXXX functions. * * I had a very real experience that these checks DID NOT fail eg PNG support if it didn't exist! * So first (1) we check if the functions are there. If they ARE we are going to make further investigations (2) by creating an actual image. * And if THAT succeeds also, then we can be certain of the support! */ /** * @return [type] ... */ function isGD() { if (function_exists("imagecreate")) { if (@imagecreate (50, 100)) return 1; } } /** * [Describe function...] * * @return [type] ... */ function isGIF() { if (function_exists("imagecreatefromgif") && function_exists("imagegif") && ($this->ImageTypes() & IMG_GIF)) { // If GIF-functions exists, also do a real test of them: $im = @imagecreatefromgif(t3lib_extMgm::extPath("install")."imgs/jesus.gif"); return $im?1:0; } } /** * [Describe function...] * * @return [type] ... */ function isJPG() { if (function_exists("imagecreatefromjpeg") && function_exists("imagejpeg") && ($this->ImageTypes() & IMG_JPG)) { return 1; } } /** * [Describe function...] * * @return [type] ... */ function isPNG() { if (function_exists("imagecreatefrompng") && function_exists("imagepng") && ($this->ImageTypes() & IMG_PNG)) { $im = imagecreatefrompng(t3lib_extMgm::extPath("install")."imgs/jesus.png"); return $im?1:0; } } /** * [Describe function...] * * @return [type] ... */ function ImageTypes() { if (phpversion()!="4.1.2") { return imagetypes(); } else return IMG_GIF+IMG_JPG+IMG_PNG; // all... } /** * Returns general information about GDlib * * @return [type] ... */ function getGDSoftwareInfo() { return trim(" You can get GDLib in the PNG version from ".$this->linkIt("http://www.boutell.com/gd/").".
FreeType is for download at ".$this->linkIt("http://www.freetype.org/").". 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").". "); } /** * Returns general information about configuration of TYPO3. * * @return [type] ... */ function generallyAboutConfiguration() { $out=' Local configuration is done by overriding default values in the included file, typo3conf/localconf.php. In this file you enter the database information along with values in the global array TYPO3_CONF_VARS. The options in the TYPO3_CONF_VARS array and how to use it for your own purposes is discussed in the base configuration file, t3lib/config_default.php. This file sets up the default values and subsequently includes the localconf.php file in which you can then override values. See this page for '.$this->linkIt("http://typo3.org/1275.0.html","more information about system requirements.").' '; return trim($out); } /********************** * * IMAGE processing * **********************/ /** * jesus.TIF: IBM/LZW * jesus.GIF: Save for web, 32 colors * jesus.JPG: Save for web, 30 quality * jesus.PNG: Save for web, PNG-24 * jesus.tga 24 bit TGA file * jesus.pcx * jesus.bmp 24 bit BMP file * jesus_ps6.PDF: PDF w/layers and vector data * typo3logo.ai: Illustrator 8 file * pdf_from_imagemagick.PDF PDF-file made by Acrobat Distiller from InDesign PS-file * * * Imagemagick * - Read formats * - Write png, gif, jpg * * Problems may arise from the use of safe_mode (eg. png) * In safemode you will automatically execute the program convert in the safe_mode_exec_path no matter what other path you specify * check fileexist before anything... * * - compare gif size * - scaling (by stdgraphic) * - combining (by stdgraphic) * * GDlib: * - create from:.... * - ttf text * * From TypoScript: (GD only, GD+IM, IM) * * @return [type] ... */ function checkTheImageProcessing() { $this->message("Image Processing","What is it?"," TYPO3 is known for its ability to process images on the server. In the backend interface (TBE) thumbnails are automatically generated (by ImageMagick in thumbs.php) as well as icons, menu items and pane tabs (by GDLib). In the TypoScript enabled frontend all kinds of graphical elements are processed. Typically images are scaled down to fit the pages (by ImageMagick) and menu items, graphical headers and such are generated automatically (by GDLib + ImageMagick). In addition TYPO3 is able to handle many file formats (thanks to ImageMagick), for example TIF, BMP, PCX, TGA, AI and PDF in addition to the standard web formats; JPG, GIF, PNG. In order to do this, TYPO3 uses two sets of tools: ImageMagick: For conversion of non-web formats to webformats, combining images with alpha-masks, performing image-effects like blurring and sharpening. ImageMagick is a collection of external programs on the server called by the exec() function in PHP. TYPO3 uses three of these, namely 'convert' (converting fileformats, scaling, effects), 'combine'/'composite' (combining images with masks) and 'identify' (returns image information). Because ImageMagick are external programs, two requirements must be met: 1) The programs must be installed on the server and working and 2) if safe_mode is enabled, the programs must be located in the folder defined by the php.ini setting, safe_mode_exec_dir (else they are not executed). ImageMagick is available for both Windows and Unix. The current version is 5+, but TYPO3 enthusiasts prefer an old version 4.2.9 because that version has three main advantages: It's faster in some operations, the blur-function works, the sharpen-function works. Anyway you do it, you must tell TYPO3 by configuration whether you're using version 5+ or 4.2.9. (flag: [GFX][im_version_5]) ImageMagick homepage is at ".$this->linkIt("http://www.imagemagick.org/")." GDLib: For drawing boxes and rendering text on images with truetype fonts. Also used for icons, menuitems and generally the TypoScript GIFBUILDER object is based on GDlib, but extensively utilizing ImageMagick to process intermediate results. GDLib is accessed through internal functions in PHP, so in this case, you have no safe_mode problems, but you'll need a version of PHP with GDLib compiled in. Also in order to use TrueType fonts with GDLib you'll need FreeType compiled in as well. ".$this->getGDSoftwareInfo()." You can disable all image processing options in TYPO3 ([GFX][image_processing]=0), but that would seriously disable TYPO3. "); $this->message("Image Processing","Verifying the image processing capabilities of your server"," This page performs image processing and displays the result. It's a thorough check that everything you've configured is working correctly. It's quite simple to verify your installation; Just look down the page, the images in pairs should look like each other. If some images are not alike, something is wrong. You may also notice warnings and errors if this tool found signs of any problems. The image to the right is the reference image (how it should be) and to the left the image made by your server. The reference images are made with the classic ImageMagick install based on the 4.2.9 RPM and 5.2.3 RPM. If the version 5 flag is set, the reference images are made by the 5.2.3 RPM. This test will work only if your ImageMagick/GDLib configuration allows it to. The typo3temp/ folder must be writable for all the temporary image files. They are all prefixed 'install_' so they are easy to recognize and delete afterwards. "); // debug($this->config_array); $im_path = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path"]; $im_path_version = $this->config_array["im_versions"][$im_path]["convert"]; $im_path_lzw = $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_path_lzw"]; $im_path_lzw_version = $this->config_array["im_versions"][$im_path_lzw]["convert"]; $msg = " ImageMagick enabled: ".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im"]." ImageMagick path: ".$im_path." (".$im_path_version.") ImageMagick path/LZW: ".$im_path_lzw." (".$im_path_lzw_version.") Version 5 flag: ".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_version_5"]." GDLib enabled: ".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib"]." GDLib using PNG: ".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib_png"]." GDLib 2 enabled: ".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib_2"]." IM5 effects enabled: ".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_v5effects"]." (Blurring/Sharpening with IM 5+) Freetype DPI: ".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["TTFdpi"]." (Should be 96 for Freetype 2) Mask invert: ".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_imvMaskState"]." (Should be set for some IM versions approx. 5.4+) File Formats: ".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"]." "; if (($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_version_5"]?true:false) != (doubleval($im_path_version)>=5)) { $msg.="Warning: Mismatch between the version of ImageMagick (".$im_path_version.") and the configuration of [GFX][im_version_5] (".$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_version_5"].")"; $etype=2; } else $etype=1; $this->message("Image Processing","Current configuration",$msg,$etype); if (!$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["image_processing"]) { $this->message("Image Processing","Image Processing disabled!"," Image Processing is disabled by the config flag [GFX][image_processing] set to false (zero) ",2); echo $this->outputWrapper($this->printAll()); return; } if (!$this->config_array["dir_typo3temp"]) { $this->message("Image Processing","typo3temp/ not writeable!"," You must make typo3temp/ write enabled before you can proceed with this test. ",2); echo $this->outputWrapper($this->printAll()); return; } $msg='Click each of these links in turn to test a topic. Please be aware that each test may take several seconds!: '.$this->imagemenu(); $this->message("Image Processing","Testmenu",$msg,""); $this->messageFunc_nl2br=0; $parseStart = microtime(); $imageProc = t3lib_div::makeInstance("t3lib_stdGraphic"); $imageProc->init(); $imageProc->tempPath=$this->typo3temp_path; $imageProc->dontCheckForExistingTempFile=1; // $imageProc->filenamePrefix="install_".($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_version_5"]?"v5":""); $imageProc->filenamePrefix="install_"; $imageProc->dontCompress=1; $imageProc->alternativeOutputKey="TYPO3_INSTALL_SCRIPT"; $imageProc->noFramePrepended=$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["im_noFramePrepended"]; // Very temporary!!! $imageProc->dontUnlinkTempFiles=0; $imActive = ($this->config_array["im"] && $im_path); $gdActive = ($this->config_array["gd"] && $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gdlib"]); switch($this->INSTALL["images_type"]) { case "read": $refParseTime="5600"; // 4.2.9 $refParseTime="3300"; // 5.2.3 $headCode = "Reading and converting images"; $this->message($headCode,"Supported file formats"," This verifies that your ImageMagick installation is able to read the nine default file formats; JPG, GIF, PNG, TIF, BMP, PCX, TGA, PDF, AI. The tool 'identify' will be used to read the pixeldimensions of non-web formats. The tool 'convert' is used to read the image and write a temporary JPG-file "); if ($imActive) { // Reading formats - writing JPG $extArr = explode(",","jpg,gif,png,tif,bmp,pcx,tga"); while(list(,$ext)=each($extArr)) { if ($this->isExtensionEnabled($ext, $headCode, "Read ".strtoupper($ext))) { $imageProc->IM_commands=array(); $theFile = t3lib_extMgm::extPath("install")."imgs/jesus.".$ext; if (!@is_file($theFile)) die("Error: ".$theFile." was not a file"); $imageProc->imageMagickConvert_forceFileNameBody="read_".$ext; $fileInfo = $imageProc->imageMagickConvert($theFile,"jpg","","","","","",1); $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); $this->message($headCode,"Read ".strtoupper($ext),$result[0],$result[1]); } } if ($this->isExtensionEnabled("pdf", $headCode, "Read PDF")) { $imageProc->IM_commands=array(); $theFile = t3lib_extMgm::extPath("install")."imgs/pdf_from_imagemagick.pdf"; if (!@is_file($theFile)) die("Error: ".$theFile." was not a file"); $imageProc->imageMagickConvert_forceFileNameBody="read_pdf"; $fileInfo = $imageProc->imageMagickConvert($theFile,"jpg","170","","","","",1); $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); $this->message($headCode,"Read PDF",$result[0],$result[1]); } if ($this->isExtensionEnabled("ai", $headCode, "Read AI")) { $imageProc->IM_commands=array(); $theFile = t3lib_extMgm::extPath("install")."imgs/typo3logotype.ai"; if (!@is_file($theFile)) die("Error: ".$theFile." was not a file"); $imageProc->imageMagickConvert_forceFileNameBody="read_ai"; $fileInfo = $imageProc->imageMagickConvert($theFile,"jpg","170","","","","",1); $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); $this->message($headCode,"Read AI",$result[0],$result[1]); } } else { $this->message($headCode,"Test skipped"," Use of ImageMagick has been disabled in the configuration. Refer to section 'Basic Configuration' to change or review you configuration settings ",2); } break; case "write": $refParseTime="300"; // Writingformats - writing JPG $headCode = "Writing images"; $this->message($headCode,"Writing GIF and PNG"," This verifies that ImageMagick is able to write GIF and PNG files. The GIF-file is attempted compressed with LZW by the t3lib_div::gif_compress() function. "); if ($imActive) { // Writing GIF $imageProc->IM_commands=array(); $theFile = t3lib_extMgm::extPath("install")."imgs/jesus.gif"; if (!@is_file($theFile)) die("Error: ".$theFile." was not a file"); $imageProc->imageMagickConvert_forceFileNameBody="write_gif"; $fileInfo = $imageProc->imageMagickConvert($theFile,"gif","","","","","",1); if ($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gif_compress"]) { clearstatcache(); $prevSize=t3lib_div::formatSize(@filesize($fileInfo[3])); $returnCode = t3lib_div::gif_compress($fileInfo[3],""); clearstatcache(); $curSize=t3lib_div::formatSize(@filesize($fileInfo[3])); $note = array("Note on gif_compress() function:","The 'gif_compress' method used was '".$returnCode."'.
Previous filesize: ".$prevSize.". Current filesize:".$curSize); } else $note=array("Note on gif_compress() function:","Not used! Disabled by [GFX][gif_compress]"); $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands, $note); $this->message($headCode,"Write GIF",$result[0],$result[1]); // Writing PNG $imageProc->IM_commands=array(); $theFile = t3lib_extMgm::extPath("install")."imgs/jesus.gif"; $imageProc->imageMagickConvert_forceFileNameBody="write_png"; $fileInfo = $imageProc->imageMagickConvert($theFile,"png","","","","","",1); $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); $this->message($headCode,"Write PNG",$result[0],$result[1]); } else { $this->message($headCode,"Test skipped"," Use of ImageMagick has been disabled in the configuration. Refer to section 'Basic Configuration' to change or review you configuration settings ",2); } break; case "scaling": $refParseTime="650"; // Scaling $headCode = "Scaling images"; $this->message($headCode,"Scaling transparent images"," This shows how ImageMagick reacts when scaling transparent GIF and PNG files. "); if ($imActive) { // Scaling transparent image $imageProc->IM_commands=array(); $theFile = t3lib_extMgm::extPath("install")."imgs/jesus2_transp.gif"; if (!@is_file($theFile)) die("Error: ".$theFile." was not a file"); $imageProc->imageMagickConvert_forceFileNameBody="scale_gif"; $fileInfo = $imageProc->imageMagickConvert($theFile,"gif","150","","","","",1); if ($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["gif_compress"]) { clearstatcache(); $prevSize=t3lib_div::formatSize(@filesize($fileInfo[3])); $returnCode = t3lib_div::gif_compress($fileInfo[3],""); clearstatcache(); $curSize=t3lib_div::formatSize(@filesize($fileInfo[3])); $note = array("Note on gif_compress() function:","The 'gif_compress' method used was '".$returnCode."'.
Previous filesize: ".$prevSize.". Current filesize:".$curSize); } else $note=array("Note on gif_compress() function:","Not used! Disabled by [GFX][gif_compress]"); $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands,$note); $this->message($headCode,"GIF to GIF, 150 pixels wide",$result[0],$result[1]); $imageProc->IM_commands=array(); $theFile = t3lib_extMgm::extPath("install")."imgs/jesus2_transp.png"; if (!@is_file($theFile)) die("Error: ".$theFile." was not a file"); $imageProc->imageMagickConvert_forceFileNameBody="scale_png"; $fileInfo = $imageProc->imageMagickConvert($theFile,"png","150","","","","",1); $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); $this->message($headCode,"PNG to PNG, 150 pixels wide",$result[0],$result[1]); $imageProc->IM_commands=array(); $theFile = t3lib_extMgm::extPath("install")."imgs/jesus2_transp.gif"; if (!@is_file($theFile)) die("Error: ".$theFile." was not a file"); $imageProc->imageMagickConvert_forceFileNameBody="scale_jpg"; $fileInfo = $imageProc->imageMagickConvert($theFile,"jpg","150","","","","",1); $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); $this->message($headCode,"GIF to JPG, 150 pixels wide",$result[0],$result[1]); } else { $this->message($headCode,"Test skipped"," Use of ImageMagick has been disabled in the configuration. Refer to section 'Basic Configuration' to change or review you configuration settings ",2); } break; case "combining": $refParseTime="150"; // 4.2.9 $refParseTime="250"; // 5.2.3 // Combine $headCode = "Combining images"; $this->message($headCode,"Combining images"," This verifies that the ImageMagick tool, 'combine'/'composite', is able to combine two images through a grayscale mask.
If the masking seems to work but inverted, that just means you'll have to make sure the invert flag is set (some combination of im_negate_mask/im_imvMaskState) "); if ($imActive) { $imageProc->IM_commands=array(); $input = t3lib_extMgm::extPath("install")."imgs/greenback.gif"; $overlay = t3lib_extMgm::extPath("install")."imgs/jesus.jpg"; $mask = t3lib_extMgm::extPath("install")."imgs/blackwhite_mask.gif"; if (!@is_file($input)) die("Error: ".$input." was not a file"); if (!@is_file($overlay)) die("Error: ".$overlay." was not a file"); if (!@is_file($mask)) die("Error: ".$mask." was not a file"); $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5($imageProc->alternativeOutputKey."combine1").".jpg"; $imageProc->combineExec($input,$overlay,$mask,$output); $fileInfo = $imageProc->getImageDimensions($output); $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); $this->message($headCode,"Combine using a GIF mask with only black and white",$result[0],$result[1]); // Combine $imageProc->IM_commands=array(); $input = t3lib_extMgm::extPath("install")."imgs/combine_back.jpg"; $overlay = t3lib_extMgm::extPath("install")."imgs/jesus.jpg"; $mask = t3lib_extMgm::extPath("install")."imgs/combine_mask.jpg"; if (!@is_file($input)) die("Error: ".$input." was not a file"); if (!@is_file($overlay)) die("Error: ".$overlay." was not a file"); if (!@is_file($mask)) die("Error: ".$mask." was not a file"); $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5($imageProc->alternativeOutputKey."combine2").".jpg"; $imageProc->combineExec($input,$overlay,$mask,$output); $fileInfo = $imageProc->getImageDimensions($output); $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); $this->message($headCode,"Combine using a JPG mask with graylevels",$result[0],$result[1]); } else { $this->message($headCode,"Test skipped"," Use of ImageMagick has been disabled in the configuration. Refer to section 'Basic Configuration' to change or review you configuration settings ",2); } break; case "gdlib": $refParseTime="1800"; // GIF / 4.2.9 / LZW (5.2.3) $refParseTime="2700"; // PNG / 4.2.9 / LZW (5.2.3) $refParseTime="1600"; // GIF / 5.2.3 / LZW (5.2.3) // GDLibrary $headCode = "GDLib"; $this->message($headCode,"Testing GDLib"," This verifies that the GDLib installation works properly. "); if ($gdActive) { // GD with box $imageProc->IM_commands=array(); $im = imageCreate(170,136); ImageColorAllocate ($im, 0, 0, 0); $workArea=array(0,0,170,136); $conf=array( "dimensions" => "10,50,150,36", "color" => "olive" ); $imageProc->makeBox($im,$conf,$workArea); $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5("GDbox").".".$imageProc->gifExtension; $imageProc->ImageGif ($im,$output); $fileInfo = $imageProc->getImageDimensions($output); $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); $this->message($headCode,"Create simple image",$result[0],$result[1]); // GD from image with box $imageProc->IM_commands=array(); $input = t3lib_extMgm::extPath("install")."imgs/jesus.".$imageProc->gifExtension; if (!@is_file($input)) die("Error: ".$input." was not a file"); $im = $imageProc->imageCreateFromGif($input); $workArea=array(0,0,170,136); $conf=array(); $conf["dimensions"]="10,50,150,36"; $conf["color"]="olive"; $imageProc->makeBox($im,$conf,$workArea); $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5("GDfromImage+box").".".$imageProc->gifExtension; $imageProc->ImageGif ($im,$output); $fileInfo = $imageProc->getImageDimensions($output); $GDWithBox_filesize = @filesize($output); $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); $this->message($headCode,"Create image from file",$result[0],$result[1]); // GD with text $imageProc->IM_commands=array(); $im = imageCreate(170,136); ImageColorAllocate ($im, 128,128,150); $workArea=array(0,0,170,136); $conf=array( "iterations" => 1, "angle" => 0, "antiAlias" => 1, "text" => "HELLO WORLD", "fontColor" => "#003366", "fontSize" => 18, "fontFile" => $this->backPath."t3lib/fonts/verdana.ttf", "offset" => "17,40" ); $conf["BBOX"] = $imageProc->calcBBox($conf); $imageProc->makeText($im,$conf,$workArea); $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5("GDwithText").".".$imageProc->gifExtension; $imageProc->ImageGif ($im,$output); $fileInfo = $imageProc->getImageDimensions($output); $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands); $this->message($headCode,"Render text with TrueType font",$result[0],$result[1]); if ($imActive) { // extension: GD with text, niceText $conf["offset"] = "17,65"; $conf["niceText"] = 1; $imageProc->makeText($im,$conf,$workArea); $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5("GDwithText-niceText").".".$imageProc->gifExtension; $imageProc->ImageGif ($im,$output); $fileInfo = $imageProc->getImageDimensions($output); $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands, array("Note on 'niceText':","'niceText' is a concept that tries to improve the antialiasing of the rendered type by actually rendering the textstring in double size on a black/white mask, downscaling the mask and masking the text onto the image through this mask. This involves ImageMagick 'combine'/'composite' and 'convert'.")); $this->message($headCode,"Render text with TrueType font using 'niceText' option", "(If the image has another background color than the image above (eg. dark background color with light text) then you will have to set TYPO3_CONF_VARS[GFX][im_imvMaskState]=1)

". $result[0],$result[1]); } else { $this->message($headCode,"Render text with TrueType font using 'niceText' option"," Test is skipped!

Use of ImageMagick has been disabled in the configuration. ImageMagick is needed to generate text with the niceText option. Refer to section 'Basic Configuration' to change or review you configuration settings ",2); } if ($imActive) { // extension: GD with text, niceText AND shadow $conf["offset"] = "17,90"; $conf["niceText"] = 1; $conf["shadow."] = array( "offset"=>"2,2", "blur" => $imageProc->V5_EFFECTS?"20":"90", "opacity" => "50", "color" => "black" ); $imageProc->makeShadow($im,$conf["shadow."],$workArea,$conf); $imageProc->makeText($im,$conf,$workArea); $output = $imageProc->tempPath.$imageProc->filenamePrefix.t3lib_div::shortMD5("GDwithText-niceText-shadow").".".$imageProc->gifExtension; $imageProc->ImageGif ($im,$output); $fileInfo = $imageProc->getImageDimensions($output); $result = $this->displayTwinImage($fileInfo[3],$imageProc->IM_commands, array("Note on drop shadows:","Drop shadows are done my using ImageMagick to blur a mask through which the drop shadow is generated. The blurring of the mask only works in ImageMagick 4.2.9 and not ImageMagick 5 - which is why you may see a hard and not soft shadow.")); $this->message($headCode,"Render 'niceText' with a shadow under", "(This test makes sense only if the above test had a correct output. But if so, you may not see a soft dropshadow from the third text string as you should. In that case you are most likely using ImageMagick 5 and should set the flag TYPO3_CONF_VARS[GFX][im_v5effects]. However this may cost server performance!
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)

". $result[0],$result[1]); } else { $this->message($headCode,"Render 'niceText' with a shadow under"," Test is skipped!

Use of ImageMagick has been disabled in the configuration. ImageMagick is needed to generate shadows. Refer to section 'Basic Configuration' to change or review you configuration settings ",2); } if ($imageProc->gifExtension=="gif") { $buffer=20; $assess = "This assessment is based on the filesize from 'Create image from file' test, which were ".$GDWithBox_filesize." bytes"; $goodNews = "If the image was LZW compressed you would expect to have a size of less than 9000 bytes. If you open the image with Photoshop and saves it from Photoshop, you'll a filesize like that.
The good news is (hopefully) that your [GFX][im_path_lzw] path is correctly set so the gif_compress() function will take care of the compression for you!"; if ($GDWithBox_filesize<8784+$buffer) { $msg="Your GDLib appears to have LZW compression!
This assessment is based on the filesize from 'Create image from file' test, which were ".$GDWithBox_filesize." bytes.
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, please set the config option [GFX][im_path_lzw] to an empty string!
When you disable the use of ImageMagick for LZW compressing, you'll see that the gif_compress() function has a return code of 'GD' (for GDLib) instead of 'IM' (for ImageMagick) "; } elseif ($GDWithBox_filesize>19000) { $msg="Your GDLib appears to have no compression at all!
".$assess."
".$goodNews; } else { $msg="Your GDLib appears to have RLE compression
".$assess."
".$goodNews; } $this->message($headCode,"GIF compressing in GDLib"," ".$msg." ",1); } } else { $this->message($headCode,"Test skipped"," Use of GDLib has been disabled in the configuration. Refer to section 'Basic Configuration' to change or review you configuration settings ",2); } break; } if ($this->INSTALL["images_type"]) { // End info if ($this->fatalError) { $this->message("Info","Errors"," It seems that you had some fatal errors in this test. Please make sure that your ImageMagick and GDLib settings are correct. Refer to the 'Basic Configuration' section for more information and debugging of your settings. "); } $parseStop = microtime(); $parseMS = t3lib_div::convertMicrotime($parseStop)-t3lib_div::convertMicrotime($parseStart); $this->message("Info","Parsetime",$parseMS." ms"); } echo $this->outputWrapper($this->printAll()); } /** * [Describe function...] * * @param [type] $ext: ... * @param [type] $headCode: ... * @param [type] $short: ... * @return [type] ... */ function isExtensionEnabled($ext, $headCode, $short) { if (!t3lib_div::inList($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"],$ext)) { $this->message($headCode,$short,"Skipped - extension not in the list of allowed extensions ([GFX][imagefile_ext]).",1); } else { return 1; } } /** * [Describe function...] * * @param [type] $imageFile: ... * @param [type] $IMcommands: ... * @param [type] $note: ... * @return [type] ... */ function displayTwinImage ($imageFile, $IMcommands=array(), $note="") { $ex_rows=""; $errorLevels=array(-1); if ($imageFile) { $verifyFile = t3lib_extMgm::extPath("install")."verify_imgs/".basename($imageFile); $destImg = @getImageSize($imageFile); $destImgCode =''; $verifyImg = @getImageSize($verifyFile); $verifyImgCode = ''; if (!$verifyImg) { $gifVersion=1; $verifyFile_alt = substr($verifyFile,0,-3)."gif"; $verifyImg = @getImageSize($verifyFile_alt); if ($verifyImg) { $verifyImgCode = ''; $verifyImgCode= '
'.$verifyImgCode.'
'.$this->fw("NO REFERENCE FOUND!

GIF version looks like this.").'
'; } else { $verifyImgCode= '
'.$this->fw("NO REFERENCE FOUND!

".basename($verifyFile)).'
'; } } clearstatcache(); $destImg["filesize"] = @filesize($imageFile); clearstatcache(); $verifyImg["filesize"] = @filesize($verifyFile); $ex_rows.=''; $ex_rows.=''.$destImgCode.''; $ex_rows.=''; $ex_rows.=''.$verifyImgCode.''; $ex_rows.=''; $ex_rows.=$this->getTwinImageMessage("", t3lib_div::formatSize($destImg["filesize"]).", ".$destImg[0]."x".$destImg[1]." pixels", t3lib_div::formatSize($verifyImg["filesize"]).", ".$verifyImg[0]."x".$verifyImg[1]." pixels"); if ($destImg["filesize"]!=$verifyImg["filesize"]) { if (intval($destImg["filesize"]) && abs(($verifyImg["filesize"]/$destImg["filesize"])-1) < 0.05) { // debug(abs(($verifyImg["filesize"]/$destImg["filesize"])-1)); $ex_rows.=$this->getTwinImageMessage("File size is a bit different from reference", $destImg["filesize"], $verifyImg["filesize"]); $errorLevels[]=1; } else { $ex_rows.=$this->getTwinImageMessage("File size is very different from reference", $destImg["filesize"], $verifyImg["filesize"]); $errorLevels[]=2; } } if ($destImg[0]!=$verifyImg[0] || $destImg[1]!=$verifyImg[1]) { $ex_rows.=$this->getTwinImageMessage("Pixel dimension are not equal!"); $errorLevels[]=2; } if ($note) { $ex_rows.=$this->getTwinImageMessage($note[0],$note[1]); } if ($this->dumpImCommands && count($IMcommands)) { $ex_rows.=$this->getTwinImageMessage("ImageMagick commands executed:",$this->formatImCmds($IMcommands)); } } else { $ex_rows.=$this->getTwinImageMessage("There was no result from the ImageMagick operation", "Below there's a dump of the ImageMagick commands executed:
".$this->formatImCmds($IMcommands)); $errorLevels[]=3; } $out=''.$ex_rows.'
'; return array($out,max($errorLevels)); } /** * [Describe function...] * * @param [type] $message: ... * @param [type] $label_1: ... * @param [type] $label_2: ... * @return [type] ... */ function getTwinImageMessage($message, $label_1="", $label_2="") { if ($message) $out.=''.$this->fw($message).''; if ($label_1 && !$label_2) { $out.=''.$this->fw($label_1).''; } elseif ($label_1 || $label_2) { $out.=''.$this->fw($label_1).''.$this->fw($label_2).''; } return $out; } /** * [Describe function...] * * @param [type] $arr: ... * @return [type] ... */ function formatImCmds($arr) { $out=array(); if (is_array($arr)) { reset($arr); while(list($k,$v)=each($arr)) { $out[]=$v[1]; if ($v[2]) $out[]=" RETURNED: ".$v[2]; } } if (count($out)) { $col = t3lib_div::intInRange(count($out),2,10); $outputStr = ''; return '
'.$outputStr.'
'; }; } /** * [Describe function...] * * @return [type] ... */ function imagemenu() { $menuitems = array( "read" => "Reading image formats", "write" => "Writing GIF and PNG", "scaling" => "Scaling images", "combining" => "Combining images", "gdlib" => "GD library functions" ); reset($menuitems); $c=0; $out=array(); while(list($k,$v)=each($menuitems)) { $bgColor = ($this->INSTALL["images_type"]==$k ? ' bgColor="#ABBBB4"' : ' bgColor="#F4F0E8"'); $c++; $out[]=''.$this->fw($c.': '.$v).''; } $code = ''.implode($out,"").'
'; $code = '
'.$code.'
'; return '
'.$code.'
'; } /********************** * * DATABASE analysing * **********************/ /** * @return [type] ... */ function checkTheDatabase() { if (!$this->config_array["mysqlConnect"]) { $this->message("Database Analyser","Your database connection failed"," Please go to the 'Basic Configuration' section and correct this problem first. ",2); echo $this->outputWrapper($this->printAll()); return; } if ($this->config_array["no_database"]) { $this->message("Database Analyser","No database selected"," Please go to the 'Basic Configuration' section and correct this problem first. ",2); echo $this->outputWrapper($this->printAll()); return; } // Getting current tables $whichTables=$this->getListOfTables(); // Getting number of static_template records if ($whichTables["static_template"]) { $res_static = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'static_template', ''); list($static_template_count) = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res_static); } $static_template_count=intval($static_template_count); $headCode ="Database Analyser"; $this->message($headCode,"What is it?"," In this section you can get an overview of your currently selected database compared to sql-files. You can also import sql-data directly into the database or upgrade tables from earlier versions of TYPO3. ",0); $cInfo=" Username: ".TYPO3_db_username." Password: ".TYPO3_db_password." Host: ".TYPO3_db_host." "; $this->message($headCode, "Connected to SQL database successfully"," ".trim($cInfo)." ",-1,1); $this->message($headCode, "Database"," ".TYPO3_db." is selected as database. Has ".count($whichTables)." tables. ",-1,1); // Menu $this->messageFunc_nl2br = 0; $sql_files = array_merge( t3lib_div::getFilesInDir(PATH_typo3conf,"sql",1,1), # t3lib_div::getFilesInDir(PATH_t3lib."stddb/","sql",1,1), array() ); $action_type = $this->INSTALL["database_type"]; $actionParts = explode("|",$action_type); if (count($actionParts)<2) { $action_type=""; } $out=''; $out.=' '.$this->fw('Update required tables').' '.$this->fw('COMPARE').' '.$this->fw(' ').' '.$this->fw(' ').' '; $out.=' '.$this->fw('Dump static data').' '.$this->fw(' ').' '.$this->fw('IMPORT').' '.$this->fw(' ').' '; $out.='   '; reset($sql_files); $directJump=""; while(list($k,$file)=each($sql_files)) { if ($this->mode=="123" && !count($whichTables) && strstr($file,"_testsite")) { $directJump = $this->action.'&TYPO3_INSTALL[database_type]=import|'.rawurlencode($file); } $lf=t3lib_div::testInt($k); $fShortName = substr($file,strlen(PATH_site)); /* $spec1 = (!count($whichTables) && $fShortName==TYPO3_mainDir."t3lib/install/tables_".str_replace(".","",$GLOBALS["TYPO_VERSION"]).".sql" ? " (1)" : ""); $spec2 = (count($whichTables) && !$static_template_count && $fShortName==TYPO3_mainDir."t3lib/install/static_template_".str_replace(".","",$GLOBALS["TYPO_VERSION"])."+adt.sql" ? " (2)" : ""); */ $out.=' '.$this->fw($fShortName." (".t3lib_div::formatSize(filesize($file)).")").' '.$this->fw('COMPARE').' '.$this->fw('IMPORT'.$spec1.$spec2.'').' '.$this->fw('VIEW'.$spec1.$spec2.'').' '; } // TCA $out.=' '.$this->fw('Compare with $TCA').' '; $out.=' '.$this->fw('Create "admin" user').' '; $out.=' '.$this->fw('Reset user preferences').' '; $out.=' '.$this->fw('Clear tables').' '; $theForm=''.$out.'
'; $theForm.=''; if ($directJump) { if (!$action_type) { $this->message($headCode, "Menu",' ',0,1); } } else { $this->message($headCode, "Menu"," From this menu you can select which of the available SQL files you want to either compare or import/merge with the existing database.

COMPARE: Compares the tables and fields of the current database and the selected file. It also offers to 'update' the difference found.
IMPORT: 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.
VIEW: Shows the content of the SQL-file, limiting characters on a single line to a reader-friendly amount.

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 mysqldump tool or at least be formatted like that tool would do.

".$theForm." ",0,1); } // Install user // clear uc if ($action_type) { switch($actionParts[0]) { case "cmpFile": $tblFileContent=""; if (!strcmp($actionParts[1],"CURRENT_TABLES")) { $tblFileContent = t3lib_div::getUrl(PATH_t3lib."stddb/tables.sql"); reset($GLOBALS["TYPO3_LOADED_EXT"]); while(list(,$loadedExtConf)=each($GLOBALS["TYPO3_LOADED_EXT"])) { if (is_array($loadedExtConf) && $loadedExtConf["ext_tables.sql"]) { $tblFileContent.= chr(10).chr(10).chr(10).chr(10).t3lib_div::getUrl($loadedExtConf["ext_tables.sql"]); } } #debug(array($tblFileContent)); } elseif (@is_file($actionParts[1])) { $tblFileContent = t3lib_div::getUrl($actionParts[1]); } if ($tblFileContent) { $fileContent = implode( $this->getStatementArray($tblFileContent,1,"^CREATE TABLE "), chr(10) ); $FDfile = $this->getFieldDefinitions_sqlContent($fileContent); if (!count($FDfile)) { die ("Error: There were no 'CREATE TABLE' definitions in the provided file"); } // Updating database... if (is_array($this->INSTALL["database_update"])) { $FDdb = $this->getFieldDefinitions_database(); $diff = $this->getDatabaseExtra($FDfile, $FDdb); $update_statements = $this->getUpdateSuggestions($diff); $diff = $this->getDatabaseExtra($FDdb, $FDfile); $remove_statements = $this->getUpdateSuggestions($diff,"remove"); $this->performUpdateQueries($update_statements["add"],$this->INSTALL["database_update"]); $this->performUpdateQueries($update_statements["change"],$this->INSTALL["database_update"]); $this->performUpdateQueries($remove_statements["change"],$this->INSTALL["database_update"]); $this->performUpdateQueries($remove_statements["drop"],$this->INSTALL["database_update"]); $this->performUpdateQueries($update_statements["create_table"],$this->INSTALL["database_update"]); $this->performUpdateQueries($remove_statements["change_table"],$this->INSTALL["database_update"]); $this->performUpdateQueries($remove_statements["drop_table"],$this->INSTALL["database_update"]); } // Init again / first time depending... $FDdb = $this->getFieldDefinitions_database(); $diff = $this->getDatabaseExtra($FDfile, $FDdb); $update_statements = $this->getUpdateSuggestions($diff); $diff = $this->getDatabaseExtra($FDdb, $FDfile); $remove_statements = $this->getUpdateSuggestions($diff,"remove"); $tLabel = "Update database tables and fields"; if ($remove_statements || $update_statements) { $formContent = $this->generateUpdateDatabaseForm("get_form",$update_statements,$remove_statements,$action_type); $this->message($tLabel,"Table and field definitions should be updated"," There seems to be a number of differencies between the database and the selected SQL-file. Please select which statements you want to execute in order to update your database:

".$formContent." ",2); } else { $formContent = $this->generateUpdateDatabaseForm("get_form",$update_statements,$remove_statements,$action_type); $this->message($tLabel,"Table and field definitions are OK."," The tables and fields in the current database corresponds perfectly to the database in the selected SQL-file. ",-1); } } break; case "cmpTCA": $this->includeTCA(); $this->mysqlVersion = "3.23"; // Set this previously to calling the function below in order to make the rendering right for the comparison. $FDdb = $this->getFieldDefinitions_database(); // Displaying configured fields which are not in the database $tLabel="Tables and fields in \$TCA, but not in database"; $cmpTCA_DB = $this->compareTCAandDatabase($GLOBALS["TCA"],$FDdb); if (!count($cmpTCA_DB["extra"])) { $this->message($tLabel,"Table and field definitions OK"," All fields and tables configured in $TCA appeared to exist in the database as well ",-1); } else { $this->message($tLabel,"Invalid table and field definitions in \$TCA!"," There are some tables and/or fields configured in the \$TCA array which does not exist in the database! This will most likely cause you trouble with the TYPO3 backend interface! ",3); while(list($tableName, $conf)=each($cmpTCA_DB["extra"])) { $this->message($tLabel, $tableName,$this->displayFields($conf["fields"],0,"Suggested database field:"),2); } } // Displaying tables that are not setup in $cmpDB_TCA = $this->compareDatabaseAndTCA($FDdb,$GLOBALS["TCA"]); $excludeTables="be_sessions,fe_session_data,fe_sessions"; if (TYPO3_OS=="WIN") {$excludeTables = strtolower($excludeTables);} $excludeFields = array( "be_users" => "uc,lastlogin,usergroup_cached_list", "fe_users" => "uc,lastlogin,fe_cruser_id", "pages" => "SYS_LASTCHANGED", "sys_dmail" => "mailContent", "tt_board" => "doublePostCheck", "tt_guest" => "doublePostCheck", "tt_products" => "ordered" ); $tCount=0; $fCount=0; $tLabel="Tables from database, but not in \$TCA"; $fLabel="Fields from database, but not in \$TCA"; $this->message($tLabel); if (is_array($cmpDB_TCA['extra'])) { while(list($tableName, $conf)=each($cmpDB_TCA['extra'])) { if (!t3lib_div::inList($excludeTables,$tableName) && substr($tableName,0,4)!="sys_" && substr($tableName,-3)!="_mm" && substr($tableName,0,6)!="index_" && substr($tableName,0,6)!="cache_") { if ($conf["whole_table"]) { $this->message($tLabel, $tableName,$this->displayFields($conf["fields"]),1); $tCount++; } else { list($theContent, $fC) = $this->displaySuggestions($conf["fields"],$excludeFields[$tableName]); $fCount+=$fC; if ($fC) $this->message($fLabel, $tableName,$theContent,1); } } } } if (!$tCount) { $this->message($tLabel,"Correct number of tables in the database"," There are no extra tables in the database compared to the configured tables in the \$TCA array. ",-1); } else { $this->message($tLabel,"Extra tables in the database"," There are some tables in the database which are not configured in the \$TCA array. You should probably not worry about this, but please make sure that you know what these tables are about and why they are not configured in \$TCA. ",2); } if (!$fCount) { $this->message($fLabel,"Correct number of fields in the database"," There are no additional fields in the database tables compared to the configured fields in the \$TCA array. ",-1); } else { $this->message($fLabel,"Extra fields in the database"," There are some additional fields the database tables which are not configured in the \$TCA array. You should probably not worry about this, but please make sure that you know what these fields are about and why they are not configured in \$TCA. ",2); } // Displaying actual and suggested field database defitions if (is_array($cmpTCA_DB["matching"])) { $tLabel="Comparison between database and \$TCA"; $this->message($tLabel,"Actual and suggested field definitions"," This table shows you the suggested field definitions which are calculated based on the configuration in \$TCA. If the suggested value differs from the actual current database value, you should not panic, but simply check if the datatype of that field is sufficient compared to the data, you want TYPO3 to put there. ",0); while(list($tableName, $conf)=each($cmpTCA_DB["matching"])) { $this->message($tLabel, $tableName,$this->displayFieldComp($conf["fields"], $FDdb[$tableName]["fields"]),1); } } break; case "import": $mode123Imported=0; $tblFileContent=""; if (!strcmp($actionParts[1],"CURRENT_STATIC")) { reset($GLOBALS["TYPO3_LOADED_EXT"]); while(list(,$loadedExtConf)=each($GLOBALS["TYPO3_LOADED_EXT"])) { if (is_array($loadedExtConf) && $loadedExtConf["ext_tables_static+adt.sql"]) { $tblFileContent.= chr(10).chr(10).chr(10).chr(10).t3lib_div::getUrl($loadedExtConf["ext_tables_static+adt.sql"]); } } } elseif (@is_file($actionParts[1])) { $tblFileContent = t3lib_div::getUrl($actionParts[1]); } if ($tblFileContent) { $tLabel="Import SQL dump"; // Getting statement array from $statements = $this->getStatementArray($tblFileContent,1); list($statements_table, $insertCount) = $this->getCreateTables($statements,1); // Updating database... if ($this->INSTALL["database_import_all"]) { reset($statements); $r=0; while(list($k,$v)=each($statements)) { $res = $GLOBALS['TYPO3_DB']->admin_query($v); $r++; } $this->message($tLabel,"Imported ALL"," Queries: ".$r." ",1,1); if (t3lib_div::_GP("goto_step")) { $this->action.="&step=".t3lib_div::_GP("goto_step"); Header("Location: ".t3lib_div::locationHeaderUrl($this->action)); exit; } } elseif (is_array($this->INSTALL["database_import"])) { // Traverse the tables reset($this->INSTALL["database_import"]); while(list($table,$md5str)=each($this->INSTALL["database_import"])) { if ($md5str==md5($statements_table[$table])) { $res = $GLOBALS['TYPO3_DB']->admin_query("DROP TABLE IF EXISTS ".$table); $res = $GLOBALS['TYPO3_DB']->admin_query($statements_table[$table]); if ($insertCount[$table]) { $statements_insert = $this->getTableInsertStatements($statements, $table); reset($statements_insert); while(list($k,$v)=each($statements_insert)) { $res = $GLOBALS['TYPO3_DB']->admin_query($v); } } $this->message($tLabel,"Imported '".$table."'"," Rows: ".$insertCount[$table]." ",1,1); } } } $mode123Imported=$this->isBasicComplete($tLabel); if (!$mode123Imported) { // Re-Getting current tables - may have been changed during import $whichTables=$this->getListOfTables(); if (count($statements_table)) { reset($statements_table); $out=''; while(list($table,$definition)=each($statements_table)) { $exist=isset($whichTables[$table]); $out.=' '.$this->fw($table).' '.$this->fw($insertCount[$table]?"Rows: ".$insertCount[$table]:"").' '.($exist?''.$this->fw("Table exists!"):'').' '; } $content =''; if ($this->mode!="123") { $content.=''.$out.'

'; } $content.='mode=="123"||t3lib_div::_GP("presetWholeTable")?" checked":"").'>'.$this->fw("Import the whole file '".basename($actionParts[1])."' directly (ignores selections above):").'
'; $form = $this->getUpdateDbFormWrap($action_type, $content); $this->message($tLabel,"Select tables to import"," This is an overview of the CREATE TABLE definitions in the SQL file. Select which tables you want to dump to the database. Any table you choose dump to the database is dropped from the database first, so you'll loose all data in existing tables. ".$form,1,1); } else { $this->message($tLabel,"No tables"," There seems to be no CREATE TABLE definitions in the SQL file. 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. ",3,1); } } } break; case "view": if (@is_file($actionParts[1])) { $tLabel="Import SQL dump"; // Getting statement array from $sqlContent = t3lib_div::getUrl($actionParts[1]); $statements = $this->getStatementArray($sqlContent,1); $maxL=1000; $strLen = strlen($sqlContent); $maxlen = 200+($maxL-t3lib_div::intInRange(($strLen-20000)/100,0,$maxL)); // debug($maxlen); if (count($statements)) { reset($statements); $out=''; while(list(,$statement)=each($statements)) { $out.=nl2br(htmlspecialchars(t3lib_div::fixed_lgd($statement,$maxlen)).chr(10).chr(10)); } } $this->message($tLabel,"Content of ".basename($actionParts[1]),$out,1); } break; case "adminUser": if ($whichTables["be_users"]) { if (is_array($this->INSTALL["database_adminUser"])) { $username = ereg_replace("[^[:alnum:]_-]","",trim($this->INSTALL["database_adminUser"]["username"])); $username = str_replace(" ","_",$username); $pass = trim($this->INSTALL["database_adminUser"]["password"]); if ($username && $pass) { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'be_users', 'username="'.$GLOBALS['TYPO3_DB']->quoteStr($username, 'be_users').'"'); if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) { $insertFields = array( 'username' => $username, 'password' => md5($pass), 'admin' => 1, 'uc' => '', 'fileoper_perms' => 7, 'tstamp' => time(), 'crdate' => time() ); $GLOBALS['TYPO3_DB']->exec_INSERTquery('be_users', $insertFields); $this->isBasicComplete($headCode); $this->message($headCode,"User created",' Username: '.htmlspecialchars($username).'
Password: '.htmlspecialchars($pass).'
' ,1,1); } else { $this->message($headCode,"Username not unique!",' The username, '.htmlspecialchars($username).', was not unique.',2,1); } } } $content = ' username - unique, no space, lowercase
password '; $form = $this->getUpdateDbFormWrap($action_type, $content); $this->message($headCode,"Create admin user"," Enter username and password for a new admin user.
You should use this function only if there are no admin users in the database, for instance if this is a blank database.
After you've created the user, log in and add the rest of the user information, like email and real name.

".$form." ",0,1); } else { $this->message($headCode,"Required table not in database"," 'be_users' must be a table in the database! ",3,1); } break; case "UC": if ($whichTables["be_users"]) { if (!strcmp($this->INSTALL["database_UC"],1)) { $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_users', '', array('uc' => '')); $this->message($headCode,"Clearing be_users.uc",'Done.',1); } $content = ' Clear be_users preferences ("uc" field) '; $form = $this->getUpdateDbFormWrap($action_type, $content); $this->message($headCode,"Clear user preferences"," 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).
This may come in handy in rare cases where that configuration may be corrupt.
Clearing this will clear all user settings from the 'Setup' module.

".$form); } else { $this->message($headCode,"Required table not in database"," 'be_users' must be a table in the database! ",3); } break; case "cache": $tableListArr = explode(",","cache_pages,cache_pagesection,cache_hash,--div--,sys_log,sys_history,--div--,be_sessions,fe_sessions,fe_session_data". (t3lib_extMgm::isLoaded("indexed_search") ? ",--div--,index_words,index_rel,index_phash,index_grlist,index_section,index_fulltext" : ""). (t3lib_extMgm::isLoaded("tt_products") ? ",--div--,sys_products_orders,sys_products_orders_mm_tt_products" : ""). (t3lib_extMgm::isLoaded("direct_mail") ? ",--div--,sys_dmail_maillog" : ""). (t3lib_extMgm::isLoaded("sys_stat") ? ",--div--,sys_stat" : "") ); if (is_array($this->INSTALL["database_clearcache"])) { $qList=array(); reset($tableListArr); while(list(,$table)=each($tableListArr)) { if ($table!="--div--") { $table_c = TYPO3_OS=="WIN" ? strtolower($table) : $table; if ($this->INSTALL["database_clearcache"][$table] && $whichTables[$table_c]) { $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, ''); $qList[] = $table; } } } if (count($qList)) { $this->message($headCode,"Clearing cache",' The following tables were emptied:

'.implode($qList,"
") ,1); } } // Count entries and make checkboxes $labelArr = array( "cache_pages" => "Pages", "cache_pagesection" => "TS template related information", "cache_hash" => "Multipurpose md5-hash cache", "sys_log" => "Backend action logging", "sys_stat" => "Page hit statistics", "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.", "be_sessions" => "Backend User sessions", "fe_sessions" => "Frontend User sessions", "fe_session_data" => "Frontend User sessions data", "sys_dmail_maillog" => "Direct Mail log", "sys_products_orders" => "tt_product orders", "sys_products_orders_mm_tt_products" => "relations between tt_products and sys_products_orders" ); $checkBoxes=array(); $countEntries=array(); reset($tableListArr); while(list(,$table)=each($tableListArr)) { if ($table!="--div--") { $table_c = TYPO3_OS=="WIN" ? strtolower($table) : $table; if ($whichTables[$table_c]) { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, ''); list($countEntries[$table]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); // Checkboxes: $checkBoxes[]= 'INSTALL["database_clearcache"][$table]||$GLOBALS["HTTP_GET_VARS"]["PRESET"]["database_clearcache"][$table]?" checked":"").'> '.$table.' ('.$countEntries[$table].' rows) - '.$labelArr[$table]; } } else { $checkBoxes[]= '
'; } } $content = implode("
",$checkBoxes)."

"; $form = $this->getUpdateDbFormWrap($action_type, $content); $this->message($headCode,"Clear out selected tables",' Pressing this button will delete all records from the selected tables.

'.$form.' '); break; } } echo $this->outputWrapper($this->printAll()); } /** * [Describe function...] * * @return [type] ... */ function isBackendAdminUser() { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'be_users', 'admin'); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return current($row); } /** * [Describe function...] * * @return [type] ... */ function isStaticTemplates() { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'static_template', ''); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); return current($row); } /** * [Describe function...] * * @param [type] $tLabel: ... * @return [type] ... */ function isBasicComplete($tLabel) { if ($this->mode=="123") { $tables = $this->getListOfTables(); if (count($tables)) { $beuser = $this->isBackendAdminUser(); $static = $this->isStaticTemplates(); } if (count($tables) && $beuser && $static) { $mode123Imported=1; $this->message($tLabel,"Basic Installation Completed",nl2br($this->messageBasicFinished()),-1,1); $this->message($tLabel,"Security Risk!",nl2br($this->securityRisk().$this->alterPasswordForm()),2,1); } else { $this->message($tLabel,"Still missing something?",nl2br(" You may be missing one of these points before your TYPO3 installation is complete: ".(count($tables)?"":"- You haven't imported any tables yet. ") .($static?"":"- You haven't imported the static_template table. ") .($beuser?"":"- You haven't created an admin-user yet. ") ." You you're about to import a database with a complete site in it, these three points should be met. "),-1,1); } } return $mode123Imported; } /** * [Describe function...] * * @param [type] $type: ... * @param [type] $arr_update: ... * @param [type] $arr_remove: ... * @param [type] $action_type: ... * @return [type] ... */ function generateUpdateDatabaseForm($type, $arr_update, $arr_remove, $action_type) { switch($type) { case "get_form": $content=""; $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_update["add"],"Add fields"); $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_update["change"],"Changing fields",1,0,$arr_update["change_currentValue"]); $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_remove["change"],"Remove unused fields (rename with prefix)",$this->setAllCheckBoxesByDefault,1); $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_remove["drop"],"Drop fields (really!)",$this->setAllCheckBoxesByDefault); $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_update["create_table"],"Add tables"); $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_remove["change_table"],"Removing tables (rename with prefix)",$this->setAllCheckBoxesByDefault,1,$arr_remove["tables_count"],1); $content.=$this->generateUpdateDatabaseForm_checkboxes($arr_remove["drop_table"],"Drop tables (really!)",$this->setAllCheckBoxesByDefault,0,$arr_remove["tables_count"],1); $form = $this->getUpdateDbFormWrap($action_type, $content); return $form; break; default: break; } } /** * [Describe function...] * * @param [type] $action_type: ... * @param [type] $content: ... * @param [type] $label: ... * @return [type] ... */ function getUpdateDbFormWrap($action_type, $content, $label="Write to database") { $form = '
'.$content.'
'; return $form; } /** * [Describe function...] * * @param [type] $arr: ... * @param [type] $pre: ... * @param [type] $label: ... * @return [type] ... */ function displayFields($arr, $pre=0, $label="") { $out=""; $out.=''.$this->fw("Field name:").''.$this->fw($label?$label:"Info:").''; if (is_array($arr)) { reset($arr); while(list($fieldname, $fieldContent)=each($arr)) { if ($pre) { $fieldContent = '
'.trim($fieldContent).'
'; } else { $fieldContent = $this->fw($fieldContent); } $out.=''.$this->fw($fieldname).''.$fieldContent.''; } } $out= ''.$out.'
'; return $out; } /** * [Describe function...] * * @param [type] $arr: ... * @param [type] $arr_db: ... * @return [type] ... */ function displayFieldComp($arr, $arr_db) { $out=""; $out.=''.$this->fw("Field name:").' '.$this->fw("Suggested value from \$TCA:").' '.$this->fw("Actual value from database:").' '; if (is_array($arr)) { reset($arr); while(list($fieldname, $fieldContent)=each($arr)) { // This tries to equalize the types tinyint and int $str1 = $fieldContent; $str2 = trim($arr_db[$fieldname]); $str1 = str_replace("tinyint(3)","tinyint(4)",$str1); $str2 = str_replace("tinyint(3)","tinyint(4)",$str2); $str1 = str_replace("int(10)","int(11)",$str1); $str2 = str_replace("int(10)","int(11)",$str2); // Compare: if (strcmp($str1,$str2)) { $bgColor=' bgcolor="#ABBBB4"'; } else { $bgColor=' bgcolor="#D9D5C9"'; } $fieldContent = $this->fw($fieldContent); $fieldContent_db = $this->fw($arr_db[$fieldname]); $out.=' '.$this->fw($fieldname).' '.$fieldContent.' '.$fieldContent_db.' '; } } $out= ''.$out.'
'; return $out; } /** * [Describe function...] * * @param [type] $arr: ... * @param [type] $excludeList: ... * @return [type] ... */ function displaySuggestions($arr, $excludeList="") { $out=""; $out.=''.$this->fw("Field name:").''.$this->fw("Info / Suggestion for the field:").''; $fC=0; if (is_array($arr)) { reset($arr); while(list($fieldname, $fieldContent)=each($arr)) { if (!t3lib_div::inList($excludeList,$fieldname) && substr($fieldname,0,strlen($this->deletedPrefixKey))!=$this->deletedPrefixKey && substr($fieldname,-1)!=".") { $fieldContent = $this->fw($fieldContent); if ($arr[$fieldname."."]) { $fieldContent.= '
'; $fieldContent.= '
'.trim($arr[$fieldname."."]).'
'; } $out.=''.$this->fw($fieldname).''.$fieldContent.''; $fC++; } } } $out= ''.$out.'
'; return array($out,$fC); } /** * Compares an array with field definitions with $TCA array * * @param [type] $FDsrc: ... * @param [type] $TCA: ... * @param [type] $onlyFields: ... * @return [type] ... */ function compareDatabaseAndTCA($FDsrc, $TCA, $onlyFields=0) { $extraArr=array(); if (is_array($FDsrc)) { reset($FDsrc); while(list($table,$info)=each($FDsrc)) { if (!isset($TCA[$table])) { if (!$onlyFields) { $extraArr[$table]=$info; // If the table was not in the FDcomp-array, the result array is loaded with that table. $extraArr[$table]["whole_table"]=1; unset($extraArr[$table]["keys"]); } } else { $theKey="fields"; $excludeListArr=array(); if (is_array($TCA[$table]["ctrl"]["enablecolumns"])) $excludeListArr[]=$TCA[$table]["ctrl"]["enablecolumns"]; $excludeListArr[]=$TCA[$table]["ctrl"]["tstamp"]; $excludeListArr[]=$TCA[$table]["ctrl"]["sortby"]; $excludeListArr[]=$TCA[$table]["ctrl"]["delete"]; $excludeListArr[]=$TCA[$table]["ctrl"]["cruser_id"]; $excludeListArr[]=$TCA[$table]["ctrl"]["crdate"]; $excludeListArr[]="uid"; $excludeListArr[]="pid"; if ($table=="pages") { $excludeListArr[]="perms_userid"; $excludeListArr[]="perms_groupid"; $excludeListArr[]="perms_user"; $excludeListArr[]="perms_group"; $excludeListArr[]="perms_everybody"; } if ($table=="sys_dmail") { $excludeListArr[]="scheduled"; $excludeListArr[]="scheduled_begin"; $excludeListArr[]="scheduled_end"; $excludeListArr[]="query_info"; } if (is_array($info[$theKey])) { reset($info[$theKey]); while(list($fieldN,$fieldC)=each($info[$theKey])) { if (!isset($TCA[$table]["columns"][$fieldN]) && !in_array($fieldN,$excludeListArr)) { $extraArr[$table][$theKey][$fieldN] = $info["fields"][$fieldN]; $extraArr[$table][$theKey][$fieldN."."]=$this->suggestTCAFieldDefinition($fieldN,$fieldC); } } } } } } return array("extra"=>$extraArr); } /** * Compares the $TCA array with a field definition array * * @param [type] $TCA: ... * @param [type] $FDcomp: ... * @return [type] ... */ function compareTCAandDatabase($TCA, $FDcomp) { $extraArr=array(); $matchingArr=array(); if (is_array($TCA)) { reset($TCA); while(list($table)=each($TCA)) { $info=$TCA[$table]; if (!isset($FDcomp[$table])) { // $extraArr[$table]=$info; // If the table was not in the FDcomp-array, the result array is loaded with that table. $extraArr[$table]["whole_table"]=1; } else { reset($info["columns"]); while(list($fieldN,$fieldC)=each($info["columns"])) { $fieldDef = $this->suggestFieldDefinition($fieldC); if (!is_array($fieldDef)) { if (!isset($FDcomp[$table]["fields"][$fieldN])) { $extraArr[$table]["fields"][$fieldN]=$fieldDef; } else { $matchingArr[$table]["fields"][$fieldN]=$fieldDef; } } } } } } return array("extra"=>$extraArr, "matching"=>$matchingArr); } /** * Suggests a field definition for a TCA config array. * * @param [type] $fieldInfo: ... * @return [type] ... */ function suggestFieldDefinition($fieldInfo) { $out=""; switch($fieldInfo["config"]["type"]) { case "input": if (ereg("date|time|int|year",$fieldInfo["config"]["eval"])) { $us=ereg("date|time",$fieldInfo["config"]["eval"]) ? " unsigned" : ""; $out = "int(11)".$us." NOT NULL default '0'"; } else { $max = intval($fieldInfo["config"]["max"]); if ($max>0 && $max<200) { $out = "varchar(".$max.") NOT NULL default ''"; } else { $out = "tinytext NOT NULL"; } } break; case "text": $out = "text NOT NULL"; break; case "check": if (is_array($fieldInfo["config"]["items"]) && count($fieldInfo["config"]["items"])>8) { $out = "int(11) unsigned NOT NULL default '0'"; } else { $out = "tinyint(3) unsigned NOT NULL default '0'"; } break; case "radio": if (is_array($fieldInfo["config"]["items"])) { $out = $this->getItemArrayType($fieldInfo["config"]["items"]); } else { $out = "ERROR: Radiobox did not have items!"; } break; case "group": if ($fieldInfo["config"]["internal_type"]=="db") { $max = t3lib_div::intInRange($fieldInfo["config"]["maxitems"],1,10000); if (count(explode(",",$fieldInfo["config"]["allowed"]))>1) { $len = $max*(10+1+5+1); // Tablenames are 10, "_" 1, uid's 5, comma 1 $out=$this->getItemBlobSize($len); } elseif ($max<=1) { $out = "int(11) unsigned NOT NULL default '0'"; } else { $len = $max*(5+1); // uid's 5, comma 1 $out=$this->getItemBlobSize($len); } } if ($fieldInfo["config"]["internal_type"]=="file") { $max = t3lib_div::intInRange($fieldInfo["config"]["maxitems"],1,10000); $len = $max*(30+1); // Filenames is 30+ chars.... $out=$this->getItemBlobSize($len); } break; case "select": $max = t3lib_div::intInRange($fieldInfo["config"]["maxitems"],1,10000); if ($max<=1) { if ($fieldInfo["config"]["foreign_table"]) { $out = "int(11) unsigned NOT NULL default '0'"; } else { $out = $this->getItemArrayType($fieldInfo["config"]["items"]); } } else { // five chars (special=10) + comma: $len = $max*(($fieldInfo["config"]["special"]?10:5)+1); $out=$this->getItemBlobSize($len); } break; default: break; } return $out?$out:$fieldInfo; } /** * Private * * @param [type] $arr: ... * @return [type] ... */ function getItemArrayType($arr) { if (is_array($arr)) { reset($arr); $type[]=0; $intSize[]=0; while(list(,$item)=each($arr)) { if (!t3lib_div::testInt($item[1]) && $item[1]!="--div--") { $type[]=strlen($item[1]); } else { $intSize[]=$item[1]; } } $us = min($intSize)>=0 ? " unsigned" : ""; if (max($type)>0) { $out = "varchar(".max($type).") NOT NULL default ''"; } elseif (max($intSize)>(!$us?127:255)) { $out = "int(11)".$us." NOT NULL default '0'"; } else { $out = "tinyint(3)".$us." NOT NULL default '0'"; } } return $out; } /** * Private * * @param [type] $len: ... * @return [type] ... */ function getItemBlobSize($len) { return ($len>255 ? "tiny" : "")."blob NOT NULL"; } /** * Should suggest a TCA configuration for a specific field. * * @param [type] $fieldName: ... * @param [type] $fieldInfo: ... * @return [type] ... */ function suggestTCAFieldDefinition($fieldName,$fieldInfo) { list($type,$len) = split(" |\(|\)",$fieldInfo,3); switch($type) { case "int": $out=' "'.$fieldName.'" => Array ( "label" => "'.strtoupper($fieldName).':", "exclude" => 0, "config" => Array ( "type" => "input", "size" => "8", "max" => "20", "eval" => "date", "default" => "0", "checkbox" => "0" ) ), ----- OR ----- "'.$fieldName.'" => Array ( "label" => "'.strtoupper($fieldName).':", "exclude" => 0, "config" => Array ( "type" => "select", "items" => Array ( Array("[nothing]", 0), Array("Extra choice! Only negative values here.", -1), Array("__Divider:__", "--div--") ), "foreign_table" => "[some_table_name]" ) ),'; break; case "varchar": if ($len>10) { $out=' "'.$fieldName.'" => Array ( "label" => "'.strtoupper($fieldName).':", "exclude" => 0, "config" => Array ( "type" => "input", "size" => "8", "max" => "'.$len.'", "eval" => "trim", "default" => "" ) ),'; } else { $out=' "'.$fieldName.'" => Array ( "label" => "'.strtoupper($fieldName).':", "exclude" => 0, "config" => Array ( "type" => "select", "items" => Array ( Array("Item number 1", "key1"), Array("Item number 2", "key2"), Array("-----", "--div--"), Array("Item number 3", "key3") ), "default" => "1" ) ),'; } break; case "tinyint": $out=' "'.$fieldName.'" => Array ( "label" => "'.strtoupper($fieldName).':", "exclude" => 0, "config" => Array ( "type" => "select", "items" => Array ( Array("Item number 1", "1"), Array("Item number 2", "2"), Array("-----", "--div--"), Array("Item number 3", "3") ), "default" => "1" ) ), ----- OR ----- "'.$fieldName.'" => Array ( "label" => "'.strtoupper($fieldName).':", "exclude" => 0, "config" => Array ( "type" => "check", "default" => "1" ) ),'; break; case "tinytext": $out=' "'.$fieldName.'" => Array ( "label" => "'.strtoupper($fieldName).':", "exclude" => 0, "config" => Array ( "type" => "input", "size" => "40", "max" => "255", "eval" => "", "default" => "" ) ),'; break; case "text": case "mediumtext": $out=' "'.$fieldName.'" => Array ( "label" => "'.strtoupper($fieldName).':", "config" => Array ( "type" => "text", "cols" => "48", "rows" => "5" ) ),'; break; default: $out=' "'.$fieldName.'" => Array ( "label" => "'.strtoupper($fieldName).':", "exclude" => 0, "config" => Array ( "type" => "input", "size" => "30", "max" => "", "eval" => "", "default" => "" ) ),'; break; } return $out?$out:$fieldInfo; } /** * Includes TCA * * @return [type] ... */ function includeTCA() { global $TCA; include (TYPO3_tables_script ? PATH_typo3conf.TYPO3_tables_script : PATH_t3lib."stddb/tables.php"); // Extension additions if ($GLOBALS["TYPO3_LOADED_EXT"]["_CACHEFILE"]) { include(PATH_typo3conf.$GLOBALS["TYPO3_LOADED_EXT"]["_CACHEFILE"]."_ext_tables.php"); } else { include(PATH_t3lib."stddb/load_ext_tables.php"); } if (TYPO3_extTableDef_script) { include (PATH_typo3conf.TYPO3_extTableDef_script); } reset($TCA); while(list($table)=each($TCA)) { t3lib_div::loadTCA($table); } } /********************** * * GENERAL FUNCTIONS * **********************/ /** * This creates a link to the given $url. If $link is set, that'll be the link-text * * @param [type] $url: ... * @param [type] $link: ... * @return [type] ... */ function linkIt($url,$link="") { return ''.($link?$link:$url).''; } /** * Setting a message in the message-log and sets the fatalError flag if error type is 3. */ function message($head, $short_string="", $long_string="", $type=0, $force=0) { // type: -1=OK sign, 0=message, 1=notification, 2=warning , 3=error if (!$force && $this->mode=="123" && $type<2) {return;} // Return directly if mode-123 is enabled. if ($type==3) {$this->fatalError=1;} if ($this->messageFunc_nl2br) { $long_string = nl2br(trim($long_string)); } else { $long_string = trim($long_string); } if (!$this->silent) $this->printSection($head, $short_string, $long_string, $type); } /** * This "prints" a section with a message to the ->sections array * * @param [type] $head: ... * @param [type] $short_string: ... * @param [type] $long_string: ... * @param [type] $type: ... * @return [type] ... */ function printSection($head, $short_string, $long_string, $type) { $icon=""; $bgCol =' bgcolor=#D9D5C9'; switch($type) { case "3": $bgCol =' bgcolor=red'; $icon = 't3lib/gfx/icon_fatalerror.gif'; break; case "2": // $bgCol =' bgcolor=#9BA1A8'; $icon = 't3lib/gfx/icon_warning.gif'; break; case "1": // $bgCol =' bgcolor=#ABBBB4'; $icon = 't3lib/gfx/icon_note.gif'; break; case "-1": // $bgCol =' bgcolor=yellow'; $icon = 't3lib/gfx/icon_ok.gif'; break; default: $bgCol =' bgcolor='.t3lib_div::modifyHTMLcolor("#ABBBB4",+40,+30,+40); break; } if (!trim($short_string)) { $this->sections[$head][]=""; } else { $this->sections[$head][]=' '.($icon?'':'').''.$this->fw($short_string).''.(trim($long_string)?' '.$this->fw($long_string).'

' : ''); } } /** * Wraps the str in a font-tag with verdana 1 * * @param [type] $str: ... * @param [type] $size: ... * @return [type] ... */ function fw($str,$size=1) { if ($GLOBALS["CLIENT"]["SYSTEM"]=="unix" && $GLOBALS["CLIENT"]["BROWSER"]=="konqu") { return ''.$str.''; } return ''.$str.''; } /** * Wraps the str in a font-tag with verdana 1 * * @param [type] $str: ... * @return [type] ... */ function fwheader($str) { return '
'.$this->fw($str,3).'
'; } /** * Wrapping labal/content in a table-row. * * @param [type] $label: ... * @param [type] $content: ... * @return [type] ... */ function wrapInCells($label,$content) { return ''.$this->fw($label).' '.$this->fw($content).'
'; } /** * This prints all the messages in the ->section array * * @return [type] ... */ function printAll() { reset($this->sections); $out=""; while(list($header,$valArray)=each($this->sections)) { $out.='  
'.$this->fw($header.":",2).'
'; $out.=implode($valArray,chr(10)); } return ''.$out.'
'; } /** * This wraps and returns the main content of the page into proper html-code. * * @param [type] $content: ... * @return [type] ... */ function outputWrapper($content) { $out=' '.$this->headerStyle.' TYPO3 Install Tool '.($this->JSmessage?' ':'').' '.$this->contentBeforeTable.'
TYPO3 '.$GLOBALS["TYPO_VERSION"].' Install Tool
Site: '.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"].'

'.($this->step?$this->stepHeader():$this->menu()).$content.'
'.$this->note123().$this->endNotes().'
'; return $out; } /** * [Describe function...] * * @return [type] ... */ function menu() { if (!$this->passwordOK) return; reset($this->menuitems); $c=0; $out=array(); while(list($k,$v)=each($this->menuitems)) { $bgColor = ($this->INSTALL["type"]==$k ? ' bgColor="#ABBBB4"' : ' bgColor="#F4F0E8"'); $c++; $out[]=''.$this->fw($c.': '.$v).''; } $code = ''.implode($out,chr(10)).'
'; $code = '
'.$code.'
'; return '
'.$code.'
'; } /** * [Describe function...] * * @return [type] ... */ function stepHeader() { $msg1='Type in your database parameters here:'; $msg2='Database'; $msg3='Import the database sql-file'; $msg4='You\'re done!'; $out='
'; $msg=""; switch(strtolower($this->step)) { case 1: $msg=$msg1; break; case 2: $msg=$msg2; break; case 3: $msg=$msg3; break; case "go": $msg=$msg4; break; default: break; } $out.='
'.$this->fw($msg,2).'
'; return $out; } /** * [Describe function...] * * @return [type] ... */ function note123() { if ($this->mode=="123") { $c='
'.$this->fontTag1.'NOTICE: Install Tool is running in \'123\' mode. Click here to disable.
'; return $c; } } /** * [Describe function...] * * @return [type] ... */ function endNotes() { if ($this->mode!="123" && $this->passwordOK) { $c.="OS detected: ".(TYPO3_OS=="WIN"?"WIN":"UNIX")."
"; $c.="UNIX/CGI detected: ".(php_sapi_name()=="cgi" ? "YES" : "NO")."
"; $c.="PATH_thisScript: ".PATH_thisScript."
"; $c.="
"; $c.="Backend admin in new window.
"; $c.="Frontend website in new window.
"; return $this->fw($c); } } /** * [Describe function...] * * @param [type] $bytes: ... * @return [type] ... */ function convertByteSize($bytes) { if (stristr($bytes,"m")) { $bytes=doubleval($bytes)*1024*1024; } elseif (stristr($bytes,"k")) { $bytes=doubleval($bytes)*1024; } return $bytes; } /** * [Describe function...] * * @return [type] ... */ function securityRisk() { $c="This script is a great danger to the security of TYPO3 if you don't secure it somehow. We suggest one of the following: - change the password as defined by the md5-hash in TYPO3_CONF_VARS[BE][installToolPassword]. - delete the folder 'typo3/install/' with this script in or just insert an 'exit;' line in the script-file there. - password protect the 'typo3/install/' folder, eg. with a .htaccess file The TYPO3_CONF_VARS[BE][installToolPassword] is always active, but choosing one of the other options will improve security and is recommended highly. "; return $c; } /** * [Describe function...] * * @return [type] ... */ function alterPasswordForm() { $content = ' Enter new password:
Enter again:
'; return $content; } /** * [Describe function...] * * @return [type] ... */ function messageBasicFinished() { $msg =" Apparently you have completed the basic setup of the TYPO3 database. Now you can choose between these options: - Go to the frontend pages - Go to the backend login (username may be: admin, password may be: password.) - Continue to configure TYPO3 (Recommended). 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 must dig into the this! "; return $msg; } /** * [Describe function...] * * @param [type] $type: ... * @return [type] ... */ function setScriptName($type) { $value = $this->scriptSelf."?TYPO3_INSTALL[type]=".$type.($this->mode?"&mode=".rawurlencode($this->mode):"").($this->step?"&step=".rawurlencode($this->step):""); return $value; } /** * [Describe function...] * * @param [type] $size: ... * @param [type] $textarea: ... * @param [type] $styleOverride: ... * @return [type] ... */ function formWidth($size=48,$textarea=0,$styleOverride="") { // Input or text-field attribute (size or cols) $wAttrib = $textarea?"cols":"size"; if (!$GLOBALS["CLIENT"]["FORMSTYLE"]) { // If not setting the width by style-attribute $size = ceil($size*1); $retVal = ' '.$wAttrib.'="'.$size.'"'; } else { // Setting width by style-attribute. "cols" MUST be avoided with NN6+ $pixels = ceil($size*10); $retVal = $styleOverride ? ' style="'.$styleOverride.'"' : ' style="width:'.$pixels.'px;"'; } return $retVal; } /** * [Describe function...] * * @param [type] $size: ... * @param [type] $styleOverride: ... * @param [type] $wrap: ... * @return [type] ... */ function formWidthText($size=48,$styleOverride="",$wrap="") { $wTags = $this->formWidth($size,1,$styleOverride); // 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... if (strtolower(trim($wrap))!="off" && $GLOBALS["CLIENT"]["BROWSER"]=="net" && $GLOBALS["CLIENT"]["VERSION"]>=5) { $wTags.=' cols="'.$size.'"'; } return $wTags; } } if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/install/mod/class.tx_install.php']) { include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/install/mod/class.tx_install.php']); } ?>