You are here

function _acquia_spi_security_review_htaccess_analyze in Acquia Connector 6.2

Same name and namespace in other branches
  1. 7.3 acquia_spi/security_review.inc \_acquia_spi_security_review_htaccess_analyze()
  2. 7.2 acquia_spi/security_review.inc \_acquia_spi_security_review_htaccess_analyze()

Helper function to analyze .htaccess in specified directory.

Parameters

$directory string:

Return value

bool

1 call to _acquia_spi_security_review_htaccess_analyze()
acquia_spi_security_review_check_executable_php in acquia_spi/security_review.inc
Check if PHP files written to the files directory can be executed.

File

acquia_spi/security_review.inc, line 621
Stand-alone security checks and review system.

Code

function _acquia_spi_security_review_htaccess_analyze($directory) {
  $contents = file_get_contents($directory . '/.htaccess');

  // Text from includes/file.inc.
  $expected = file_htaccess_lines(FALSE);
  if (trim($contents) !== trim($expected)) {
    $expected = _acquia_spi_security_review_htaccess_parse($expected);
    $contents = _acquia_spi_security_review_htaccess_parse($contents);
    if (!empty($expected) && !empty($contents)) {
      foreach ($expected as $key => $value) {
        if (is_array($value)) {
          if (!isset($contents[$key])) {
            return FALSE;
          }
          foreach ($value as $k => $v) {
            if (array_search($v, $contents[$key]) === FALSE) {
              return FALSE;
            }
          }
        }
        else {
          if (array_search($value, $contents) === FALSE) {
            return FALSE;
          }
        }
      }
    }
    else {
      return FALSE;
    }
  }
  return TRUE;
}