FileSecurity
class FileSecurity (View source)
| internal |
Provides file security functions.
IMPORTANT: This file is duplicated at /lib/Drupal/Component/FileSecurity. If any change is made here, the same change should be made in the duplicate. See https://www.drupal.org/project/drupal/issues/3079481.
Methods
Writes an .htaccess file in the given directory, if it doesn't exist.
Returns the standard .htaccess lines that Drupal writes.
Returns htaccess directives to deny execution in a given directory.
Returns htaccess directives to block all access to a given directory.
Writes a web.config file in the given directory, if it doesn't exist.
Returns the standard web.config lines for security.
Writes the contents to the file in the given directory.
Details
static bool
writeHtaccess(string $directory, bool $deny_public_access = TRUE, bool $force = FALSE)
Writes an .htaccess file in the given directory, if it doesn't exist.
static string
htaccessLines(bool $deny_public_access = TRUE)
Returns the standard .htaccess lines that Drupal writes.
static protected string
htaccessPreventExecution()
Returns htaccess directives to deny execution in a given directory.
static protected string
denyPublicAccess()
Returns htaccess directives to block all access to a given directory.
static bool
writeWebConfig(string $directory, bool $force = FALSE)
Writes a web.config file in the given directory, if it doesn't exist.
static string
webConfigLines()
Returns the standard web.config lines for security.
static protected bool
writeFile(string $directory, string $filename, string $contents, bool $force)
Writes the contents to the file in the given directory.