Файл: html/chatclan.php
Строк: 125
<?php
require_once ('system/func.php');
$login = $user['login'];
$password = $user['password'];
$access = (int) $user['access'];
$clan = $mc->query("SELECT * FROM `clan` WHERE `id` = '" . $user['id_clan'] . "'")->fetch_array(MYSQLI_ASSOC);
$chat = (int) $user['id_clan'] + 5;
if ($chat > 5) {
?>
<html>
<head>
<title>Mobitva v1.0</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#C8AC70">
<link rel="shortcut icon" href="favicon.ico" />
<meta name="author" content="Kalashnikov"/>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<center style="padding-top: 6px;margin-bottom: -4px; font-size:19px; text-decoration:underline;">
<a onclick="showContent('/clan/clan_all.php?see_clan=<?=$user['id_clan'];?>')" ><?php echo $clan['name']; ?></a>
</center>
<center>
<hr style="background-color: #e8cf99;">
<input style="width:94%; background-color:#e8cf99;" type="text" id="msg" class="input_real chat_input" name="msg" value="" maxlength="200" autocomplete="off">
<br>
<input id="mybutton" class="button_alt_01" type="submit" value="Отправить" style="margin-bottom:-4px; width:90%;">
</center>
<hr style="background-color: #e8cf99;">
<div style ='width:"100%"; height:"100%"; overflow-y:auto'>
<div id='chat'></div>
<script>
MyLib.c = 0;
MyLib.a = 1;
$(document).ready(function () {
$("mobitva:eq(-1)").find('#mybutton').click(function () {
$("mobitva:eq(-1)").find('#mybutton').attr('disabled', true);
MyLib.c = 5;
MyLib.a = 1;
MyLib.send();
});
MyLib.fc = function () {
if (MyLib.a === 0) {
if (MyLib.c > 0) {
$("mobitva:eq(-1)").find('#mybutton').val('Ждите ' + MyLib.c);
MyLib.c = MyLib.c - 1;
} else {
$("mobitva:eq(-1)").find('#mybutton').removeAttr('disabled');
$("mobitva:eq(-1)").find('#mybutton').val(' Отправить ');
}
}
}
MyLib.send = function () {
$.ajax({
type: "POST",
url: "system/chatwrite.php",
data: {
"nick": "<?php echo $login; ?>",
"names": "<?php echo $user['name']; ?>",
"pass": "<?php echo $password; ?>",
"msg": $("mobitva:eq(-1)").find('#msg').val(),
"chat": "<?php echo $chat; ?>"
},
success: function (data) {
$("mobitva:eq(-1)").find('#msg').val("");
MyLib.a = 0;
MyLib.update();
if (data !== "0") {
$("mobitva:eq(-1)").find("#chat").prepend("<font color='#ff0000'>" + data + "</font><br>");
}
}
});
}
var lastId = 0;
MyLib.update = function () {
$.ajax({
type: "POST",
url: 'system/chatread.php',
data: {
"nick": "<?php echo $login; ?>",
"pass": "<?php echo $password; ?>",
"lastId": lastId,
"chat": "<?php echo $chat; ?>"
},
success: function (data) {
if (lastId === 0 || JSON.parse(data).length > 0 && lastId !== JSON.parse(data)[0][0]) {
try {
lastId = JSON.parse(data)[0][0];
for (var i = JSON.parse(data).length - 1; i >= 0; i--) {
<?php if ((int) $user['access'] == 1 && $chat != 3 && $chat < 4 || (int) $user['access'] == 2 && $chat != 3 && $chat < 4) { ?>
if (JSON.parse(data)[i][2] > 0) {
$("mobitva:eq(-1)").find("#chat").prepend("<div><a onclick="showContent('/Adb.php?id=" + JSON.parse(data)[i][2] + "&id_room=" +<?php echo $chat; ?> + "&id_message=" + JSON.parse(data)[i][0] + "')">±</a>" + JSON.parse(data)[i][1] + "</div>");
} else {
$("mobitva:eq(-1)").find("#chat").prepend("<div>" + JSON.parse(data)[i][1] + "</div>");
}
<?php } else { ?>
$("mobitva:eq(-1)").find("#chat").prepend("<div>" + JSON.parse(data)[i][1] + "</div>");
<?php } ?>
}
} catch (e) {
}
}
}
});
}
MyLib.update();
MyLib.intervaltimer.push(setInterval(function () {
MyLib.update();
}, 10000));
MyLib.intervaltimer.push(setInterval(function () {
MyLib.fc();
}, 1000));
});
</script>
<?php
$footval = "chatclan";
require_once ('system/foot/foot.php');
} else {
?>
<center><br><br><br><br><br><br><br><br>
<div>клана нет</div>
</center>
<?php
$footval = "chatclannone";
require_once ('system/foot/foot.php');
}?>