|
164 | 164 | unlink(api_get_path(SYS_PATH).'courses/.htaccess');
|
165 | 165 | }
|
166 | 166 |
|
167 |
| - // Delete all "courses/ABC/index.php" files. |
168 |
| - |
169 |
| - $finder = new Finder(); |
170 |
| - $dirs = $finder->directories()->in(api_get_path(SYS_APP_PATH).'courses'); |
171 |
| - $fs = new Filesystem(); |
172 |
| - /** @var Symfony\Component\Finder\SplFileInfo $dir */ |
173 |
| - foreach ($dirs as $dir) { |
174 |
| - $indexFile = $dir->getPath().'/index.php'; |
175 |
| - if ($fs->exists($indexFile)) { |
176 |
| - $fs->remove($indexFile); |
177 |
| - } |
178 |
| - } |
179 |
| - |
180 | 167 | // Move dirs into new structures.
|
181 |
| - |
182 | 168 | $movePathList = [
|
183 | 169 | api_get_path(SYS_CODE_PATH).'upload/users/groups' => api_get_path(SYS_UPLOAD_PATH),
|
184 | 170 | api_get_path(SYS_CODE_PATH).'upload/users' => api_get_path(SYS_UPLOAD_PATH),
|
|
194 | 180 | }
|
195 | 181 | }
|
196 | 182 |
|
197 |
| - // Remove archive |
198 |
| - @rrmdir(api_get_path(SYS_PATH).'archive'); |
| 183 | + |
| 184 | + // Delete all "courses/ABC/index.php" files. |
| 185 | + $finder = new Finder(); |
| 186 | + |
| 187 | + $courseDir = api_get_path(SYS_APP_PATH).'courses'; |
| 188 | + if (is_dir($courseDir)) { |
| 189 | + $dirs = $finder->directories()->in($courseDir); |
| 190 | + $fs = new Filesystem(); |
| 191 | + /** @var Symfony\Component\Finder\SplFileInfo $dir */ |
| 192 | + foreach ($dirs as $dir) { |
| 193 | + $indexFile = $dir->getPath().'/index.php'; |
| 194 | + if ($fs->exists($indexFile)) { |
| 195 | + $fs->remove($indexFile); |
| 196 | + } |
| 197 | + } |
| 198 | + } |
199 | 199 |
|
200 | 200 | // Remove old "courses" folder if empty
|
201 |
| - $dirs = $finder->directories()->in(api_get_path(SYS_PATH).'courses'); |
202 |
| - $files = $finder->directories()->in(api_get_path(SYS_PATH).'courses'); |
203 |
| - $dirCount = $dirs->count(); |
204 |
| - $fileCount = $dirs->count(); |
205 |
| - if ($fileCount == 0 && $dirCount == 0) { |
206 |
| - @rrmdir(api_get_path(SYS_PATH).'courses'); |
| 201 | + $originalCourseDir = api_get_path(SYS_PATH).'courses'; |
| 202 | + |
| 203 | + if (is_dir($originalCourseDir)) { |
| 204 | + $dirs = $finder->directories()->in($originalCourseDir); |
| 205 | + $files = $finder->directories()->in($originalCourseDir); |
| 206 | + $dirCount = $dirs->count(); |
| 207 | + $fileCount = $dirs->count(); |
| 208 | + if ($fileCount == 0 && $dirCount == 0) { |
| 209 | + @rrmdir(api_get_path(SYS_PATH).'courses'); |
| 210 | + } |
207 | 211 | }
|
208 | 212 |
|
| 213 | + |
| 214 | + // Remove archive |
| 215 | + @rrmdir(api_get_path(SYS_PATH).'archive'); |
| 216 | + |
209 | 217 | } else {
|
210 | 218 | echo 'You are not allowed here !'. __FILE__;
|
211 | 219 | }
|
|
0 commit comments