What is the meaning of this constant in Cohan?

In the base class Kohana there is a constant FILE_SECURITY .

 string(60) "<?php defined('SYSPATH') or die('No direct script access.');" 

Now, obviously, if you put this at the beginning of your files, and if it is available outside the Kohana environment, it will die() .

But what is the purpose of this constant? We cannot eval() it, because it has a leading <?php .

Does Kohana create PHP files somewhere and use it to add it to the top of the file?

+6
php kohana
source share
2 answers

The Kohana_Log_File::write function uses a constant:

 // 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); } 

It appears to be pasted into the journal so that it is not readable from a public URL.

+7
source share

You can also use this constant when auto-generating your custom files, for example config (perhaps in installation applications?).

0
source share

All Articles