PHP :: 您的 *.inc 文件安全吗?

Posted on 25th March 2005 by Nio in 程序人生

通过 Google 的搜索 http://www.google.com/search?q=inurl%3Adb.inc,可以找到很多网站的 db.inc 文件,而且点击浏览这些链接,竟然都可以看到源代码,狂汗!!下边列出了一些找到的结果:[url]http://www.behavioralhearthealth.org/calendar/db.inc[/url]
[url]http://www.tecra.net/squizlib/db/db.inc[/url]
[url]http://www.pupesoft.com/2k/db.inc[/url]

通过如下几种方式中的任何一种均可避免出现这种安全漏洞:

* 最好的方法是将你所使用的库文件放到发布目录之外。
* 修改 Apache 设置,使其将 .inc 作为 PHP 代码解析:
    AddType application/x-httpd-php .php .php3 .phtml .inc
* 为 *.inc 加上扩展名 .php,如 db.inc.php,这样默认作为 PHP 解析,也不会显示出源代码。
* 修改 Apache 设置,加上如下代码:
    <Files ~ "\.inc$">
        Order allow,deny
        Deny from all
    </Files>

2 Comments »

  1. 哈哈!我以前还真不喜欢用inc的后缀,inc的我都用*.inc.php,为什么?因为*.inc在edit+中没有语法加亮!

    Comment by Joe — March 28, 2005 @ 9:25 am

  2. 倒。。。。你不会将 inc 扩展名加到语法加亮设置中去呀~

    Comment by Nio — March 29, 2005 @ 7:46 pm

Leave a comment