<?php
define('ROOT', dirname(__FILE__));
require_once 'system/func.php';
require_once 'system/header.php';
?>
<style>
    @font-face {
        font-family: ariales-matic;
        src: url(css/ariales-matic.ttf);
    }

    .shrif {
        font-family: ariales-matic, arial, serif;
        font-size: 18px;
    }
</style>


<?php
/**
 * <script type="text/javascript" src="oksdk.js"></script>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () {
var config = {
app_id: 1261984000,      // <-- insert APP ID here
app_key: 'CBAKFJDMEBABABABA'     // <-- insert APP PUBLIC KEY here
};
OKSDK.init(config, function () {

OKSDK.REST.call('users.getCurrentUser', null, function (status, data, error) {
if (status === 'ok') {
//document.getElementById('content').innerHTML = 'Hello World and hi, ' + data.name + '.';
document.cookie = "uid=" + data.uid;
document.cookie = "gender=" + data.gender;
} else {
alert('Unable to retrieve current user ' + OKSDK.Util.toString(error));
}
});
}, function (error) {
alert('OKSDK error' + OKSDK.Util.toString(error));
})
});
</script>
 */

/*echo '<pre>';
print_r($_COOKIE);
echo '</pre>';*/



noauth(); // Закроем от авторизованных
/* СЧЕТЧИКИ */
$registr = mysql_num_rows(mysql_query("SELECT * FROM `users`"));
$key = rand(33123, 99656);
echo ' <center>' . div('wrappe') . '' . div('heade') . ' <span class="gold"></span></div>' . div('content_blue') . '</div><img src="/images/logo.jpg" style="width:100%; >' . div('header') . ' ' . color('gold') . '</font></div></div>';
echo " <div class='header'><span style='color: gold'>Это игра ,  в которой вы окунётесь в мир полных опасностей и удивительных приключений</div></div></a>";

echo " <div class='header'><a href='/r.php?'> <img src='/images/other/StartGame.png'> </a></div>";
//echo div('block_lose')." Регистрация временно закрыта</div>";

$auth_ip = __DIR__ . '/logs_auth/' . $_SERVER['REMOTE_ADDR'];
if (file_exists($auth_ip)) {
    $auth_time = intval(file_get_contents($auth_ip));
} else {
    $auth_time = 0;
}


if (isset($_POST['auth'])) {

    $name = text($_POST['nickname']);
    $pass = text($_POST['password']);

    if ($auth_time > time() - 1800 && $_POST['captcha'] != $_SESSION['captcha']) {
        file_put_contents($auth_ip, time());
        $err = 'Неверный проверочный код!';
    } elseif (empty($name)) {
        $err = 'Введите логин';
    } elseif (empty($pass)) {
        $err = 'Введите пароль';
    } elseif (!$sql = mysql_fetch_array(mysql_query("SELECT `login`,`password` FROM `users` WHERE `login` = '" . mysql_real_escape_string($name) . "' AND `password`='" . md5($pass) . "' LIMIT 1"))) {
        file_put_contents($auth_ip, time());
        $err = 'Неверный логин или пароль.';
    } else {
        setcookie('login', $name, time() + 86400 * 365, '/');
        setcookie('password', md5($pass), time() + 86400 * 365, '/');
        header('location: /?key=$key');
        exit;
    }

    $_SESSION['msg'] = $err;
    header('Location: /');
    exit();
}
echo div('content_blue') . '<div class="header">
	<form action="" method="post">
<div class="bor_bg item_center"> 	<font size="2px"> ' . span('grey') . 'Логин: </span></font></div>
<input class="center" type="text1" name="nickname" maxlength="25" placeholder=" " required/>
	 <div class="bor_bg item_center" > 	<font size="2px"> ' . span('grey') . '	Пароль: </span></font></div>
<input class="center" type="password1" name="password" maxlength="25" placeholder="" required/>';

if ($auth_time > time() - 1800) {

    echo '<div class="bor_bg item_center" ><font size="2px"> ' . span('grey') . '  Проверочный код: </span></font><img src="/captcha/captcha.php" id="captcha" onclick="document.getElementById(\'captcha\').src =\'/captcha/captcha.php?\' + Math.random()"></div>
<input class="center" type="text" name="captcha" maxlength="25" placeholder="" autocomplete="off" required/><br/>';

}


echo '<center>
<input type="submit" name="auth" class="btn_g" value="Войти"> </br><a href="/recovery/" > Забыли пароль? </a>
</center>

';

//echo '<div style="text-align: center;"><a class="btn_grey" href="https://connect.ok.ru/oauth/authorize?client_id=' . urlencode('1261984000') . '&scope=' . urlencode('VALUABLE_ACCESS') . '&response_type=code&redirect_uri=' . urlencode('https://legepoh.ru/okru.php') . '&layout=a">Войти через ОК</a></div>';
echo '</div></div>';
echo '<div style="text-align: center;">' . div('header') . '<a href="/common/agreement/" > Соглашение </a></div></div>';
echo "<center><img src='/images/pims1.png'></center>";


ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
?>





    <script src="//local.adguard.com/adguard-ajax-api/injections/userscripts/Adguard Assistant?ts=63620941169594"
            type="text/javascript"></script>
    <a href="http://statok.net/go/16151"><img src="http://statok.net/image/16151" alt="Statok.net"/></a>
    