<?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 arr = document.getElementsByTagName('script');
for (var i=0; i < arr.length; i++){
	if (arr[i].src == "<?php echo HOST.'/teasers/'; ?>"+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{
document.write("<a href='<?php echo HOST.'/?err=10'; ?>'></a><div style='height: 10px;'><span style='float: right; '><a href='<?php echo HOST; ?>'></span></div><?PHP
$qr = DB :: run() -> query("SELECT * FROM `setkods` WHERE `id`=? LIMIT 1;", array($id));
  $dt = $qr -> fetch();
  if ($dt < 1) {
  $qr = DB :: run() -> query("SELECT * FROM `setkods` WHERE `id`=? LIMIT 1;", array(1));
  $dt = $qr -> fetch();
}
  $num = $dt["num_t"];
$querypost = DB :: run() -> query("SELECT * FROM `teasers`".($dt['xxx_t'] == '1' ? " WHERE `adult` = '0'" : "")." ORDER BY rand() LIMIT $num;");
 $total = DB :: run() -> querySingle("SELECT count(*) FROM `teasers`".($dt['xxx_t'] == '1' ? " WHERE `adult` = '0'" : "").";");
 if ($total > 0) {
 while ($data = $querypost -> fetch()) {
 echo "<div style='border: 1px dotted #ccc; padding: 5px; border-radius: ".$dt['bradius_t']."px; margin-top: 3px;'>";

echo "<a href='".HOST; ?>/go.php?md5=<?php echo md5($id.date('dmyh', time())."Ulty"); ?>&ididid=<?php echo $id; ?>&type=teasers&<?php echo $data['id']; ?>'><table cellspacing='0' cellpadding='0' border='0'  style='opacity:1; margin: 2px; padding: 6px 10px 6px 4px; display: block; font-size: <?php echo $dt['size_t']; ?>px;' width='450px'><tr><?php echo ($dt['img_t'] == '1' ? "<td align='right'><img style='background: #ccc; padding: 6px; margin: 4px;' src='".HOST."/teasers/images/".$data['img']."' width='".$dt['img_t_x']."' height='".$dt['img_t_x']."'></td>" : "")."<td>".(empty($data['title']) ? "" : "<b>".$data['title']."</b><br />")."".$data['text']."</td></tr></table></a>";
echo '</div>';
}
}
$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'), 'teasers'));
  $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'), 'teasers'));

  if($click == 0 && $clickip == 0) {
DB :: run() -> query ("UPDATE `counter` SET `pokaz` = `pokaz`+3 WHERE `type` = 'teasers';");
}
?>");
}