aboutsummaryrefslogtreecommitdiff
path: root/publishannouncement.php
diff options
context:
space:
mode:
authorarf20 <aruizfernandez05@gmail.com>2024-05-01 13:26:26 +0200
committerarf20 <aruizfernandez05@gmail.com>2024-05-01 13:26:26 +0200
commit531356f97c3a0268fbe0ab98c7158f8147bacd66 (patch)
tree7b7de2666ca1ca6c7680fada5bbcf2b5c796fea1 /publishannouncement.php
parent5e4caac04d9a92b375133edfe6fe8324d274a7ad (diff)
downloadarfnet2-cstims-531356f97c3a0268fbe0ab98c7158f8147bacd66.tar.gz
arfnet2-cstims-531356f97c3a0268fbe0ab98c7158f8147bacd66.zip
NNTP announce working
Diffstat (limited to 'publishannouncement.php')
-rw-r--r--publishannouncement.php17
1 files changed, 10 insertions, 7 deletions
diff --git a/publishannouncement.php b/publishannouncement.php
index b9f3351..37bb2dc 100644
--- a/publishannouncement.php
+++ b/publishannouncement.php
@@ -115,28 +115,31 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
do {
$read = fread($fd, 1024);
} while (!str_contains($read, "Message-ID"));
- $msgidheader = substr($read, strpos($read, "Message-ID"), -1);
+ /* Assumes CRLF */
+ $msgidheader = substr($read, strpos($read, "Message-ID"), -2);
$msgidheader = str_replace("Message-ID", "Message-ID:", $msgidheader);
- echo $msgidheader;
-
- fwrite($fd,
- $msgidheader."\r\n".
+ $message =
"From: System <system@arf20.com>\r\n".
"Reply-To: ".getuserbyid($id)["email"]."\r\n".
"Newsgroups: ".ANNOUNCE_NNTPGROUP."\r\n".
"Subject: ".$_POST["subject"]."\r\n".
"Date: ".date("r")."\r\n".
+ $msgidheader."\r\n".
"Organization: ARFNET\r\n".
"User-Agent: ARFNET CSTIMS UAS\r\n\r\n".
$_POST["body"]."\r\n".
- ".\r\n");
+ ".\r\n";
- echo fread($fd, 1024);
+ $response = fread($fd, 1024);
fwrite($fd, "QUIT\r\n");
fclose($fd);
+
+ if (str_contains($response, "240 Article received"))
+ echo "ok";
+ else echo "error $response<br>";
}
die();