Skip to content

Commit

Permalink
NNTP announce working
Browse files Browse the repository at this point in the history
  • Loading branch information
arf20 committed May 1, 2024
1 parent 5e4caac commit 531356f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
6 changes: 6 additions & 0 deletions config.php.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ define('MAIL_FROM', '[email protected]');

define('ANNOUNCE_MAIL', '[email protected]');
define('ANNOUNCE_DISCORD', 'https://discord.com/api/webhooks/thing');
define('ANNOUNCE_IRCSERVER', 'irc.example.com');
define('ANNOUNCE_IRCCHANNEL', '#example');
define('ANNOUNCE_NNTPSERVER', 'news.example.com');
define('ANNOUNCE_NNTPUSER', 'user');
define('ANNOUNCE_NNTPPASS', 'password');
define('ANNOUNCE_NNTPGROUP', 'misc.test');

define('DOMAIN', 'dash.example.com');

Expand Down
17 changes: 10 additions & 7 deletions publishannouncement.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,28 +115,31 @@
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 <[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".
$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();
Expand Down

0 comments on commit 531356f

Please sign in to comment.