Файл: chat.php
Строк: 188
<?php
include("includes/config.php");
ob_start();
header("Cache-Control: no-store, no-cache, must-revalidate");
echo "<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>";
if($diz_id==1){
include("includes/style.php");
}
if($diz_id==2){
include("includes/style1.php");
}
else
{
include("includes/style.php");
}
echo "<title>$PAGE_NAME_TITLE</title>
<link rel="shortcut icon" type="image/ico" href="img/ico.png"/>
</head><body>
<div class="in">
<div class="block">
<img src="img/logo.png" alt="*"/>
</div>";
$dm = is_logged();
if(!$dm) {
header("Location: index.php");
exit();
}
juosta();
if($id == "") {
section_online($useris,1,false);
$gavejas = filter($_GET['k']);
if($gavejas != false) {
$value = "$gavejas,";
}
$k = $_GET['k'];
$nuskaitymas13 = mysql_query("SELECT * FROM vartotojai WHERE nick='".$useris."'");
$stulpeliai13 = mysql_fetch_array($nuskaitymas13);
//nick='".$stulpeliai1['nick']."'
$id_ban= $stulpeliai13['ban_chat_time'];
$id_us= $stulpeliai13['id'];
$nuskaitymas14 = mysql_query("SELECT * FROM ban_chat WHERE nick_id='".$id_us."'");
$stulpeliai14 = mysql_fetch_array($nuskaitymas14);
$prich_us_ban= $stulpeliai14['priezastis'];
if($id_ban!=0)
{
echo "<div class="meniu center">
<b>Вы забанены в чате!</b> Причина: $prich_us_ban. </br>
<small>В случае, если вы не согласны,обратитесь в <b> техническую поддержку.</b> Желательно предоставив скриншоты или свидетелей. </small> </br></br>
</div>
";
}
else {
echo "<form action="chat.php?id=write" method="post">
<div class="meniu center">
<a href="chat.php?b=".rand(0,9999)."">Обновить чат</a> | Текст(<a href="help.php?id=bbcode">BB CODE</a>):
<br/>
<textarea rows="4" cols="17" name="zinute">$value</textarea>
<br/>
<input type="submit" value="Писать"/>
</div>
</form>";
}
$nuskaitoma = mysql_query("SELECT * FROM chat");
$viso = mysql_num_rows($nuskaitoma);
if($viso == false) {
echo "<div class="meniu center">
Нет сообщений.
</div>";
}
else
{
$nuo = (int) ereg_replace("[^0-9]","",$_GET['nuo']);
$puslapiu_skaicius = 20;
$nuskaitymas = mysql_query("SELECT * FROM chat ORDER BY id DESC LIMIT $nuo,$puslapiu_skaicius");
echo "<div class="meniu">";
while($stulpeliai = mysql_fetch_array($nuskaitymas)) {
$vafetch = mysql_fetch_array(mysql_query("SELECT * FROM vartotojai WHERE nick='".$stulpeliai['nick']."'"));
$stulpeliai['zinute'] = bbcode($stulpeliai['zinute']);
$user = user($vafetch['nick'],$vafetch['statusas']);
if($dm['statusas'] > 2) {
$xx = "[<a href="chat.php?id=clean&m=1&z=".$stulpeliai['id']."">уд</a>]";
}
if($dm['statusas'] >=4 ) {
$xxx = "[<a href="chat.php?id=ban&k=".$stulpeliai['nick']."">бан</a>]";
}
echo "$xx $xxx <i><b><a href="chat.php?k=".$stulpeliai['nick']."">$user</a></b></i> [<a href="index.php?id=info&k=".$vafetch['id']."">?</a>]<small><i>(".$stulpeliai['laikas'].")</i></small>: ".$stulpeliai['zinute']."
<br/>
<br/>";
}
echo "</div>
<div class="line"></div>
<div class="meniu center">";
$viso_puslapiai = 0;
$starto_skaicius = 1;
$ceil = ceil($viso / $puslapiu_skaicius);
$rodomas = ceil($nuo / $puslapiu_skaicius) + 1;
while($viso_puslapiai < $viso) {
if($starto_skaicius == 1 or ($starto_skaicius >= $rodomas - 1 && $starto_skaicius < $rodomas + 3) or $starto_skaicius > $ceil - 1) {
$taskai = 0;
if($nuo == $viso_puslapiai) {
echo "[$starto_skaicius]";
}
else
{
echo "<a href="chat.php?nuo=$viso_puslapiai">[$starto_skaicius]</a>";
}
}
else
{
if($taskai == false) {
echo "...";
$taskai ++;
}
}
$viso_puslapiai = $viso_puslapiai + $puslapiu_skaicius;
$starto_skaicius ++;
}
echo "</div>";
}
echo "<div class="line"></div>
<div class="meniu">
Сообщений в чате: <b>$viso</b>
<br/>
Онлайн чата: ";
$nuskaitymas3 = mysql_query("SELECT * FROM chat_online ORDER BY laikas DESC");
$kiek = mysql_num_rows($nuskaitymas3);
$aa = 1;
while($stulpeliai3 = mysql_fetch_array($nuskaitymas3)) {
$vafetch = mysql_fetch_array(mysql_query("SELECT id,nick,statusas FROM vartotojai WHERE nick='".$stulpeliai3['nick']."'"));
$user = user($vafetch['nick'],$vafetch['statusas']);
if($aa == $kiek) {
echo "<small><a href="index.php?id=info&k=".$vafetch['id']."">$user</a>.</small>";
}
else
{
echo "<small><a href="index.php?id=info&k=".$vafetch['id']."">$user</a>,</small> ";
}
$aa ++;
}
if($dm['statusas'] > 2) {
echo "<br/>
[»] <a href="chat.php?id=clean">Очистить чат</a>";
}
echo "</div>
<div class="block">
<a href="index.php" class="cc">Главная</a>
<br/>
$PAGE_SLOGAN
</div></div>";
}
elseif($id == "write") {
section_online($useris,1,false);
$pop = mysql_fetch_array(mysql_query("SELECT SUM(gyventojai) FROM gyvenvietes WHERE kieno='$useris'"));
$zinute = filter($_POST['zinute']);
if($pop[0] < $WRITE * $SPEED && $useris != $ADMIN) {
$klaida = "Писать в чате доступно со ".$WRITE * $SPEED." ПОП(число населения).";
}
elseif($zinute == false) {
$klaida = "Оставлено пустое поле.";
}
elseif(strlen($zinute) > 1000) {
$klaida = "Сообщение слишком длинное.";
}
if($klaida != false) {
echo "<div class="meniu center">
$klaida
</div>
<div class="block">
<a href="chat.php" class="cc">Назад</a> | <a href="index.php" class="cc">Главная</a>
<br/>
$PAGE_SLOGAN
</div></div>";
}
else
{
$sk = mysql_num_rows(mysql_query("SELECT id FROM chat"));
if($sk >= 200) {
$dt = mysql_fetch_array(mysql_query("SELECT * FROM chat ORDER BY id ASC LIMIT 1"));
mysql_query("DELETE FROM chat WHERE id='".$dt['id']."'");
}
$zinute = str_replace("n","<br/>",$zinute);
mysql_query("INSERT INTO chat(id,nick,zinute,laikas) VALUES('','$useris','$zinute','".date("H:i:s")."')");
header("Location: chat.php");
}
}
elseif($id == "ban") {
if($dm['statusas'] < 3) {
header("Location: index.php");
exit();
}
$k = $_GET['k'];
$nuskaitymas1 = mysql_query("SELECT * FROM vartotojai WHERE nick='".$k."'");
$stulpeliai1 = mysql_fetch_array($nuskaitymas1);
//nick='".$stulpeliai1['nick']."'
$k= $stulpeliai1['id'];
echo "<form action="chat.php?id=ban2&k=$k" method="post">
<div class="meniu center">
Время минутами:
<br/>
<input name="laikas" type="text" maxlength="4"/>
<br/>
Причина(<a href="help.php?id=bbcode">BB CODE</a>):
<br/>
<textarea rows="10" cols="17" name="priezastis"></textarea>
</div>
<div class="meniu center">
<input type="submit" value="ОК"/>
</div>
</form>
<div class="block">
<a href="index.php?id=info&k=$k" class="cc">Назад</a> | <a href="index.php" class="cc">Главная</a>
<br/>
$PAGE_SLOGAN
</div></div>";
}
elseif($id == "ban2") {
if($dm['statusas'] < 3) {
header("Location: index.php");
exit();
}
$k = ereg_replace("[^0-9]","",$_GET['k']);
$laikas = (int) ereg_replace("[^0-9]","",$_POST['laikas']);
$priezastis = filter($_POST['priezastis']);
$query = mysql_query("SELECT * FROM vartotojai WHERE id='$k'");
$fetch = mysql_fetch_array($query);
if($priezastis == false or $laikas == false) {
$klaida = "Оставлено пустое поле.";
}
elseif(mysql_num_rows(mysql_query("SELECT * FROM ban_chat WHERE nick_id='$k'")) > 0) {
$klaida = "Этот игрок уже заблокирован.";
}
elseif(strlen($priezastis) > 1500) {
$klaida = "Текст причины слишком длинный.";
}
elseif($laikas > 9999) {
$klaida = "Время блокировки слишком велико.";
}
elseif(($fetch['statusas'] == 3 or $fetch['statusas'] == 4) && $useris != $ADMIN) {
$klaida = "Администраторов и хранителей порядка блокировать нельзя.";
}
elseif($dm['laikas_iki_ban'] > time() && $useris != $ADMIN) {
$kiek_liko = $dm['laikas_iki_ban'] - time();
$klaida = "Блокировать можно раз в 3 минуты. Вам осталось ждать $kiek_liko с.";
}
if($klaida != false) {
echo "<div class="meniu center">
$klaida
</div>
<div class="block">
<a href="other.php?id=ban&k=$k" class="cc">Назад</a> | <a href="index.php" class="cc">Главная</a>
<br/>
$PAGE_SLOGAN
</div></div>";
}
else
{
$laikas = $laikas * 60 + time();
$priezastis = str_replace("n","<br/>",$priezastis);
mysql_query("INSERT INTO ban_chat (id,nick_id,kas,priezastis,laikas) VALUES('','$k','".$dm['id']."','$priezastis','$laikas')");
mysql_query("UPDATE vartotojai SET ban_chat_time=1 WHERE id='$k'");
mysql_query("INSERT INTO chat(id,nick,zinute,laikas) VALUES('','Модератор','<b>Модератор</b> забанил игрока <b> ".$stulpeliai11['nick']."</b>.','".date("H:i:s")."')");
header("Location: chat.php");
}
}
elseif($id == "clean") {
if($dm['statusas'] < 3) {
header("Location: index.php");
exit();
}
$z = ereg_replace("[^0-9]","",$_GET['z']);
if(ereg_replace("[^0-9]","",$_GET['m']) == false) {
mysql_query("DELETE FROM chat");
mysql_query("INSERT INTO chat(id,nick,zinute,laikas) VALUES('','$useris','<b>$useris</b> очистил чат.','".date("H:i:s")."')");
}
else
{
$query = mysql_query("SELECT * FROM chat WHERE id='$z'");
$fetch = mysql_fetch_array($query);
if(mysql_num_rows($query) != false && $fetch['nick'] != $useris) {
mysql_query("DELETE FROM chat WHERE id='$z'");
mysql_query("INSERT INTO chat(id,nick,zinute,laikas) VALUES('','$useris','<b>$useris</b> удалил сообщение, которое написал <b>".$fetch['nick']."</b>.','".date("H:i:s")."')");
}
}
header("Location: chat.php");
}
else
{
header("Location: index.php");
}
mysql_close($connect);
ob_end_flush();
?>
</body></html>