battles/chat.php

60 lines
1.1 KiB
PHP

<?php
/**
* Copyright (c) 2018.
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
use Battles\Chat;
use Battles\Database\Db;
use Battles\Template;
require_once "config.php";
$chat = new Chat(Db::getInstance());
if (!empty($_POST['msg'])) {
$chat->sendMessage($_POST['msg']);
}
Template::header('chat');
echo $chat->getMessages();
?>
<style>
form {
padding: 3px;
position: fixed;
bottom: 0;
width: 100%;
}
form input {
border: 0;
padding: 10px;
width: 80%;
margin-right: .5%;
}
form input[type="submit"] {
width: 15%;
border: none;
padding: 10px;
}
span.chatsys {
color:maroon;
background:#faa;
}
span.chatsms {
color:darkgreen;
background:#afa;
}
span.chatprivate {
background:#efe;
}
</style>
<div>
<?php ?>
</div>
<form action="chat.php" method="post">
<input id="msg" name="msg" size="100" placeholder="Введите сообщение...">
<input type="submit" value="Отправить">
</form>