$val) { //??????????????? $_POST[$key] = iconv(mb_detect_encoding($_POST[$key], 'auto'), 'utf-8', $val); } $username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_SPECIAL_CHARS); $password = filter_input(INPUT_POST, 'password'); $battle = filter_input(INPUT_COOKIE, 'battle'); $error = ""; $data = db::c()->query('SELECT `id`, `login` ,`pass`, `room`, `block` FROM `users` WHERE `login` = "?s" AND `pass` = "?s" LIMIT 1', $username, md5($password))->fetch_assoc(); if (!$data['id']) { $error = 'Неверные учётные данные!'; } elseif ($data['block'] == 1) { $error = 'Ваш персонаж был заблокирован!'; } if (!$error) { if ($battle != null && $data['id'] != $battle) { db::c()->query('INSERT INTO `delo_multi` (`idperslater`, `idpersnow`) VALUES (?i, ?i)', $battle, $data['id']); } setcookie("battle", $data['id']); $_SESSION['uid'] = $data['id']; setcookie("uid", $data['id'], time() + 43200, "/", GAMEDOMAIN); setcookie("hashcode", md5($data['id'] . $data["pass"] . $data["login"]), time() + 43200, "/", GAMEDOMAIN); $_SESSION['sid'] = session_id(); $onl = db::c()->query('SELECT `id` FROM `online` WHERE `id` = "?s" LIMIT 1', $data['id'])->fetch_assoc(); if (isset($onl['id'])) { db::c()->query('UPDATE `online` SET `date` = ?i WHERE `id` = "?s"', time(), $data['id']); } else { db::c()->query('INSERT INTO `online` (`id`, `date`, `room`) VALUES (?i, ?i, ?i)', $data['id'], time(), $data['room']); } db::c()->query('UPDATE `users` SET `sid` = "?s", `enter_game` = ?i WHERE `id` = ?i LIMIT 1', session_id(), 1, $data['id']); $_SESSION['sid'] = session_id(); //TODO Лог IP адресов планировался удаляться из проекта. $ip = $_SERVER['REMOTE_ADDR']; db::c()->query('INSERT INTO `iplog` (`owner`, `ip`, `date`) VALUES (?i, "?s", ?i)', $data['id'], $ip, time()); $rs = db::c()->query('SELECT * FROM `telegraph` WHERE `owner` = ?i', $data['id'])->fetch_assoc(); while ($rs) { addchp($rs['text'], '{[]}' . $data['login'] . '{[]}'); } db::c()->query('DELETE FROM `telegraph` WHERE `owner` = ?i', $data['id']); header("Location: fight.php"); } ?>