You are here

function _acquia_spi_security_review_check_file_perms_scan in Acquia Connector 6.2

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

Parameters

$directory:

$ignore:

Return value

array

1 call to _acquia_spi_security_review_check_file_perms_scan()
acquia_spi_security_review_check_file_perms in acquia_spi/security_review.inc
Check that files aren't writeable by the server.

File

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

Code

function _acquia_spi_security_review_check_file_perms_scan($directory, $ignore) {
  $items = array();
  if (is_readable($directory) && ($handle = opendir($directory))) {
    while (($file = readdir($handle)) !== FALSE) {

      // Don't check hidden files or ones we said to ignore, or subdir site links.
      if ($file[0] != "." && !in_array($file, $ignore) && !(is_link($file) && readlink($file) == '.')) {
        $file = $directory . "/" . $file;
        if (is_dir($file) && !in_array($file, $ignore)) {
          $items = array_merge($items, _acquia_spi_security_review_check_file_perms_scan($file, $ignore));
          if (is_writable($file)) {
            $items[] = preg_replace("/\\/\\//si", "/", $file);
          }
        }
        elseif (is_writable($file)) {
          $items[] = preg_replace("/\\/\\//si", "/", $file);
        }
      }
    }
    closedir($handle);
  }
  return $items;
}