在Kohana的核心课程中,有一个常数FILE_SECURITY.
string(60) "<?php defined('SYSPATH') or die('No direct script access.');"
Run Code Online (Sandbox Code Playgroud)
现在很明显,如果你把它放在你的文件的开头,如果它是在Kohana环境之外访问的话,它会die().
但这个常数的目的是什么?我们不能eval()因为它有领先优势<?php.
Kohana是否在某处创建PHP文件并使用它将其添加到文件的开头?
该Kohana_Log_File::write函数使用常量:
// Set the name of the log file
$filename = $directory.date('d').EXT;
if ( ! file_exists($filename))
{
// Create the log file
file_put_contents($filename, Kohana::FILE_SECURITY.' ?>'.PHP_EOL);
// Allow anyone to write to log files
chmod($filename, 0666);
}
Run Code Online (Sandbox Code Playgroud)
看起来它被插入到日志中以阻止它从公共URL中读取.