简体   繁体   English

防止人们访问您的课程并直接包含文件

[英]Prevent people from accessing your classes and include files directly

I'm making my own MVC framework and I remember seeing something like this in phpBB forums index page code: 我正在制作自己的MVC框架,并且记得在phpBB论坛索引页面代码中看到了类似的内容:

define('IN_PHPBB', true);

and then in the files that are only ment to be included and not directly accessed it has this at the top: 然后在仅包含但不直接访问的文件中,其顶部为:

if(!defined('IN_PHPBB')) {
    die();
}

I was wondering if that is neccessary especially with class files because if they are directly accessed they won't run anyway since they were not instantiated. 我想知道这是否是必需的,尤其是对于类文件,因为如果直接访问它们,它们将不会运行,因为它们没有被实例化。

I suggest to you to put a file .htaccess with with the directive deny from all inside the folder with your php class files. 我建议您将所有带有php类文件的文件夹中的.htaccess文件与指令deny放在一起。 The official documentation is here 官方文档在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM