You are here

function cleantalk_boot in Anti Spam by CleanTalk 7.2

Same name and namespace in other branches
  1. 8 cleantalk.module \cleantalk_boot()
  2. 7.5 cleantalk.module \cleantalk_boot()
  3. 7 cleantalk.module \cleantalk_boot()
  4. 7.4 cleantalk.module \cleantalk_boot()

Implements hook_boot()

File

./cleantalk.module, line 2340
Main CleanTalk integration module functions.

Code

function cleantalk_boot() {
  $is_sfw = variable_get('cleantalk_sfw', 0);
  if ($is_sfw == 1) {
    $ct_key = variable_get('cleantalk_authkey', '');
    if ($ct_key != '') {
      $ct_sfw_last_logs_sent = variable_get('ct_sfw_last_logs_sent', null);
      if ($ct_sfw_last_logs_sent && time() - $ct_sfw_last_logs_sent > 3600) {
        CleanTalkSFW::send_logs($ct_key);
      }
      $ct_sfw_last_updated = variable_get('ct_sfw_last_updated', null);
      if ($ct_sfw_last_updated && time() - $ct_sfw_last_updated > 86400) {
        CleanTalkSFW::sfw_update($ct_key);
      }
      $is_sfw_check = true;
      $ip = CleantalkGetIP();
      $ip = array_unique($ip);
      foreach ($ip as $key => $value) {
        if (isset($_COOKIE['ct_sfw_pass_key']) && $_COOKIE['ct_sfw_pass_key'] == md5($value . $ct_key)) {
          $is_sfw_check = false;
          if (isset($_COOKIE['ct_sfw_passed'])) {
            @setcookie('ct_sfw_passed');

            //Deleting cookie
            CleanTalkSFW::sfw_update_logs($value, 'passed');
          }
        }
      }
      unset($key, $value);
      if ($is_sfw_check) {
        $sfw = new CleanTalkSFW();
        $sfw
          ->cleantalk_get_real_ip();
        $sfw
          ->check_ip();
        if ($sfw->result) {
          CleanTalkSFW::sfw_update_logs($sfw->blocked_ip, 'blocked');
          $sfw
            ->sfw_die();
        }
      }
    }
  }
}