<?php
/**
* This file is the messages index in quarantine for logged in users.
* It provides a listing of all messages corresponding to:
* - attachment ('B')
* - spam ('S')
* - viruses ('V')
* - bad headers ('H')
* @author Samuel Tran
* @version 04-03-07
* @package MailZu
*
* Copyright (C) 2005 - 2007 MailZu
* License: GPL, see LICENSE
*/
/**
* Include Template class
*/
include_once('lib/Template.class.php');
/**
* Include common output functions
*/
include_once('templates/common.template.php');
/**
* Include quarantine-specific output functions
*/
include_once('templates/summary.template.php');

if (!Auth::is_logged_in()) {
    Auth::print_login_msg();	// Check if user is logged in
}

$_SESSION['sessionNav'] = "Quarantine Summary";
$t = new Template(translate('Quarantine Summary'));

$db = new DBEngine();

$t->printHTMLHeader();
$t->printWelcome();
$t->startMain();

// Break table into 2 columns, put quick links on left side and all other tables on the right
startQuickLinksCol();
showQuickLinks();		// Print out My Quick Links
startDataDisplayCol();

// Print a loading message until database returns...
printMessage(translate('Loading Summary...'));

//// MULTI EMAIL ATTACHMENT ////
// check if email attachement occurred once. Dont run twice.

if ($_SESSION['mult_flag'] != "1")
{
	// flag variable to know that this code was already run
	$_SESSION['mult_flag']='1';
	
	// count number of items in session array
	$mult_array_count = count ($_SESSION['sessionMail']);
	
	// query database to fetch attached emails
	
	$db_connect = @mysql_pconnect($conf['db']['hostSpec'],$conf['db']['dbUser'],$conf['db']['dbPass']) or die ("<html><body><h1>ERROR connecting to server</h1><br></body></html>"."\n"); 
	mysql_select_db ( $conf['db']['dbName'], $db_connect ) or die ("<html><body><h1>ERROR opening db</h1><br></body></html>"."\n");
	
	// concatenate array with attached emails
	
	for ($i = 0; $i < $mult_array_count; $i++)
	{
		$sql_emails_query = mysql_query("SELECT * FROM mailzu_multiple WHERE mult_email='".$_SESSION['sessionMail'][$i]."'");
		while ($row = mysql_fetch_array($sql_emails_query))
		{
			extract($row);
			$_SESSION['sessionMail'][$mult_array_count+$mult_count] = $mult_attach;
			$mult_count++;
		}
	}
}
//// END OF MULTI EMAIL ATTACHMENT CODE

$count_array = $db->get_user_summary($_SESSION['sessionMail']);

showSummary( $count_array ); 

// Hide the message after the table loads.
hideMessage(translate('Loading Summary...'));

endDataDisplayCol();
$t->endMain();
$t->printHTMLFooter();
?>