<?php
require( "inc/conf.inc.php" );
require( "inc/check.php" );
include "includes/header.php";
include "includes/inc_online.php";
include "russian/lang_main.php";
if(!empty($id)) 
{
$q = mysql_query("select id,login,pass from users where id='".$id."';"); 
}

if($dbid!=0)
{
if(!empty($dbid)) 
{
$qdb = mysql_query("select id,login,pass from users where id='".$dbid."';"); 
}
else
{
die ($lang['select_user_false']."</small></p></card></wml>");
}
}
$data = mysql_fetch_array($q);

$id=$data['id'];
$login=$data['login'];

if($dbid!=0)
{
$dbdata = mysql_fetch_array($qdb);
$dblogin=$dbdata['login'];
$dbpass=$dbdata['pass'];
}

mysql_query("update users set last='".time()."',city='0' where id='".$id."';");


switch ($mode) 
{  
case "del":
mysql_query("delete from messagi where kto='".$dbid."' and komu='".$id."' limit 1;");
print $lang['mes_deleted']."<br/>";
break;
case "reply":
mysql_query("DELETE FROM messagi WHERE kto='".$dbid."' and komu='".$id."' limit 1;");
if(!empty($a))
{
if(empty($messaga)) print $lang['mes_empty']."<br/>";
else
{
$predl_que=mysql_query("select komu from messagi where kto='$id' and komu='$dbid';");
$predl_data = mysql_fetch_array($predl_que);
if(!empty($predl_data['komu'])) print $lang['patience']."<br/>";
else
{
print $lang['mes_succes1']." $dblogin ".$lang['mes_succes2']."<br/>";

$messaga=htmlspecialchars(stripslashes(trim($messaga)));
$messaga="<b>".$lang['mes_mes1']." $login:</b><br/>".$messaga."<br/>[<a href=\"./../mes.php?pass=$dbpass&amp;id=$dbid&amp;dbid=$id&amp;mode=reply\">".$lang['mes_reply']."</a>/<a href=\"./../mes.php?pass=$dbpass&amp;id=$dbid&amp;dbid=$id&amp;mode=del\">".$lang['mes_del']."</a>]";
mysql_query("insert into messagi values(0,'$id','$dbid','$messaga');");
}
}
}
else
{
//print $lang['mes_for']." <b>$dblogin</b>:";
//print "</small><br/>";
//print "<input name=\"messaga\" type=\"text\"/><br/><small>";
//print "<anchor>".$lang['ok']."
//<go href=\"mes.php?id=$id&amp;dbid=$dbid&amp;pass=$pass&amp;mode=reply\" method=\"post\">
//<postfield name=\"messaga\" value=\"$(messaga)\"/>
//<postfield name=\"a\" value=\"b\"/>
//</go>
//</anchor><br/>";

echo "<form method=\"post\" action=\"mes.php?id=$id&amp;dbid=$dbid&amp;pass=$pass&amp;mode=reply\">";
print $lang['mes_for']." <b>$dblogin</b>:";
print "<input name=\"messaga\" type=\"text\"/><br/>";
echo "<input value=\"Отправка\" type=\"submit\"/>";
echo "</form>";
}
break;
default:
print $lang['mes_empty']."<br/></small></p></card></wml>";
exit;
break;
}

$ref=mysql_fetch_array(mysql_query("select refer from refers where userid='".$id."';"));
$link=$ref['refer'];
if(empty($link))
print "---<br/>&gt;<anchor>".$lang['back']."<prev/></anchor><br/>";
else
{
$link=preg_replace ("'&'", "&amp;", $link);
print "---<br/>&gt;<a href=\"".$link."\">".$lang['back']."</a><br/>";
}

print "&gt;&gt;<a href=\"game.php?id=$id&amp;pass=$pass\">".$lang['menu']."</a><br/>";
echo "<br/><a href=\"../enter.php?id={$id}&amp;pass={$pass}&amp;ref={$ref}\">Прихожка</a><br/>";
mysql_close();
print "</small></p></card></wml>";
?>