You are here

public function SFW::update_log in Anti Spam by CleanTalk 8.4

Same name and namespace in other branches
  1. 9.1.x src/lib/Cleantalk/Common/Firewall/Modules/SFW.php \Cleantalk\Common\Firewall\Modules\SFW::update_log()

* Add entry to SFW log. * Writes to database. * *

Parameters

string $ip: * @param string $status

string $network:

string $source:

1 call to SFW::update_log()
SFW::check in src/lib/Cleantalk/Common/Firewall/Modules/SFW.php
* Use this method to execute main logic of the module. * *

File

src/lib/Cleantalk/Common/Firewall/Modules/SFW.php, line 125

Class

SFW

Namespace

Cleantalk\Common\Firewall\Modules

Code

public function update_log($ip, $status, $network = null, $source = null) {
  $id = md5($ip . $this->module_name);
  $time = time();
  if (!$source) {
    $source = 'NULL';
  }
  if (!$network) {
    $network = 'NULL';
  }
  $query = "INSERT INTO `{$this->db_log_table_name}`\n\t\tSET\n\t\t\t`id` = '{$id}',\n\t\t\t`ip` = '{$ip}',\n\t\t\t`status` = '{$status}',\n\t\t\t`all_entries` = 1,\n\t\t\t`blocked_entries` = " . (strpos($status, 'DENY') !== false ? 1 : 0) . ",\n\t\t\t`entries_timestamp` = '{$time}',\n\t\t\t`ua_name` = '" . Server::get('HTTP_USER_AGENT') . "',\n\t\t\t`source` = {$source},\n\t\t\t`network` = '{$network}',\n      `first_url` = '" . substr(Server::get('HTTP_HOST') . Server::get('REQUEST_URI'), 0, 100) . "',\n      `last_url` = '" . substr(Server::get('HTTP_HOST') . Server::get('REQUEST_URI'), 0, 100) . "'\n\t\tON DUPLICATE KEY\n\t\tUPDATE\n\t\t\t`status` = '{$status}',\n\t\t\t`source` = {$source},\n\t\t\t`all_entries` = `all_entries` + 1,\n\t\t\t`blocked_entries` = `blocked_entries`" . (strpos($status, 'DENY') !== false ? ' + 1' : '') . ",\n\t\t\t`entries_timestamp` = '{$time}',\n\t\t\t`ua_name` = '" . Server::get('HTTP_USER_AGENT') . "',\n\t\t\t`network` = '{$network}',\n      `last_url` = '" . substr(Server::get('HTTP_HOST') . Server::get('REQUEST_URI'), 0, 100) . "'";
  $this->db
    ->execute(str_replace(';', '', $query));
}