System chat from zayavka
This commit is contained in:
@@ -18,10 +18,20 @@ if ($msg) db::c()->query('INSERT INTO `chat` (`cid`, `uid`, `msg`) VALUES (?i, ?
|
||||
|
||||
function show_messages()
|
||||
{
|
||||
$chat = db::c()->query('SELECT `msg`, `msgdate`, (SELECT `login` FROM `users` WHERE `users`.`id` = `uid`) AS `from` FROM `chat` ORDER BY `id` ASC LIMIT 50');
|
||||
$chat = db::c()->query('
|
||||
SELECT
|
||||
`msg`,
|
||||
`msgdate`,
|
||||
(SELECT `login` FROM `users` WHERE `users`.`id` = `uid`) AS `from`,
|
||||
`type`
|
||||
FROM `chat` ORDER BY `id` ASC LIMIT 50');
|
||||
|
||||
while ($message = $chat->fetch_assoc()) {
|
||||
$d = new DateTime($message['msgdate']);
|
||||
$m = htmlspecialchars($message['msg']);
|
||||
if (!empty($message['type'])) {
|
||||
echo sprintf('<span style="color:maroon">%s %s</span>', $d->format('H:i'),$m)." <br>";
|
||||
}
|
||||
echo sprintf('%s [%s]: %s', $d->format('H:i'),$message['from'],$m)." <br>";
|
||||
}
|
||||
}
|
||||
@@ -42,8 +52,8 @@ show_messages();
|
||||
<!--<div>-->
|
||||
<?php ?>
|
||||
<!--</div>-->
|
||||
<!--<!--<form action="chat.php" method="post">-->-->
|
||||
<!--<!-- <input id="msg" name="msg" size="100" placeholder="Введите сообщение...">-->-->
|
||||
<!--<!-- <input type="submit" value="Отправить">-->-->
|
||||
<!--<!--</form>-->-->
|
||||
<!--<form action="chat.php" method="post">-->
|
||||
<!-- <input id="msg" name="msg" size="100" placeholder="Введите сообщение...">-->
|
||||
<!-- <input type="submit" value="Отправить">-->
|
||||
<!--</form>-->
|
||||
<!--</body>-->
|
||||
Reference in New Issue
Block a user