Add handling for moderated newsgroups.
This commit is contained in:
parent
e5ff52f299
commit
2508c5e56f
|
@ -1200,7 +1200,7 @@ function check_bbs_auth($username, $password)
|
||||||
$keyFilename = $config_dir . "/userconfig/" . $username;
|
$keyFilename = $config_dir . "/userconfig/" . $username;
|
||||||
|
|
||||||
foreach ($banned_list as $banned) {
|
foreach ($banned_list as $banned) {
|
||||||
if($banned[0] == '#')
|
if ($banned[0] == '#')
|
||||||
continue;
|
continue;
|
||||||
if (strtolower(trim($username)) == strtolower(trim($banned))) {
|
if (strtolower(trim($username)) == strtolower(trim($banned))) {
|
||||||
file_put_contents($logfile, "\n" . format_log_date() . " AUTH Failed for: " . $username . ' (user is banned)', FILE_APPEND);
|
file_put_contents($logfile, "\n" . format_log_date() . " AUTH Failed for: " . $username . ' (user is banned)', FILE_APPEND);
|
||||||
|
@ -1551,10 +1551,10 @@ function create_xref_from_msgid($msgid, $thisgroup = null, $thisnumber = null)
|
||||||
|
|
||||||
function get_search_snippet($body, $content_type = '', $content_transfer_encoding = null)
|
function get_search_snippet($body, $content_type = '', $content_transfer_encoding = null)
|
||||||
{
|
{
|
||||||
if($content_transfer_encoding == 'base64') {
|
if ($content_transfer_encoding == 'base64') {
|
||||||
$body = base64_decode($body);
|
$body = base64_decode($body);
|
||||||
}
|
}
|
||||||
if($content_transfer_encoding == 'quoted-printable') {
|
if ($content_transfer_encoding == 'quoted-printable') {
|
||||||
$body = quoted_printable_decode($body);
|
$body = quoted_printable_decode($body);
|
||||||
}
|
}
|
||||||
if ($content_type !== '') {
|
if ($content_type !== '') {
|
||||||
|
@ -2026,6 +2026,62 @@ function verify_gpg_signature($res, $signed_text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function is_moderated($newsgroups)
|
||||||
|
{
|
||||||
|
global $CONFIG, $OVERRIDES, $spooldir;
|
||||||
|
$moderated_groups_file = $spooldir . '/moderated_groups.dat';
|
||||||
|
$unmoderated_groups_file = $spooldir . '/unmoderated_groups.dat';
|
||||||
|
$moderated_groups = array();
|
||||||
|
$unmoderated_groups = array();
|
||||||
|
|
||||||
|
$ngroups = preg_split("/[\s,]+/", $newsgroups);
|
||||||
|
foreach ($ngroups as $group) {
|
||||||
|
if (file_exists($moderated_groups_file)) {
|
||||||
|
$moderated_groups = file($moderated_groups_file, FILE_IGNORE_NEW_LINES);
|
||||||
|
if (in_array($group, $moderated_groups)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file_exists($unmoderated_groups_file)) {
|
||||||
|
$unmoderated_groups = file($unmoderated_groups_file, FILE_IGNORE_NEW_LINES);
|
||||||
|
if (in_array($group, $unmoderated_groups)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$ns = nntp2_open();
|
||||||
|
if (! $ns) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($ngroups as $group) {
|
||||||
|
fputs($ns, "list active $group\r\n");
|
||||||
|
while ($weg = line_read($ns)) {
|
||||||
|
if (strcmp($weg, ".") == 0) {
|
||||||
|
nntp_close($ns);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (strpos($weg, $group . ' ') !== false) {
|
||||||
|
if (str_ends_with($weg, 'm')) {
|
||||||
|
nntp_close($ns);
|
||||||
|
if (! in_array($newsgroups, $moderated_groups)) {
|
||||||
|
file_put_contents($moderated_groups_file, $group . "\n", FILE_APPEND);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
nntp_close($ns);
|
||||||
|
if (! in_array($newsgroups, $unmoderated_groups)) {
|
||||||
|
file_put_contents($unmoderated_groups_file, $group . "\n", FILE_APPEND);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nntp_close($ns);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function get_next_article_number($group)
|
function get_next_article_number($group)
|
||||||
{
|
{
|
||||||
$ok_article = get_article_list($group);
|
$ok_article = get_article_list($group);
|
||||||
|
|
|
@ -260,8 +260,13 @@ if ($type == "post") {
|
||||||
}
|
}
|
||||||
// Article sent without errors, or duplicate?
|
// Article sent without errors, or duplicate?
|
||||||
if ((substr($message, 0, 3) == "240") || (substr($message, 0, 7) == "441 435")) {
|
if ((substr($message, 0, 3) == "240") || (substr($message, 0, 7) == "441 435")) {
|
||||||
echo '<h1 class="np_post_headline"><' . $text_post["message_posted"] . '></h1>';
|
// Is there a moderated group in Newsgroups: ?
|
||||||
echo '<p>' . $text_post["message_posted2"] . '</p>';
|
if(is_moderated($newsgroups)) {
|
||||||
|
echo '<p>** <i>Moderated Newsgroup **</p>';
|
||||||
|
echo '<p>** <i>Message Queued for Moderation **</p>';
|
||||||
|
} else {
|
||||||
|
echo '<p>' . $text_post["message_posted2"] . '</p>';
|
||||||
|
}
|
||||||
if (isset($CONFIG['auto_return']) && ($CONFIG['auto_return'] == true)) {
|
if (isset($CONFIG['auto_return']) && ($CONFIG['auto_return'] == true)) {
|
||||||
echo '<meta http-equiv="refresh" content="0;url=' . $file_thread . '?group=' . urlencode($returngroup) . '"';
|
echo '<meta http-equiv="refresh" content="0;url=' . $file_thread . '?group=' . urlencode($returngroup) . '"';
|
||||||
}
|
}
|
||||||
|
@ -278,17 +283,6 @@ if ($type == "post") {
|
||||||
file_put_contents($logfile, "\n" . format_log_date() . " Post in: " . $returngroup . " by " . $name, FILE_APPEND);
|
file_put_contents($logfile, "\n" . format_log_date() . " Post in: " . $returngroup . " by " . $name, FILE_APPEND);
|
||||||
}
|
}
|
||||||
echo '<p><a href="' . $file_thread . '?group=' . $returngroup . '">Back</a></p>';
|
echo '<p><a href="' . $file_thread . '?group=' . $returngroup . '">Back</a></p>';
|
||||||
/*
|
|
||||||
* if (isset($_REQUEST['returngroup']) && $_REQUEST['returngroup'] !== '') {
|
|
||||||
* echo '<p><a href="' . $file_thread . '?group=' . $_REQUEST['returngroup'] . '">Your post will appear in ' . group_display_name($_REQUEST['returngroup']) . '</a></p>';
|
|
||||||
* }
|
|
||||||
* if (isset($_SESSION['return_page'])) {
|
|
||||||
* echo '<p><a href="' . $file_thread . '?group=' . $returngroup . '">Back</a></p>';
|
|
||||||
* //echo '<p><a href="' . $_SESSION['return_page'] . '">Back to Previous Page</a></p>';
|
|
||||||
* } else {
|
|
||||||
* echo '<p><a href="' . $file_thread . '?group=' . $returngroup . '">Back</a></p>';
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
} else {
|
} else {
|
||||||
// article not accepted by the newsserver
|
// article not accepted by the newsserver
|
||||||
$type = "retry";
|
$type = "retry";
|
||||||
|
|
|
@ -7,12 +7,12 @@ function interact($msgsock, $use_crypto = false)
|
||||||
$path = $workpath . "articles/";
|
$path = $workpath . "articles/";
|
||||||
$groupconfig = $spooldir . "/spoolnews/groups.txt";
|
$groupconfig = $spooldir . "/spoolnews/groups.txt";
|
||||||
|
|
||||||
if(isset($OVERRIDES['nntp_full_auth_required']) && $OVERRIDES['nntp_full_auth_required'] == true) {
|
if (isset($OVERRIDES['nntp_full_auth_required']) && $OVERRIDES['nntp_full_auth_required'] == true) {
|
||||||
$nntp_full_auth_required = true;
|
$nntp_full_auth_required = true;
|
||||||
} else {
|
} else {
|
||||||
$nntp_full_auth_required = false;
|
$nntp_full_auth_required = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$logfile = $logdir . '/nntp.log';
|
$logfile = $logdir . '/nntp.log';
|
||||||
$nntp_group = "";
|
$nntp_group = "";
|
||||||
$nntp_article = "";
|
$nntp_article = "";
|
||||||
|
@ -56,8 +56,8 @@ function interact($msgsock, $use_crypto = false)
|
||||||
$command = explode(' ', $buf);
|
$command = explode(' ', $buf);
|
||||||
$command[0] = strtolower($command[0]);
|
$command[0] = strtolower($command[0]);
|
||||||
// Check if auth required for everything or only posting
|
// Check if auth required for everything or only posting
|
||||||
if($nntp_full_auth_required == true && $auth_ok == 0) {
|
if ($nntp_full_auth_required == true && $auth_ok == 0) {
|
||||||
if($command[0] == 'authinfo' || $command[0] == 'quit' || $command[0] == 'mode') {
|
if ($command[0] == 'authinfo' || $command[0] == 'quit' || $command[0] == 'mode') {
|
||||||
// Ok to continue
|
// Ok to continue
|
||||||
} else {
|
} else {
|
||||||
// Auth is required. Try again
|
// Auth is required. Try again
|
||||||
|
@ -66,7 +66,7 @@ function interact($msgsock, $use_crypto = false)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($command[1])) {}
|
if (isset($command[1])) {}
|
||||||
if ($command[0] == 'date') {
|
if ($command[0] == 'date') {
|
||||||
$msg = '111 ' . date('YmdHis') . "\r\n";
|
$msg = '111 ' . date('YmdHis') . "\r\n";
|
||||||
|
@ -339,7 +339,7 @@ function prepare_post($filename)
|
||||||
$nocem_file = tempnam($spooldir . "/nocem", "nocem-" . $group . "-");
|
$nocem_file = tempnam($spooldir . "/nocem", "nocem-" . $group . "-");
|
||||||
copy($filename, $nocem_file);
|
copy($filename, $nocem_file);
|
||||||
}
|
}
|
||||||
$response = "240 Article received OK\r\n";
|
$response = "240 Article received OK (posted)\r\n";
|
||||||
} else {
|
} else {
|
||||||
// $response = "441 Posting failed (group not found)\r\n";
|
// $response = "441 Posting failed (group not found)\r\n";
|
||||||
}
|
}
|
||||||
|
@ -1125,6 +1125,11 @@ function insert_article($section, $nntp_group, $filename, $subject_i, $from_i, $
|
||||||
{
|
{
|
||||||
global $enable_rslight, $spooldir, $CONFIG, $OVERRIDES, $logdir, $lockdir, $logfile;
|
global $enable_rslight, $spooldir, $CONFIG, $OVERRIDES, $logdir, $lockdir, $logfile;
|
||||||
|
|
||||||
|
if(is_moderated($nntp_group)) {
|
||||||
|
file_put_contents($logfile, "\n" . format_log_date() . " " . $section . " Moderated group... Queuing local post: " . $nntp_group, FILE_APPEND);
|
||||||
|
$return_val = "240 Article received OK (queued for moderation)\r\n";
|
||||||
|
return ($return_val);
|
||||||
|
}
|
||||||
if (isset($OVERRIDES['insert_disable']) && $OVERRIDES['insert_disable'] != '') {
|
if (isset($OVERRIDES['insert_disable']) && $OVERRIDES['insert_disable'] != '') {
|
||||||
$insert_disable = explode(',', $OVERRIDES['insert_disable']);
|
$insert_disable = explode(',', $OVERRIDES['insert_disable']);
|
||||||
foreach ($insert_disable as $disable) {
|
foreach ($insert_disable as $disable) {
|
||||||
|
|
Loading…
Reference in New Issue