diff --git a/Rocksolid_Light/rocksolid/lib/post.inc.php b/Rocksolid_Light/rocksolid/lib/post.inc.php index 435cf92..60d4709 100644 --- a/Rocksolid_Light/rocksolid/lib/post.inc.php +++ b/Rocksolid_Light/rocksolid/lib/post.inc.php @@ -443,13 +443,12 @@ function message_post($subject, $from, $newsgroups, $ref, $body, $encryptthis = /* * SPAM CHECK */ - if ((isset($CONFIG['spamassassin']) && ($CONFIG['spamassassin'] == true))) { + if (isset($CONFIG['spamassassin']) && ($CONFIG['spamassassin'] == true)) { $spam_result_array = check_spam($subject, $from, $newsgroups, $ref, $body, $msgid); $res = $spam_result_array['res']; $spamresult = $spam_result_array['spamresult']; $spamcheckerversion = $spam_result_array['spamcheckerversion']; $spamlevel = $spam_result_array['spamlevel']; - $spam_fail = $spam_result_array['spam_fail']; } if ($do_attach) { move_uploaded_file($_FILES["photo"]["tmp_name"], $attachment_temp_dir . $_FILES["photo"]["name"]); @@ -461,9 +460,8 @@ function message_post($subject, $from, $newsgroups, $ref, $body, $encryptthis = if (! is_dir($spooldir . '/upload/' . $uploadname)) { mkdir($spooldir . '/upload/' . $uploadname); } - if (! file_exists($spooldir . '/upload/' . $uploadname . '/' . $_FILES["photo"]["name"])) { - copy($attachment_temp_dir . $_FILES["photo"]["name"], $spooldir . '/upload/' . $uploadname . '/' . $_FILES["photo"]["name"]); - } + // Copy attachment to user's upload directory + copy($attachment_temp_dir . $_FILES["photo"]["name"], $spooldir . '/upload/' . $uploadname . '/' . $_FILES["photo"]["name"]); } $ns = nntp_open($server, $port); if ($ns != false) { @@ -484,8 +482,9 @@ function message_post($subject, $from, $newsgroups, $ref, $body, $encryptthis = } // X-Rslight headers + if ((isset($CONFIG['spamassassin']) && ($CONFIG['spamassassin'] == true))) { - if (isset($res) && $spam_fail == 0) { + if ($res === 1) { fputs($ns, $spamcheckerversion . "\r\n"); if (strpos($spamlevel, '*') !== false) fputs($ns, $spamlevel . "\r\n"); @@ -495,6 +494,7 @@ function message_post($subject, $from, $newsgroups, $ref, $body, $encryptthis = } } } + fputs($ns, 'From: ' . $from . "\r\n"); if ($followupto !== null) { fputs($ns, 'Followup-To: ' . $followupto . "\r\n"); diff --git a/Rocksolid_Light/rocksolid/newsportal.php b/Rocksolid_Light/rocksolid/newsportal.php index 4b4611d..6724c8a 100644 --- a/Rocksolid_Light/rocksolid/newsportal.php +++ b/Rocksolid_Light/rocksolid/newsportal.php @@ -1311,38 +1311,30 @@ function check_spam($subject, $from, $newsgroups, $ref, $body, $msgid) global $CONFIG; $logfile = $logdir . '/spam.log'; $spamfile = tempnam($spooldir, 'spam-'); - - $tmpheader = 'From: ' . $from . "\r\n"; - if (strpos($from, $CONFIG['anonusername'])) { - $tmpheader .= "Anonymous: TRUE\r\n"; - } - $tmpheader .= 'Message-ID: ' . $msgid . "\r\n"; - $tmpheader .= 'Subject: ' . encode_subject($subject) . "\r\n\r\n"; - if ($spamFileHandle = fopen($spamfile, 'w')) { - fwrite($spamFileHandle, $tmpheader); - fwrite($spamFileHandle, $body); - $spamcommand = $CONFIG['spamc'] . ' -E < ' . $spamfile; - ob_start(); - $spamresult = passthru($spamcommand, $res); - $spamresult = ob_get_contents(); - ob_end_clean(); - $spam_fail = 1; - foreach (explode(PHP_EOL, $spamresult) as $line) { - $line = str_replace(array( - "\n\r", - "\n", - "\r" - ), '', $line); - if (strpos($line, 'X-Spam-Checker-Version:') !== FALSE) { - $spamcheckerversion = $line; - $spam_fail = 0; - } - if (strpos($line, 'X-Spam-Level:') !== FALSE) { - $spamlevel = $line; - } + file_put_contents($spamfile, $body); + $spamcommand = $CONFIG['spamc'] . ' -E < ' . $spamfile; + ob_start(); + passthru($spamcommand, $res); + $spamresult = ob_get_contents(); + ob_end_clean(); + $spam_fail = 1; + foreach (explode(PHP_EOL, $spamresult) as $line) { + $line = str_replace(array( + "\n\r", + "\n", + "\r" + ), '', $line); + if (strpos($line, 'X-Spam-Checker-Version:') !== FALSE) { + $spamcheckerversion = $line; + $spam_fail = 0; + } + if (strpos($line, 'X-Spam-Level:') !== FALSE) { + $spamlevel = $line; + } + if ((strpos($line, "X-Spam-Flag: YES") === 0) && ($res !== 1)) { + $res = 1; } } - fclose($spamFileHandle); unlink($spamfile); if ($res === 1) { file_put_contents($logfile, "\n" . format_log_date() . " " . $spamresult . "\n------------\n", FILE_APPEND); @@ -1475,7 +1467,7 @@ function create_xref_from_msgid($msgid, $thisgroup = null, $thisnumber = null) } $xref .= ' ' . $row['newsgroup'] . ':' . $row['number']; } - if (!$found) { + if (! $found) { $xref .= ' ' . $thisgroup . ':' . $thisnumber; } $overview_dbh = null; diff --git a/Rocksolid_Light/rslight/scripts/rslight-lib.php b/Rocksolid_Light/rslight/scripts/rslight-lib.php index dc3a08e..b1eb78f 100644 --- a/Rocksolid_Light/rslight/scripts/rslight-lib.php +++ b/Rocksolid_Light/rslight/scripts/rslight-lib.php @@ -300,7 +300,8 @@ function prepare_post($filename) $allgroups = preg_split("/\ |\,/", $ngroups[1]); foreach ($allgroups as $agroup) { $agroup = trim($agroup); - if ((testGroup($agroup)) || $agroup == '') { + if (testGroup($agroup)) { + // if ((testGroup($agroup)) || $agroup == '') { $response = process_post($message, $agroup); if (substr($response, 0, 3) == "240") { $ok = 1; @@ -322,7 +323,7 @@ function prepare_post($filename) } $response = "240 Article received OK\r\n"; } else { - $response = "441 Posting failed (group not found)\r\n"; + // $response = "441 Posting failed (group not found)\r\n"; } return $response; } @@ -404,6 +405,8 @@ function process_post($message, $group) $orig_newsgroups = $newsgroups; $newsgroups = $CONFIG['spamgroup']; $group = $newsgroups; + $response = "441 Posting failed (Exceeds Spam Score)\r\n"; + return $response; } /* Find section for posting */ $section = get_section_by_group($group); @@ -450,7 +453,7 @@ function process_post($message, $group) chmod($postfilename, 0600); unlink($filename); if ($section == "") { - $response = "441 Posting failed (group not found)\r\n"; + $response = "441 Posting failed (section not found)\r\n"; } else { $response = insert_article($section, $group, $postfilename, $subject[1], $from[1], $article_date, $date_rep, $msgid, $references, $bytes, $lines, $xref, $body); } diff --git a/Rocksolid_Light/rslight/scripts/spoolnews.php b/Rocksolid_Light/rslight/scripts/spoolnews.php index 61e3194..3a5b12a 100644 --- a/Rocksolid_Light/rslight/scripts/spoolnews.php +++ b/Rocksolid_Light/rslight/scripts/spoolnews.php @@ -451,18 +451,36 @@ function get_articles($ns, $group) $current_article['article'] = $this_article; $current_article['snippet'] = $this_snippet; - foreach ($allgroups as $agroup) { - $agroup = trim($agroup); - if ((! testGroup($agroup)) || $agroup == '') { - continue; - } - $current_article['group'] = $agroup; - if ($group == $agroup) { - $current_article['local'] = $local; - insert_article_from_array($current_article); - } else { - $current_article['local'] = get_next_article_number($agroup); - insert_article_from_array($current_article); + // Check Spam + if (isset($CONFIG['spamassassin']) && ($CONFIG['spamassassin'] == true)) { + $spam_result_array = check_spam($subject[1], $from[1], $groupnames[1], $references, $body, $mid[1]); + $res = $spam_result_array['res']; + $spamresult = $spam_result_array['spamresult']; + $spamcheckerversion = $spam_result_array['spamcheckerversion']; + $spamlevel = $spam_result_array['spamlevel']; + } + if ($res === 1) { + unlink($grouppath . "/" . $local); + file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Skipping: " . $CONFIG['remote_server'] . " " . $group . ":" . $article . " Exceeds Spam Score", FILE_APPEND); + // $orig_newsgroups = $newsgroups; + // $newsgroups = $CONFIG['spamgroup']; + // $group = $newsgroups; + $i --; + $local --; + } else { + foreach ($allgroups as $agroup) { + $agroup = trim($agroup); + if ((! testGroup($agroup)) || $agroup == '') { + continue; + } + $current_article['group'] = $agroup; + if ($group == $agroup) { + $current_article['local'] = $local; + insert_article_from_array($current_article); + } else { + $current_article['local'] = get_next_article_number($agroup); + insert_article_from_array($current_article); + } } }