Файл: public_html/bancode.php
Строк: 80
<?php
define('BASE_DIR', $_SERVER['DOCUMENT_ROOT']);
define('TIME', time());
require_once(BASE_DIR.'/inc/init.php');
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
$query = $mysqli->query("SELECT * FROM `".PREFIX."_blocks` WHERE `type` = '2' and `id` = '".$id."' LIMIT 1");
if ($query->num_rows)
{
$res = $query->fetch_assoc();
$stats = json_decode($res['stats'], true);
$ip = $_SERVER['REMOTE_ADDR'];
$query = $mysqli->query("SELECT `id` FROM `".PREFIX."_blocks_view` WHERE `time_add` >= CURDATE() and `ident` = '".$id."' and `ip` = '".$ip."' LIMIT 1");
if ($query->num_rows)
{
$res_view = $query->fetch_assoc();
$mysqli->query("UPDATE `".PREFIX."_blocks_view` SET `view` = `view` + 1 WHERE `id` = '".$res_view['id']."' and `ip` = '".$ip."'");
@$stats[date("Y-m-d", TIME)]['view'] += 1;
}
else
{
@$stats[date("Y-m-d", TIME)]['user'] += 1;
@$stats[date("Y-m-d", TIME)]['view'] += 1;
$mysqli->query("INSERT INTO `".PREFIX."_blocks_view`
(
`ident`,
`time_add`,
`ip`,
`view`,
`type`
)
VALUES
(
'".$id."',
NOW(),
'".$ip."',
'1',
'2'
)");
}
$mysqli->query("UPDATE `".PREFIX."_blocks` SET `stats` = '".json_encode($stats)."' WHERE `id` = '".$id."'");
$str = getWord($res['sum'], array('рубль', 'рубля', 'рублей'));
$size = explode('x', $res['size']);
$query = $mysqli->query("SELECT *, UNIX_TIMESTAMP(time_add) as time FROM `".PREFIX."_banners` WHERE `ident` = '".$id."' and `status` = '1'");
if ($query->num_rows)
{
$res_ban_q = $mysqli->fetch_assoc_all($query);
$buy_slots = $query->num_rows;
$res_ban = $res_ban_q[rand(0, $buy_slots - 1)];
$token = md5(TIME);
if ($buy_slots < $res['slots'])
{
//когда есть баннеры и есть свободные места
$code = "var ls = document.getElementById('tourus_".$res['id']."');ls.innerHTML = '<div style="position:relative;width:".$size[0]."px;height:".$size[1]."px;overflow:hidden;"><a href="http://www.tourus.site/go.php?type=2&id=".$res_ban['id']."&token=".$token."" target="_blank"><img src="http://www.tourus.site/uploads/".$res_ban['url_banner']."" width="".$size[0]."" height="".$size[1].""/></a><a href="http://www.tourus.site/banner.php?id=".$res['id']."" target="_blank"><img title="Свободно ".($res['slots'] - $buy_slots)." из ".$res['slots']." мест. Стоимость размещения ".$res['sum']." руб. за неделю." src="http://www.tourus.site/img/buyb.png" style="position:absolute; top:0px; border:0 !important; height: 16px !important; width: 139px !important; overflow:hidden;right:-110px; -webkit-transition: right 0.7s ease;-moz-transition: right 0.7s ease;-o-transition: right 0.7s ease;" onmouseover="this.style.right='0px';" onmouseout="this.style.right='-110px';"></a></div>';";
}
else
{
$time_free = 0;
foreach ($res_ban_q as $value)
{
if ($time_free == 0)
{
$time_free = $value['time'] + (($value['weeks'] * 7) * 86400);
}
else if ($time_free > $value['time'] + (($value['weeks'] * 7) * 86400))
{
$time_free = $value['time'] + (($value['weeks'] * 7) * 86400);
}
}
//когда есть баннеры и нет свободных мест
$code = "var ls = document.getElementById('tourus_".$res['id']."');ls.innerHTML = '<a title="Место освободится ".date('d.m.Y в H:i', $time_free)."" href="http://www.tourus.site/go.php?type=2&id=".$res_ban['id']."&token=".$token."" target="_blank"><img src="http://www.tourus.site/uploads/".$res_ban['url_banner']."" width="".$size[0]."" height="".$size[1].""/></a>';";
}
}
else
{
//когда нет банеров
$code = "var ls = document.getElementById('tourus_".$res['id']."');ls.innerHTML = '<a title="Место свободно! Цена за неделю ".$res['sum']." ".$str."" href="http://www.tourus.site/banner.php?id=".$res['id']."" target="_blank"><img src="http://www.tourus.site/promo/dummy/".$res['size'].".png" width="".$size[0]."" height="".$size[1].""/></a>';";
}
exit($code);
}
exit(header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true));