Файл: html/chat.php
Строк: 150
<?php
require_once ('system/func.php');
require_once ('system/dbc.php');
$footval = "chat";
auth();
$login = $user['login'];
$password = $user['password'];
$access = (int) $user['access'];
$name_1 = $user['name'];
$user_id = $user['id'];
$user['id_clan']=$user['id_clan']+5;
if (isset($_GET['chat'])) {
$chat = (int) $_GET['chat'];
} else {
$chat = 0;
}
//проверяем бан
$time = time();
$banned = 0;
$result11 = $mc->query("SELECT * FROM `chatban` WHERE `username` = '" . $name_1 . "' AND `time`>'$time' ORDER BY `id` DESC LIMIT 1");
if ($result11->num_rows && $chat < 2) {
$userbanchat = $result11->fetch_array(MYSQLI_ASSOC);
$banned = 1;
}
?>
<tr bgcolor='$bgcolor'>
<center style="padding-top: 6px;margin-bottom: -4px;">
<?php if ($chat == 0) { ?>
<a style="font-weight: bolder;">Общий зал </a>
<?php } else { ?>
<a onclick="showContent('chat.php?chat=0')" >Общий зал</a>
<?php } ?>
<?php if ($chat == 1) { ?>
<a style="font-weight: bolder;">Задворки </a>
<?php } else { ?>
<a onclick="showContent('chat.php?chat=1')" >Задворки </a>
<?php } ?>
<?php if ($chat == $user['id_clan'] && $user['id_clan'] > 5) { ?>
<a style="font-weight: bolder;">Клан </a>
<?php } else if ($user['id_clan'] > 5) { ?>
<a onclick="showContent('/chatclan.php')">Клан </a>
<?php } ?>
<?php if ($access == 1 || $access > 1) { ?>
<?php if ($chat == 3) { ?>
<a style="font-weight: bolder;">МД </a>
<?php } else { ?>
<a onclick="showContent('chat.php?chat=3')" >МД </a>
<?php } ?>
<?php } ?>
<?php if ($access > 2) { ?>
<?php if ($chat == 4) { ?>
<a style="font-weight: bolder;">ЛДГТЧ </a>
<?php } else { ?>
<a onclick="showContent('chat.php?chat=4')" >ЛДГТЧ </a>
<?php } ?>
<?php } ?>
<?php if ($access > 2) { ?>
<?php if ($chat == 5) { ?>
<a style="font-weight: bolder;">Логи </a>
<?php } else { ?>
<a onclick="showContent('chat.php?chat=5')" >Логи</a>
<?php } ?>
<?php } ?>
</center>
<hr style="background-color: #e7ce98;">
<?php if ($banned == 1) {
// set default timezone
date_default_timezone_set('UTC');
?>
<center>
<?php echo 'отправка заблокирована до <br>' . date('Y-m-d H:i:s', $userbanchat['time']+10800); ?>
</center>
<?php } else if (isset($user['level']) && $user['level'] < 4) { ?>
<center>
Отправка не доступна до 4 уровня.
</center>
<?php } else { ?>
<center>
<input 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:80%;">
<?php if ($user['access'] > '3') { ?>
<input type="checkbox" id="pip" name="pip" value="Yes" />
<?php } ?>
</center>
<?php } ?>
<hr style="background-color: #e7ce98;">
<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; ?>",
"pass": "<?php echo $password; ?>",
"msg": $("mobitva:eq(-1)").find('#msg').val(),
"chat": "<?php echo $chat; ?>",
"pip": $("mobitva:eq(-1)").find("#pip").prop('checked')
},
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;
var cl = 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 (JSON.parse(data).length > 0 && 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 ($access == 1 && $chat < 2 && $banned == 0 || (int) $user['access'] > 1 && $chat < 2) { ?>
if (JSON.parse(data)[i][2] > 0 && JSON.parse(data)[i][2] !== <?php echo $user_id; ?>) {
$("mobitva:eq(-1)").find("#chat").prepend("<div style='margin-bottom: 6px;word-break: break-word;'>" + JSON.parse(data)[i][1].replace("] <font style='font", "] <a class='msgid' msgid=" + JSON.parse(data)[i][0] + ">±</a> <font style='font") + "</div>");
} else {
$("mobitva:eq(-1)").find("#chat").prepend("<div style='margin-bottom: 6px;word-break: break-word;'>" + JSON.parse(data)[i][1] + "</div>");
}
<?php } else { ?>
$("mobitva:eq(-1)").find("#chat").prepend("<div style='margin-bottom: 6px;word-break: break-word;'>" + JSON.parse(data)[i][1] + "</div>");
<?php } ?>
}
<?php if ($access == 1 && $chat < 2 && $banned == 0 || (int) $user['access'] > 1 && $chat < 2) { ?>
$(".msgid").click(function () {
if(cl == 0){
showContent("/adb.php?msgid=" + $(this).attr("msgid") + "&chat=<?php echo $chat; ?>");
cl++;
}
});
<?php } ?>
} catch (e) {
}
}
}
});
};
MyLib.update();
MyLib.intervaltimer.push(setInterval(function () {
MyLib.update();
}, 10000));
MyLib.intervaltimer.push(setInterval(function () {
MyLib.fc();
}, 1000));
});
</script>
<?php
include 'system/foot/foot.php';
?>