You are here

static function Cleantalk::apache_request_headers in Anti Spam by CleanTalk 7.4

Same name and namespace in other branches
  1. 7.5 src/Cleantalk.php \Cleantalk::apache_request_headers()
2 calls to Cleantalk::apache_request_headers()
Cleantalk::cleantalk_get_real_ip in src/Cleantalk.php
Cleantalk::httpRequest in src/Cleantalk.php
httpRequest

File

src/Cleantalk.php, line 730

Class

Cleantalk
Cleantalk Base class

Code

static function apache_request_headers() {
  $headers = array();
  foreach ($_SERVER as $key => $val) {
    if (preg_match('/\\AHTTP_/', $key)) {
      $server_key = preg_replace('/\\AHTTP_/', '', $key);
      $key_parts = explode('_', $server_key);
      if (count($key_parts) > 0 and strlen($server_key) > 2) {
        foreach ($key_parts as $part_index => $part) {
          $key_parts[$part_index] = mb_strtolower($part);
          $key_parts[$part_index][0] = strtoupper($key_parts[$part_index][0]);
        }
        $server_key = implode('-', $key_parts);
      }
      $headers[$server_key] = $val;
    }
  }
  return $headers;
}