/** * Removes the extension directory (including content) * * @param string Extension directory to remove (with trailing slash) * @param boolean If set, will leave the extension directory * @return boolean False on success, otherwise error string. */ function removeExtDirectory($removePath, $removeContentOnly = 0) { $errors = array(); if (@is_dir($removePath) && substr($removePath, -1) == '/' && (t3lib_div::isFirstPartOfStr($removePath, tx_em_Tools::typePath('G')) || t3lib_div::isFirstPartOfStr($removePath, tx_em_Tools::typePath('L')) || t3lib_div::isFirstPartOfStr($removePath, tx_em_Tools::typePath('S')) && $this->systemInstall || t3lib_div::isFirstPartOfStr($removePath, PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/'))) { // All files in extension directory: $fileArr = t3lib_div::getAllFilesAndFoldersInPath(array(), $removePath, '', 1); if (is_array($fileArr)) { // Remove files in dirs: foreach ($fileArr as $removeFile) { if (!@is_dir($removeFile)) { if (@is_file($removeFile) && t3lib_div::isFirstPartOfStr($removeFile, $removePath) && strcmp($removeFile, $removePath)) { // ... we are very paranoid, so we check what cannot go wrong: that the file is in fact within the prefix path! @unlink($removeFile); clearstatcache(); if (@is_file($removeFile)) { $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_could_not_be_deleted'), $removeFile); } } else { $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_file'), $removeFile, $removePath); } } } // Remove directories: $remDirs = tx_em_Tools::extractDirsFromFileList(t3lib_div::removePrefixPathFromList($fileArr, $removePath)); $remDirs = array_reverse($remDirs); // Must delete outer directories first... foreach ($remDirs as $removeRelDir) { $removeDir = $removePath . $removeRelDir; if (@is_dir($removeDir)) { @rmdir($removeDir); clearstatcache(); if (@is_dir($removeDir)) { $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_files_left'), $removeDir); } } else { $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_no_dir'), $removeDir); } } // If extension dir should also be removed: if (!$removeContentOnly) { @rmdir($removePath); clearstatcache(); if (@is_dir($removePath)) { $errors[] = sprintf($GLOBALS['LANG']->getLL('rmExtDir_error_folders_left'), $removePath); } } } else { $errors[] = $GLOBALS['LANG']->getLL('rmExtDir_error') . ' ' . $fileArr; } } else { $errors[] = $GLOBALS['LANG']->getLL('rmExtDir_error_unallowed_path') . ' ' . $removePath; } // Return errors if any: return implode(LF, $errors); }