Jump to content

[SOLVED] view all files and directories


The Little Guy

Recommended Posts

I don't think that is what I need...

 

 

I would like to have a code on my site that will make a list of all the files on a users website. Basically, I want the user to come and copy this code to a file on their website, and then the code will be placed in the root folder of their site. When the code runs, I would like it to grab every file textual web file they have created, such as some of these formats:

html,htm,php,shtml,asp,dhtml,txt

 

This would also search all subdirectories as well, and save those URL's too.

 

The EXACT URL of each file will then be saved to a txt file that will be saved in their root directory.

 

I would like it to ignore all image files, exe files, and anything that would not contain textual content that can be displayed on the web.

 

anyone know of a way to do this?

<?php
function kids($dir, $allowed_extensions)
{
    if ($handle = opendir($dir))
    {
        $output = array();
        while (false !== ($item = readdir($handle)))
        {
            if (is_dir($dir.'/'.$item) and $item != "." and $item != "..")
            {
                $output = array_merge($output, kids($dir.'/'.$item, $allowed_extensions));
            }
            elseif(is_file($dir.'/'.$item) and
                   in_array(preg_replace('/^.*((?<=\.)[^.]+)$/', '$1', $item), $allowed_extensions))
            {
                $output[] = $dir.'/'.$item;
            }
        }
        closedir($handle);
        return $output;
    }
    return false;
}
print_r(kids('.', array('html','htm','php','shtml','asp','dhtml','txt','cmf','jsp','aspx'))); 
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.