dougaicha5258 2013-07-03 15:59
浏览 48
已采纳

查看网站内容文件名的最简单方法是什么?

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.

I found this

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;
}
?>
  • 写回答

1条回答 默认 最新

  • douchensou6969 2013-07-03 16:08
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度