From 5e4caac04d9a92b375133edfe6fe8324d274a7ad Mon Sep 17 00:00:00 2001 From: arf20 Date: Sun, 28 Apr 2024 19:45:06 +0200 Subject: announce NNTP almost there --- publishannouncement.php | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'publishannouncement.php') diff --git a/publishannouncement.php b/publishannouncement.php index d190e7e..b9f3351 100644 --- a/publishannouncement.php +++ b/publishannouncement.php @@ -77,7 +77,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { // send login fwrite($fd, "NICK system\r\n"); - fwrite($fd, "USER system 0 * ARFNET CSTIMS Announcement System\r\n"); + fwrite($fd, "USER system 0 * ARFNET CSTIMS UAS\r\n"); // read ping do { @@ -95,11 +95,50 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { // send message fwrite($fd, "PRIVMSG ".ANNOUNCE_IRCCHANNEL." :New announcement: ".$_POST["subject"]."\r\n"); + fwrite($fd, "QUIT\r\n"); + fclose($fd); echo "ok"; } + if (defined("ANNOUNCE_NNTPSERVER")) { + echo "nntp "; + + $fd = fsockopen(ANNOUNCE_NNTPSERVER, 119, $errno, $errstr, 5); + + fwrite($fd, "AUTHINFO USER ".ANNOUNCE_NNTPUSER."\r\n"); + fwrite($fd, "AUTHINFO PASS ".ANNOUNCE_NNTPPASS."\r\n"); + fread($fd, 1024); // flush + + fwrite($fd, "POST\r\n"); + do { + $read = fread($fd, 1024); + } while (!str_contains($read, "Message-ID")); + $msgidheader = substr($read, strpos($read, "Message-ID"), -1); + $msgidheader = str_replace("Message-ID", "Message-ID:", $msgidheader); + + echo $msgidheader; + + fwrite($fd, + $msgidheader."\r\n". + "From: System \r\n". + "Reply-To: ".getuserbyid($id)["email"]."\r\n". + "Newsgroups: ".ANNOUNCE_NNTPGROUP."\r\n". + "Subject: ".$_POST["subject"]."\r\n". + "Date: ".date("r")."\r\n". + "Organization: ARFNET\r\n". + "User-Agent: ARFNET CSTIMS UAS\r\n\r\n". + $_POST["body"]."\r\n". + ".\r\n"); + + echo fread($fd, 1024); + + fwrite($fd, "QUIT\r\n"); + + fclose($fd); + } + die(); } -- cgit v1.2.3