public function AntiFlood::update_log in Anti Spam by CleanTalk 8.4
Same name and namespace in other branches
- 9.1.x src/lib/Cleantalk/Common/Firewall/Modules/AntiFlood.php \Cleantalk\Common\Firewall\Modules\AntiFlood::update_log()
Add entry to SFW log. Writes to database.
Parameters
string $ip:
$status:
1 call to AntiFlood::update_log()
- AntiFlood::check in src/
lib/ Cleantalk/ Common/ Firewall/ Modules/ AntiFlood.php - Use this method to execute main logic of the module.
File
- src/
lib/ Cleantalk/ Common/ Firewall/ Modules/ AntiFlood.php, line 150
Class
Namespace
Cleantalk\Common\Firewall\ModulesCode
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__table__logs}`\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));
}