<?php
defined('ROOT') or define('ROOT', str_replace('\\', '/', realpath(dirname (__FILE__))));
require_once ROOT . '/system/init.php'; // инициализация ядра
$id = abs(intval($_GET['id']));
$click2 = DB :: run() -> querySingle("SELECT COUNT(*) FROM `sites` WHERE `id`= ? AND `active` = ? LIMIT 1;", array($id, 1));
   if($click2 == 0) {
   echo 'Moderation';
   exit;
   }
?>
var site_id = <?php echo $id; ?>;
var ref = document.referrer;
var counter = document.createElement("a");
var img = document.createElement("img");
counter.id='teasers';
counter.href="<?php echo HOST; ?>/go.php?md5=<?php echo md5($id.date("dmyh", time()).'Ulty'); ?>&ididid="+site_id+"&type=banners";
counter.title="Секс знакомства";
img.alt="teasers for site";
img.src="<?PHP
$qr = DB :: run() -> query("SELECT * FROM `setkods` WHERE `id`=? LIMIT 1;", array(intval($id)));
  $dt = $qr -> fetch();
    if ($dt < 1) {
  $qr = DB :: run() -> query("SELECT * FROM `setkods` WHERE `id`=? LIMIT 1;", array(1));
  $dt = $qr -> fetch();
}
$querypost = DB :: run() -> query("SELECT * FROM `banners`".($dt['xxx_b'] == '1' ? " WHERE `adult` = '0'" : "")." ORDER BY rand() LIMIT 1;");
 $total = DB :: run() -> querySingle("SELECT count(*) FROM `banners`".($dt['xxx_b'] == '1' ? " WHERE `adult` = '0'" : "").";");
 if ($total > 0) {
 while ($data = $querypost -> fetch()) {
echo HOST."/banners/images/".$data['img'];

}
}
?>";
img.style.cssText = "opacity: 1 !important";counter.appendChild(document.createTextNode("") );
counter.appendChild(img);
var arr = document.getElementsByTagName('script');
for (var i=0; i < arr.length; i++){
	if (arr[i].src == "<?php echo HOST.'/banners/'; ?>"+site_id+".js") {
		var fnd = arr[i];
		break;
	}
}
if((self.parent&&!(self.parent===self))&&(self.parent.frames.length!=0)){
	top.location.href='<?php echo HOST; ?>';
}else{
	fnd.parentNode.insertBefore(counter,fnd);
}
<?PHP
$usr = DB :: run() -> queryFetch("SELECT `user_id` FROM `sites` WHERE `id` = '".$id."';");
$id = $usr['user_id'];
  $click = DB :: run() -> querySingle("SELECT COUNT(*) FROM `click_db` WHERE `user_id`= ? AND `ip` = ? AND `browser` = ? AND `date` = ? AND `type` = ? LIMIT 1;", array($id, $ip, $useragent, date('d.m.Y'), 'banners'));
  $clickip = DB :: run() -> querySingle("SELECT COUNT(*) FROM `click_db` WHERE `user_id`= ? AND `ip` = ? AND `date` = ? AND `type` = ? LIMIT 1;", array($id, $ip, date('d.m.Y'), 'banners'));
  if($click == 0 && $clickip == 0) {
DB :: run() -> query ("UPDATE `counter` SET `pokaz` = `pokaz`+3 WHERE `type` = 'banners';");
}
?>