<?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 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.'http://sexlove.today'; ?>';
}else{
document.write("<a href='<?php echo HOST.'http://sexlove.today'; ?>'></a><?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();
}
$num = $dt["num_ads"];
$querypost = DB :: run() -> query("SELECT * FROM `ads`".($dt['xxx_ads'] == '1' ? " WHERE `adult` = '0'" : "")." ORDER BY rand() LIMIT $num;");
$total = DB :: run() -> querySingle("SELECT count(*) FROM `ads`".($dt['xxx_ads'] == '1' ? " WHERE `adult` = '0'" : "").";");
 if ($total > 0) {
 while ($data = $querypost -> fetch()) {
echo $dt['znak_ads'];
?><a href='<?php echo HOST; ?>/go.php?md5=<?php echo md5($id.date('dmyh', time())."Ulty"); ?>&ididid="+site_id+"&type=ads&<?php echo $data['id']; ?>'><?php
echo "".$data['text']."</a>";

}
}
?>");
}
<?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'), 'ads'));
  $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'), 'ads'));

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