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) {
|
||||
global $spooldir,$compress_spoolfiles;
|
||||
$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 ($compress_spoolfiles) {
|
||||
$file=gzopen("$spooldir/$group-data.dat","r");
|
||||
|
@ -97,13 +108,13 @@ function thread_cache_save($headers,$group) {
|
|||
global $spooldir,$compress_spoolfiles,$logdir,$config_name;
|
||||
$logfile=$logdir.'/newsportal.log';
|
||||
if ($compress_spoolfiles) {
|
||||
$file=gzopen("$spooldir/$group-data.dat","w");
|
||||
$file=gzopen("$spooldir/$group-data.dat-writing","w");
|
||||
$islock = flock($file, LOCK_EX);
|
||||
gzputs($file,serialize($headers));
|
||||
flock($file, LOCK_UN);
|
||||
gzclose($file);
|
||||
} else {
|
||||
$file=fopen("$spooldir/$group-data.dat","w");
|
||||
$file=fopen("$spooldir/$group-data.dat-writing","w");
|
||||
if($file===false) {
|
||||
die('The spool-directory is not writeable. Please change the user '.
|
||||
'permissions to give the webserver write-access to it.');
|
||||
|
@ -112,6 +123,7 @@ function thread_cache_save($headers,$group) {
|
|||
fputs($file,serialize($headers));
|
||||
flock($file, LOCK_UN);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1133,9 +1133,9 @@ function is_multibyte($s) {
|
|||
|
||||
function check_spam($subject,$from,$newsgroups,$ref,$body,$msgid)
|
||||
{
|
||||
global $msgid_generate,$msgid_fqdn;
|
||||
global $msgid_generate,$msgid_fqdn,$spooldir;
|
||||
global $CONFIG;
|
||||
$spamfile = tempnam('./spool', 'spam-');
|
||||
$spamfile = tempnam($spooldir, 'spam-');
|
||||
|
||||
$tmpheader='From: '.$from."\r\n";
|
||||
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);
|
||||
if($makearray == 1) {
|
||||
$thisarticle = preg_split("/\r\n|\n|\r/", trim($msg2));
|
||||
array_pop($thisarticle);
|
||||
return $thisarticle;
|
||||
} else {
|
||||
return trim($msg2);
|
||||
|
|
|
@ -296,6 +296,20 @@ function process_post($filename) {
|
|||
}
|
||||
}
|
||||
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 */
|
||||
$menulist = file($config_dir."menu.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
foreach($menulist as $menu) {
|
||||
|
@ -334,6 +348,9 @@ function process_post($filename) {
|
|||
if($no_org == 1) {
|
||||
fputs($postfilehandle, "Organization: ".$CONFIG['organization']."\r\n");
|
||||
}
|
||||
if($res === 1) {
|
||||
fputs($postfilehandle,"X-Rslight-Original-Group: ".$orig_newsgroups."\r\n");
|
||||
}
|
||||
foreach($message as $line) {
|
||||
if(stripos($line, "Newsgroups: ") === 0) {
|
||||
fputs($postfilehandle, "Newsgroups: ".$newsgroups."\r\n");
|
||||
|
|
Loading…
Reference in New Issue