Файл: dialog.php
Строк: 125
<?
define('PROTECTOR', 1);
$textl='Почта';
include('files/db.php');
include($path.'files/auth.php');
if ($user_id==0){
header('location: index.php');exit;
}
if(isset($_GET['sms']))
{
$bans = mysql_query("SELECT * FROM `ban` WHERE `usr` = '".$udata['id']."' and `place`='3'");
$banq=mysql_num_rows($bans);
if($banq!=0)
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
else
{
if($udata['lvl']<10)
{
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='Писать личные сообщения доступно с 10 уровня!'
");
header('location: game.php');exit;
}
$msg=$_POST['sms'];
$msg=substr($msg, 0, 1000);
$msg=$_POST['sms'];
$msg = addslashes($msg);
$msg=nl2br($msg);
if($udata['admin']==6)
{
$msg=html_entity_decode($msg);
}
if($msg=='')
{
header('location: mail.php');exit;
}
else
{
$rows=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr1`='".$udata['id']."' and `id`='".$_GET['id']."'"));
$rows21=mysql_num_rows(mysql_query("SELECT * FROM `msg_kont` WHERE `usr1`='".$rows['usr2']."' and `usr2`='".$udata['id']."'"));
if($rows21==0)
{
mysql_query("INSERT INTO `msg_kont` SET
`id`='',
`usr1`='".$rows['usr2']."',
`usr2`='".$udata['id']."',
`read`='1',
`time`='".time()."'
");
}else
{
$rows2=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='".$udata['id']."' and `usr1`='".$rows['usr2']."'"));
mysql_query("UPDATE `msg_kont` SET `read`='1', `time`='".time()."' WHERE `usr2`='".$udata['id']."' and `usr1`='".$rows2['usr1']."'");
}
$rows2=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='".$udata['id']."' and `usr1`='".$rows['usr2']."'"));
mysql_query("INSERT INTO `msg_dialog` SET
`id`='',
`dialog`='".$rows2['id']."',
`vhod`='1',
`time`='".time()."',
`text`='".$msg."',
`usr`='".$rows['usr2']."'
");
mysql_query("INSERT INTO `msg_dialog` SET
`id`='',
`dialog`='".$rows['id']."',
`vhod`='0',
`time`='".time()."',
`text`='".$msg."',
`usr`='".$rows['usr1']."'
");
}
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}}
if(isset($_GET['del']))
{
$rowsf=mysql_num_rows(mysql_query("SELECT * FROM `msg_dialog` WHERE `id`='".$_GET['id']."' and `usr`='".$udata['id']."'"));
if($rowsf==0)
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
else
{
mysql_query("DELETE FROM `msg_dialog` WHERE `id`='".$_GET['id']."'");
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
}
include($path.'files/head.php');
include($path.'files/zag.php');
echo '<table width=100%>
<tr>
<td width=35%>
<a href=game.php><div style="background: #882222; border-radius: 7px 0 0 7px" class="m p bts bbs brs bls" align=center>Главная</div></a>
</td><td>';
echo '<a href=?id='.$_GET['id'].'><div class="line bts brs bls bbs p m" style="border-radius: 0 7px 7px 0">
<font color=#ffffff>Диалог
</font>
</div></a></td></tr></table>';
echo '<div class="bat bts brs bls bbs p">';
$rows=mysql_num_rows(mysql_query("SELECT * FROM `msg_kont` WHERE `usr1`='".$udata['id']."' and `id`='".$_GET['id']."'"));
if($rows==0)
{
echo 'Диалога не существует!';
}
else
{
mysql_query("UPDATE `msg_kont` SET `read`='0' WHERE `id`='".$rows['id']."'");
$rows=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont` WHERE `usr1`='".$udata['id']."' and `id`='".mysql_real_escape_string($_GET['id'])."'"));
mysql_query("UPDATE `msg_kont` SET `read`='0' WHERE `id`='".$rows['id']."'");
$usq = mysql_query("SELECT * FROM users WHERE `id`='".$rows['usr2']."'");
$us = mysql_fetch_array($usq);
if($rows['usr2']==0)
{
$us['usr']='Игровая Система';
$us['klass']=2;
$us['rasa']=2;
$us['id']=2;
}
echo 'Диалог с <a href=info.php?id='.$us['id'].'>'.$us['usr'].'</a><br>';
echo '<a href=dialog.php?id='.$rows['id'].'&page=0>Обновить</a>';
$bans = mysql_query("SELECT * FROM `ban` WHERE `usr` = '".$udata['id']."' and `place`='3'");
$banq=mysql_num_rows($bans);
if($banq!=0)
{
echo '<br>';
echo '<font color=#ff0000>У вас бан почты! Вы не можете тут писать!</font>';
}
else
{
if($udata['lvl']<10)
{
echo '<br>';
echo '<font color=#ff0000>Писать личные сообщения доступно с 10 уровня!</font>';
}
else
{
echo '<form action=dialog.php?sms&id='.$rows['id'].' method=POST>
<center><textarea name=sms rows="3" style="width:90%"></textarea><br>
<input type=submit value=Отправить>
</center>
</form>';
}
}
echo'<hr>';
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 text FROM msg_dialog"));
$puslap = floor($viso/10);
$kontakts=mysql_query("SELECT * FROM `msg_dialog` WHERE `usr`='".$udata['id']."' and `dialog`='".$rows['id']."' ORDER BY `time` DESC LIMIT $num,10");
while($sms=mysql_fetch_array($kontakts))
{
$sms['text'] = $sms['text'];
if($sms['vhod']==1)
{
if($us['admin']>0)
{
$c='#ffff00';
}
else
{
$c='#ffffff';
}
echo '<div align=left style="width: 80%; background: #333333; border-radius: 7px; margin: 2px;">';
echo '<img src=img/main/c'.$us['klass'].'.png> <img src=img/main/r'.$us['rasa'].'.png>
<a href=info.php?id='.$us['id'].'>'.$us['usr'].'</a> <font color=#1faee9>';
$sek=time()-$sms['time'];
$h=round($sek/(60*60));
$m=round(($sek % (60*60))/60);
$s=($sek % 60);
if($h!=0)
{echo $h.'ч ';}
if($m!=0)
{echo $m.'м ';}
if($s!=0)
{echo $s.'с ';}
echo '</font> ';
echo '[<a href=dialog.php?del&id='.$sms['id'].'>x</a>]<br>';
echo'<div style="margin-left: 5px"><font color='.$c.'>'.$sms['text'].'</font></div>';
echo '</div>';
}
else
{
if($udata['admin']>0)
{
$c='#ffff00';
}
else
{
$c='#ffffff';
}
echo '<div align="right"><div align=right style="width: 80%; background: #444444; border-radius: 7px; margin: 2px;">';
echo '<img src=img/main/c'.$udata['klass'].'.png> <img src=img/main/r'.$udata['rasa'].'.png>
<a href=info.php?id='.$udata['id'].'>'.$udata['usr'].'</a> <font color=#1faee9>';
$sek=time()-$sms['time'];
$h=round($sek/(60*60));
$m=round(($sek % (60*60))/60);
$s=($sek % 60);
if($h!=0)
{echo $h.'ч ';}
if($m!=0)
{echo $m.'м ';}
if($s!=0)
{echo $s.'с ';}
echo '</font> ';
echo '[<a href=dialog.php?del&id='.$sms['id'].'>x</a>]<br>';
echo'<div style="margin-right: 5px"><font color='.$c.'>'.$sms['text'].'</font></div>';
echo '</div></div>';
}
}
}
echo '<hr>';
$kol_us=mysql_num_rows(mysql_query("SELECT * FROM `msg_dialog` WHERE `usr`='".$udata['id']."' and `dialog`='".$rows['id']."'"));
$pag=ceil($kol_us/10);
$m_p=$_GET['page']-2;
$mx_p=$_GET['page']+6;
echo '<table width=100%><tr>';
for($k=0; $k<=$pag; $k++)
{
if($k>=$m_p and $k<=$mx_p and $k>0)
{
$i=$k-1;
if($_GET['page']==''){$_GET['page']=0;}
if($_GET['page']!=$i)
{
echo '<td><a href=?id='.$_GET['id'].'&page='.$i.'><div style="background: #000044; padding: 3px; margin-top: 3px;" class="bts bbs brs bls" align=center>'.$k.'</div></a></td>';
}
else
{
echo '<td><a href=?id='.$_GET['id'].'&page='.$i.'><div style="background: #044440; padding: 3px; margin-top: 3px;" class="bts bbs brs bls" align=center>'.$k.'</div></a></td>';
}
}
}
echo'</tr></table>';
echo '</div></div>';
include($path.'files/down.php');
?>