More verbose nntp response messages.
This commit is contained in:
parent
e425d993e8
commit
a799624061
|
@ -256,8 +256,12 @@ function prepare_post($filename)
|
||||||
global $logdir, $spooldir, $config_dir, $rslight_gpg;
|
global $logdir, $spooldir, $config_dir, $rslight_gpg;
|
||||||
$logfile = $logdir . '/nntp.log';
|
$logfile = $logdir . '/nntp.log';
|
||||||
$message = file($filename, FILE_IGNORE_NEW_LINES);
|
$message = file($filename, FILE_IGNORE_NEW_LINES);
|
||||||
|
$response = "441 Posting failed\r\n";
|
||||||
$lines = 0;
|
$lines = 0;
|
||||||
$is_header = 1;
|
$is_header = 1;
|
||||||
|
$head_from = false;
|
||||||
|
$head_subject = false;
|
||||||
|
$head_newsgroups = false;
|
||||||
$nocem_check = "@@NCM";
|
$nocem_check = "@@NCM";
|
||||||
$bbsmail_check = "@@RSL";
|
$bbsmail_check = "@@RSL";
|
||||||
|
|
||||||
|
@ -269,27 +273,36 @@ function prepare_post($filename)
|
||||||
if ($lines > 0 && $is_header = 0) {
|
if ($lines > 0 && $is_header = 0) {
|
||||||
$break;
|
$break;
|
||||||
}
|
}
|
||||||
|
if (stripos($line, "From: ") === 0) {
|
||||||
|
$lines ++;
|
||||||
|
$head_from = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (stripos($line, "Newsgroups: ") === 0) {
|
if (stripos($line, "Newsgroups: ") === 0) {
|
||||||
$ngroups = explode(': ', $line);
|
$ngroups = explode(': ', $line);
|
||||||
// $newsgroups = $ngroups[1];
|
|
||||||
$lines ++;
|
$lines ++;
|
||||||
|
$head_newsgroups = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (stripos($line, "Subject: ") === 0) {
|
if (stripos($line, "Subject: ") === 0) {
|
||||||
$sub = explode(': ', $line);
|
$sub = explode(': ', $line);
|
||||||
$subject = $sub[1];
|
$subject = $sub[1];
|
||||||
$lines ++;
|
$lines ++;
|
||||||
|
$head_subject = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ok = 0;
|
$ok = 0;
|
||||||
|
if (! $head_from || ! $head_subject || ! $head_newsgroups) {
|
||||||
|
$response = "441 Posting failed (Missing header line)\r\n";
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
$allgroups = preg_split("/\ |\,/", $ngroups[1]);
|
$allgroups = preg_split("/\ |\,/", $ngroups[1]);
|
||||||
foreach ($allgroups as $agroup) {
|
foreach ($allgroups as $agroup) {
|
||||||
$agroup = trim($agroup);
|
$agroup = trim($agroup);
|
||||||
if ((testGroup($agroup)) || $agroup == '') {
|
if ((testGroup($agroup)) || $agroup == '') {
|
||||||
$result = process_post($message, $agroup);
|
$response = process_post($message, $agroup);
|
||||||
if (substr($result, 0, 3) == "240") {
|
if (substr($response, 0, 3) == "240") {
|
||||||
$ok = 1;
|
$ok = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -309,7 +322,7 @@ function prepare_post($filename)
|
||||||
}
|
}
|
||||||
$response = "240 Article received OK\r\n";
|
$response = "240 Article received OK\r\n";
|
||||||
} else {
|
} else {
|
||||||
$response = "441 Posting failed\r\n";
|
$response = "441 Posting failed (group not found)\r\n";
|
||||||
}
|
}
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
@ -396,7 +409,7 @@ function process_post($message, $group)
|
||||||
$section = get_section_by_group($group);
|
$section = get_section_by_group($group);
|
||||||
|
|
||||||
@mkdir($spooldir . "/" . $section . "/outgoing", 0755, 'recursive');
|
@mkdir($spooldir . "/" . $section . "/outgoing", 0755, 'recursive');
|
||||||
$postfilename = $spooldir . '/' . $section . '/outgoing/'.$mid[1].'.msg';
|
$postfilename = $spooldir . '/' . $section . '/outgoing/' . $mid[1] . '.msg';
|
||||||
$postfilehandle = fopen($postfilename, 'w');
|
$postfilehandle = fopen($postfilename, 'w');
|
||||||
if ($no_date == 1) {
|
if ($no_date == 1) {
|
||||||
$article_date = time();
|
$article_date = time();
|
||||||
|
|
Loading…
Reference in New Issue