aboutsummaryrefslogtreecommitdiff
path: root/publishannouncement.php
diff options
context:
space:
mode:
authorarf20 <aruizfernandez05@gmail.com>2024-04-28 19:45:06 +0200
committerarf20 <aruizfernandez05@gmail.com>2024-04-28 19:45:06 +0200
commit5e4caac04d9a92b375133edfe6fe8324d274a7ad (patch)
treeac31a961dc2b6c7215997203bcb92783d47ad8b2 /publishannouncement.php
parentebb17203d4cc11cc674d5a7959d9158cf3ccc8f5 (diff)
downloadarfnet2-cstims-5e4caac04d9a92b375133edfe6fe8324d274a7ad.tar.gz
arfnet2-cstims-5e4caac04d9a92b375133edfe6fe8324d274a7ad.zip
announce NNTP almost there
Diffstat (limited to 'publishannouncement.php')
-rw-r--r--publishannouncement.php41
1 files changed, 40 insertions, 1 deletions
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 <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".
+ "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();
}