<? include("header.php");?>
<div class="menucenter">
<?
if ($_SESSION["username"]=="") {print"<div class='error'>Ошибка! Для доступа к данной странице необходимо зарегистрироваться!</div>"; include("footer.php"); exit;}
$user = $_SESSION["username"];

if ($_GET["p"]==read) {

$id=$_GET["id"];
$id=intval($id);
$substr=substr($user,0,1);
$mailp_count=mysql_query("SELECT COUNT(*) FROM tb_adsmail WHERE tr_$substr NOT LIKE '%$user,%' AND id='$id' AND plan!=members AND play = '0'");
$mailp_row=mysql_fetch_row($mailp_count);

if ($id=="" or $mailp_row[0]==0) {print"<div class='error'>Ошибка! Такого письма не существует!</div>"; include("footer.php"); exit;}

$sqlml="SELECT id, text, title, tr_$substr FROM tb_adsmail WHERE id='$id' and play = '0'";
$resultml=mysql_query($sqlml);
$rowml=mysql_fetch_assoc($resultml);

$rowml[text]=str_replace("\n","<br>",$rowml[text]);

print"<div class='menucenter'>
<div class='name'>$rowml[title]</div>
$rowml[text]<br>
</div>
<fieldset class='ok'><a href=view_mail.php?id=$rowml[id] target=_blank>Подтвердить прочтение письма &gt;&gt;</a></fieldset>";


include("footer.php"); exit;}

print"
<table class='reyt' width='100%' border='0' cellpadding='0' cellspacing='0'>
<thead><tr>
<th style=\"padding:2px;\">Заголовок</th>
<th style=\"border-left:0;padding:2px;\">Оплата</th>
<th style=\"border-left:0;padding:2px;\">Читать &gt;&gt;</th>
</tr></thead>";
$sql="select price from tb_config where item='mail_clic'";
$res=mysql_query($sql);
$mailclic=mysql_result($res,0,0);
$substr=substr($user,0,1);
$sqlm="SELECT tr_$substr, id, title FROM tb_adsmail WHERE tr_$substr NOT LIKE '%$user,%' AND plan!=members AND play = '0'";
$resultm=mysql_query($sqlm);
while($rowm=mysql_fetch_assoc($resultm)){

print"<tr>
<td align=center style=\"border-top:0;padding:2px;\"><b><font color=#ff0000>$rowm[title]</font></b></td>
<td align=center style=\"border-top:0;padding:2px;\"><b><font color=#ff0000>$mailclic</font></b></td>
<td align=center style=\"border-top:0;border-left:0;padding:2px;\"><a href=mail_text.php?p=read&id=$rowm[id]>Читать &gt;&gt;</a></td>
</tr>";

}

?>
</table><br>
<center><a href=advertise.php?adv=mail_ads>» Заказать текстовые письма</a></center>
<?include("footer.php");?>