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

check_sqlite() приватный Метод

Checks for the existance of a SQLite datafile tries to create it if it does not exist
private check_sqlite ( )
    private function check_sqlite()
    {
        $db_file = $this->handler_vars['db_file'];
        if ($db_file == basename($db_file)) {
            // The filename was given without a path
            $db_file = Site::get_path('user', true) . $db_file;
        }
        if (file_exists($db_file) && is_writable($db_file) && is_writable(dirname($db_file))) {
            // the file exists, and is writable.  We're all set
            return true;
        }
        // try to figure out what the problem is.
        if (file_exists($db_file)) {
            // the DB file exists, why can't we access it?
            if (!is_writable($db_file)) {
                $this->theme->assign('form_errors', array('db_file' => _t('Cannot write to %s. The SQLite data file is not writable by the web server.', array($db_file))));
                return false;
            }
            if (!is_writable(dirname($db_file))) {
                $this->theme->assign('form_errors', array('db_file' => _t('Cannot write to %s directory. SQLite requires that the directory that holds the DB file be writable by the web server.', array($db_file))));
                return false;
            }
        }
        if (!file_exists($db_file)) {
            // let's see if the directory is writable
            // so that we could create the file
            if (!is_writable(dirname($db_file))) {
                $this->theme->assign('form_errors', array('db_file' => _t('Cannot write to %s directory. The SQLite data file does not exist, and it cannot be created in the specified directory. SQLite requires that the directory containing the database file be writable by the web server.', array($db_file))));
                return false;
            }
        }
        return true;
    }