Beispiel #1
0
    /**
     * Generate HTML for search engine
     * @param $content_type: 'B' (attachment) or 'S' (spam)
     */
    function searchEngine($content_type, $submit_page, $full_search = false)
    {
        global $conf;
        $fields_array = array("f" => translate('From'), "s" => translate('Subject'));
        if (Auth::isMailAdmin() || $conf['app']['allowMailid']) {
            $fields_array = array_merge(array("m" => "Mail ID"), $fields_array);
        }
        if ($full_search) {
            $fields_array = array_merge(array("t" => translate('To')), $fields_array);
        }
        ?>
		<table border=0 width="100%">
		<form action="<?php 
        echo $submit_page;
        ?>
" method="get" name="quarantine">
			<tr><td colspan=2 align="center"><?php 
        echo translate('Search for messages whose:');
        ?>
&nbsp;</td></tr>
			<tr><td align="right">&nbsp;
		<?php 
        $i = 1;
        $array_size = count($fields_array);
        foreach ($fields_array as $k => $name) {
            echo "\t\t\t{$name}: \n";
            echo "\t\t\t<select name='" . $k . "_criterion' class='button'>\n";
            echo "\t\t\t<option value='contains'";
            echo "contains" == CmnFns::getGlobalVar($k . '_criterion', GET) ? " selected='true'>" : ">";
            echo translate('contains') . "</option>\n";
            echo "\t\t\t<option value='not_contain'";
            echo "not_contain" == CmnFns::getGlobalVar($k . '_criterion', GET) ? " selected='true'>" : ">";
            echo translate('doesn\'t contain') . "</option>\n";
            echo "\t\t\t<option value='equals'";
            echo "equals" == CmnFns::getGlobalVar($k . '_criterion', GET) ? " selected='true'>" : ">";
            echo translate('equals') . "</option>\n";
            echo "\t\t\t<option value='not_equal'";
            echo "not_equal" == CmnFns::getGlobalVar($k . '_criterion', GET) ? " selected='true'>" : ">";
            echo translate('doesn\'t equal') . "</option>\n";
            echo "\t\t\t</select>\n";
            echo "\t\t\t<input type='text' name='" . $k . "_string' size='20' value='" . CmnFns::getGlobalVar($k . '_string', GET) . "' />\n";
            echo $i % 2 ? "\t\t\t&nbsp;</td>\n\t\t\t<td align='left'>&nbsp\n" : "\t\t\t&nbsp;</td></tr>\n\t\t\t<tr><td align='right'>&nbsp\n";
            $i++;
        }
        ?>
			<?php 
        echo translate('Content Type');
        ?>
:
			<select name="ctype" class="button">
					<option value="A" <?php 
        echo $content_type == 'A' ? ' selected="true"' : '';
        ?>
>
					<?php 
        echo translate('All');
        ?>
</option>
					<option value="S" <?php 
        echo $content_type == 'S' ? ' selected="true"' : '';
        ?>
>
					<?php 
        echo translate('Spam');
        ?>
</option>
					<option value="B" <?php 
        echo $content_type == 'B' ? ' selected="true"' : '';
        ?>
>
					<?php 
        echo translate('Banned');
        ?>
</option>
			<?php 
        if (Auth::isMailAdmin() || $conf['app']['allowViruses']) {
            ?>
					<option value="V" <?php 
            echo $content_type == 'V' ? ' selected="true"' : '';
            ?>
>
					<?php 
            echo translate('Virus');
            ?>
</option>
			<?php 
        }
        if (Auth::isMailAdmin() || $conf['app']['allowBadHeaders']) {
            ?>
					<option value="H" <?php 
            echo $content_type == 'H' ? ' selected="true"' : '';
            ?>
>
					<?php 
            echo translate('Bad Header');
            ?>
</option>
			<?php 
        }
        echo "</select>";
        $i++;
        echo $i % 2 ? "&nbsp;</td></tr>\n\t\t\t<tr><td colspan='2' align='center'>&nbsp\n" : "&nbsp;</td><td align='left'>&nbsp";
        ?>
			<input type="submit" class="button" name="search_action" value="<?php 
        echo translate('Search');
        ?>
" />
			<?php 
        if (CmnFns::didSearch()) {
            echo "<input type=\"submit\" class=\"button\" name=\"search_action\" value=\"" . translate('Clear search results') . "\" />";
        }
        ?>
			&nbsp;</td></tr>
		</form>
		</table>
		<?php 
    }
/**
* 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>';
    }
}