game/repass.php

131 lines
5.5 KiB
PHP
Raw Normal View History

<?php
2022-12-19 20:16:24 +00:00
2022-12-30 19:03:37 +00:00
use Core\{Config, Database, Db};
2022-12-19 20:16:24 +00:00
if (!defined('GAME_VERSION')) {
require_once '_incl_data/autoload.php';
}
2022-06-06 21:30:34 +00:00
$step = 1;
$error = '';
2022-12-30 19:03:37 +00:00
Config::init();
Database::init();
2022-06-06 21:30:34 +00:00
if (isset($_GET['login'])) {
$_POST['relogin'] = $_GET['login'];
2022-06-06 21:30:34 +00:00
}
if (isset($_POST['relogin'])) {
$_POST['relogin'] = htmlspecialchars($_POST['relogin'], null, 'cp1251');
$u = User::start();
2022-12-19 20:16:24 +00:00
2022-12-30 19:03:37 +00:00
$usr = Db::getRow('select * from users where login =?', [$_POST['relogin']]);
if (!isset($usr['id'])) {
$error = '<27><><EFBFBD><EFBFBD><EFBFBD> "' . htmlspecialchars($_POST['relogin'], null, 'cp1251') . '" <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD>.';
} else {
if ($usr['admin'] != 0 || $usr['banned'] != 0) {
$error = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "' . $_POST['relogin'] . '" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!';
} else {
$step = 2;
if (isset($_POST['redate'])) {
2022-12-19 18:26:14 +00:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>
2022-12-30 19:03:37 +00:00
$lst_psw = Db::getValue(
'select count(*) from repass where uid = ? and time > unix_timestamp() - 24 * 60 * 60 and type = 1',
[$usr['id']]
2022-12-19 20:16:24 +00:00
);
2022-12-30 19:03:37 +00:00
if ($lst_psw) {
2022-12-19 18:26:14 +00:00
$error = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>.';
} elseif (
2022-12-30 19:03:37 +00:00
str_replace('0', '', $_POST['redate']) == str_replace('0', '', $usr['bithday'])
) {
2022-12-19 18:26:14 +00:00
$error = '<br><br><br><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> &quot;' . $usr['login'] . '&quot; <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> E-mail <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>! <br><br><br>';
2022-12-30 19:03:37 +00:00
$re = Db::getValue(
'select count(*) from logs_auth where uid = ? and type = 0 and depass != ?',
[$usr['id'], '']
2022-12-19 20:16:24 +00:00
);
if ($u['securetime'] < Config::get('securetime')) {
unset($re);
}
2022-12-30 19:03:37 +00:00
if (!isset($re)) {
$newPassword = PassGen::new();
$title = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> "' . $usr['login'] . '".';
$txt = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.<br>';
$txt .= '<27> IP-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <b>' . UserIp::get(
) . '</b>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.<br><3E><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><> <20><>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.<br><br>';
$txt .= '<27><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>: <b>' . $usr['login'] . '</b><br>';
$txt .= '<27><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ' . $newPassword . '<br><br>';
$txt .= '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>.<br><br>';
$txt .= '<27> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<br>';
$txt .= '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>';
$mail = Core\Mail::send($usr['mail'], $txt, $title);
2022-12-30 19:03:37 +00:00
if ($mail === 1) {
Db::sql(
'update users set securetime = unix_timestamp(), allLock = unix_timestamp(), pass = ? where id = ?',
[md5($newPassword), $usr['id']]
);
Db::sql(
'insert into repass (uid, time, ip, type) values (?,unix_timestamp(),?,1)',
[$usr['id'], UserIp::get()]
);
$step = 3;
} else {
$error = $mail;
}
unset($mail);
}
} else {
2022-12-30 19:03:37 +00:00
$error = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.';
}
}
}
}
}
2022-06-06 21:30:34 +00:00
?>
<!DOCTYPE html>
<html lang="ru-RU">
<head>
2022-12-19 18:26:14 +00:00
<title><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD></title>
2022-12-30 19:03:37 +00:00
<meta name="keywords" content="<?= Config::get('keys') ?>">
<meta name="description" content="<?= Config::get('desc') ?>"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
2022-12-30 19:03:37 +00:00
<link type="text/css" rel="stylesheet" href="stylen.css"/>
<style>
input[type=text], input[type=date] {
padding: 3px;
}
</style>
2022-06-06 21:30:34 +00:00
</head>
<body>
2022-12-30 19:03:37 +00:00
<form method="post" id="repass"></form>
<div style="display: flex; justify-content: center; align-items: center; flex-direction: column; height: 50%">
<h1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></h1>
<?= $error ? '<b style="color: red">' . $error . '</b>' : '' ?>
<?php if ($step === 1): ?>
<label for="relogin"><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:</label>
<input form="repass" placeholder="<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" maxlength="30" name="relogin" type="text" class="inup" id="relogin">
<br>
<input form="repass" type="submit" class="btn" value="<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>">
<?php elseif ($step === 2): ?>
<label for="relogin"><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:</label>
<input form="repass" maxlength="30" name="relogin" type="text" class="inup" value="<?= $_POST['relogin'] ?>" id="relogin">
<br>
<label for="redate"><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:</label>
<input form="repass" name="redate" type="date" class="inup" id="redate"><br>
<small class="testro">(<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
dd.mm.yyyy)</small><br>
<input form="repass" type="submit" class="btn" value="<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> E-mail">
<?php endif; ?>
</div>
<div style="display: flex; justify-content: center;">
<a href="https://<?= Config::get('host') ?>/"><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></a>
</div>
<div style="display: flex; justify-content: center;">
<span class="testro">&laquo;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>&raquo; &nbsp; &nbsp; 2018-<?= date('Y') ?> &copy; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD></span>
</div>
2022-06-06 21:30:34 +00:00
</body>
</html>