Habari\InstallHandler::secure_sqlite PHP Метод

secure_sqlite() публичный Метод

attempts to write the Files clause to the .htaccess file if the clause for this sqlite doesn't exist.
public secure_sqlite ( ) : boolean
Результат boolean success or failure
    public function secure_sqlite()
    {
        if (false === strpos($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
            // .htaccess is only needed on Apache
            // @TODO: Notify people on other servers to take measures to secure the SQLite file.
            return true;
        }
        if (!file_exists(HABARI_PATH . '/.htaccess')) {
            // no .htaccess to write to
            return false;
        }
        if (!is_writable(HABARI_PATH . DIRECTORY_SEPARATOR . '.htaccess')) {
            // we can't update the file
            return false;
        }
        // Get the files clause
        $sqlite_contents = $this->sqlite_contents();
        $files_contents = "\n" . implode("\n", $sqlite_contents) . "\n";
        // See if it already exists
        $current_files_contents = file_get_contents(HABARI_PATH . DIRECTORY_SEPARATOR . '.htaccess');
        if (false === strpos($current_files_contents, $files_contents)) {
            // If not, append the files clause to the .htaccess file
            if ($fh = fopen(HABARI_PATH . DIRECTORY_SEPARATOR . '.htaccess', 'a')) {
                if (false === fwrite($fh, $files_contents)) {
                    // Can't write to the file
                    return false;
                }
                fclose($fh);
            } else {
                // Can't open the file
                return false;
            }
        }
        // Success!
        return true;
    }