<?php

//die('Что-то тут не так...');

function getIP()
{
    if (isset($_SERVER['HTTP_X_REAL_IP'])) {
        return $_SERVER['HTTP_X_REAL_IP'];
    }
    return $_SERVER['REMOTE_ADDR'];
}

# Получаем IP
function getIPblock()
{
    if (isset($_SERVER['HTTP_X_REAL_IP'])) {
        return $_SERVER['HTTP_X_REAL_IP'];
    }
    return $_SERVER['REMOTE_ADDR'];
}

# Выполняем проверку безопасности.

/*if( $_SERVER['HTTP_CF_CONNECTING_IP'] != $_SERVER['SERVER_ADDR'] && $_SERVER['HTTP_CF_CONNECTING_IP'] != '127.0.0.1' ) {  die('Hello pussy!');   }
if(getIPblock() != $_SERVER['SERVER_ADDR'] && getIPblock() != '127.0.0.1' && getIPblock() != '' && getIPblock() != '5.187.7.71') {
    die(getIPblock().'<br>'.$_SERVER['SERVER_ADDR']);
}*/


define('GAME', true);

include('_incl_data/__config.php');
include('_incl_data/class/__db_connect.php');
include('_incl_data/class/__user.php');

function e($t)
{
    mysql_query('INSERT INTO `chat` (`text`,`city`,`to`,`type`,`new`,`time`) VALUES ("core #' . date('d.m.Y') . ' %' . date('H:i:s') . ' (Критическая ошибка): <b>' . mysql_real_escape_string($t) . '</b>","capitalcity","LEL","6","1","-1")');
}

$sp = mysql_query('SELECT `u`.*,`s`.*,`u`.`id`,`s`.`id` FROM `users` AS `u` LEFT JOIN `stats` AS `s` ON ( `s`.`id` = `u`.`id` AND `s`.`bot` = 0 ) WHERE `login` = "Crowley"');
while ($pl = mysql_fetch_array($sp)) {
    $last_dnow = mysql_fetch_array(mysql_query('SELECT * FROM `save_dungeon` WHERE `uid` = "' . $pl['id'] . '"'));
    if (isset($last_dnow['id'])) {
        mysql_query('UPDATE `users` SET `room` = "405" WHERE `id` = "' . $last_dnow['uid'] . '"');
        mysql_query('UPDATE `stats` SET `dnow` = "' . $last_dnow['dnow'] . '",`x` = "' . $last_dnow['x'] . '",`y` = "' . $last_dnow['y'] . '" WHERE `id` = "' . $last_dnow['uid'] . '"');
    }
}
