<?
include_once'../system/xcms_core.php';
$q=$db->query("select * from `ads` where `id`='$id'")->fetch(PDO::FETCH_ASSOC);
if($q){
$w=$db->query("select * from `ads_out` where `link`='$id' and `ip`='$sess_ip'")->rowCount();
if(!$w){
$db->query("insert into `ads_out` set `ip`='$sess_ip', `ua`='$sess_ua', `time`='$time', `link`='$id'");
if($user)$db->prepare("update `user` set `balans`=`balans`+$da[bal_rekl] where `id`='$user[id]'")->execute();
header('location: '.$q['link']);
}else{
header('location: '.$q['link']);
}
}else{
header('location: /');
}
?>