Просмотр файла techno/chat.php

Размер файла: 10Kb
<?php
define('PROTECTOR', 1);

$head = 'chat';//фикс. места

$textl='Чат';
@include('files/db.php');
@include('files/auth.php');
@include('files/func.php');
@include('files/core.php');
@include('files/head.php');
@include('files/zag.php');

//если бан
$req = mysql_query("SELECT * FROM `ban` WHERE `usr` = '$log' LIMIT 1");
// //////////////////////////
$avto = mysql_num_rows($req);
if ($avto == 1) {
echo"<font color='red'> Ваш персонаж забанен! Доступ в чат закрыт!<br> Осталось: ";
$ban[ban_time]=$ban[ban_time]-time();
if($ban[ban_time]<60){
echo "$ban[ban_time] сек.</font>";

}elseif($ban[ban_time]>60 and $ban[ban_time]<3600){
$ban[ban_time]=round($ban[ban_time]/60);
echo "$ban[ban_time] мин.<br>";

}elseif($ban[ban_time]>3600 and $ban[ban_time]<86400){
$ban[ban_time]=round($ban[ban_time]/3600);
echo "$ban[ban_time] часов.<br>";}
else{
$ban[ban_time]=round($ban[ban_time]/86400);
echo "$ban[ban_time] суток.<br>";
}
echo "Забанил: $ban[admin]</br></font>";
include('files/down.php');exit;}
//конец бана

switch($_GET[mod]){

default:

/////////////
$rand = rand(1000,9999);
///////////////////
echo'<div class="hid" align="left">';
echo "<img src='pic/pers/smile.png' alt='*'/> <a href=\"smile.php?\">Смайлы</a><br/>";
echo "<img src='pic/update.png' alt='*'/> <a href=\"chat.php?r=$rand\">Обновить</a>";
echo "<form action=\"chat.php?mod=writes\" method=\"POST\">";
echo "<textarea name=\"zin\" maxlength=\"5000\"/></textarea><br/><input type=\"submit\" value=\"Написать\" class=\"ibutton\"></div>";
$times = date("H:i:s");
echo "<br/>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `komentarai`"),0); 
$k_page=k_page($k_post,10);
$page=page($k_page);
$start=10*$page-10;
$asd=mysql_query("SELECT * FROM `komentarai` ORDER BY `id` DESC LIMIT $start, 10");
while($dsa=mysql_fetch_array($asd))
{
$nickas = strip_tags($dsa['nick']);
$koment = strip_tags($dsa['komentaras']);
$time = strip_tags($dsa['time']);
$koment = smiles($koment);
$req = mysql_query("SELECT * FROM `users` WHERE `usr` = '$nickas'");
$usdata = mysql_fetch_array($req);
if($usdata[prava]=="5"){$im=adm;$tcolor=ffc22b;}
if($usdata[prava]=="2"){$im=mod;$tcolor=BCEE68;}
if($usdata[prava]=="3"){$im=mod3;$tcolor=a5ff30;}
if($usdata[prava]=="4"){$im=adm;$tcolor=ff1111;}
if($usdata[prava]=="0"){$tcolor=ffffff;}
$sett = mysql_query("SELECT * FROM `set` WHERE `usr` = '$usdata[usr]' LIMIT 1");
$set = mysql_fetch_array($sett);
if($set[vip]=='on'){$vip='[VIP]';}else{$vip='';}
if($usdata[prava]!=="0"){$imgakk = "<img src='/techno/pic/main/status/$usdata[pol]$im.png' alt='*'/> ";}else{$imgakk = '';}
echo "<div class=\"dot\"><font color='#f4d06e'>[$time] </font> $imgakk <b><a href=\"chat.php?nick=$nickas&amp;mod=write\"><font color='$tcolor'>$nickas</font></a></b> <small>$vip</small> ";
$koment=htmlspecialchars_decode($koment);
echo"<a href=\"search.php?nick=$nickas&amp;go=go\"> <img src=\"pic/main/info.gif\" alt=\"i\"> </a> ";
$koment=htmlspecialchars_decode($koment);
 echo"$koment";
if($udata[prava]>=2){
echo"[<a href=\"chat.php?mod=del_post&amp;p=$dsa[id]\">X</a>]";}
echo'<br/></div>';
}
echo "</div><div class=menu align=center>";
if ($k_page>1)str("chat.php?",$k_page,$page); // Вывод страниц 
echo "<br/></div>";
if($udata[prava] >= 6){
echo "<a href=\"chat.php?mod=trinti\">Удалить сообщения</a><br/>";}
break;

case 'del_post':
if($udata[prava] >= 2){
if(empty($_GET[p])){
echo"Не выбран пост!<br/>";
}else{
$_GET[p] = htmlspecialchars(stripslashes(addslashes($_GET['p'])));
$asd = mysql_query("SELECT * FROM komentarai WHERE id='$_GET[p]' LIMIT 1");
$avto=mysql_num_rows($asd);
if($avto==0){
echo'Нет такого поста!<br/>';
}else{
mysql_query("DELETE FROM `komentarai` WHERE id='$_GET[p]' LIMIT 1");
echo'Пост успешно удалён!<br/>';
echo "<a href=\"chat.php?\">Назад</a>";}}}else{
echo "Ошибка!Доступ закрыт!";}
break;

case 'write':
echo"<b>Сообщение</b><br/>";
echo "<form action=\"chat.php?mod=writes\" method=\"POST\">";
if (isset($_GET[nick])){
$nick = htmlspecialchars($_GET[nick]);
echo "<input type=\"text\" name=\"zin\" maxlength=\"250\" value=\"$nick, \" size=\"10\"/><br/>";}else{
echo "<input type=\"text\" name=\"zin\" maxlength=\"250\" size=\"10\"/><br/>";}
echo "<input type=\"submit\" value=\"Ok\" class=\"ibutton\"><br/>";
echo "<a href=\"chat.php?\">« Назад</a><br>";
if (isset($_GET[nick])){
///////////////////////////////////
$set = mysql_query("SELECT * FROM `set` WHERE `usr` = '$nick' LIMIT 1");
$info = mysql_fetch_array($set);
///////////////////////////////////
if ($info[system] == 1){
$text = "<strong>Оповещение:</strong> Игрок $log ответил(а) вам в чате.";
mysql_query("INSERT INTO `msg_r` SET `user_from` = 'Система', `user_to` = '$nick', `time` = '$time', `read` = 1, `mail_msg` = '$text'");
}
}

break;

case 'writes':
if($udata[lvl] <= 2){
echo "Можно писать с 3 уровня.<br><a href=\"chat.php\">« Назад</a><br>";break;}
$msg=$_POST['zin'];
$msg=substr($msg, 0, 512);
$msg=stripslashes(htmlspecialchars($msg));
$msg=str_replace("\r\n","<br />",$msg);
$msg=str_replace("\r","<br />",$msg);
$msg=str_replace("\n","<br />",$msg);
$msg=eregi_replace("((https?|ftp|http)://[[:alnum:]_=/-]+(\\.[[:alnum:]_=/-]+)*(/[[:alnum:]+&._=/%]*(\\?[[:alnum:]?+&_=/%]*)?)?).(ru|org|net|info|org.ua|h2m.ru|wen.ru|com|game-l2.ru з|l2wap.ru з|l2full.ru з|game-l2 .ru з)", "Реклама запрещена", $msg);
$msg=eregi_replace("([[:alnum:]_=/-]+(\\.[[:alnum:]_=/-]+)*(/[[:alnum:]+&._=/%]*(\\?[[:alnum:]?+&_=/%]*)?)?).(ru|org|net|info|org.ua|h2m.ru|wen.ru|com|game-l2.ru з|l2wap.ru з|l2full.ru з|game-l2 .ru з)", "Реклама запрещена", $msg);
$msg = addslashes($msg);
$msg=preg_replace ("|[\r\n]+|si","",$msg);
$a = mysql_num_rows(mysql_query("SELECT komentaras FROM komentarai WHERE komentaras = '$msg'"));
$b = mysql_fetch_array(mysql_query("SELECT * FROM komentarai WHERE nick = '$log' ORDER BY kada DESC LIMIT 1"));
$data_kom = strip_tags($b['kada']);
$data = date("y/m/d H:i:s", strtotime("+20 seconds"));
$data_dbr = date("y/m/d H:i:s");
$time = date("H:i:s");
if($data_dbr >= $data_kom && $msg != "" && $msg!=$b[komentaras] ){
mysql_query("INSERT INTO komentarai SET nick = '$log', komentaras = '$msg', kada = '$data', time = '$time'");
$rand = rand(1000,9999);
header("Location: chat.php");
//start
/////////////
$rand = rand(1000,9999);
///////////////////
echo'<div class="hid" align="left">';
echo "<a href=\"smile.php?\">Смайлы</a><br/>";
echo "<a href=\"chat.php?r=$rand\">Обновить</a>";
echo "<form action=\"chat.php?mod=writes\" method=\"POST\">";
echo "<textarea name=\"zin\" maxlength=\"5000\"/></textarea><br/><input type=\"submit\" value=\"Написать\" class=\"ibutton\"></div>";

if ($_GET[page] == "" || $_GET[page] < 0 || $_GET[page] == "0") {
$_GET[page] = 0;}
$next = $_GET[page] + 1;
$back = $_GET[page] - 1;
$num = $_GET[page] * 10;
if($_GET[page] == "0")
{$i = 1;}
else{$i = ($_GET[page]*10)+1;}
$viso = mysql_num_rows(mysql_query("SELECT komentaras FROM komentarai"));
$puslap = floor($viso/10);
$times = date("H:i");
echo "<br/> ";
$asd = mysql_query("SELECT * FROM komentarai ORDER BY id DESC LIMIT $num,10");
echo"<div align='left'>";
while($dsa = mysql_fetch_array($asd)){
$nickas = strip_tags($dsa['nick']);
$koment = strip_tags($dsa['komentaras']);
$time = strip_tags($dsa['time']);
$koment = smiles($koment);
$req = mysql_query("SELECT * FROM `users` WHERE `usr` = '$nickas'");
$usdata = mysql_fetch_array($req);
if($usdata[prava]=="5"){$im=adm;$tcolor=ffc22b;}
if($usdata[prava]=="2"){$im=mod;$tcolor=BCEE68;}
if($usdata[prava]=="3"){$im=mod3;$tcolor=a5ff30;}
if($usdata[prava]=="4"){$im=adm;$tcolor=ff1111;}
if($usdata[prava]=="0"){$tcolor=ffffff;}
$sett = mysql_query("SELECT * FROM `set` WHERE `usr` = '$usdata[usr]' LIMIT 1");
$set = mysql_fetch_array($sett);
if($set[vip]=='on'){$vip='[VIP]';}else{$vip='';}
if($usdata[prava]!=="0"){$imgakk = "<img src='/techno/pic/main/status/$usdata[pol]$im.png' alt='*'/> ";}else{$imgakk = '';}
echo "<div class=\"dot\"><font color='#f4d06e'>[$time] </font> $imgakk <b><a href=\"chat.php?nick=$nickas&amp;mod=write\"><font color='$tcolor'>$nickas </font></a></b> <small>$vip</small> ";
$koment=htmlspecialchars_decode($koment);
echo"<a href=\"search.php?nick=$nickas&amp;go=go\"><img src=\"pic/main/info.gif\" alt=\"i\"></a>
 $koment ";
if($udata[prava]>=2){
echo"[</font><a href=\"chat.php?mod=del_post&amp;p=$dsa[id]\">X</a>]";}
echo'<br/></div>';}
echo "</div></div>";
if($udata[prava] == 10){
echo "<a href=\"chat.php?mod=trinti\">Удалить сообщения</a><br/>";}
if ($_GET[page] > 0){
echo "</div><div class='menu'><a href=\"chat.php?page=$back\">< Назад |</a>";}elseif($_GET[page] == 0){echo"</div>";}

if($_GET[page] < $puslap || $_GET[page] == "" || $_GET[page] == 0)
{echo "</div><div class='menu'><a href=\"chat.php?page=$next\"> Далее ></a></div>";}}
elseif($msg==$b[komentaras]){$rand = rand(1000,9999);
echo "Ваше сообщение повторяет предыдущее!<br/>";
echo"<a href=\"chat.php?r=$rand\">Продолжить</a>";}
elseif($data_dbr < $data_kom){
$sec = $data_kom-$data_dbr;
$rand = rand(1000,9999);
echo "Защита от Флуда! Подождите $sec секунд<br/>";
echo"<a href=\"chat.php?r=$rand\">Продолжить</a>";}
elseif($msg == ""){
$rand = rand(1000,9999);
echo "Вы не написали сообщение!<br/>";
echo"<a href=\"chat.php?r=$rand\">Продолжить</a>";}else{
$rand = rand(1000,9999);
echo "Ошибка!<br/>";
echo"<a href=\"chat.php?r=$rand\">Продолжить</a>";}
break;

case 'trinti':
if($udata[prava] == 10){
mysql_query("DELETE FROM komentarai");
echo "Все сообщения удалены!";
echo "<br/><a href=\"chat.php?\">Назад</a><br/></div>";}else{
echo "Ошибка!Доступ закрыт!<br/></div>";}
break;
}
echo " <div class='menu' align='center'><a href='http://igru6ek.ru'> <img src='igru6ek.jpg' alt='*'/></a></div>";
@include('files/down.php');
?>