Example #1
0
startQuickLinksCol();
showQuickLinks();
// Print out My Quick Links
startDataDisplayCol();
$mail_id = CmnFns::get_mail_id();
$content_type = CmnFns::getGlobalVar('ctype', GET);
$recip_email = CmnFns::getGlobalVar('recip_email', GET);
$query_string = CmnFns::querystring_exclude_vars(array('mail_id', 'recip_email'));
$m = new MailEngine($mail_id, $recip_email);
if (!$m->msg_found) {
    CmnFns::do_error_box(translate('Message Unavailable'));
} else {
    echo '<form name="messages_process_form" action="messagesProcessing.php" method="POST">';
    echo '  <input type="hidden" name="mail_id_array[]" value="' . $mail_id . '_' . $recip_email . '">';
    echo '  <input type="hidden" name="query_string" value="' . $query_string . '">';
    printActionButtons(false);
    echo '</form>';
    MsgDisplayOptions(CmnFns::get_mail_id(), $recip_email);
    startMessage();
    MsgDisplayHeaders($m->struct);
    // Give a space before the body displays
    echo '<br>' . "\n";
    if (!$m->msg_error) {
        MsgDisplayBody($m->struct);
    } else {
        echo "<p> {$m->last_error} </p>";
    }
    endMessage();
}
endDataDisplayCol();
$t->endMain();
/**
* Print table listing messages in quarantine
* This function prints a table of all spam/attachment in quarantine
* for the current user.  It also
* provides a way for them to release and delete
* their messages
* @param string $content_type 'B', 'S', ...
* @param mixed $res array of message data
* @param integer $page current page number
* @param string $order previous order field
* @param string $vert previous vertical order
* @param string $numRows total number of rows in table
*/
function showMessagesTable($content_type, $res, $page, $order, $vert, $numRows = 0)
{
    global $link;
    global $conf;
    // grab the display size limit set in config.php
    $sizeLimit = isset($conf['app']['displaySizeLimit']) && is_numeric($conf['app']['displaySizeLimit']) ? $conf['app']['displaySizeLimit'] : 50;
    if ('ASC' == $vert) {
        $new_vert = 'DESC';
        $mouseover_text = translate('Sort by descending order');
    } else {
        $new_vert = 'ASC';
        $mouseover_text = translate('Sort by ascending order');
    }
    // If there are messages in quarantine, draw tables
    if ($res) {
        // $res is only a subset of the message quarantine
        // Its number of rows is $sizeLimit
        $count = $numRows;
        $start_entry = 0;
        $end_entry = count($res);
        $query_string = $_SERVER['QUERY_STRING'];
        $pager_html = $count > $sizeLimit ? CmnFns::genMultiPagesLinks($page, $sizeLimit, $count) : '';
        ?>

		<form name="messages_process_form" action="messagesProcessing.php" method="POST">

		<input type="hidden" name="ctype" value="<?php 
        echo $content_type;
        ?>
">
		<input type="hidden" name="query_string" value="<?php 
        echo $query_string;
        ?>
">

		<?php 
        // Draw 'Release', 'Delete' and 'Delete All' buttons
        printActionButtons(!CmnFns::didSearch() && !("Site Quarantine" == $_SESSION['sessionNav']));
        // Draw 'Select All, Clear All' and multi pages links
        printSelectAndPager($pager_html);
        flush();
        ?>

		<table width="100%" border="0" cellspacing="0" cellpadding="1" align="center">
  			<tr>
    			<td class="tableBorder">

			<!-- Draw 'Showing messages ...' table -->
      			<table width="100%" border="0" cellspacing="1" cellpadding="0">
        			<tr>
				<td colspan="5" class="tableTitle">
				<?php 
        echo translate('Showing messages', array(number_format($page * $sizeLimit + 1), number_format($page * $sizeLimit + $end_entry), $count));
        ?>
				</td>

        			<td class="tableTitle">
            			<div align="right">
              				<?php 
        $link->doLink('javascript: help(\'msg_index\');', '?', '', 'color: #FFFFFF;', translate('Help') . ' - ' . translate('My Quarantine'));
        ?>
            			</div>
        			</td>
        			</tr>
      			</table>

			<!-- Print messages table -->
      			<table width="100%" border="0" cellspacing="1" cellpadding="0">
				<!-- Print table's headers -->
			<tr class="rowHeaders">
				<td width="2%">&nbsp;</td>
				<?php 
        if (count($_SESSION['sessionMail']) > 1 || Auth::isMailAdmin() && ("Site Quarantine" == $_SESSION['sessionNav'] || "Site Pending Requests" == $_SESSION['sessionNav'])) {
            ?>
				<td width="15%" <?php 
            echo "recip.email" == $order ? ' class="reservedCell"' : '';
            ?>
>
					<?php 
            $link->doLink($_SERVER['PHP_SELF'] . '?' . CmnFns::querystring_exclude_vars(array('order', 'vert')) . '&amp;order=recip.email&amp;vert=' . $new_vert, translate('To'), '', '', $mouseover_text);
            ?>
				</td>
				<?php 
        }
        ?>
				<td width="25%" <?php 
        echo "from_addr" == $order ? ' class="reservedCell"' : '';
        ?>
>
 					<?php 
        $link->doLink($_SERVER['PHP_SELF'] . '?' . CmnFns::querystring_exclude_vars(array('order', 'vert')) . '&amp;order=from_addr&amp;vert=' . $new_vert, translate('From'), '', '', $mouseover_text);
        ?>
				</td>
				<td width="33%" <?php 
        echo "msgs.subject" == $order ? ' class="reservedCell"' : '';
        ?>
>
					<?php 
        $link->doLink($_SERVER['PHP_SELF'] . '?' . CmnFns::querystring_exclude_vars(array('order', 'vert')) . '&amp;order=msgs.subject&amp;vert=' . $new_vert, translate('Subject'), '', '', $mouseover_text);
        ?>
				</td>
				<td width="10%" <?php 
        echo "msgs.time_num" == $order ? ' class="reservedCell"' : '';
        ?>
>
					<?php 
        $link->doLink($_SERVER['PHP_SELF'] . '?' . CmnFns::querystring_exclude_vars(array('order', 'vert')) . '&amp;order=msgs.time_num&amp;vert=' . $new_vert, translate('Date'), '', '', $mouseover_text);
        ?>
				</td>
				<td width="5%" <?php 
        echo "spam_level" == $order ? ' class="reservedCell"' : '';
        ?>
>
					<?php 
        $link->doLink($_SERVER['PHP_SELF'] . '?' . CmnFns::querystring_exclude_vars(array('order', 'vert')) . '&amp;order=spam_level&amp;vert=' . $new_vert, translate('Score'), '', '', $mouseover_text);
        ?>
				</td>
				<td width="5%" <?php 
        echo "msgs.content" == $order ? ' class="reservedCell"' : '';
        ?>
>
					<?php 
        $link->doLink($_SERVER['PHP_SELF'] . '?' . CmnFns::querystring_exclude_vars(array('order', 'vert')) . '&amp;order=msgs.content&amp;vert=' . $new_vert, translate('Content Type'), '', '', $mouseover_text);
        ?>
				</td>
					<?php 
        if (Auth::isMailAdmin() && ("Site Quarantine" == $_SESSION['sessionNav'] || "Site Pending Requests" == $_SESSION['sessionNav'])) {
            ?>
				<td width="8%" <?php 
            echo "mail_id" == $order ? ' class="reservedCell"' : '';
            ?>
>
					<?php 
            $link->doLink($_SERVER['PHP_SELF'] . '?' . CmnFns::querystring_exclude_vars(array('order', 'vert')) . '&amp;order=mail_id&amp;vert=' . $new_vert, translate('Mail ID'), '', '', $mouseover_text);
            ?>
				</td>
				<?php 
        }
        ?>
			</tr>

        			<?php 
        // For each line in table, print message fields
        for ($i = $start_entry; $i < $end_entry; $i++) {
            $rs = $res[$i];
            // Make sure that there is a clickable subject
            $subject = $rs['subject'] ? htmlspecialchars($rs['subject']) : '(none)';
            $from = $rs['from_addr'] ? htmlspecialchars($rs['from_addr']) : '(none)';
            if (count($_SESSION['sessionMail']) > 1 || Auth::isMailAdmin() && ("Site Quarantine" == $_SESSION['sessionNav'] || "Site Pending Requests" == $_SESSION['sessionNav'])) {
                $to = $rs['email'] ? htmlspecialchars($rs['email']) : '(none)';
            }
            $class = ($rs['content'] == 'V' ? 'cellVirus' : 'cellColor') . $i % 2;
            echo "<tr class=\"{$class}\" align=\"center\">";
            echo '  <td><input type="checkbox" onclick="ColorRow(this,\'lightyellow\')" 
						name="mail_id_array[]" value="' . $rs['mail_id'] . '_' . $rs['email'] . '"></td>';
            if (count($_SESSION['sessionMail']) > 1 || Auth::isMailAdmin() && ("Site Quarantine" == $_SESSION['sessionNav'] || "Site Pending Requests" == $_SESSION['sessionNav'])) {
                echo '  <td>' . $to . '</td>';
            }
            echo '  <td>' . $from . '</td>';
            echo '  <td>' . ($rs['quar_type'] == 'Q' ? $link->getLink('read_mail.php' . '?mail_id=' . urlencode($rs['mail_id']) . "&amp;recip_email=" . urlencode($rs['email']) . "&amp;{$query_string}", $subject, '', '', translate('View this message'), $rs['rs'] == 'v' || $rs['rs'] == 'p' ? false : true) : "<b>{$subject}</b>") . '</td>';
            echo '  <td>' . CmnFns::formatDateTime($rs['time_num']) . '</td>';
            echo '  <td>' . ($rs['content'] == 'S' ? $rs['spam_level'] : 'N/A') . '</td>';
            switch ($rs['content']) {
                case 'S':
                    $type = translate('Spam');
                    break;
                case 'B':
                    $type = translate('Banned');
                    break;
                case 'V':
                    $type = translate('Virus');
                    break;
                case 'H':
                    $type = translate('Bad Header');
                    break;
            }
            echo ($rs['content'] == 'V' ? '<td class="typeVirus">' : '<td>') . $type . '</td>';
            if (Auth::isMailAdmin() && ("Site Quarantine" == $_SESSION['sessionNav'] || "Site Pending Requests" == $_SESSION['sessionNav'])) {
                echo '  <td>' . $rs['mail_id'] . '</td>';
            }
            echo "</tr>\n";
        }
        ?>
      			</table>

    			</td>
  			</tr>
		</table>
		<?php 
        // Draw 'Select All, Clear All' and multi pages links
        printSelectAndPager($pager_html);
        // Draw 'Release', 'Delete' and 'Delete All' buttons
        printActionButtons(!CmnFns::didSearch() && !("Site Quarantine" == $_SESSION['sessionNav']));
        unset($res);
        ?>
		</form>
	<?php 
    } else {
        echo '<table width="100%" border="0" cellspacing="1" cellpadding="0">';
        echo '<tr><td align="center">' . translate('There are no matching records.') . '</td></tr>';
        echo '</table>';
    }
}