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

Adding ClamAV installation fix #65

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Binary file added clamav-installation-fix/Clamav.php
Binary file not shown.
Binary file added pes-sa-remove/12388423006743.kb
Binary file not shown.
50 changes: 50 additions & 0 deletions pes-sa-remove/checking.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
### Copyright 1999-2024. WebPros International GmbH.

###############################################################################
# This script shows addresses in spamfilter and spamfilter_preference that are not present in Plesk.
# Requirements : >php7.4, GNU coreutils
# Version : 1.0
#########

$mysql_pass = trim(file_get_contents('/etc/psa/.psa.shadow', false));

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

$mysql = new mysqli('localhost', 'admin', $mysql_pass, 'psa');

$get_list_username_spamfilter = mysqli_query($mysql, "SELECT id, username FROM spamfilter");

print ("Start the checking of the spamfilter table \n");

while ($mailboxes = mysqli_fetch_array($get_list_username_spamfilter))
{
[$login, $domain] = explode("@", $mailboxes['username']);
$checking_domain = mysqli_query($mysql, "select id, name from domains where name = '$domain'");
if (mysqli_num_rows($checking_domain) == 0)
{
print ("========================================================================================================== \n");
print ("domain '$domain' does not exist in Plesk \n");
print ("========================================================================================================== \n");
}
else {
$sql = "select
mail.mail_name,
mail.dom_id
from mail
left join domains
on mail.dom_id = domains.id
where
mail.mail_name = '$login'
and domains.name = '$domain'";
$checking_user = mysqli_query($mysql, $sql);
if (mysqli_num_rows($checking_user) == 0)
{
print ("========================================================================================================== \n");
print ("mailbox {$login}@{$domain} does not exist in Plesk, please recreate it via the Plesk UI \n");
print ("========================================================================================================== \n");
}
}
}

print ("The checking is complete \n");
57 changes: 57 additions & 0 deletions pes-sa-remove/checking_and_fixing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
### Copyright 1999-2024. WebPros International GmbH.

###############################################################################
# This script removes addresses from spamfilter and spamfilter_preference that are not present in Plesk.
# Requirements : >php7.4, GNU coreutils
# Version : 1.0
#########
$mysql_pass = trim(file_get_contents('/etc/psa/.psa.shadow', false));

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

$mysql = new mysqli('localhost', 'admin', $mysql_pass, 'psa');

$get_list_username_spamfilter = mysqli_query($mysql, "SELECT id, username FROM spamfilter");

print "Start the checking and fixing of the spamfilter table \n";

while ($mailboxes = mysqli_fetch_array($get_list_username_spamfilter))
{
if ($mailboxes['username'] == "*@*") continue;
[$login, $domain] = explode("@", $mailboxes['username']);

$checking_domain = mysqli_query($mysql, "select id, name from domains where name = '$domain'");
if (mysqli_num_rows($checking_domain) == 0)
{
print ("========================================================================================================== \n");
print ("Domain '$domain' does not exist in Plesk. The rows about the mailbox {$login}@{$domain} will be removed from the SpamAssassin tables \n");
$removing_pref = mysqli_query($mysql, "delete from spamfilter_preferences where spamfilter_id = $mailboxes[id]");
$removing_filter = mysqli_query($mysql, "delete from spamfilter where id = $mailboxes[id]");
print ("The rows related to mailbox {$login}@{$domain} have been removed\n");
print ("========================================================================================================== \n");
}
else {
$sql = "select
mail.mail_name,
mail.dom_id
from mail
left join domains
on mail.dom_id = domains.id
where
mail.mail_name = '$login'
and domains.name = '$domain'";
$checking_user = mysqli_query($mysql, $sql);
if (mysqli_num_rows($checking_user) == 0)
{
print ("========================================================================================================== \n");
print ("Mailbox {$login}@{$domain} does not exist in Plesk. The rows about this mailbox will be removed from the SpamAssassin tables \n");
$removing_pref = mysqli_query($mysql, "delete from spamfilter_preferences where spamfilter_id = $mailboxes[id]");
$removing_filter = mysqli_query($mysql, "delete from spamfilter where id = $mailboxes[id]");
print ("The rows related to mailbox {$login}@{$domain} have been removed\n");
print ("========================================================================================================== \n");
}
}
}

print ("All rows related to not existing domains or mailboxes have been removed \n");