directories()->in(api_get_path(SYS_APP_PATH).'courses'); $fs = new Filesystem(); /** @var Symfony\Component\Finder\SplFileInfo $dir */ foreach ($dirs as $dir) { $indexFile = $dir->getPath().'/index.php'; if ($fs->exists($indexFile)) { $fs->remove($indexFile); } } // Move dirs into new structures. $movePathList = [ api_get_path(SYS_CODE_PATH).'upload/users/groups' => api_get_path(SYS_UPLOAD_PATH), api_get_path(SYS_CODE_PATH).'upload/users' => api_get_path(SYS_UPLOAD_PATH), api_get_path(SYS_CODE_PATH).'upload/badges' => api_get_path(SYS_UPLOAD_PATH), api_get_path(SYS_PATH).'courses' => api_get_path(SYS_APP_PATH), api_get_path(SYS_PATH).'searchdb' => api_get_path(SYS_UPLOAD_PATH).'plugins/xapian', api_get_path(SYS_PATH).'home' => api_get_path(SYS_APP_PATH) ]; foreach ($movePathList as $origin => $destination) { if (is_dir($origin)) { move($origin, $destination); } } // Remove archive @rrmdir(api_get_path(SYS_PATH).'archive'); } else { echo 'You are not allowed here !'. __FILE__; } /** * Quick function to remove a directory with its subdirectories * @param $dir */ function rrmdir($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($dir."/".$object) == "dir") { @rrmdir($dir."/".$object); } else { @unlink($dir."/".$object); } } } reset($objects); rmdir($dir); } }