<?php 
include("../includes/site_config.php");
include('../session_handler.inc');
include('../functions.php');
include('../error.php');
include('../message.php');
include('../lib/lib.Functions.php');
include('paginate.php');

$db = new db();
$option_manager = new OptionManager();
$CONST_MAIL = $option_manager->GetValue('mail');

if(isset($_REQUEST['rID'])){
$rID=form_get('rID');
$query="DELETE FROM messages WHERE MD5(msg_id) = '$rID'";
$db->query($query); 
}
?>
<?php include("include/header.php"); ?>
<?php include('approve_menu.php'); ?>
<div class="mainwidth">
<div class="admin-page-header">
<div class="admin-page-heading">&nbsp;&nbsp;<?=APPR_EMAIL?></div>
</div>
<div class="clear"></div>
<div class="admin-page">

  <table width="<?php print("$CONST_TABLE_WIDTH"); ?>" align="<?php print("$CONST_TABLE_ALIGN"); ?>" border="0" cellspacing="<?php print("$CONST_TABLE_CELLSPACING"); ?>" cellpadding="<?php print("$CONST_TABLE_CELLPADDING"); ?>">
  
  <tr><td width="15%"><strong>Sender:</strong></td><td width="15%"><strong>Receiver:</strong></td><td width="15%"><strong>Date:</strong></td><td width="15%"><strong>Subject:</strong></td><td width="30%"><strong>Email:</strong></td><td width="10%">&nbsp;</td></tr>
  <tr><td>&nbsp;</td></tr>
  <? 
  
  $quer="SELECT *, adv_approved FROM messages LEFT JOIN adverts ON (msg_senderid=adv_userid) where msg_title!='Someone is flirting with you.' ORDER BY msg_dateadded DESC";			   

$record_per_page='20';

$pager = new PS_Pagination($link,$quer,$record_per_page,5);
$rs = $pager->paginate();					   
	while($app_Blog=mysql_fetch_object($rs)){	
	$row = $db->get_row("
        					SELECT 	*
							FROM adverts
        					WHERE adv_userid='$app_Blog->msg_receiverid'");		
	$date=strtotime($app_Blog->msg_dateadded);
	$dat=date('m-d-Y', $date);								   
  ?>
  
  <tr><td> <?=$app_Blog->msg_senderhandle?></td>
  <td> <?=$row->adv_username?></td>
  <td><?=$dat?></td>
  <td><?=$app_Blog->msg_title?></td>
  <td><?=$app_Blog->msg_text?></td>
  <td><? if($DEMO==false){?><a href="<?=$_SERVER['PHP_SELF']?>?rID=<?=md5($app_Blog->msg_id)?>">delete</a><? }?></td>
  
  
  
  </tr>
  <tr><td colspan="6"><hr /></td></tr>
  <? }?>
  
  </table>
  <table><div align="right"><? echo $pager->renderNext(); ?></div></table>
        </div></div><div class="admin-page-bottom"></div></div>
<?php include("include/footer.php"); ?>