ignore_list_arr" array to specify file and folder names to ignore.] * 2.Upload it in a password protected directory within the web root of the site, then point your browser to the script * 3.Copy and paste the resulting list and save it in a text file. Its the text between "--Download List START--" and "--Download List END--" * * * * This script was written by John Walker - EatMyBusiness.com * See: http://www.eatmybusiness.com/food/2008/11/15/tutorial-how-to-quickly-create-a-flat-local-rendered-copy-of-your-dynamic-web-sites-output-files-its-web-imprint/81/ * * It is an adaption of a previous script called 'look for hiddens' * See: http://www.eatmybusiness.com/food/2007/05/03/php-script-that-finds-htaccess-within-a-specified-directory/19/ * * Feel free to use it on your own website * * THIS SOFTWARE IS PROVIDED 'AS IS' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ //turn off error reporting to prevent 'open file permissions errors' from halting the script restore_error_handler(); error_reporting(0); // *** set the path to the web root directory (with no trailing slash) //example //$dir_path = '/home/web/htdocs'; //OR //$dir_path = '/home/www/vhosts/example.com/httpdocs/'; $dir_path = ''; $helperline_number = __LINE__; //leave this line // *** set your URL prefix //(this is used as a prefix for the use in the Download List $fully_qualified_url_to_root ='http://www.example.com/'; //including trailing slash $lister_obj = new wgp_filesystem_lister(); /** * @desc Uncomment the set strings to ignore if matched as elements of the "$lister_obj->ignore_list_arr" array * Tips: "example_directory_name" * matches: /example_directory_name/ * does not match: /example_directory_name2/ */ //$lister_obj->ignore_list_arr[]='example_directory_name'; //$lister_obj->ignore_list_arr[]='examplefile.exe'; $lister_obj->list_line_prefix_str = "\n".$fully_qualified_url_to_root; $lister_obj->list_line_suffix_str =''; /** * Y O U D O N O T N E E D T O * C H A N G E A N Y T H I N G B E L O W T H I S L I N E */ if (strlen($dir_path) < 1) { //If you remember Weird Science you will understand the significance of the "You forgot to hook up the doll" part of the error message ;o) echo('You forgot to hook up the doll! - No directory path specified on line ' . ($helperline_number -1)); exit; } //initialize the array $paths_of_interest_arr =array(); //comment these out to make it work - i use these lines to disable the script when im not actively using it //echo('disabled on purpose'); //exit; //recurses the function to subdirectories $is_recursive = TRUE; $lister_obj->collect_files_list($dir_path,$is_recursive); $html_head = '
');
$paths_of_interest_arr = $lister_obj->paths_of_interest_arr;
reset($paths_of_interest_arr);
$num_elements = count($paths_of_interest_arr);
if ($num_elements > 0)
{
echo("\n--Download List START--");
//tells Website Downloader your web site adddress
echo("\nLinks from: ".$fully_qualified_url_to_root."\n");
//outputs the list of files to download, one per line
echo($paths_of_interest_arr['list_str']);
echo("\n--Download List END--");
echo("\n\n");
echo("\n--Ignored Hiddens Array --");
print_r($paths_of_interest_arr['ignored_hiddens']);
echo("\n\n");
echo("\n--Ignored Matches Array --");
print_r($paths_of_interest_arr['ignored_matches']);
echo("\n\n");
echo("\n--Found Hiddens Array --");
print_r($paths_of_interest_arr['hiddens']);
}
else {
echo('Nothing of interest found');
}
echo('');
echo($html_foot);
//I just exit here to stop any appended scripts that may try to run
exit;
/**
*@desc this class loops through the filesystem recursively collecting paths to files of interest and ignoring those specified in $ignore_list_arr
*
*/
class wgp_filesystem_lister
{
/**
*@desc fixed to TRUE - could be made public and turned FALSE if we want to collect hiddens
*/
private $ignore_hiddens=1;
public $ignore_list_arr=array();
/**
*@desc holds the returning data
*/
public $paths_of_interest_arr;
/**
*@desc these two properties can be used to wrap the resulting lines of output within strings - e.g could be used to dynamicly write a switch statement
*/
public $list_line_suffix_str;
public $list_line_prefix_str;
/**
*@desc this function is a throwback from the old script and can be ignored
*/
function is_hidden($directory_item)
{
//check if there is an empty string before the first dot
$filename_arr = explode('.',$directory_item);
if (strlen($filename_arr[0]) < 1)
{
//looks like we found a hidden file
return 1;
}
//else
return 0;
}
function collect_files_list($dir_path,$is_recursive,$recursed_path = '')
{
$dir = @dir($dir_path);
if ($dir == FALSE)
{
$this->paths_of_interest_arr['failed_to_open'][]=$dir_path;
}
else {
while(false !== ($directory_item = $dir->read()))
{
if ($directory_item == '.' || $directory_item == '..')
{
continue;
}
if (($this->ignore_hiddens==1) && (substr($directory_item, 0,1)=='.' ) )
{
//its a hidden directory
$this->paths_of_interest_arr['ignored_hiddens'][]=$recursed_path.$directory_item;
continue;
}
if (($this->ignore_list_arr) && (in_array($directory_item,$this->ignore_list_arr) ))
{
//it matches an ignore string
//echo('ignoring: ' . $directory_item);
$this->paths_of_interest_arr['ignored_matches'][]=$recursed_path.$directory_item;
continue;
}
if (is_dir($dir_path.'/'.$directory_item))
{
if ($is_recursive)
{
$this->collect_files_list($dir_path.'/'.$directory_item,$is_recursive, $recursed_path.basename($directory_item).'/' );
}
}
elseif ($this->is_hidden($directory_item))
{
$this->paths_of_interest_arr['hiddens'][]=$recursed_path.$directory_item;
}
else
{
$line_str='';
if ($this->list_line_prefix_str)
{
//we have been given something to put at the front
$line_str =$this->list_line_prefix_str.$recursed_path.$directory_item;
}
else {
//else just add a new line char
$line_str = "\n".$recursed_path.$directory_item;
}
if ($this->list_line_suffix_str)
{
//we have been given something to append on the end
$line_str .=$this->list_line_suffix_str;
}
$this->paths_of_interest_arr['list_str'] .=$line_str;
}
}
}
}
}