You are here

function htaccess_cron in Htaccess 7.2

Same name and namespace in other branches
  1. 8.2 htaccess.module \htaccess_cron()

File

./htaccess.module, line 139
Htaccess is a module which autogenerates a Drupal root htaccess file based on your settings.

Code

function htaccess_cron() {

  // try to get current htaccess content
  $root_path = DRUPAL_ROOT;
  $htaccess_filepath = $root_path . '/.htaccess';
  $htaccess_current = file_get_contents($htaccess_filepath);
  if ($htaccess_current) {

    // Get the current htaccess deployed
    $htaccess_deployed = db_select('htaccess', 'h')
      ->fields('h')
      ->condition('deployed', 1, '=')
      ->execute()
      ->fetchAssoc();
    if ($htaccess_deployed) {
      $htaccess_deployed = $htaccess_deployed['htaccess'];

      // Compare the two results
      if ($htaccess_current === $htaccess_deployed) {
        variable_del('htaccess_altered');
      }
      else {
        drupal_set_message(t('The htaccess seems to be altered.'), 'warning');
        variable_set('htaccess_altered', true);
      }
    }
  }
}