<?
defined('PROTECTOR') or die('Error: restricted access');

$user_id = 0; //гость
if (isset ($_SESSION['log']) && isset ($_SESSION['pas'])) {
    $log = $_SESSION['log'];
    $pas = $_SESSION['pas'];
} 
// //////////////////////////////////////////////////////////
// Авторизация по COOKIE                                   //
// //////////////////////////////////////////////////////////
elseif (isset ($_COOKIE['log']) && isset ($_COOKIE['pas'])) {
    $log = base64_decode($_COOKIE['log']);
    $_SESSION['log'] = $log;
    $pas = $_COOKIE['pas'];
    $_SESSION['pas'] = $pas;
}
$req = mysql_query("SELECT * FROM `users` WHERE `usr` = '$log' and `pass`='$pas' LIMIT 1");
// //////////////////////////
$avto = mysql_num_rows($req);

if ($avto == 1) {

    $user_id = 1; //авторизованый
    $udata = mysql_fetch_assoc($req);
    
        $in_battle = mysql_num_rows(mysql_query("SELECT * FROM tmp WHERE usr = '$log' LIMIT 1"));

    $inpk = mysql_num_rows(mysql_query("SELECT * FROM pk WHERE usr = '$log' LIMIT 1"));

    $inaw = mysql_num_rows(mysql_query("SELECT * FROM arena_wait WHERE usr = '$log' LIMIT 1"));

    $inar = mysql_num_rows(mysql_query("SELECT * FROM arena WHERE usr = '$log' LIMIT 1"));
    
    $inzasada = mysql_num_rows(mysql_query("SELECT * FROM zasada WHERE usr = '$log' LIMIT 1"));

    $inryd = mysql_num_rows(mysql_query("SELECT * FROM rydnik WHERE usr = '$log' LIMIT 1"));
    
    include($path.'files/online.php');
    include($path.'files/regeneration.php');

    // ///////////последний визит
    $dater = date("d F, Y", time());
    $time = date("H:i:s", time());
    $dater = str_replace("January", "января", $dater);
    $dater = str_replace("February", "февраля", $dater);
    $dater = str_replace("March", "марта", $dater);
    $dater = str_replace("April", "апреля", $dater);
    $dater = str_replace("May", "мая", $dater);
    $dater = str_replace("June", "июня", $dater);
    $dater = str_replace("July", "июля", $dater);
    $dater = str_replace("August", "августа", $dater);
    $dater = str_replace("September", "сентября", $dater);
    $dater = str_replace("October", "октября", $dater);
    $dater = str_replace("November", "ноября", $dater);
    $dater = str_replace("December", "декабря", $dater);

    mysql_query("UPDATE `users` SET `lvisit` = '$dater $time' WHERE usr = '$log' LIMIT 1");
    
    // /получаем местоположение
    if (isset($headmod)) {
        mysql_query("UPDATE `mesto` SET `place` = '$headmod' WHERE `usr` = '$log' LIMIT 1");
    } //фиксируем положение

    }
    
    if(isset($_GET[site])){
    $_SESSION['site']=$_GET[site];
    }
?>