You are here

public static function CleanTalkSFW::sfw_update_logs in Anti Spam by CleanTalk 7.2

Same name and namespace in other branches
  1. 7.5 src/CleantalkSFW.php \CleantalkSFW::sfw_update_logs()
  2. 7.4 src/CleantalkSFW.php \CleantalkSFW::sfw_update_logs()
1 call to CleanTalkSFW::sfw_update_logs()
cleantalk_boot in ./cleantalk.module
Implements hook_boot()

File

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

Class

CleanTalkSFW
Cleantalk Spam FireWall class

Code

public static function sfw_update_logs($ip, $result) {
  if ($ip === NULL || $result === NULL) {
    error_log('SFW log update failed');
    return;
  }
  $blocked = $result == 'blocked' ? ' + 1' : '';
  $time = time();
  $query = "INSERT INTO `cleantalk_sfw_logs`\n\t\tSET \n\t\t\t`ip` = '{$ip}',\n\t\t\t`all` = 1,\n\t\t\t`blocked` = 1,\n\t\t\t`timestamp` = '" . $time . "'\n\t\tON DUPLICATE KEY \n\t\tUPDATE \n\t\t\t`all` = `all` + 1,\n\t\t\t`blocked` = `blocked`" . $blocked . ",\n\t\t\t`timestamp` = '" . $time . "'";
  $result = db_query($query);
}