Add handling message-id for stat command.
This commit is contained in:
parent
a4e1134065
commit
3191d40b24
|
@ -579,8 +579,8 @@ function get_next($nntp_group)
|
||||||
$nntp_article++;
|
$nntp_article++;
|
||||||
$database = $spooldir . '/articles-overview.db3';
|
$database = $spooldir . '/articles-overview.db3';
|
||||||
$table = 'overview';
|
$table = 'overview';
|
||||||
$dbh = overview_db_open($database, $table);
|
$overview_dbh = overview_db_open($database, $table);
|
||||||
$stmt = $dbh->prepare("SELECT * FROM $table WHERE newsgroup=:newsgroup AND number=:number");
|
$stmt = $overview_dbh->prepare("SELECT * FROM $table WHERE newsgroup=:newsgroup AND number=:number");
|
||||||
$stmt->bindParam(':newsgroup', $nntp_group);
|
$stmt->bindParam(':newsgroup', $nntp_group);
|
||||||
$stmt->bindParam(':number', $nntp_article);
|
$stmt->bindParam(':number', $nntp_article);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -588,7 +588,7 @@ function get_next($nntp_group)
|
||||||
$msgid = $found['msgid'];
|
$msgid = $found['msgid'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$dbh = null;
|
$overview_dbh = null;
|
||||||
$response = "223 " . $nntp_article . " " . $msgid . " Article retrieved; request text separately\r\n";
|
$response = "223 " . $nntp_article . " " . $msgid . " Article retrieved; request text separately\r\n";
|
||||||
}
|
}
|
||||||
return $response;
|
return $response;
|
||||||
|
@ -610,8 +610,8 @@ function get_last($nntp_group)
|
||||||
$nntp_article--;
|
$nntp_article--;
|
||||||
$database = $spooldir . '/articles-overview.db3';
|
$database = $spooldir . '/articles-overview.db3';
|
||||||
$table = 'overview';
|
$table = 'overview';
|
||||||
$dbh = overview_db_open($database, $table);
|
$overview_dbh = overview_db_open($database, $table);
|
||||||
$stmt = $dbh->prepare("SELECT * FROM $table WHERE newsgroup=:newsgroup AND number=:number");
|
$stmt = $overview_dbh->prepare("SELECT * FROM $table WHERE newsgroup=:newsgroup AND number=:number");
|
||||||
$stmt->bindParam(':newsgroup', $nntp_group);
|
$stmt->bindParam(':newsgroup', $nntp_group);
|
||||||
$stmt->bindParam(':number', $nntp_article);
|
$stmt->bindParam(':number', $nntp_article);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
@ -619,7 +619,7 @@ function get_last($nntp_group)
|
||||||
$msgid = $found['msgid'];
|
$msgid = $found['msgid'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$dbh = null;
|
$overview_dbh = null;
|
||||||
$response = "223 " . $nntp_article . " " . $msgid . " Article retrieved; request text separately\r\n";
|
$response = "223 " . $nntp_article . " " . $msgid . " Article retrieved; request text separately\r\n";
|
||||||
}
|
}
|
||||||
return $response;
|
return $response;
|
||||||
|
@ -781,9 +781,9 @@ function get_xover($articles, $msgsock)
|
||||||
|
|
||||||
$database = $spooldir . '/articles-overview.db3';
|
$database = $spooldir . '/articles-overview.db3';
|
||||||
$table = 'overview';
|
$table = 'overview';
|
||||||
$dbh = overview_db_open($database, $table);
|
$overview_dbh = overview_db_open($database, $table);
|
||||||
|
|
||||||
$stmt = $dbh->prepare("SELECT * FROM $table WHERE newsgroup=:thisgroup AND number=:number"); // Why doesn't BETWEEN work properly here?
|
$stmt = $overview_dbh->prepare("SELECT * FROM $table WHERE newsgroup=:thisgroup AND number=:number"); // Why doesn't BETWEEN work properly here?
|
||||||
for ($i = $first; $i <= $last; $i++) {
|
for ($i = $first; $i <= $last; $i++) {
|
||||||
$stmt->execute([
|
$stmt->execute([
|
||||||
'thisgroup' => $nntp_group,
|
'thisgroup' => $nntp_group,
|
||||||
|
@ -793,22 +793,41 @@ function get_xover($articles, $msgsock)
|
||||||
$msg .= $row['number'] . "\t" . $row['subject'] . "\t" . $row['name'] . "\t" . $row['datestring'] . "\t" . $row['msgid'] . "\t" . $row['refs'] . "\t" . $row['bytes'] . "\t" . $row['lines'] . "\t" . $row['xref'] . "\r\n";
|
$msg .= $row['number'] . "\t" . $row['subject'] . "\t" . $row['name'] . "\t" . $row['datestring'] . "\t" . $row['msgid'] . "\t" . $row['refs'] . "\t" . $row['bytes'] . "\t" . $row['lines'] . "\t" . $row['xref'] . "\r\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$dbh = null;
|
$overview_dbh = null;
|
||||||
$msg .= ".\r\n";
|
$msg .= ".\r\n";
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_stat($article)
|
function get_stat($article)
|
||||||
{
|
{
|
||||||
global $nntp_group, $nntp_article, $workpath, $path;
|
global $nntp_group, $nntp_article, $spooldir;
|
||||||
if ($nntp_group == '') {
|
|
||||||
$msg = "412 Not in a newsgroup\r\n";
|
|
||||||
return $msg;
|
|
||||||
}
|
|
||||||
// Use article pointer
|
// Use article pointer
|
||||||
if (! isset($article) && is_numeric($nntp_article)) {
|
if (! isset($article) && is_numeric($nntp_article)) {
|
||||||
$article = $nntp_article;
|
$article = $nntp_article;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// By Message-ID
|
||||||
|
if (preg_match("/\<.*\@.*\>/", $article)) {
|
||||||
|
$found = find_article_by_msgid($article);
|
||||||
|
$nntp_group = $found['newsgroup'];
|
||||||
|
$article = $found['number'];
|
||||||
|
if (!$found) {
|
||||||
|
$msg = "430 No such article\r\n";
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (! is_numeric($article)) {
|
||||||
|
$msg = "501 Syntax error in Message-ID\r\n";
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($nntp_group == '') {
|
||||||
|
$msg = "412 Not in a newsgroup\r\n";
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
if (! is_numeric($article)) {
|
if (! is_numeric($article)) {
|
||||||
$msg = "423 No article number selected\r\n";
|
$msg = "423 No article number selected\r\n";
|
||||||
return $msg;
|
return $msg;
|
||||||
|
@ -818,8 +837,8 @@ function get_stat($article)
|
||||||
if (! is_file($database)) {
|
if (! is_file($database)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$dbh = overview_db_open($database);
|
$overview_dbh = overview_db_open($database);
|
||||||
$query = $articles_dbh->prepare('SELECT * FROM overview WHERE number=:number AND newsgroup=:newsgroup');
|
$query = $overview_dbh->prepare('SELECT * FROM overview WHERE number=:number AND newsgroup=:newsgroup');
|
||||||
$query->execute([
|
$query->execute([
|
||||||
'number' => $article,
|
'number' => $article,
|
||||||
'newsgroup' => $nntp_group
|
'newsgroup' => $nntp_group
|
||||||
|
@ -829,7 +848,7 @@ function get_stat($article)
|
||||||
$found = 1;
|
$found = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$dbh = null;
|
$overview_dbh = null;
|
||||||
if ($found == 1) {
|
if ($found == 1) {
|
||||||
$msg = "223 " . $article . " " . $row['msgid'] . " status\r\n";
|
$msg = "223 " . $article . " " . $row['msgid'] . " status\r\n";
|
||||||
} else {
|
} else {
|
||||||
|
@ -1354,8 +1373,8 @@ function find_article_by_msgid($msgid)
|
||||||
global $spooldir;
|
global $spooldir;
|
||||||
$database = $spooldir . '/articles-overview.db3';
|
$database = $spooldir . '/articles-overview.db3';
|
||||||
$table = 'overview';
|
$table = 'overview';
|
||||||
$dbh = overview_db_open($database, $table);
|
$overview_dbh = overview_db_open($database, $table);
|
||||||
$stmt = $dbh->prepare("SELECT * FROM $table WHERE msgid like :terms");
|
$stmt = $overview_dbh->prepare("SELECT * FROM $table WHERE msgid like :terms");
|
||||||
$stmt->bindParam(':terms', $msgid);
|
$stmt->bindParam(':terms', $msgid);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
while ($found = $stmt->fetch()) {
|
while ($found = $stmt->fetch()) {
|
||||||
|
@ -1364,7 +1383,7 @@ function find_article_by_msgid($msgid)
|
||||||
$return['msgid'] = $found['msgid'];
|
$return['msgid'] = $found['msgid'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$dbh = null;
|
$overview_dbh = null;
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue