Removed Telegraf due to database loss

This commit is contained in:
Igor Barkov (iwork) 2020-06-23 18:13:46 +03:00
parent 384c3e61b3
commit 072057d86c

View File

@ -32,20 +32,21 @@ if ($username && $password) {
setcookie("hashcode", md5($data['id'] . $data["pass"] . $data["login"]), time() + 43200, "/", GAMEDOMAIN); setcookie("hashcode", md5($data['id'] . $data["pass"] . $data["login"]), time() + 43200, "/", GAMEDOMAIN);
$_SESSION['sid'] = session_id(); $_SESSION['sid'] = session_id();
$onl = db::c()->query('SELECT `id` FROM `online` WHERE `id` = "?s"', $data['id'])->fetch_assoc(); $onl = db::c()->query('SELECT user_id FROM online WHERE user_id = "?s"', $data['id'])->fetch_assoc();
if (isset($onl['id'])) { if (isset($onl['id'])) {
db::c()->query('UPDATE `online` SET `date` = ?i WHERE `id` = "?s"', time(), $data['id']); db::c()->query('UPDATE online SET date = ?i WHERE user_id = "?s"', time(), $data['id']);
} else { } else {
db::c()->query('INSERT INTO `online` (`id`, `date`, `room`) VALUES (?i, ?i, ?i)', $data['id'], time(), $data['room']); db::c()->query('INSERT INTO online (user_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', session_id(), 1, $data['id']); db::c()->query('UPDATE `users` SET `sid` = "?s", `enter_game` = ?i WHERE `id` = ?i', session_id(), 1, $data['id']);
// DEPRECATED. NO TABLE IN DB!
// $sms = db::c()->query('SELECT * FROM `telegraph` WHERE `receiver` = ?i', $data['id']);
// while ($res = $sms->fetch_assoc()) {
// db::c()->query('INSERT INTO `chat` (`touid`, `msg`, `type`) VALUES (?i, "?s", "?s")', $res['receiver'], $res['text'], 'sms');
// }
// db::c()->query('DELETE FROM `telegraph` WHERE `receiver` = ?i', $data['id']);
$sms = db::c()->query('SELECT * FROM `telegraph` WHERE `receiver` = ?i', $data['id']);
while ($res = $sms->fetch_assoc()) {
db::c()->query('INSERT INTO `chat` (`touid`, `msg`, `type`) VALUES (?i, "?s", "?s")', $res['receiver'], $res['text'], 'sms');
}
db::c()->query('DELETE FROM `telegraph` WHERE `receiver` = ?i', $data['id']);
header("Location: fight.php"); header("Location: fight.php");
} }
} }