在Kohana的核心类中,有一个常量 FILE_SECURITY
.
string(60) "<?php defined('SYSPATH') or die('No direct script access.');"
现在很明显,如果你把它放在文件的开头,并且如果在 Kohana 环境之外访问它,它会 die()
.
但是这个常量的目的是什么?我们不能eval()
因为它有一个领先的 <?php
.
Kohana 是否在某处创建 PHP 文件并使用它来将其添加到文件的开头?
最佳答案
Kohana_Log_File::write
function使用常量:
// 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);
}
看起来它被插入到日志中以阻止从公共(public) URL 读取它。
关于php - Kohana 中这个常数的意义何在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4160727/