Файл: sumerki.mobi/sumerki.mobi/chat.php
Строк: 138
<?php
//////////////////////////////////////////////////////////////
//////////////////////Онлайн игра "сумерки"///////////////////
//////////////////////Основатель: Mc Laren////////////////////
///////////////////Контакты: ICQ - 597687549//////////////////
/////////////////////Пример: Sumerki.Mobi/////////////////////
///////////Если ты это читаешь, значит скрипт слили :D////////
//////////////////////////////////////////////////////////////
define('PROTECTOR', 1);
$headmod = 'chat';//фикс. места
$textl='Cумеречный чат';
include('files/path.php');
include('files/gzips.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');
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="zagolovok"><div class="zagolovok1"> <div class="zagolovok2"><div class="zagolovok_right"></div><div class="zagolovok_left"></div><div class="ch_name">';
echo 'Чат';
echo '</div><div class="clearFix"></div></div></div></div>';
echo '<div class="fon bg"><div class="bg1"><div class="bg2"><div class="bg3"><div class="bg4"><div class="bg5"><div class="bg6"><div class="bg7"><div class="bg8">';
echo "<center><a class= "buuut" href="smile.php?">Смайлы</a> <a class= "buuut" href="chat.php?r=$rand">Обновить</a></center>";
echo '</div></div></div></div></div></div></div></div></div>';
echo '<div class="fon bgray"><div class="bg1"><div class="bg2"><div class="bg3"><div class="bg4"><div class="bg5"><div class="bg6"><div class="bg7"><div class="bg8">';
echo "Написать:";
echo "<form action="chat.php?mod=writes" method="POST">";
echo "<input type="text" name="zin" maxlength="5000"/> <input type="submit" value="Написать" class="buuut">";
echo '</div></div></div></div></div></div></div></div></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"));
if($viso>=100){
mysql_query("DELETE FROM `komentarai` ORDER BY `id` LIMIT 50");
}
$puslap = floor($viso/5);
$times = date("H:i");
$asd = mysql_query("SELECT * FROM komentarai ORDER BY id DESC LIMIT $num,10");
echo"<div align='left'>";
while($dsa = mysql_fetch_array($asd))
{
$time_ban=time()+$_POST[time];
$nickas = strip_tags($dsa['nick']);
$koment = strip_tags($dsa['komentaras']);
$time = strip_tags($dsa['time']);
$koment = smiles($koment);
$req = mysql_query("SELECT `storona`,`prava` FROM `users` WHERE `usr` = '$nickas'");
$pic = mysql_fetch_array($req);
if($pic['prava']==5){$koment='<span class="adm">'.$koment.'</span>';}
if($pic['prava']==2){$koment='<span class="mod">'.$koment.'</span>';}
echo '<div class="fon bgray"><div class="bg1"><div class="bg2"><div class="bg3"><div class="bg4"><div class="bg5"><div class="bg6"><div class="bg7"><div class="bg8">';
echo'<img src="pic/main/'.$pic['storona'].'.png" alt="#"/>';
echo" <b>$nickas</b>";
if($pic['prava']==5){
echo'<font color="ADFF2F"> (Адм)</font>';
}
/*if($pic['prava']==2){
echo'<font color="blue"> (Мод)</font>';
}*/
if($udata[prava]>=2){
echo"<a href="chat.php?mod=del_post&id=$dsa[id]"><img width="12" height="12" alt="del" src="pic/ico/red-delete.png"></a>";
}
echo" <a href="search.php?nick=$nickas&go=go">[i]</a>: <small><font color=#999999> [$time]</font></small><br>$koment<br>
<div align="right"> <a class="buuut" href="chat.php?nick=$nickas&mod=write">Ответить</a></div>";
echo '</div></div></div></div></div></div></div></div></div>';
}
//echo "<hr/>";
if ($_GET[page] > 0)
{
echo "<h1><a href="chat.php?page=$back"><img src="pic/ico/left_ico.png"></a>";
}
elseif ($_GET[page] == 0)
{
echo "<h1><img src="pic/ico/left_ico.png">";
}
echo" ";
if($_GET[page] < $puslap || $_GET[page] == "" || $_GET[page] == 0)
{echo "<a href="chat.php?page=$next"><img src="pic/ico/right_ico.png"></a></h1>";}
else
{echo "<img src="pic/ico/right_ico.png"></h1>";}
break;
case 'write':
echo '<div class="fon bgray"><div class="bg1"><div class="bg2"><div class="bg3"><div class="bg4"><div class="bg5"><div class="bg6"><div class="bg7"><div class="bg8">';
echo"<div class='okrest'><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], " /> ";
}
else
{
echo "<input type="text" name="zin" maxlength="250" size="10"/>";
}
echo " <input type="submit" value="Написать" class="buuut">";
echo '</div></div></div></div></div></div></div></div></div>';
break;
case 'del_post':
if($udata[prava] >= 2)
{
if(empty($_GET[id])){
echo"Не выбран пост!<br/>";
}else{
$asd = mysql_query("SELECT * FROM komentarai WHERE `id`='".mysql_real_escape_string($_GET['id'])."' LIMIT 1");
$avto=mysql_num_rows($asd);
if($avto==0){
echo'Нет такого поста!<br/>';
}else{
mysql_query("DELETE FROM `komentarai` WHERE id='".mysql_real_escape_string($_GET['id'])."' LIMIT 1");
header ('Location: chat.php?');
}
}
}else{
echo "Ошибка!Доступ закрыт!";
}
break;
case 'writes':
if($udata[lvl]<"1"){
echo'В чате можно писать с 1 уровня!';
include($path.'files/down.php');
include($path.'files/meny.php');
exit;
}
$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 = 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 kada 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 != "")
{
mysql_query("INSERT INTO komentarai SET nick = '$log', komentaras = '$msg', kada = '$data', time = '$time'");
$rand = rand(1000,9999);
header ('Location: chat.php?');
}
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);
header ('Location: chat.php?');
}
else
{
$rand = rand(1000,9999);
header ('Location: chat.php?');
}
break;
}
echo '</div>';
include($path.'files/down.php');
include($path.'files/meny.php');
?>