如何在实时站点上查看 PHP

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1319603/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:01:10  来源:igfitidea点击:

How to view PHP on live site

phpsecurity

提问by Oliver Bayes-Shelton

Is it possible to view the PHP code of a live website ?

是否可以查看实时网站的 PHP 代码?

回答by Jonathan Prior

No, as it is interpreted on the server-side and the results are sent to the user. If you want to view the source code of a site you control in-browser, consider the FirePHPextension for Firebug, or just access your site files with your preferred method.

不,因为它在服务器端解释并将结果发送给用户。如果您想查看您在浏览器中控制的站点的源代码,请考虑FirebugFirePHP扩展,或者仅使用您喜欢的方法访问您的站点文件。

回答by catfarm

Usually, no, as others have said, unless of course this is something you want to be the case. Then you can set it up so that using .phps (or any other extension really, but this is the norm) will display the source code of the page (with syntax coloring I believe). Something like:

通常,不,正如其他人所说,除非当然这是您想要的情况。然后你可以设置它,以便使用 .phps(或任何其他扩展名,但这是规范)将显示页面的源代码(我相信使用语法着色)。就像是:

AddHandler application/x-httpd-php-source .phps

AddHandler 应用程序/x-httpd-php-source .phps

in your apache configuration should do the trick.

在您的 apache 配置中应该可以解决问题。

Note, you will need to save your .php files with a .phps for their source to be displayed.

请注意,您需要使用 .phps 保存您的 .php 文件以显示其源代码。

回答by Wim ten Brink

Everyone is wrong! Yes, it is possible! But if you do see the code in your web browser then this would be a serious security breach or some major trouble in the web server. I've seen it happen once, where some dumb administrator had removed the PHP extension for IIS thus the browser provided all sources as text files instead of executing them.

大家都错了!对的,这是可能的!但是,如果您确实在 Web 浏览器中看到了代码,那么这将是严重的安全漏洞或 Web 服务器中的一些重大问题。我见过这种情况发生过一次,一些愚蠢的管理员删除了 IIS 的 PHP 扩展,因此浏览器将所有源作为文本文件提供,而不是执行它们。

Then again, there is an alternative method, which is through FTP. Most websites give access to their file system through FTP, so administrators don't need physical access to the system. You will need to know username and password, plus the FTP address to get access, but once you have this information, you have access to the whole site. Useful for administrators, yet also a very good reason to be very careful with passwords.

再说一次,还有一种替代方法,即通过 FTP。大多数网站都允许通过 FTP 访问其文件系统,因此管理员不需要对系统进行物理访问。您需要知道用户名和密码,以及 FTP 地址才能访问,但是一旦您获得这些信息,您就可以访问整个站点。对管理员有用,但也是非常小心密码的一个很好的理由。

回答by Limitless isa

Current Page add to php code: http://php.net/manual/en/function.show-source.php

当前页面添加到 php 代码:http: //php.net/manual/en/function.show-source.php

 <?php show_source(__FILE__); ?> 

回答by David McEwing

Do you have access to the files on the live server? If so yes, otherwise no, it is only possible to see the result of the script execution.

您可以访问实时服务器上的文件吗?如果是yes,否则no,只能看到脚本执行的结果。

回答by Benjamin Wohlwend

No, unless the server admin screwed up.

不,除非服务器管理员搞砸了。

回答by lpfavreau

Not if PHP is configured properly.

如果 PHP 配置正确,则不会。

PHP is served already interpreted to the visitor.

PHP 服务已经解释给访问者。

Seeing the PHP code on a live website would be considered hacking which is probably outside the ethical scope of stackoverflow.

在实时网站上查看 PHP 代码将被视为黑客行为,这可能超出了 stackoverflow 的道德范围。

回答by evandrix

check out php://inputand php://filter/convert.base64-encode/resource=<filepath>, eg. http://level11.tasteless.eu/index.php?file=php://filter/convert.base64-encode/resource=config.easy.inc.php

退房php://inputphp://filter/convert.base64-encode/resource=<filepath>,例如。http://level11.tasteless.eu/index.php?file=php://filter/convert.base64-encode/resource=config.easy.inc.php

回答by Vipul Jethva

You can't do that. Because the server side script (here PHP scripts) execute on the web server and its output is embedded inside HTML which is then thrown back to your browser. So all you can view is the HTML. Just imagine, if what you asked was possible, then evryone would have the source code of facebook, flipkart in their hands now.

你不能那样做。因为服务器端脚本(此处为 PHP 脚本)在 Web 服务器上执行,并且其输出嵌入在 HTML 中,然后将其返回到您的浏览器。因此,您只能查看 HTML。试想一下,如果你问的是可能的,那么现在每个人都将拥有 facebook、flipkart 的源代码。

回答by Jeremy Ruten

There are a few sites that allow you to view their PHP source. Try googling for inurl:viewsource.php(my site should turn up in there somewhere :)).

有几个站点允许您查看其 PHP 源代码。尝试使用谷歌搜索inurl:viewsource.php(我的网站应该出现在某个地方:))。

Also you can view php.net's source: http://www.php.net/source.php?url=/index.php

您也可以查看php.net的来源:http: //www.php.net/source.php?url=/ index.php