public function htaccessDeny(string $dir, bool $allow_static_access = false): int
    {
        $deny = // `.htaccess` file.
            '<IfModule authz_core_module>'."\n".
            '	Require all denied'."\n".
            '</IfModule>'."\n".
            '<IfModule !authz_core_module>'."\n".
            '	deny from all'."\n".
            '</IfModule>';

        if ($allow_static_access) {
            $deny .= "\n\n".// Allow these file extensions.
            '<FilesMatch "\.(js|css|gif|jpg|png|svg|eot|woff|ttf|html|txt|md)$">'."\n".
            '	<IfModule authz_core_module>'."\n".
            '		Require all granted'."\n".
            '	</IfModule>'."\n".
            '	<IfModule !authz_core_module>'."\n".
            '		allow from all'."\n".
            '	</IfModule>'."\n".
            '</FilesMatch>';
        }
        return (int) file_put_contents($dir.'/.htaccess', $deny);
    }