<?php

require_once('wu_init.php');

//Обновление пользователей онлайн
if($ip!='unknown'){
$past=time()-600;
$result=mysqli_query($connect_db, "SELECT la FROM ".DB_PREFIX."_online WHERE ip='".$cip."'");
if(mysqli_num_rows($result)!=0){ mysqli_query($connect_db, "UPDATE ".DB_PREFIX."_online SET usr='$u_id', la='$dt', url='$online_url', ti='$online_title' WHERE ip='$cip' LIMIT 1"); }
else{
mysqli_query($connect_db, "INSERT INTO ".DB_PREFIX."_online (usr,ip,la,url,ti) VALUES ('$u_id','$cip','$dt','$online_url','$online_title')"); }
if(substr($dt,9,1)==0){ mysqli_query($connect_db, "DELETE FROM ".DB_PREFIX."_online WHERE la<".$past); }
}
$onla = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT COUNT(id) AS `how` FROM ".DB_PREFIX."_online")); $onl = $onla['how'];

//Проверка реферера
if(isset($_GET["ref"])) { setcookie('referer', intval($_GET['ref']), time()+604800, '/', SITE); }

//Определение реферера
if (!isset($_COOKIE['fromsite']) && isset($_SERVER['HTTP_REFERER'])) { if (!stristr($_SERVER['HTTP_REFERER'], SITE)) { setcookie('fromsite', $_SERVER['HTTP_REFERER'], time()+604800, '/', SITE); } }

//Создание токена
$token = wu_token_gen();

//Подключение шаблона
include(dirname(__FILE__).'/../wu-themes/'.$wu_conf['theme'].'/wu_header.php');