You are here

private function SFW::sfw_die in Anti Spam by CleanTalk 8.3

1 call to SFW::sfw_die()
SFW::check_ip in src/lib/Cleantalk/Antispam/SFW.php

File

src/lib/Cleantalk/Antispam/SFW.php, line 295

Class

SFW

Namespace

Drupal\cleantalk\lib\Cleantalk\Antispam

Code

private function sfw_die($cookie_prefix = '', $cookie_domain = '') {

  // File exists?
  if (file_exists(dirname(__FILE__) . '/../../sfw_die_page.html')) {
    $sfw_die_page = file_get_contents(dirname(__FILE__) . '/../../sfw_die_page.html');
  }
  else {
    die("IP BLACKLISTED");
  }

  // Service info
  $sfw_die_page = str_replace('{REMOTE_ADDRESS}', $this->ips_array['real']['ip'], $sfw_die_page);
  $sfw_die_page = str_replace('{REQUEST_URI}', $_SERVER['REQUEST_URI'], $sfw_die_page);
  $sfw_die_page = str_replace('{SFW_COOKIE}', md5($this->ips_array['real']['ip'] . $this->api_key), $sfw_die_page);
  $sfw_die_page = isset($this->ips_array['test']) ? str_replace('{TEST_IP}', 'Tested IP <b>' . $this->ips_array['test']['ip'] . '</b> - ' . ($this->ips_array['test']['in_list'] ? '<span style = "color:red">In list</span>' : '<span style = "color:green">Not in list</span>'), $sfw_die_page) : str_replace('{TEST_IP}', '', $sfw_die_page);

  // Headers
  if (headers_sent() === false) {
    header('Expires: ' . date(DATE_RFC822, mktime(0, 0, 0, 1, 1, 1971)));
    header('Cache-Control: no-store, no-cache, must-revalidate');
    header('Cache-Control: post-check=0, pre-check=0', FALSE);
    header('Pragma: no-cache');
    header("HTTP/1.0 403 Forbidden");
    $sfw_die_page = str_replace('{GENERATED}', "", $sfw_die_page);
  }
  else {
    $sfw_die_page = str_replace('{GENERATED}', "<h2 class='second'>The page was generated at&nbsp;" . date("D, d M Y H:i:s") . "</h2>", $sfw_die_page);
  }
  die($sfw_die_page);
}