<?php
if (!isset($ab_version)) die('stop block');

if ($ab_config['antibot_log_block'] == 1) {
$ab_exec_time = round(microtime(true) - $ab_start_time, 5);
$sql = 'INSERT INTO hits (cid, date, ip, ptr, useragent, uid, country, referer, page, lang, generation, passed, recaptcha, js_w, js_h, js_cw, js_ch, js_co, js_pi, refhost, adblock, asnum, asname, result, http_accept, method, ym_uid, ga_uid, ip_short) VALUES (\''.$ab_config['cid'].'\', \''.$ab_config['time'].'\', \''.$ab_config['ip'].'\', \''.$ab_config['ptr'].'\', \''.$ab_config['useragent'].'\', \''.$ab_config['uid'].'\', \''.$ab_config['country'].'\', \''.$ab_config['referer'].'\', \''.$ab_config['page'].'\', \''.$ab_config['accept_lang'].'\', \''.$ab_exec_time.'\', \'6\', \'0\', \'\', \'\', \'\', \'\', \'\', \'\', \''.$ab_config['refhost'].'\', \'\', \''.$ab_config['asnum'].'\', \''.$ab_config['asname'].'\', \''.$ab_config['result'].'\', \''.$ab_config['http_accept'].'\', \''.$ab_config['request_method'].'\', \''.$ab_config['ym_uid'].'\', \''.$ab_config['ga_uid'].'\', \''.$ab_config['ip_short'].'\');';

$add = @$antibot_db->exec($sql);
if ($antibot_db->lastErrorMsg() == 'database is locked') {
file_put_contents(__DIR__.'/../data/sqlerrorlog/'.date("YmdH", $ab_config['time']).floor(date("i")/10).'.txt', $sql."\n", FILE_APPEND | LOCK_EX);
}
}

file_put_contents(__DIR__.'/../data/counters/block_'.date('Ymd', $ab_config['time']), '1', FILE_APPEND | LOCK_EX);

header('X-Robots-Tag: noindex');
header($ab_config['protocol'].' '.$ab_config['error_headers'][$ab_config['header_error_code']]);
header('Status: '.$ab_config['error_headers'][$ab_config['header_error_code']]);
$error_tpl = file_get_contents(__DIR__.'/../data/error.txt');
$error_tpl = str_replace('ERROR', 'ERROR '.$ab_config['ip'].' '.date('d.m.Y H:i:s', $ab_config['time']), $error_tpl);

if (isset($ab_ip_test['expires'])) {
if (is_numeric($ab_ip_test['expires']) AND $ab_ip_test['expires'] - $ab_config['time'] < 86401) {
// перевод заглушки на язык посетителя:
if ($ab_config['tpl_lang'] == '') {$ab_config['tpl_lang'] = $ab_config['lang'];}
if (file_exists(__DIR__.'/../lang/tpl/'.$ab_config['tpl_lang'].'.php')) {
require_once(__DIR__.'/../lang/tpl/'.$ab_config['tpl_lang'].'.php');
}
$error_tpl = str_replace('<!--ip_ban_msg-->', '<center>'.abTranslate('Your IP has been blocked. Minutes to unlock:').' '.ceil(($ab_ip_test['expires'] - $ab_config['time']) / 60).'</center>', $error_tpl);
}
}

echo $error_tpl.'<!-- Protected by AntiBot.Cloud -->';
