<?php

$file = __FILE__;
include ("inc/inc_common.php");
include ("inc/inc_connect.php");
include ("inc/inc_admincheck.php");
include ("inc/inc_getdate.php");
include ("inc/inc_forumname.php");
$page = "Inbox";
$pagelink = $file;
include("inc/inc_setonline.php");
$title = "Inbox";
include ("inc/inc_head.php");
include ("inc/inc_body.php");
$title = "Inbox";
include ("inc/inc_title.php");

print "</centeR><table border=0 width=\"100%\" cellpadding=1 cellspacing=0><tr><td  width=\"20%\">
<table border=0 cellpadding=1 cellspacing=0><tr><td>
<font face=\"$font\" size=$fontsize><image src=\"images/folder_icon.gif\">&nbsp;<a href=\"index.php\">$name1&nbsp;Home</a>
</td></tr>
<tr><td><image src=\"images/folder_line.gif\">
<font face=\"$font\" size=$fontsize><image src=\"images/open_folder_icon.gif\">&nbsp;Inbox</td></tr>
</table>
</td><td><center>";

include ("inc/inc_navigation.php");
include ("inc/inc_newmailsdisplay.php");
print "</td></tr></table><br><center>";

//end of include files...


if ( $sent == 1 )
{
    print "<font face=$font size=3>Your message to $name was sent.<br><br>";
}

if ( $sent == 2 )
{
    print "<font face=$font size=3>Your message was deleted.<br><br>";
}

if ( $sent == 3 )
{
    print "<font face=$font size=3>All messages deleted.<br><br>";
}

print"<br>
<table border=1 cellpadding=0 cellspacing=0 style=\"border-collapse: collapse\" bordercolor=\"$bordercolor\" width=\"80%\">
<tr><td width=\"100%\" bgcolor=\"$fgcolour\" align=\"center\">
<p align=\"right\">
<a OnClick=\"return confirm('Are you sure you want to delete ALL of your private messages?')\" href=\"inbox_delete_all.php\"><img border=0 src=\"images/delete_private_message.gif\"></a>
<a href=\"inbox_create.php\"><img border=0 src=\"images/new_private_message.gif\"></a></td>
</tr>
</table>
<table border=1 cellspacing=0 width=\"80%\" cellpadding=0 style=\"border-collapse: collapse\" bordercolor=\"$bordercolor\">
<td width=3% align=center>
<img border=0 src=\"images/e-mail_topic.gif\"></td>
<td width=32%>
<font face=$font size=2>&nbsp;<b>Subject</b></font></td>
<td width=20% align=center><font face=$font size=2><b>From</font></td>
<td width=25% align=center><font face=$font size=2><b>Time Received</font></td>
<td width=20% align=center><font face=$font size=2><b>Mailing Options</font></td></tr>";

$counter = 0;
$result = mysql_query( "SELECT * FROM $pmtable WHERE strTo = '$gfcookie[1]' ORDER BY intId DESC" );
$num_rows = mysql_num_rows( $result );

// no records
if ($num_rows == 0)
{
    print "</table><table border=1 cellpadding=0 cellspacing=0 style=\"border-collapse: collapse\" bordercolor=#111111 width=80% align=center><tr><td width=100%><font face=$font size=2><center><br><br>You have no private messages!<br><br><br></td></tr></table>";
}

//Dispay records
while ( $a_row = mysql_fetch_object( $result ) )
{
    if ($counter == 0)
    {
        print "<tr bgcolor=$afgcolour>";
        $counter = 1;
    }
    else
    {
        print "<tr>";
        $counter = 0;
    }

    print "<td width=3% align=center>";
    if ($a_row->intRead == 1)
    {
        print "<img border=0 src=\"images/no_new_posts_icon.gif\"></td>";
    }
    else
    {
        print "<img border=0 src=\"images/e-mail_topic.gif\"></td>";
    }
    print "<td width=32%>
    <font face=$font size=2>&nbsp;<a href=\"inbox_readmessage.php?messageid=$a_row->intId&to=$a_row->strFrom&subject=Re: $a_row->strSubject&id=$a_row->intId\">$a_row->strSubject</a>";

    if ($a_row->intReplied == 1)
    {
        print "<font color=green>&nbsp;(Replied: $a_row->strDateReplied)";
    }

    print "</font></td>
    <td width=20% align=center><font face=$font size=2>";
    if ($a_row->strFrom != "Forum Admin")
    {
        print "<a title=\"See $a_row->strFrom's Profile\" href=\"profile.php?userid=$a_row->strFrom&groupid=$groupid\">";
    }

    print "$a_row->strFrom</a></font></td>
    <td width=25% align=center><font face=$font size=2>";

    if ($a_row->strDateRecieved == "" OR $a_row->strTimeRecived == "00:00:00")
    {
        print "Unknown";
    }
    else
    {
        print "$a_row->strTimeRecieved on the $a_row->strDateRecieved";
    }
    print "</td>
    <td width=20% align=center><font face=$font size=2>
    <a href=\"inbox_delete.php?id=$a_row->intId\">Delete</a>&nbsp;";
    if ($a_row->strFrom != "Forum Admin")
    {
        print "<a href=\"inbox_create.php?to=$a_row->strFrom&subject=Re: $a_row->strSubject&id=$a_row->intId\">Reply</a>&nbsp;";
    }

    if ($a_row->strFrom != "Forum Admin")
    {
        print "<a title=\"Add $a_row->strFrom to your buddy list\" href=\"addbuddy.php?name=$gfcookie[1]&buddyname=$a_row->strFrom&topicid=inbox\">Add Buddy</a>";
    }

    print "</td></tr>
    ";
}
print "</table><br><br>";
include ("inc/inc_footer.php")
?>