System chat from zayavka

This commit is contained in:
lopar 2018-11-05 22:54:18 +02:00
parent 073d56fc6b
commit 9d14ff16b3
3 changed files with 24 additions and 15 deletions

View File

@ -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>-->

View File

@ -2512,14 +2512,13 @@ function addchp($text, $who, $room = 0)
fclose($fp); //закрытие
}
function AddChatSystem($text)
/**
* @param $msg
* @throws \Krugozor\Database\Mysql\Exception
* Отправка системного сообщения в чат.
*/function AddChatSystem($msg)
{
$fp = fopen("tmp/chat.txt", "a");
flock($fp, LOCK_EX);
fputs($fp, ":[" . time() . "]:[!sys2all!!]:[" . ($text) . "]:[1]\r\n");
fflush($fp);
flock($fp, LOCK_UN);
fclose($fp);
if ($msg) db::c()->query('INSERT INTO `chat` (`cid`,`uid`,`msg`,`type`) VALUES (?i,"?s","?s","?s")', 1, 'System', $msg, 'sys');
}
function err($t)

View File

@ -625,17 +625,17 @@ if ($_REQUEST['level'] == 'begin') {
}
if($_POST['back2']) {
$z = $zay->getlist(1,null,$user['zayavka']);
addchp ('<font color=red>Внимание!</font> '.nick::id($user['id'])->short().' отозвал заявку. ','{[]}'.nick::id($res['$z[$user['zayavka']]['team1'][0]'])->short().'{[]}');
AddChatSystem('Внимание!'.nick::id($user['id'])->short().' отозвал заявку.');
echo $zay->delteam (2,$user['id'], $user['zayavka'], 1);
}
if($_POST['cansel']) {
$z = $zay->getlist(1,null,$user['zayavka']);
echo $zay->delteam (2,$z[$user['zayavka']]['team2'][0], $user['zayavka'], 1);
addchp ('<font color=red>Внимание!</font> '.nick::id($user['id'])->full(1).' отказался от поединка. ','{[]}'.nick::id($res['$z[$user['zayavka']]['team2'][0]'])->short().'{[]}');
AddChatSystem('Внимание!'.nick::id($user['id'])->short().' отказался от поединка.');
}
if($_POST['confirm2']) {
$z = $zay->getlist(1,null,$_REQUEST['gocombat']);
addchp ('<font color=red>Внимание!</font> '.nick::id($user['id'])->full(1).' принял заявку, нужно принять вызов или отказать. ','{[]}'.nick::id($z[$_REQUEST['gocombat']]['team1'][0])->short().'{[]}');
AddChatSystem('Внимание!'.nick::id($user['id'])->short().' принял заявку, нужно принять вызов или отказать.');
echo $zay->addteam (2,$user['id'], $_REQUEST['gocombat'], 1);
die("<script>document.location='zayavka.php?level=begin';</script>");
}