You are here

function _pardot_get_user_headers in Pardot Integration 6

Same name and namespace in other branches
  1. 7 pardot.module \_pardot_get_user_headers()

Returns the user headers filtered for types that shouldn't be needed

Return value

array

1 call to _pardot_get_user_headers()
pardot_webform_submit in ./pardot.module
Submit handler added to webforms to store submissions for pardot.

File

./pardot.module, line 289
ParDot integration module.

Code

function _pardot_get_user_headers() {
  $headers = array();

  // Getting the request headers only exists in apache.
  if (function_exists('apache_request_headers')) {
    $headers = apache_request_headers();
  }
  else {

    // Logic judiciously stolen from http://www.php.net/manual/en/function.apache-request-headers.php#72498
    foreach ($_SERVER as $k => $v) {
      if (substr($k, 0, 5) == 'HTTP_') {
        $k = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($k, 5)))));
        $headers[$k] = $v;
      }
    }
  }

  // Check to see if the function succeeded or not.
  if (!$headers) {
    return array();
  }

  // lowercase just to be sure we're consistent.
  foreach ($headers as $key => $value) {
    $headers[strtolower($key)] = $value;
  }
  unset($headers['host']);
  unset($headers['cookie']);
  return $headers;
}