Enable spam checking incoming (peer/newsreader) articles
This commit is contained in:
parent
7d6b551cb4
commit
0cca82eb1a
@ -69,6 +69,17 @@ function thread_pageselect($group,$article_count,$first) {
|
|||||||
function thread_cache_load($group) {
|
function thread_cache_load($group) {
|
||||||
global $spooldir,$compress_spoolfiles;
|
global $spooldir,$compress_spoolfiles;
|
||||||
$filename=$spooldir."/".$group."-data.dat";
|
$filename=$spooldir."/".$group."-data.dat";
|
||||||
|
$now = time();
|
||||||
|
while(file_exists($filename."-writing")) {
|
||||||
|
$waiting = 1;
|
||||||
|
if(time() > $now + 30) {
|
||||||
|
unlink($filename."-writing");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($waiting == 1) {
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
if (!file_exists($filename)) return false;
|
if (!file_exists($filename)) return false;
|
||||||
if ($compress_spoolfiles) {
|
if ($compress_spoolfiles) {
|
||||||
$file=gzopen("$spooldir/$group-data.dat","r");
|
$file=gzopen("$spooldir/$group-data.dat","r");
|
||||||
@ -97,13 +108,13 @@ function thread_cache_save($headers,$group) {
|
|||||||
global $spooldir,$compress_spoolfiles,$logdir,$config_name;
|
global $spooldir,$compress_spoolfiles,$logdir,$config_name;
|
||||||
$logfile=$logdir.'/newsportal.log';
|
$logfile=$logdir.'/newsportal.log';
|
||||||
if ($compress_spoolfiles) {
|
if ($compress_spoolfiles) {
|
||||||
$file=gzopen("$spooldir/$group-data.dat","w");
|
$file=gzopen("$spooldir/$group-data.dat-writing","w");
|
||||||
$islock = flock($file, LOCK_EX);
|
$islock = flock($file, LOCK_EX);
|
||||||
gzputs($file,serialize($headers));
|
gzputs($file,serialize($headers));
|
||||||
flock($file, LOCK_UN);
|
flock($file, LOCK_UN);
|
||||||
gzclose($file);
|
gzclose($file);
|
||||||
} else {
|
} else {
|
||||||
$file=fopen("$spooldir/$group-data.dat","w");
|
$file=fopen("$spooldir/$group-data.dat-writing","w");
|
||||||
if($file===false) {
|
if($file===false) {
|
||||||
die('The spool-directory is not writeable. Please change the user '.
|
die('The spool-directory is not writeable. Please change the user '.
|
||||||
'permissions to give the webserver write-access to it.');
|
'permissions to give the webserver write-access to it.');
|
||||||
@ -112,6 +123,7 @@ function thread_cache_save($headers,$group) {
|
|||||||
fputs($file,serialize($headers));
|
fputs($file,serialize($headers));
|
||||||
flock($file, LOCK_UN);
|
flock($file, LOCK_UN);
|
||||||
fclose($file);
|
fclose($file);
|
||||||
|
rename("$spooldir/$group-data.dat-writing", "$spooldir/$group-data.dat");
|
||||||
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Locking status: ".$islock." for ".$group, FILE_APPEND);
|
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Locking status: ".$islock." for ".$group, FILE_APPEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1133,9 +1133,9 @@ function is_multibyte($s) {
|
|||||||
|
|
||||||
function check_spam($subject,$from,$newsgroups,$ref,$body,$msgid)
|
function check_spam($subject,$from,$newsgroups,$ref,$body,$msgid)
|
||||||
{
|
{
|
||||||
global $msgid_generate,$msgid_fqdn;
|
global $msgid_generate,$msgid_fqdn,$spooldir;
|
||||||
global $CONFIG;
|
global $CONFIG;
|
||||||
$spamfile = tempnam('./spool', 'spam-');
|
$spamfile = tempnam($spooldir, 'spam-');
|
||||||
|
|
||||||
$tmpheader='From: '.$from."\r\n";
|
$tmpheader='From: '.$from."\r\n";
|
||||||
if(strpos($from, $CONFIG['anonusername'])) {
|
if(strpos($from, $CONFIG['anonusername'])) {
|
||||||
@ -1345,6 +1345,7 @@ function np_get_db_article($article, $group, $makearray=1, $dbh=null) {
|
|||||||
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." DEBUG: fetched: ".$article." from ".$group, FILE_APPEND);
|
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." DEBUG: fetched: ".$article." from ".$group, FILE_APPEND);
|
||||||
if($makearray == 1) {
|
if($makearray == 1) {
|
||||||
$thisarticle = preg_split("/\r\n|\n|\r/", trim($msg2));
|
$thisarticle = preg_split("/\r\n|\n|\r/", trim($msg2));
|
||||||
|
array_pop($thisarticle);
|
||||||
return $thisarticle;
|
return $thisarticle;
|
||||||
} else {
|
} else {
|
||||||
return trim($msg2);
|
return trim($msg2);
|
||||||
|
@ -296,6 +296,20 @@ function process_post($filename) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
rewind($message);
|
rewind($message);
|
||||||
|
/*
|
||||||
|
* SPAM CHECK
|
||||||
|
*/
|
||||||
|
if (isset($CONFIG['spamassassin']) && ($CONFIG['spamassassin'] == true)) {
|
||||||
|
$spam_result_array = check_spam($subject[1],$from[1],$newsgroups,$references,$body,$msgid);
|
||||||
|
$res = $spam_result_array['res'];
|
||||||
|
$spamresult = $spam_result_array['spamresult'];
|
||||||
|
$spamcheckerversion = $spam_result_array['spamcheckerversion'];
|
||||||
|
$spamlevel = $spam_result_array['spamlevel'];
|
||||||
|
}
|
||||||
|
if($res === 1) {
|
||||||
|
$orig_newsgroups = $newsgroups;
|
||||||
|
$newsgroups=$CONFIG['spamgroup'];
|
||||||
|
}
|
||||||
/* Find section for posting */
|
/* Find section for posting */
|
||||||
$menulist = file($config_dir."menu.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
$menulist = file($config_dir."menu.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
foreach($menulist as $menu) {
|
foreach($menulist as $menu) {
|
||||||
@ -334,6 +348,9 @@ function process_post($filename) {
|
|||||||
if($no_org == 1) {
|
if($no_org == 1) {
|
||||||
fputs($postfilehandle, "Organization: ".$CONFIG['organization']."\r\n");
|
fputs($postfilehandle, "Organization: ".$CONFIG['organization']."\r\n");
|
||||||
}
|
}
|
||||||
|
if($res === 1) {
|
||||||
|
fputs($postfilehandle,"X-Rslight-Original-Group: ".$orig_newsgroups."\r\n");
|
||||||
|
}
|
||||||
foreach($message as $line) {
|
foreach($message as $line) {
|
||||||
if(stripos($line, "Newsgroups: ") === 0) {
|
if(stripos($line, "Newsgroups: ") === 0) {
|
||||||
fputs($postfilehandle, "Newsgroups: ".$newsgroups."\r\n");
|
fputs($postfilehandle, "Newsgroups: ".$newsgroups."\r\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user