public function CleantalkSFW::send_logs in Anti Spam by CleanTalk 7.4
Same name and namespace in other branches
- 7.5 src/CleantalkSFW.php \CleantalkSFW::send_logs()
- 7.2 cleantalk.module \CleanTalkSFW::send_logs()
File
- src/
CleantalkSFW.php, line 162
Class
Code
public function send_logs($ct_key) {
//Getting logs
$this->db_result_data = db_query('SELECT * FROM {cleantalk_sfw_logs}')
->fetchAll();
if (count($this->db_result_data)) {
//Compile logs
$data = array();
foreach ($this->db_result_data as $key => $value) {
$data[] = array(
trim($value->ip),
$value->all_entries,
$value->all_entries - $value->blocked_entries,
$value->entries_timestamp,
);
}
unset($key, $value);
//Sending the request
$result = self::api_method__sfw_logs($ct_key, $data);
//Checking answer and deleting all lines from the table
if (empty($result['error'])) {
if ($result['rows'] == count($data)) {
db_truncate('cleantalk_sfw_logs')
->execute();
return true;
}
}
else {
return $result;
}
}
else {
return array(
'error' => true,
'error_string' => 'NO_LOGS_TO_SEND',
);
}
}