123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace RTP\Module;
- class FileModule
- {
-
- public static function createSecurityIndex()
- {
- $path = PATH_APP;
- $dirs = array();
- $ban_dirs = array(
- './',
- '.',
- '../',
- '..'
- );
- self::getAllDirs($path, $dirs, $ban_dirs);
- foreach ($dirs as $dir)
- {
- if (file_exists($dir . '/index.html') || file_exists($dir . '/index.php'))
- continue;
- else
- {
- $file = fopen($dir . '/index.html', 'w');
- fwrite($file, '');
- fclose($file);
- }
- }
- }
-
- public static function getAllDirs($path, array &$dirs, array &$ban_dirs = array())
- {
- $paths = scandir($path);
- foreach ($paths as $nextPath)
- {
- if (!in_array($nextPath, $ban_dirs) && is_dir($path . DIRECTORY_SEPARATOR . $nextPath))
- {
- $dirs[] = realpath($path . DIRECTORY_SEPARATOR . urlencode($nextPath));
- self::getAllDirs($path . DIRECTORY_SEPARATOR . $nextPath, $dirs, $ban_dirs);
- }
- }
- }
-
- public static function getAllFiles($path, &$dirs, &$ban_dirs = array())
- {
- $paths = scandir($path);
- foreach ($paths as $nextPath)
- {
- if (!in_array($nextPath, $ban_dirs) && is_file($path . DIRECTORY_SEPARATOR . $nextPath))
- {
- $dirs[] = realpath($path . DIRECTORY_SEPARATOR . urlencode($nextPath));
- self::getAllFiles($path . DIRECTORY_SEPARATOR . $nextPath, $dirs, $ban_dirs);
- }
- }
- }
- }
- ?>
|