You are here

function uc_referer_check in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_store/uc_store.module \uc_referer_check()
3 calls to uc_referer_check()
uc_cart_checkout_form in uc_cart/uc_cart.module
uc_cart_checkout_review in uc_cart/uc_cart.module
Allow a customer to review their order before finally submitting it.
uc_cart_form_alter in uc_cart/uc_cart.module
Implementation of hook_form_alter().

File

uc_store/uc_store.module, line 2944
Contains global Ubercart functions and store administration functionality.

Code

function uc_referer_check($urls) {
  $http_referer = uc_referer_uri();

  // Always return true if we have no referer; covers the case of page refreshes
  // and switching from HTTP to HTTPS. This bypasses the two-time check below...
  // is it safe?
  if (empty($http_referer)) {
    return TRUE;
  }

  // Check the user didn't shamelessly two-time us with another site.
  $referer = parse_url($http_referer);
  if ($referer['host'] != $_SERVER['SERVER_NAME']) {
    return FALSE;
  }

  // The check itself.
  foreach ((array) $urls as $url) {
    if (substr($http_referer, -strlen($url)) == $url) {
      return TRUE;
    }
  }
  return FALSE;
}