Файл: sumerki.mobi/sumerki.mobi/md-chat.php
Строк: 161
<?php
//////////////////////////////////////////////////////////////
//////////////////////Онлайн игра "Сумерки"///////////////////
//////////////////////Основатель: Mc Laren////////////////////
///////////////////Контакты: ICQ - 597687549//////////////////
/////////////////////Пример: Sumerki.Mobi/////////////////////
///////////Если ты это читаешь, значит скрипт слили :D////////
//////////////////////////////////////////////////////////////
define('PROTECTOR', 1);
?>
<script language="javascript">
function SendComment(e) {
e = e || window.event;
if (e.keyCode == 13 && e.ctrlKey) {
document.getElementById('comment_form').submit();
};
};
</script>
<?php
$headmod = 'chat';//фикс. места
$textl='Чат администрации';
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:
if($udata[prava]!=2 and $udata[prava]!=5){
echo'Доступ закрыт!';
include($path.'files/down.php');
include($path.'files/meny.php');
exit;
}
function AddBB($var) {
$search = array(
'/[b](.*?)[/b]/is',
'/[i](.*?)[/i]/is',
'/[red](.*?)[/red]/is',
'/[blue](.*?)[/blue]/is',
'/[yellow](.*?)[/yellow]/is',
'/[lime](.*?)[/lime]/is',
'/[u](.*?)[/u]/is',
'/[img](.*?)[/img]/is',
'/[h1](.*?)[/h1]/is',
'/[right](.*?)[/right]/is',
'/[center](.*?)[/center]/is',
'/[url](.*?)[/url]/is',
'/[url=(.*?)](.*?)[/url]/is'
);
$replace = array(
'<strong>$1</strong>',
'<em>$1</em>',
'<font color="red">$1</font>',
'<font color="#0D00FF">$1</font>',
'<font color="FFFF00">$1</font>',
'<font color="lime">$1</font>',
'<u>$1</u>',
'<img src="$1"/></img>',
'<h1>$1</h1>',
'<p align="right">$1</p>',
'<p align="center">$1</p>',
'<a href="$1">$1</a>',
'<a href="$1">$2</a>'
);
$var = preg_replace ($search, $replace, $var);
return $var;
}
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 href="smile.php?">Смайлы</a> <a href="md-chat.php?r=$rand">Обновить</a> <a href="bb.php">Теги</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="md-chat.php?mod=writes" method="POST" id="comment_form">";
echo '<textarea name="zin" maxlength="5000" style="margin: 2px; width: 354px; height: 52px;" onkeydown="SendComment(event)" ></textarea></br>';
echo "<input type="submit" value="Написать" class="buuut"><br>";
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 mdchat"));
if($viso>=100){
mysql_query("DELETE FROM `mdchat` ORDER BY `id` LIMIT 50");
}
$puslap = floor($viso/5);
$times = date("H:i");
$asd = mysql_query("SELECT * FROM mdchat 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(AddBB($koment));
$req = mysql_query("SELECT `storona`,`prava` FROM `users` WHERE `usr` = '$nickas'");
$pic = mysql_fetch_array($req);
if($pic['prava']==5){$koment='<font color="33FF66">'.$koment.'</font>';}
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" <a href="md-chat.php?nick=$nickas&mod=write">$nickas</a>";
if($pic['prava']==5){
echo'<font color="#FF7676"> [Адм]</font>';
}
if($pic['prava']==2){
echo'<font color="yellow"> [Мод]</font>';
}
echo"<a href="search.php?nick=$nickas&go=go"></a>: <br>$koment <br><small>[$time]</small>";
if($udata[prava]>=2){
echo"<a href="md-chat.php?mod=del_post&p=$dsa[id]"><img width='12' height='12' src='pic/ico/red-delete.png'></a>";
}
echo '</div></div></div></div></div></div></div></div></div>';
}
$ress = mysql_query("SELECT COUNT(id) FROM mdchat");
$rows = mysql_fetch_row($res);
if ($_GET[page] > 0)
{
echo "<h1><a href="md-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="md-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 'del_post':
if($udata[prava] >= 2)
{
if(empty($_GET[p])){
echo"<div class="b-panel gray-panel">Невыбран пост!</div>";
}else{
$asd = mysql_query("SELECT * FROM mdchat WHERE id='".mysql_real_escape_string($_GET['p'])."' LIMIT 1");
$avto=mysql_num_rows($asd);
if($avto==0){
echo'<div class="b-panel gray-panel">Нет такого поста!</div>';
}else{
mysql_query("DELETE FROM `mdchat` WHERE id='".mysql_real_escape_string($_GET['p'])."' LIMIT 1");
header('Location: md-chat.php?');
}
}
}else{
echo "Ошибка!Доступ закрыт!";
}
break;
case 'write':
echo"<b>Сообщение</b><br/>";
echo "<form action="md-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/>";
break;
case 'writes':
$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 mdchat WHERE komentaras = '$msg'"));
$b = mysql_fetch_array(mysql_query("SELECT kada FROM mdchat 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 d.m.y");
if($data_dbr >= $data_kom && $msg != "")
{
mysql_query("INSERT INTO mdchat SET nick = '$log', komentaras = '$msg', kada = '$data', time = '$time'");
$rand = rand(1000,9999);
header('Location: md-chat.php?');
}
elseif($data_dbr < $data_kom)
{
$sec = $data_kom-$data_dbr;
$rand = rand(1000,9999);
echo "Защита от Флуда! Подождите $sec секунд<br/>";
echo"<a href="md-chat.php?r=$rand">Продолжить</a>";
}
elseif($msg == "")
{
$rand = rand(1000,9999);
header('Location: md-chat.php?');
}
else
{
$rand = rand(1000,9999);
echo "Ошибка!<br/>";
echo"<a href="md-chat.php?r=$rand">Продолжить</a>";
}
break;
}
include($path.'files/down.php');
include($path.'files/meny.php');
?>