<?php
define('NTLCMS', 1);
$module = 'away';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
$url = isset($_GET['url']) ? filter_var(str_ireplace('http://', '', $_GET['url']), FILTER_SANITIZE_STRING) : filter_var($_SERVER['HTTP_HOST'], FILTER_SANITIZE_STRING);
$sql = DB :: run() -> query("select * from `reklama` where `url` = ? limit 1", array($url));
if (DB :: run() -> querySingle("select * from `reklama` where `url` = ?", array($url))){
$row = $sql -> fetch(PDO::FETCH_OBJ);
if (!isset($_COOKIE['reklama_'.$row -> id])){
DB :: run() -> query("update `reklama` set `count` = `count` + ?, `count_all` = `count_all` + ? where `url` = ? limit 1", array(1, 1, $url));
DB :: run() -> query("insert into `reklama_stat` (`rid`, `time`, `ip`, `ua`) values (?, ?, ?, ?)", array($row -> id, TIME, $ip, $ua));
setCookie ('reklama_'.$row -> id, TIME, TIME + 3600 * 24);
}
header('Location: http://'.$row -> url);
} else {
header('Location: http://'.$url);
}
?>