2018-03-01 23:21:53 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2018.
|
|
|
|
* Author: Igor Barkov <lopar.4ever@gmail.com>
|
|
|
|
* Project name: Battles-Game
|
|
|
|
*/
|
|
|
|
|
|
|
|
session_start();
|
|
|
|
if ($_SESSION['uid'] == null) {
|
|
|
|
header("Location: index.php");
|
|
|
|
}
|
|
|
|
include_once "config.php";
|
|
|
|
include_once "functions.php";
|
|
|
|
|
|
|
|
$chat = db::c()->query('SELECT * FROM `chat` ORDER BY `id` DESC LIMIT 50');
|
|
|
|
|
|
|
|
while ($message = $chat->fetch_assoc()) {
|
2018-03-01 23:44:06 +00:00
|
|
|
$d = new DateTime($message['msgdate']);
|
|
|
|
echo $d->format('H:i').": " . $message['msg'];
|
2018-03-01 23:21:53 +00:00
|
|
|
}
|
|
|
|
|
2018-03-01 23:33:18 +00:00
|
|
|
|
2018-03-01 23:35:06 +00:00
|
|
|
$msg = filter_input(INPUT_POST,'msg');
|
2018-03-01 23:23:14 +00:00
|
|
|
$uid = $_SESSION['uid'];
|
2018-03-01 23:21:53 +00:00
|
|
|
|
|
|
|
if ($msg) db::c()->query('INSERT INTO `chat` (`cid`, `uid`, `msg`) VALUES (?i, ?i, "?s")', 1, $uid, $msg);
|
|
|
|
?>
|
|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<link rel="stylesheet" href="css/main.css">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<form action="chat.php" method="post">
|
|
|
|
<input name="msg" size="100" placeholder="Введите сообщение...">
|
|
|
|
<input type="submit">
|
|
|
|
</form>
|
|
|
|
</body>
|