I'm working on the PHP code of someone else and can't find the source file of a certain content. I'm looking for a solution which gives me an easy access to the file name of anything displayed on the website. I did some researches but don't know how to work with that and was hoping to find something like Firebug for the CSS of the website.
The PHP is this:
<?PHP
function getFileList($dir)
{
// array to hold return value
$retval = array();
// add trailing slash if missing
if(substr($dir, -1) != "/") $dir .= "/";
// open pointer to directory and read list of files
$d = @dir($dir) or die("getFileList: Failed opening directory $dir for reading");
while(false !== ($entry = $d->read())) {
// skip hidden files
if($entry[0] == ".") continue;
if(is_dir("$dir$entry")) {
$retval[] = array(
"name" => "$dir$entry/",
"type" => filetype("$dir$entry"),
"size" => 0,
"lastmod" => filemtime("$dir$entry")
);
} elseif(is_readable("$dir$entry")) {
$retval[] = array(
"name" => "$dir$entry",
"type" => mime_content_type("$dir$entry"),
"size" => filesize("$dir$entry"),
"lastmod" => filemtime("$dir$entry")
);
}
}
$d->close();
return $retval;
}
?>
Short answer: Not possible.
Long answer:
Which file is generating the content you're looking for depends on many factors. For a simple system it could be 1:1 filename to url mapping like /index.php => DOCUMENT_ROOT/index.php, and for a more complex system a single line of output might be generated by thousands of files, each printing a single character. Even if your urls are something like xyz.css it might still be generated by a .php file, or even by a file ending with .xyz or without filename extension at all.
Most popular CMS systems already use some kind of url routing / apache ( / whatever webserver ) rewrites, and without knowing anything about the system you're talking about (you aren't really providing much info) it's totally impossible to give a correct answer.
If you got more info on the system you're looking at (programming language is supposedly php - is there some framework used? php extensions? some php cms? maybe it's mixed php and some other language? which webserver? in case of apache/lighttpd/... are there rewrites/url routing in place? ...) you might get a better answer.