使用此代码有什么后果?安全缺陷?
<?php
if(file_exists("pages/" . $_GET["page"] . ".php")){
include("pages/" . $_GET["page"] . ".php");
} else{
include("pages/home.php");
}
?>
我做了它,让你不能没有“.php”结尾加载任何东西,所以我想这是非常安全的使用。如果你使用:
website.com/index.php?page=../index
在url中它会创建一个无限循环。据我所知,您无法加载外部网址。
例子:
website.com/index.php?page=anothersite.com/virus
但我真的不知道,有什么建议?或者是否可以使用?
http://php.net/manual/en/security.filesystem.nullbytes.php – zerkms
你应该看看Apache的['mod_rewrite'](http://httpd.apache.org/docs/current/mod /mod_rewrite.html),而不是(假设你使用的是Apache)。 –
@Matt Browne,如果他不使用Apache?还有一些其他Web服务器比Apache好得多。 –