Skip to content

Commit

Permalink
announce NNTP almost there
Browse files Browse the repository at this point in the history
  • Loading branch information
arf20 committed Apr 28, 2024
1 parent ebb1720 commit 5e4caac
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion publishannouncement.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

// 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 {
Expand All @@ -95,11 +95,50 @@
// 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 <[email protected]>\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();
}

Expand Down

0 comments on commit 5e4caac

Please sign in to comment.