How can I use php to determine which files are invoked and included given a url only.
eg. the URL, www.mydomain.com/index.php
might use:
- index.php
- includes.php
- content.html
I want to give php the url and it return the filenames.
Thank you :-)
How can I use php to determine which files are invoked and included given a url only.
eg. the URL, www.mydomain.com/index.php
might use:
I want to give php the url and it return the filenames.
Thank you :-)
You're not going to be able to do this from a URL. To the outside world a URL is just something that returns a bunch of text. There's little to nothing that can be done to devine how that text was created.
If you have access to the source code, placing this at the end of your entry file will be a big help.
print_r(get_included_files());
This will print out every file that's been included or required in. However, this won't give you any file that's been accessed with fopen, file_get_contents, etc. If you're interested in seeing if a particular file has been accessed or not, the unix stat
program can tell you this. However, in normal computer operation files are accessed for lots of different reasons, so you'll want to be careful relying on anything that comes out of stat.
There is no way to do this given just a URL since PHP supports dynamic inclusion of files and your code could take different execution paths. From within your PHP script, you can use get_incluided_files() after all the files have been included.
Here is an example from the PHP documentation:
<?php
// This file is abc.php
include 'test1.php';
include_once 'test2.php';
require 'test3.php';
require_once 'test4.php';
$included_files = get_included_files();
foreach ($included_files as $filename) {
echo "$filename\n";
}
?>