api_get_path(SYS_UPLOAD_PATH).'groups', api_get_path(SYS_CODE_PATH).'upload/users' => api_get_path(SYS_UPLOAD_PATH).'users', api_get_path(SYS_CODE_PATH).'upload/badges' => api_get_path(SYS_UPLOAD_PATH).'badges', api_get_path(SYS_PATH).'courses' => api_get_path(SYS_APP_PATH).'courses', 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).'home', ]; if ($debug) { error_log('Moving folders'); } $fs = new Filesystem(); foreach ($movePathList as $origin => $destination) { if (is_dir($origin)) { $fs->mirror($origin, $destination); if ($debug) { error_log("Renaming: '$origin' to '$destination'"); } try { $fs->remove($origin); } catch (IOException $e) { // If removing the directory doesn't work, just log an error and continue error_log('Could not move '.$origin.' to '.$destination.'('.$e->getMessage().'). Please move it manually.'); } } } // Delete all "courses/ABC/index.php" files. if ($debug) { error_log('Deleting old courses/ABC/index.php files'); } $finder = new Finder(); $courseDir = api_get_path(SYS_APP_PATH).'courses'; if (is_dir($courseDir)) { $dirs = $finder->directories()->in($courseDir); /** @var Symfony\Component\Finder\SplFileInfo $dir */ foreach ($dirs as $dir) { $indexFile = $dir->getPath().'/index.php'; if ($debug) { error_log('Deleting: '.$indexFile); } if ($fs->exists($indexFile)) { $fs->remove($indexFile); } } } // Remove old "courses" folder if empty $originalCourseDir = api_get_path(SYS_PATH).'courses'; if (is_dir($originalCourseDir)) { $dirs = $finder->directories()->in($originalCourseDir); $files = $finder->directories()->in($originalCourseDir); $dirCount = $dirs->count(); $fileCount = $dirs->count(); if ($fileCount == 0 && $dirCount == 0) { @rrmdir(api_get_path(SYS_PATH).'courses'); } } if ($debug) { error_log('Remove archive folder'); } // Remove archive @rrmdir(api_get_path(SYS_PATH).'archive'); } else { echo 'You are not allowed here !'.__FILE__; }