You are here

function domain_check_response in Domain Access 7.3

Same name and namespace in other branches
  1. 5 domain_admin.inc \domain_check_response()
  2. 6.2 domain.admin.inc \domain_check_response()
  3. 7.2 domain.admin.inc \domain_check_response()

Checks to see if the webserver returns a valid response for a request to a domain.

If the domain_skip_domain_check variable is not 0, the response will be assumed to be valid and a warning will be set using drupal_set_message().

Parameters

$domain: An array containing the record from the {domain} table.

$drush: Boolean value indicating a drush command.

Return value

A translated string indicating the error message or FALSE if the response is 200 "found" or if the domain_skip_domain_check variable is not 0.

6 calls to domain_check_response()
domain_form in ./domain.admin.inc
FormsAPI for editing a domain record
domain_form_validate in ./domain.admin.inc
Implement domain_form validate hook.
domain_overview_form_validate in ./domain.admin.inc
Validate handler for the domain overview form.
drush_domain_add in ./domain.drush.inc
Add a new domain.
drush_domain_default in ./domain.drush.inc
Set the default domain id.

... See full list

File

./domain.module, line 3662
Core module functions for the Domain Access suite.

Code

function domain_check_response($domain, $drush = FALSE) {

  // t() function name is different whether we are using drush or not.
  $t = empty($drush) ? 't' : 'dt';
  if (variable_get('domain_skip_domain_check', 0)) {
    drupal_set_message($t('Domain response checks have been disabled. Saving an incorrect domain may affect your site.'), 'warning', FALSE);
    return FALSE;
  }
  $url = domain_get_path($domain) . drupal_get_path('module', 'domain') . '/tests/200.png';
  $response = drupal_http_request($url, array(
    'method' => 'HEAD',
    'absolute' => TRUE,
  ));
  if ($response->code != 200) {
    return $t('!server is not responding as expected and may not be configured correctly at the server level. Server code !code was returned.', array(
      '!server' => $url,
      '!code' => $response->code,
    ));
  }
  return FALSE;
}