安全包含文件 [英] secure include files

查看:121
本文介绍了安全包含文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道保护包含文件的最佳解决方案。
现在我的解决方案就是:

I'd like to know the BEST solution to secure includes files. For now my solution is this :

在索引文件中:

define('KEY','security');
include('s.php';

s.php:

if(KEY!='security') exit;


推荐答案

大多数类似代码的情况甚至都没有检查密钥的已知值,只是检查它是否已定义。

Most cases of similar code don't even check for a known value of key, but just check if it is defined.

例如,Mediawiki在包含文件中使用它:

For example Mediawiki uses this in include files:

<?php
if( !defined( 'MEDIAWIKI' ) ) {
    die( 1 );
}

这篇关于安全包含文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆