<?

header("Cache-Control: no-cache");
if ($ver=="wml")header ("Content-type:text/vnd.wap.wml; charset=utf-8");
else header("Content-Type:text/html; charset=UTF-8");

require("inc.php");
$link = connect_db();
list($row, $id, $ps, $fsize1, $fsize2) = check_login($link);     
require("version.php");

if (isset($rm)) $takep2="&amp;rm=$rm&amp;ref=$ref";
else $takep2="&amp;ref=$ref";

if($rm==10) $takep="&amp;pwd=$pwd&amp;ref=$ref";
else if($mod=="privat") $takep="&amp;mod=$mod&amp;ref=$ref";
else $takep="&amp;ref=$ref";

if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"chatmail\" title=\"Ваши письма\">\n";
echo "<p align=\"center\">\n";                      
}else{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";
echo "<title>Ваши письма</title>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo $fsize1;
echo "В целях экономии памяти и уменьшения нагрузки на БД письма хранятся неделю. Просьба сохранять нужную информацию.<br/>\n";
echo $divide;
echo $fsize2;
$r = mysql_query ("select count(readd) as num from zapiski WHERE (idtowhom = '".$id."')and(readd = '0')and(ininc = '1')");
$a = mysql_fetch_array($r);
$inb = $a["num"]; 
$r = mysql_query ("select count(readd) as num from zapiski WHERE (idwho = '".$id."')and(readd = '0')and(insend = '1')");
$a = mysql_fetch_array($r);
$out = $a["num"]; 
mysql_close ($link);
echo $fsize1;
echo "<a href=\"inbox.php?$ses$takep2\">Входящие(".$inb.")</a><br/>\n"; 
echo "<a href=\"outbox.php?$ses$takep2\">Отправленные(".$out.")</a><br/>\n"; 
$who="";
echo "<a href=\"send.php?$ses&amp;towhom=$who$takep2\">Написать письмо</a><br/>\n";    
echo $divide;
echo "<a href=\"friends.php?$ses$takep2\">Список друзей</a><br/>\n";    
echo $divide;
echo "<a href=\"delmsg.php?$ses&amp;go=all&amp;mod=delall&amp;$takep2\">Удалить все письма</a><br/>\n";    
echo $divide;
if (isset($rm)) echo "<a href=\"chat.php?$ses&amp;rm=$rm$takep\">&#8592; В чат</a><br/>";
echo "<a href=\"enter.php?$ses&amp;ref=$ref\">&#8592; Прихожая</a><br/>\n";    
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
?>