<?
require "include/bittorrent.php";
dbconn();
stdhead();


$res=mysql_query("SELECT * FROM messages WHERE sender = $CURUSER[id] AND unread = 'yes' AND mass != 'yes' ORDER BY added DESC");

$number = mysql_num_rows($res);




$nr = 1;

begin_frame('Nachrichtenüberwachung', FALSE, "100%;");
?>
<form method="post" action="msgueber.php">
<?
begin_table(TRUE);

?>
<colgroup>
  <col width="10">
  <col width="15%">
  <col width="25%">
  <col width="20%">
  <col width="20%">
  <col width="10">
</colgroup>
<tr>
 <td class="tablecat"><div align="center"> Nr.</div></td>
 <td class="tablecat"><div align="center"> Empfänger</div></td>
 <td class="tablecat"><div align="center"> Betreff</div></td>
 <td class="tablecat"><div align="center"> Abgeschickt</div></td>
 <td class="tablecat"><div align="center"> Empfänger zuletzt aktiv</div></td>
 <td class="tablecat"><div align="center"> Ungelesen</div></td>
 <td class="tablecat"><div align="center"> Löschen</div></td>

</tr>
<tr>
<?
if ($number > 50){
echo "Du hast zu viele Nachrichten verschickt, die ungelesen sind!";
}
else{
	while ($msg = mysql_fetch_array($res)){
	$res2=mysql_query("SELECT username, last_access FROM users WHERE id = $msg[receiver]");
       $name = mysql_fetch_array($res2);
?>

<tr>
 <td class="tablea"><div align="center"> <?=$nr?></div></td>
 <td class="tableb"><div align="center"><a href="userdetails.php?id=<?=$msg[receiver]?>"><?=$name[username]?></a></div> </td>
 <td class="tablea"><div align="center"><a href="messages.php?folder=-2&action=read&id=<?=$msg[id]?>"><?=$msg[subject]?></a></div></td>
 <td class="tableb"><div align="center"><?=$msg[added]?></div> </td>
 <td class="tablea"><div align="center"><?=$name[last_access]?></div></td>
 <td class="tableb"> <font color=red><b><div align="center">JA</b></font></div></td>
<td class="tableb"> <font color=red><b><div align="center"><a href="killpm.php?id=<?=$msg[id]?>">Löschen</a></b></font></div></td>
</tr>

<?





$nr = $nr+1;


	}
}
end_table();
?>
<!--<input type="submit" name="kill" value="Löschen">-->

</form>
<?
end_frame();
stdfoot();
?>