Файл: chat.php
Строк: 238
<?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:
function smiles($string){
$dir = opendir ("pic/smiles");
while ($file = readdir ($dir)) {
if (ereg (".gif$", "$file")){
$file2=str_replace(".gif","",$file);
$string=str_replace(":$file2",'<img src="pic/smiles/'.$file.'" alt="">',$string);}}
closedir ($dir);
return $string; }
/////////////
$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 "<input type="text" name="zin" maxlength="5000"/> <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 "<center>-=$times=-</center>";
$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="lime";}
if($usdata[prava]=="2"){$im=mod;$tcolor=BCEE68;}
if($usdata[prava]=="3"){$im=mod3;$tcolor=a5ff30;}
if($usdata[prava]=="4"){$im=adm;$tcolor="lime";}
if($usdata[prava]=="0"){$tcolor=ffffff;}
if($usdata[prava]==""){$tcolor=f00;}
if($nickas=="Система"){$nik="Система ";} else {
$nik="<a href="chat.php?nick=$nickas&mod=write">$nickas </a>";
}
echo "<div class="evento"><b><font color='blue'>[$time] $nik";
echo"<a href="chat.php?nick=$nickas&go=go">(+)</a>:</b>
<font color='lime'>";
$koment=html_entity_decode($koment);
echo"$koment</font>";
if($udata[prava]>=2){
echo"[<a href="chat.php?mod=del_post&p=$dsa[id]">X</a>]";}
echo'<br/></div>';}
echo "</div></div>";
if($udata[prava] >= 5){
echo "<a href="chat.php?mod=trinti">Удалить сообщения</a><br/>";}
if ($_GET[page] > 0){
echo "$div<a href="chat.php?page=$back">< Назад |</a>";}elseif($_GET[page] == 0){echo"</div><div class='menu'>";}
if($_GET[page] < $puslap || $_GET[page] == "" || $_GET[page] == 0)
{echo "<a href="chat.php?page=$next"> Далее ></a></div>";}
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])){
$_GET[nick] = htmlspecialchars($_GET[nick]);
echo "<input type="text" name="zin" maxlength="250" value="$_GET[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 "<img src='img/feather.png' alt=''><a href="chat.php?">« Назад</a><br>";
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("rn","<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 ("|[rn]+|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");
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);
//start
function smiles($string){
$dir = opendir ("pic/smiles");
while ($file = readdir ($dir)) {
if (ereg (".gif$", "$file")){
$file2=str_replace(".gif","",$file);
$string=str_replace(":$file2",'<img src="pic/smiles/'.$file.'" alt="">',$string);}}
closedir ($dir);
return $string; }
/////////////
$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 "<input type="text" name="zin" maxlength="5000"/> <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 "<center>-=$times=-</center> ";
$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="lime";}
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;}
echo "<div class="evento"><b><font color='lime'>[$time] </font><a href="chat.php?nick=$nickas&mod=write">$nickas </a>";
if($usdata[prava]!=="0"){echo"<img src='pic/main/status/$usdata[pol]$im.png' alt='*'/> ";}
echo"<a href="search.php?nick=$nickas&go=go"><img src="pic/main/info.gif" alt="i"></a>:</b>
<font color='lime'> $koment </font>";
if($udata[prava]>=2){
echo"[</font><a href="chat.php?mod=del_post&p=$dsa[id]">X</a>]";}
echo'<br/>';}
echo "</div></div>";
if($udata[prava] ==5){
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><div class='menu'>";}
if($_GET[page] < $puslap || $_GET[page] == "" || $_GET[page] == 0)
{echo "<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] == 5){
mysql_query("DELETE FROM komentarai");
echo "Все сообщения удалены!";
echo "<br/><a href="chat.php?">Назад</a><br/></div>";}else{
echo "Ошибка!Доступ закрыт!<br/></div>";}
break;
}
@include('files/down.php');
?>