You are here

function noreferrer_subscribe in No Referrer 7

Same name and namespace in other branches
  1. 8 noreferrer.module \noreferrer_subscribe()

Retrieves whitelist from external URL.

2 calls to noreferrer_subscribe()
noreferrer_admin_submit in ./noreferrer.admin.inc
Admin settings submit handler.
noreferrer_cron in ./noreferrer.module
Implements hook_cron().

File

./noreferrer.admin.inc, line 115
Admin settings callbacks for no referrer module.

Code

function noreferrer_subscribe($url) {
  $response = drupal_http_request($url);
  if (!empty($response->error)) {
    watchdog('noreferrer', 'Error %code received at %url while retrieving domain whitelist: %error.', array(
      '%code' => $response->code,
      '%url' => $url,
      '%error' => $response->error,
    ), WATCHDOG_ERROR, l(t('Configure No Referrer settings.'), 'admin/config/search/noreferrer'));
  }
  elseif ($response->code == 200 && ($whitelist = drupal_json_decode($response->data)) && is_array($whitelist)) {
    variable_set('noreferrer_whitelisted_domains', implode(' ', $whitelist));
  }
  else {
    watchdog('noreferrer', 'Unable to extract valid data from %url while retrieving domain whitelist.', array(
      '%url' => $url,
    ), WATCHDOG_ERROR, l(t('Configure No Referrer settings.'), 'admin/config/search/noreferrer'));
  }
}