#!/bin/sh
DBPATH=/var/spool/spamassassin/bayes
##############################################################################
# SPAM
##############################################################################
SPAMFOLDER='Spam-lernen'
DOMAINS=/home/mail/*
for domain in $DOMAINS ; do
echo $domain > /tmp/user
INBOXES=$domain/$SPAMFOLDER
for inbox in $INBOXES ; do
if [ ! -f $inbox ]
then
cd $domain
touch $inbox
USER=`cat /tmp/user | grep web | cut -c12-50`
GRUPPE='poponly'
chown $USER:$GRUPPE $inbox
rm /tmp/user
fi
if [ -s $inbox ]
then
cd $domain
USER=`cat /tmp/user | grep web | cut -c12-50`
GRUPPE='poponly'
if [ -f /tmp/spam ]
then
rm /tmp/spam
fi
cat $inbox | grep From: | grep @ | sed 's/From://g' | sed 's/<//g' | sed 's/>//g' | sed 's/"//g' | awk '{print $3}' | grep @ > /tmp/spam
cat $inbox | grep From: | grep @ | sed 's/From://g' | sed 's/<//g' | sed 's/>//g' | sed 's/"//g' |awk '{print $2}' | grep @ >> /tmp/spam
touch /tmp/newlist; for i in $(cat /tmp/spam); do if [ $(grep -c $i /tmp/newlist) -eq 0 ]; then echo $i >> /tmp/newlist; fi; done; mv /tmp/newlist /home/spam/$USER
rm /tmp/spam
rm /tmp/user
fi
#sa-learn --spam --no-sync $inbox
#sa-learn --sync
done
done
if [ -f /tmp/user ]
then
rm /tmp/user
fi
##############################################################################
# HAM
##############################################################################
HAMFOLDER='No-Spam-lernen'
DOMAINS1=/home/mail/*
for domain1 in $DOMAINS1 ; do
echo $domain1 > /tmp/user1
INBOXES1=$domain1/$HAMFOLDER
for inbox1 in $INBOXES1 ; do \
if [ ! -f $inbox1 ]
then
cd $domain1
touch $inbox1
USER1=`cat /tmp/user1 | grep web | cut -c12-50`
GRUPPE1='poponly'
chown $USER1:$GRUPPE1 $inbox1
rm /tmp/user1
fi
if [ -s $inbox1 ]
then
cd $domain1
USER1=`cat /tmp/user1 | grep web | cut -c12-50`
GRUPPE1='poponly'
rm /tmp/user1
if [ -f /tmp/spam1 ]
then
rm /tmp/spam1
fi
cat $inbox1 | grep From: | grep @ | sed 's/From://g' | sed 's/<//g' | sed 's/>//g' | sed 's/"//g' | awk '{print $3}' | grep @ > /tmp/spam1
cat $inbox1 | grep From: | grep @ | sed 's/From://g' | sed 's/<//g' | sed 's/>//g' | sed 's/"//g' |awk '{print $2}' | grep @ >> /tmp/spam1
touch /tmp/newlist1; for i in $(cat /tmp/spam1); do if [ $(grep -c $i /tmp/newlist1) -eq 0 ]; then echo $i >> /tmp/newlist1; fi; done; mv /tmp/newlist1 /home/ham/$USER1
#sa-learn --ham --no-sync $inbox1
#sa-learn --sync
fi
done
done
if [ -f /tmp/user1 ]
then
rm /tmp/user1
fi
<?php
shell_exec('/root/spam_learn.sh');
?>
<?php
$db_user="******";
$db_pass="******";
$db_host="localhost";
$db_datenbank="confixx";
$server_id="********";
#Datenbankverbindung
$db_connect = mysql_connect($db_host,$db_user,$db_pass) or die(mysql_error());
$db_select = mysql_select_db($db_datenbank,$db_connect) or die(mysql_error());
######################################################################
$DOMAINS="/home/spam/";
$handle = opendir($DOMAINS);
while ($user_name = readdir ($handle))
{
if($user_name != "." AND $user_name != "..")
{
$avar = file("$DOMAINS$user_name");
for($x=0;$x<count($avar);$x++)
{
$select ="SELECT * FROM spampref WHERE username='$user_name' AND value='$avar[$x]'";
$ergebnis=mysql_query($select) or die('fehler:'.mysql_error());
$test=mysql_num_rows($ergebnis);
if($test == 0 ) #Wenn kein Eintrag in der Datenbank mit dieser emailadresse vorhanden ist, Adresse in Blacklist eintragen
{
$insert ="INSERT INTO spampref (username,preference,value,server_id) VALUES ('$user_name','blacklist_from','$avar[$x]','$server_id')";
mysql_query($insert) or die(mysql_error());
}
if($test != 0) #Wenn ein Eintrag in der Datenbank mit dieser emailadresse vorhanden ist, testen ob in white oder Blackliste
{
$prefid=mysql_result($ergebnis,0, 'prefid');
$update ="UPDATE spampref SET preference='blacklist_from' WHERE preference='whitelist_from' AND username='$user_name' AND prefid='$prefid' AND value='$avar[$x]'";
mysql_query($update) or die (mysql_error());
}
}#for ENDE ZEILE 30
}#if ZEILE 26
}#while ZEILE 23
?>
<?php
#HAM
$DOMAINS="/home/ham/";
$handle = opendir($DOMAINS);
while ($user_name = readdir ($handle))
{
if($user_name != "." AND $user_name != "..")
{
$avar = file("$DOMAINS$user_name");
for($x=0;$x<count($avar);$x++)
{
$select ="SELECT * FROM spampref WHERE username='$user_name' AND value ='$avar[$x]'";
$ergebnis=mysql_query($select) or die('fehler:'.mysql_error());
$test=mysql_num_rows($ergebnis);
if($test == 0 ) #Wenn kein Eintrag in der Datenbank mit dieser emailadresse vorhanden ist, Adresse in Whitelist eintragen
{
$insert ="INSERT INTO spampref (username,preference,value,server_id) VALUES ('$user_name','whitelist_from','$avar[$x]','$server_id')";
mysql_query($insert) or die(mysql_error());
}
if($test != 0) #Wenn ein Eintrag in der Datenbank mit dieser emailadresse vorhanden ist, update auf Whitelist
{
$prefid=mysql_result($ergebnis,0, 'prefid');
$update ="UPDATE spampref SET preference='whitelist_from' WHERE preference='blacklist_from' AND username='$user_name' AND prefid='$prefid' AND value='$avar[$x]'";
mysql_query($update) or die (mysql_error());
}
}#for ENDE ZEILE 67
}#if ZEILE 63
}#while ZEILE 60
shell_exec('/root/delete.sh');
?>
#!/bin/sh
rm /home/ham/*
rm /home/spam/*
sa-learn --spam --no-sync $inbox
sa-learn --sync
We use essential cookies to make this site work, and optional cookies to enhance your experience.