Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add counter for entries in white/black list #919

Merged
merged 2 commits into from Aug 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
1.2.6-dev
-----------
Improvements
- Add entries counter on white and black list

1.2.5
-----------
Improvements
Expand Down
4 changes: 2 additions & 2 deletions mailscanner/languages/de.php
Expand Up @@ -299,8 +299,8 @@
'to07' => 'An:',
'list07' => 'Liste:',
'action07' => 'Aktion:',
'wl07' => 'Weisse Liste',
'bl07' => 'Schwarze Liste',
'wl07' => 'Weisse Liste - %d Einträge',
'bl07' => 'Schwarze Liste - %d Einträge',
'reset07' => 'Zurücksetzen',
'add07' => 'Hinzufügen',
'delete07' => 'Löschen',
Expand Down
4 changes: 2 additions & 2 deletions mailscanner/languages/en.php
Expand Up @@ -299,8 +299,8 @@
'to07' => 'To:',
'list07' => 'List:',
'action07' => 'Action:',
'wl07' => 'Whitelist',
'bl07' => 'Blacklist',
'wl07' => 'Whitelist - %d entries',
'bl07' => 'Blacklist - %d entries',
'reset07' => 'Reset',
'add07' => 'Add',
'delete07' => 'Delete',
Expand Down
4 changes: 2 additions & 2 deletions mailscanner/languages/fr.php
Expand Up @@ -299,8 +299,8 @@
'to07' => 'À :',
'list07' => 'Liste :',
'action07' => 'Action :',
'wl07' => 'Liste Blanche',
'bl07' => 'Liste Noire',
'wl07' => 'Liste Blanche - %d entrées',
'bl07' => 'Liste Noire - %d entrées',
'reset07' => 'Réinitialiser',
'add07' => 'Ajouter',
'delete07' => 'Supprimer',
Expand Down
4 changes: 2 additions & 2 deletions mailscanner/languages/it.php
Expand Up @@ -299,8 +299,8 @@
'to07' => 'A:',
'list07' => 'Lista:',
'action07' => 'Azione:',
'wl07' => 'Whitelist',
'bl07' => 'Blacklist',
'wl07' => 'Whitelist - %d voci',
'bl07' => 'Blacklist - %d voci',
'reset07' => 'Resetta',
'add07' => 'Aggiungi',
'delete07' => 'Elimina',
Expand Down
4 changes: 2 additions & 2 deletions mailscanner/languages/pt_br.php
Expand Up @@ -299,8 +299,8 @@
'to07' => 'Para:',
'list07' => 'Lista:',
'action07' => 'Ação:',
'wl07' => 'Lista Branca',
'bl07' => 'Lista Negra',
'wl07' => 'Lista Branca - %d entradas',
'bl07' => 'Lista Negra - %d entradas',
'reset07' => 'Limpa',
'add07' => 'Adiciona',
'delete07' => 'Excluir',
Expand Down
65 changes: 38 additions & 27 deletions mailscanner/lists.php
Expand Up @@ -26,7 +26,6 @@
*/

require_once __DIR__ . '/functions.php';

require __DIR__ . '/login.function.php';

html_start(__('wblists07'), 0, false, false);
Expand Down Expand Up @@ -298,27 +297,36 @@
$url_list = '';
}

/**
* @param string $sql
* @param string $list
* @return array
*/
function build_table($sql, $list)
{
$sth = dbquery($sql);
$table_html = '';
$entries = $sth->num_rows;
if ($sth->num_rows > 0) {
echo '<table class="blackwhitelist">' . "\n";
echo ' <tr>' . "\n";
echo ' <th>' . __('from07') . '</th>' . "\n";
echo ' <th>' . __('to07') . '</th>' . "\n";
echo ' <th>' . __('action07') . '</th>' . "\n";
echo ' </tr>' . "\n";
$table_html .= '<table class="blackwhitelist">' . "\n";
$table_html .= ' <tr>' . "\n";
$table_html .= ' <th>' . __('from07') . '</th>' . "\n";
$table_html .= ' <th>' . __('to07') . '</th>' . "\n";
$table_html .= ' <th>' . __('action07') . '</th>' . "\n";
$table_html .= ' </tr>' . "\n";
while ($row = $sth->fetch_row()) {
echo ' <tr>' . "\n";
echo ' <td>' . $row[1] . '</td>' . "\n";
echo ' <td>' . $row[2] . '</td>' . "\n";
echo ' <td><a href="lists.php?token=' . $_SESSION['token'] . '&amp;submit=delete&amp;listid=' . $row[0] . '&amp;to=' . $row[2] . '&amp;list=' . $list . '">' . __('delete07') . '</a><td>' . "\n";
echo ' </tr>' . "\n";
$table_html .= ' <tr>' . "\n";
$table_html .= ' <td>' . $row[1] . '</td>' . "\n";
$table_html .= ' <td>' . $row[2] . '</td>' . "\n";
$table_html .= ' <td><a href="lists.php?token=' . $_SESSION['token'] . '&amp;submit=delete&amp;listid=' . $row[0] . '&amp;to=' . $row[2] . '&amp;list=' . $list . '">' . __('delete07') . '</a><td>' . "\n";
$table_html .= ' </tr>' . "\n";
}
echo '</table>' . "\n";
$table_html .= '</table>' . "\n";
} else {
echo __('noentries07') . "\n";
$table_html = __('noentries07') . "\n";
}

return array('html' => $table_html, 'entry_number' => $entries);
}

echo '
Expand Down Expand Up @@ -401,29 +409,32 @@ function build_table($sql, $list)
<td>' . implode('<br>', $errors) . '</td>
</tr>';
}

$whitelist = build_table(
'SELECT id, from_address, to_address FROM whitelist WHERE ' . $_SESSION['global_list'] . ' ORDER BY from_address',
'w'
);
$blacklist = build_table(
'SELECT id, from_address, to_address FROM blacklist WHERE ' . $_SESSION['global_list'] . ' ORDER BY from_address',
'b'
);
echo '</table>
</form>
<br>
<table cellspacing="1" width="100%" class="mail">
<tr>
<th class="whitelist">' . __('wl07') . '</th>
<th class="blacklist">' . __('bl07') . '</th>
<th class="whitelist">' . sprintf(__('wl07'), $whitelist['entry_number']) . '</th>
<th class="blacklist">' . sprintf(__('bl07'), $whitelist['entry_number']) . '</th>
</tr>
<tr>
<td class="blackwhitelist">
<!-- Whitelist -->';

build_table(
'SELECT id, from_address, to_address FROM whitelist WHERE ' . $_SESSION['global_list'] . ' ORDER BY from_address',
'w'
);
echo '</td>
<td class="blackwhitelist">
<!-- Blacklist -->';
build_table(
'SELECT id, from_address, to_address FROM blacklist WHERE ' . $_SESSION['global_list'] . ' ORDER BY from_address',
'b'
);
echo $whitelist['html'];
echo '</td>';
echo '<td class="blackwhitelist">
<!-- Blacklist -->';
echo $blacklist['html'];
echo '</td>
</tr>
</table>';
Expand Down
2 changes: 1 addition & 1 deletion mailscanner/quarantine.php
Expand Up @@ -190,7 +190,7 @@
AND
BINARY id IN ($msg_ids)";

// Hide high spam/mcp from regular users if enabled
// Hide high spam/mcp from regular users if enabled
if (defined('HIDE_HIGH_SPAM') && HIDE_HIGH_SPAM === true && $_SESSION['user_type'] === 'U') {
$sql .= '
AND
Expand Down
2 changes: 1 addition & 1 deletion upgrade.php
Expand Up @@ -480,7 +480,7 @@ function stringEndsWith($haystack, $needles)
echo pad(' - Fix schema for timestamp field in `maillog` table');
//First query removes ON UPDATE CURRENT_TIMESTAMP and sets a default different from CURRENT_TIMESTAMP
//Second query drops the default
$sql1 = 'ALTER TABLE `maillog` CHANGE `timestamp` `timestamp` TIMESTAMP NOT NULL DEFAULT 0';
$sql1 = 'ALTER TABLE `maillog` CHANGE `timestamp` `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP';
$sql2 = 'ALTER TABLE `maillog` ALTER COLUMN `timestamp` DROP DEFAULT';
executeQuery($sql1);
executeQuery($sql2, true);
Expand Down