* $LastChangedDate: 2014-07-05 15:00:08 +0200 (Sa, 05 Jul 2014) $ * $LastChangedBy: T. Suckow $ * $URL: http://svn.conjoon.org/trunk/src/www/htdocs/install/cache.php $ */ /** * Install chunk_7 * * Cleaning up * * @author Thorsten Suckow-Homberg <*****@*****.**> */ /** * check if user is authorized to load script */ include './scripts/check_auth.php'; InstallLogger::getInstance($_SESSION['install_process']['INSTALL_LOGGER']); InstallLogger::stdout(InstallLogger::logMessage("Cleaning up"), true); $INSTALL = array(); $INSTALL['IMREMOVING'] = array('_configCache' => file_exists('../_configCache'), 'js' => file_exists('../js')); // delete folders from a previous installation if ($INSTALL['IMREMOVING']['js']) { InstallLogger::stdout(InstallLogger::logMessage("Removing js from previous installation")); conjoon_rmdir('../js'); } if ($INSTALL['IMREMOVING']['_configCache']) { InstallLogger::stdout(InstallLogger::logMessage("Removing _configCache from previous installation")); conjoon_rmdir('../_configCache'); } // move js folder to htdocs InstallLogger::stdout(InstallLogger::logMessage("Moving js")); rename('./files/js', '../js');
/** * Removes a directory recursively. * * @param string $path */ function conjoon_rmdir($path) { $path = rtrim(str_replace("\\", "/", $path), '/') . '/'; InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[INFO] recursively deleting {$path}")); if (!file_exists($path)) { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[WARNING] rmdir {$path}: directory does not exist")); return; } $handle = opendir($path); for (; false !== ($file = readdir($handle));) { if ($file != "." and $file != "..") { $fullpath = $path . $file; if (is_dir($fullpath)) { conjoon_rmdir($fullpath); if (file_exists($fullpath) && is_dir($fullpath)) { if (!rmdir($fullpath)) { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[ERROR] could not rmdir {$fullpath}")); } else { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[SUCCESS] rmdir {$fullpath}")); } } } else { if (!unlink($fullpath)) { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[ERROR] could not unlink {$fullpath}")); } else { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[SUCCESS] unlink {$fullpath}")); } } } } closedir($handle); if (file_exists($path) && is_dir($path)) { if (!rmdir($path)) { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[ERROR] could not rmdir {$path}")); } else { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[SUCCESS] rmdir {$path}")); } } else { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[WARNING] rmdir {$path}: directory does not exist")); } }