<body background='i/town/bg.gif'>
<BODY TEXT="#000000">
<?
define('INSIDE', true);
$now=time();
require_once("inc/chat/functions.php");
include("inc/db_connect.php");
include ('inc/inf/player.php');
include ('inc/rooms.php');
echo"
<script LANGUAGE='JavaScript'>
document.ondragstart = test;
//запрет на перетаскивание
document.onselectstart = test;
//запрет на выделение элементов страницы
document.oncontextmenu = test;
//запрет на выведение контекстного меню
function test() {
return false
}
</SCRIPT>";
echo"<script language=JavaScript src=i/show_inf.js></script>
<script language=JavaScript src=i/time.js></script>";
$stat = mysql_fetch_array(mysql_query("select * from players where user='".addslashes($_COOKIE['user'])."' and pass='".addslashes($_COOKIE['pass'])."'"));
mysql_query("SET CHARSET cp1251");
if ($stat['bloked']) echo"<script>top.location='index.php?action=logout'</script>";
if ($stat['t_time']) { header("Location: prison.php"); exit; }
elseif ($stat['k_time']) { header("Location: academy.php"); exit; }
elseif ($stat['v_time']) { header("Location: ambulance.php"); exit; } // Редиректим в больницу
elseif ($stat['w_time']) { header("Location: works.php"); exit; } // Редиректим в ворку
elseif ($stat['r_time']) { header("Location: vault.php"); exit; }
elseif ($stat['o_time']) { header("Location: repair.php"); exit; }
elseif ($stat['v_time']) { header("Location: ambulance.php"); exit; }
elseif ($stat['battle']) { header("Location: battle.php"); exit; }
elseif ($stat['room']!= 444) { header("Location: main.php"); exit; }
else {
include("inc/html_header.php");
echo"
<body background='i/town/bg.gif'>
<table width=100% cellspacing=0 cellpadding=5 border=0>
<tr>
<td align=right valign=top>
<img src='i/refresh.gif' style='CURSOR: Hand' alt='Обновить' onclick='window.location.href=\"kamenj2.php?tmp=\"+Math.random();\"\"'>
<img src='i/back.gif' style='CURSOR: Hand' alt='Вернуться' onclick='window.location.href=\"world4.php?&tmp=\"+Math.random();\"\"'>
</td>
</tr>
</table>";
echo"
<table width=100% cellspacing=0 cellpadding=3 border=0>
<td align=center valign=top>
<font style='FONT-FAMILY: Arial; COLOR=RED; FONT-SIZE: 16pt;'>[b]Почтовое отделение[/b]</font>
</td>
</table>";
$unread = mysql_query("SELECT * FROM `pochta` WHERE `whom` LIKE '".$stat[user]."' AND `read` = 0 " );
$poch = mysql_query("select * from pochta where whom='".$stat[user]."' ORDER by ID DESC");
$send = mysql_query("select * from pochta where user='".$stat[user]."' ORDER by ID DESC");
echo"<body bgcolor=#bcbcbc leftmargin=0 topmargin=0>";
echo"<DIV id=hint1></DIV>";
echo"
<script language=JavaScript src='i/show_inf.js'></script>
<script language=JavaScript src='i/time.js'></script>
";
print"<table width=100% cellspacing=0 cellpadding=5 border=1>
<tr>
<td valign=top width=200 nowrap>
<FIELDSET style='WIDTH: 100%'><legend><font class=player>Папки</font></legend>
<a href=?act=new>Написать </a>
<a href=?act=read>Входящие (".mysql_num_rows($unread)." / ".mysql_num_rows($poch)." )</a>
<a href='?act=write'>Исходяшие</a>
</td>
<td width=100% valign=top><center><FIELDSET style='WIDTH: 98.6%'><legend><font class=player>Письма</font></legend></center>";
if ($_GET['act'] == "read") {
echo "
<table width=100% cellspacing=0 cellpadding=7 border=1 bordercolor=CCCCCC>
<tr><td>[b]№</td><td>[b]Отправитель</td><td width=100%>[b]Тема</td></tr>
";
while ($pochta = mysql_fetch_array($poch) ) {
$i++;
$user=$pochta["user"];
$text=$pochta["subject"];
$id=$pochta["id"];
if ($pochta[read]==0) {$read="[b]";}
else {$read="";}
print "<tr style='CURSOR: Hand' onclick='window.location.href=\"?act=let&id=$id\"'><td>$read$i</td><td nowrap>$read$user</td><td>$read$text </td></tr>";
}
echo "</table>";
}
$mny=$stat["user"];
if ($_GET['act'] == "let") {
$pochas = mysql_query("select * from pochta where id=".$_GET['id']." ORDER by ID DESC");
$let = mysql_fetch_array($pochas);
$text=$let["text"];
$subj=$let["subject"];
$user=$let["user"];
$who=$let["whom"];
echo "[b]От:[/b]"; show_player($user,$stat[img_path]); echo "
[b]Тема:[/b] $subj
[b]Текст:[/b]
$text";
if ($mny=="$who") {
mysql_query("UPDATE `pochta` SET `read` = '1' WHERE `id` = '".$_GET['id']."' ");
}
}
if ($_GET['act']=="write") {
echo "
<table width=100% cellspacing=0 cellpadding=7 border=1 bordercolor=CCCCCC>
<tr><td>[b]№</td><td>[b]Кому</td><td width=100%>[b]Тема</td></tr>
";
while ($pochta = mysql_fetch_array($send) ) {
$i++;
$user=$pochta["whom"];
$text=$pochta["subject"];
$id=$pochta["id"];
if ($pochta[read]==0) {$read="[b]";}
else {$read="";}
print "<tr style='CURSOR: Hand' onclick='window.location.href=\"?act=let&id=$id\"'><td>$read$i</td><td nowrap>$read$user</td><td>$read$text </td></tr>";
}
echo "</table>";
}
if ($_GET['act']=="new") {
?>
<form name=add action=?act=new&do=3 method="POST">Написать письмо:
Тема
<input type=text name=subj class=new size=30>
Кому
<input type=text name=target class=new size=30>
Текст письма
<textarea name=text rows=7 cols=51></textarea>
<input type=submit value="Создать" class=new>
</form>
<?
if ($_GET['do']=="3") {
$text = HtmlSpecialChars($_POST['text']);
$target = HtmlSpecialChars($_POST['target']);
$subj = HtmlSpecialChars($_POST['subj']);
$infs = mysql_query("select * from players where user='".addslashes($target )."'");
if (mysql_num_rows($infs) != 1) {die("Вазап еплан?");}
elseif ($stat["credits"]<10) {echo"У вас недостаточно денег!"; die(); }
else {
$info = mysql_fetch_array($infs);
$cost=1;
$sql ="INSERT INTO pochta(user,whom,text,subject) VALUES ('".$stat[user]."','$target','$text','$subj')";
$result = mysql_query($sql);
$cr=$stat[credits]-$cost;
mysql_query("UPDATE `players` SET `credits` = '$cr' WHERE `user` = '$mny' ");
print "Письмо $subj успешно отправлено персонажу"; show_player($info[user],$stat[img_path]);
insert_msg("С вашего счета было снято [b]\"10 зм.\"[/b]","","","1",$stat['user'],"",$stat['room']);
insert_msg("[b]Получено новое сообщение![/b]","","","1",$info['user'],"",$info['room']);
print "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=?act=new\">";
}
}
}
echo"
</td>
</tr>
</table>
";
}
?>