Merge branch 'devel'

This commit is contained in:
Retro_Guy 2024-09-11 02:07:57 -07:00
commit 7dd998fae7
11 changed files with 243 additions and 149 deletions

View File

@ -613,7 +613,7 @@ blockquote.np_article_quote {
/* headline */
h1.np_post_headline {
font-size: 1em;
font-size: 0.8em;
}
/* Head with the input fields for subject, name and email */

View File

@ -1 +1 @@
0.9.142
0.9.15

View File

@ -49,6 +49,7 @@ $text_post["button_post"]="Post Article";
$text_post["remember"]="Remember name";
$text_post["message"]="Message";
$text_post["group_head"]="Compose a post in ";
$text_post["group_head_reply"]="Reply to post in ";
$text_post["group_tail"]="";
$text_post["followup_not_allowed"]="You aren't allowed to post to the groups:";
$text_post["message_posted"]="Message posted";

View File

@ -1302,6 +1302,10 @@ function verify_logged_in($name) {
$logged_in = false;
$ip_pass = false;
if(!isset($_COOKIE['mail_name']) || trim($_COOKIE['mail_name'] == '')) {
return false;
}
// For checking session expire stuff
if(!isset($_SESSION['start_stamp'])) {
$_SESSION['start_stamp'] = time();

View File

@ -23,7 +23,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include "config.inc.php";
$CONFIG = include ($config_file);
$CONFIG = include($config_file);
include $file_newsportal;
include "head.inc";
@ -52,6 +52,11 @@ $logfile = $logdir . '/post.log';
@$references = $_REQUEST["references"];
@$id = $_REQUEST["id"];
if (isset($_REQUEST['followupto']) && trim($_REQUEST['followupto']) != '') {
$followupto = trim($_REQUEST['followupto']);
} else {
$followupto = null;
}
// Load name from cookies
if ($setcookies) {
if ((isset($_COOKIE["mail_name"])) && (! isset($name)))
@ -62,7 +67,7 @@ if ($setcookies) {
$name = substr($name, 0, 30);
$logged_in = false;
if(trim($name) != '') {
if (trim($name) != '') {
$logged_in = verify_logged_in(trim(strtolower($name)));
}
@ -75,38 +80,46 @@ if ($OVERRIDES['enable_post_log'] > 0) {
$allow_ng_header_edit_post = true;
$allow_ng_header_edit_reply = false;
if(isset($OVERRIDES['allow_ng_header_edit'])) {
if($OVERRIDES['allow_ng_header_edit'] == 'post') {
if (isset($OVERRIDES['allow_ng_header_edit'])) {
if ($OVERRIDES['allow_ng_header_edit'] == 'post') {
$allow_ng_header_edit_post = true;
} else {
$allow_ng_header_edit_post = false;
}
if($OVERRIDES['allow_ng_header_edit'] == 'reply') {
if ($OVERRIDES['allow_ng_header_edit'] == 'reply') {
$allow_ng_header_edit_reply = true;
} else {
$allow_ng_header_edit_reply = false;
}
if($OVERRIDES['allow_ng_header_edit'] == 'both') {
if ($OVERRIDES['allow_ng_header_edit'] == 'both') {
$allow_ng_header_edit_post = true;
$allow_ng_header_edit_reply = true;
}
if($OVERRIDES['allow_ng_header_edit'] == 'none') {
if ($OVERRIDES['allow_ng_header_edit'] == 'none') {
$allow_ng_header_edit_post = false;
$allow_ng_header_edit_reply = false;
}
}
$allow_ngs_edit = false;
if($type == 'reply') {
if($allow_ng_header_edit_reply) {
if ($type == 'reply') {
if ($allow_ng_header_edit_reply) {
$allow_ngs_edit = true;
}
$max_crosspost = 12;
if (isset($OVERRIDES['max_crosspost_reply']) && $OVERRIDES['max_crosspost_reply'] > 0) {
$max_crosspost = $OVERRIDES['max_crosspost_reply'];
} else {
$max_crosspost = 12;
}
} else {
if($allow_ng_header_edit_post) {
if ($allow_ng_header_edit_post) {
$allow_ngs_edit = true;
}
$max_crosspost = 3;
if (isset($OVERRIDES['max_crosspost_post']) && $OVERRIDES['max_crosspost_post'] > 0) {
$max_crosspost = $OVERRIDES['max_crosspost_post'];
} else {
$max_crosspost = 3;
}
}
if (! isset($group) && isset($newsgroups)) {
@ -129,7 +142,8 @@ $thisgroup = _rawurldecode($_REQUEST['group']);
// Is this a reply to an article containing Followup-To?
if (isset($_REQUEST['fgroups'])) {
$thisgroup = $_REQUEST['fgroups'];
$thisgroup = preg_replace('!\s+!', ',', $_REQUEST['fgroups']);
$thisgroup = preg_replace('/\,+/', ',', $thisgroup);
}
$newsgroups = $thisgroup;
@ -140,7 +154,7 @@ if ($_REQUEST['returngroup']) {
}
$linkgroups = preg_split("/[\s,]+/", $returngroup);
foreach($linkgroups as $linkgroup) {
foreach ($linkgroups as $linkgroup) {
$linkgroup = trim($linkgroup);
if (get_section_by_group($linkgroup)) {
$returngroup = $linkgroup;
@ -261,9 +275,9 @@ if ($type == "post") {
$type = "retry";
$error = $text_post["missing_subject"];
}
if($allow_ngs_edit) {
if ($allow_ngs_edit) {
$grouptotal = preg_split("/( |\,)/", $newsgroups);
if(count($grouptotal) > $max_crosspost) {
if (count($grouptotal) > $max_crosspost) {
$type = "retry";
$error = "Too many newsgroups";
}
@ -306,9 +320,9 @@ if ($type == "post") {
if (isset($_FILES["photo"]) && $_FILES["photo"]["error"] == 0) {
$_FILES['photo']['name'] = preg_replace('/[^a-zA-Z0-9\.]/', '_', $_FILES['photo']['name']);
// There is an attachment to handle
$message = message_post(quoted_printable_encode($subject), $nemail . " (" . quoted_printable_encode($name) . ")", $newsgroups, $references_array, addslashes($body), $_POST['encryptthis'], $_POST['encryptto'], strtolower($name), $_POST['fromname'], null, true);
$message = message_post(quoted_printable_encode($subject), $nemail . " (" . quoted_printable_encode($name) . ")", $newsgroups, $references_array, addslashes($body), $_POST['encryptthis'], $_POST['encryptto'], strtolower($name), $_POST['fromname'], $followupto, true);
} else {
$message = message_post(quoted_printable_encode($subject), $nemail . " (" . quoted_printable_encode($name) . ")", $newsgroups, $references_array, addslashes($body), $_POST['encryptthis'], $_POST['encryptto'], strtolower($name), $_POST['fromname']);
$message = message_post(quoted_printable_encode($subject), $nemail . " (" . quoted_printable_encode($name) . ")", $newsgroups, $references_array, addslashes($body), $_POST['encryptthis'], $_POST['encryptto'], strtolower($name), $_POST['fromname'], $followupto);
}
// Article sent without errors, or duplicate?
if ((substr($message, 0, 3) == "240") || (substr($message, 0, 7) == "441 435")) {
@ -356,12 +370,12 @@ if ($type == "reply") {
}
// For Synchronet use (deprecated)
$fromname = $bodyzeile;
// Set quote reply format (On date somebody wrote:)
if(!isset($OVERRIDES['quote_head'])) {
if (!isset($OVERRIDES['quote_head'])) {
$OVERRIDES['quote_head'] = 'date_name';
}
switch($OVERRIDES['quote_head']) {
switch ($OVERRIDES['quote_head']) {
case 'date_name':
$bodyzeile = "On " . date("D, j M Y G:i:s O,", $head->date) . " " . $bodyzeile . $text_post["wrote_suffix"] . "\n\n";
break;
@ -377,15 +391,15 @@ if ($type == "reply") {
default:
$bodyzeile = "On " . date("D, j M Y G:i:s O,", $head->date) . " " . $bodyzeile . $text_post["wrote_suffix"] . "\n\n";
break;
}
for ($i = 0; $i <= count($body) - 1; $i ++) {
for ($i = 0; $i <= count($body) - 1; $i++) {
if ((isset($cutsignature)) && ($cutsignature == true) && ($body[$i] == '-- ')) {
break;
}
// Try not to quote blank lines at the end of all quotes
if ((trim($body[$i]) == "") && ($body[$i + 1] == '-- ' || $i >= count($body) - 1)) {} else {
if ((trim($body[$i]) == "") && ($body[$i + 1] == '-- ' || $i >= count($body) - 1)) {
} else {
// Remove spaces from starting quote '>' characters
$body = preg_replace("/^> >/", ">>", $body);
@ -424,7 +438,7 @@ if ($type == "reply") {
$show = 1;
$references = false;
if (isset($head->references[0])) {
for ($i = 0; $i <= count($head->references) - 1; $i ++) {
for ($i = 0; $i <= count($head->references) - 1; $i++) {
$references .= $head->references[$i] . " ";
}
}
@ -454,7 +468,11 @@ if ($show == 1) {
}
// show post form
$fieldencrypt = md5(rand(1, 10000000));
echo '<h1 class="np_post_headline">' . $text_post["group_head"] . group_display_name($newsgroups) . $text_post["group_tail"];
if ($type == 'reply') {
echo '<h1 class="np_post_headline">' . $text_post["group_head_reply"] . group_display_name($newsgroups) . $text_post["group_tail"];
} else {
echo '<h1 class="np_post_headline">' . $text_post["group_head"] . group_display_name($newsgroups) . $text_post["group_tail"];
}
if (! $found) {
echo ' (posting will fail - no such group)';
}
@ -476,27 +494,36 @@ if ($show == 1) {
echo '</tr><tr>';
if ($has_followup) {
echo '<td align="right">';
echo '<input type="radio" id="hasfollowup" name="fgroups" value="' . $head->followup . '" checked>';
echo '<td align="right"><b>Newsgroups:&nbsp;</b>';
echo '</td><td>';
echo '<label for="followup">' . $head->followup . ' (followup-to is set';
echo '<input type="radio" id="hasfollowup" name="fgroups" value="' . $head->followup . '" checked>';
echo '&nbsp;';
echo '<label for="followup">' . $head->followup . ' (Followup-To is set';
if (! get_section_by_group($head->followup)) {
echo ' but <b><i>posting will fail - no such group </i></b>';
}
echo ')</label></td>';
echo '</tr><tr>';
echo '<tr><td align="right">';
echo '<input type="radio" id="nofollowup" name="fgroups" value="' . $head->newsgroups . '">';
echo '<td align="right"><b>or:&nbsp;</b>';
echo '</td><td>';
echo '<input type="radio" id="nofollowup" name="fgroups" value="' . $head->newsgroups . '">';
echo '&nbsp;';
echo '<label for="newsgroups">' . $head->newsgroups . '</label>';
echo '</tr><tr>';
} else {
if(!isset($OVERRIDES['disable_ngs_edit']) || $OVERRIDES['disable_ngs_edit'] == false) {
if (!isset($OVERRIDES['disable_ngs_edit']) || $OVERRIDES['disable_ngs_edit'] == false) {
echo '<td align="right"><b>Newsgroups:</b></td>';
echo '<td>';
if($allow_ngs_edit) {
echo '<input tclass="post" type="text" name="fgroups" size="40" value="' . $newsgroups . '">';
echo "&nbsp;comma separated, max $max_crosspost groups";
if ($allow_ngs_edit) {
echo '<input tclass="post" type="text" name="fgroups" size="40" maxlength="240" value="' . $newsgroups . '">';
echo "&nbsp;(max $max_crosspost groups)";
echo '</td><td>';
echo '</tr><tr>';
echo '<td align="right"><b>Followup-To:</b></td>';
echo '<td>';
echo '<input tclass="post" type="text" name="followupto" size="40" value="' . $followupto . '" maxlength="80" placeholder="name of group to redirect replies">';
echo "&nbsp;(optional)";
} else {
echo '<input tclass="post" type="text" name="fgroups" size="40" value="' . $newsgroups . '" readonly>';
}
@ -511,18 +538,18 @@ if ($show == 1) {
echo '<td align="left">';
if (! isset($name) && $CONFIG['anonuser'])
$name = $CONFIG['anonusername'];
echo '<input class="post" type="text" name="' . md5($fieldencrypt . "name") . '"';
if (isset($name))
echo 'value="' . htmlspecialchars($name) . '"';
if ($logged_in && isset($name)) {
echo 'size="40" maxlength="40" readonly>';
file_put_contents($auth_log, "\n" . logging_prefix() . " AUTH SET for: " . $name, FILE_APPEND);
} else {
echo 'size="40" maxlength="40">';
file_put_contents($auth_log, "\n" . logging_prefix() . " AUTH NOT SET for: " . $name, FILE_APPEND);
}
if ($CONFIG['anonuser'])
echo '&nbsp;or "' . $CONFIG['anonusername'] . '" with no password';
echo '<input class="post" type="text" name="' . md5($fieldencrypt . "name") . '"';
if (isset($name))
echo 'value="' . htmlspecialchars($name) . '"';
if ($logged_in && isset($name)) {
echo 'size="40" maxlength="40" readonly>';
file_put_contents($auth_log, "\n" . logging_prefix() . " AUTH SET for: " . $name, FILE_APPEND);
} else {
echo 'size="40" maxlength="40">';
file_put_contents($auth_log, "\n" . logging_prefix() . " AUTH NOT SET for: " . $name, FILE_APPEND);
}
if ($CONFIG['anonuser'])
echo '&nbsp;or "' . $CONFIG['anonusername'] . '" with no password';
echo '</td></tr><tr>';
echo '<td align="right"><b>' . $text_post["password"] . '</b></td>';
echo '<td align="left">';
@ -581,27 +608,28 @@ if ($show == 1) {
}
echo '">';
?>
<script language="JavaScript">
<!--
function quoten() {
document.getElementById("postbody").value=document.getElementById("hidebody").value;
document.getElementById("hidebody").value="";
}
//-->
</script>
?>
<script language="JavaScript">
<!--
function quoten() {
document.getElementById("postbody").value = document.getElementById("hidebody").value;
document.getElementById("hidebody").value = "";
}
//
-->
</script>
<?php } ?>
<?php } ?>
<input type="submit" value="<?php echo $text_post["button_post"];?>">
<?php if ($setcookies==true) { ?>
&nbsp;
<input tabindex="100" type="Button" name="quote"
value="<?php echo $text_post["quote"]?>"
onclick="quoten(); this.style.visibility= 'hidden';">
&nbsp;
<input type="submit" value="<?php echo $text_post["button_post"]; ?>">
<?php if ($setcookies == true) { ?>
&nbsp;
<input tabindex="100" type="Button" name="quote"
value="<?php echo $text_post["quote"] ?>"
onclick="quoten(); this.style.visibility= 'hidden';">
&nbsp;
<?php
<?php
}
if (! isset($OVERRIDES['disable_attach'])) {
$OVERRIDES['disable_attach'] = array();
@ -618,19 +646,20 @@ function quoten() {
}
?>
</table>
</div>
<input type="hidden" name="type" value="post">
<input type="hidden" name="newsgroups"
value="<?php echo htmlspecialchars($newsgroups); ?>">
<input type="hidden" name="references"
value="<?php echo htmlentities($references); ?>">
<input type="hidden" name="group"
value="<?php echo htmlspecialchars($newsgroups); ?>">
<input type="hidden" name="returngroup"
value="<?php echo htmlspecialchars($thisgroup); ?>">
<input type="hidden" name="fielddecrypt"
value="<?php echo htmlspecialchars($fieldencrypt);?>">
</form>
</table>
</div>
<input type="hidden" name="type" value="post">
<input type="hidden" name="newsgroups"
value="<?php echo htmlspecialchars($newsgroups); ?>">
<input type="hidden" name="references"
value="<?php echo htmlentities($references); ?>">
<input type="hidden" name="group"
value="<?php echo htmlspecialchars($newsgroups); ?>">
<input type="hidden" name="returngroup"
value="<?php echo htmlspecialchars($thisgroup); ?>">
<input type="hidden" name="fielddecrypt"
value="<?php echo htmlspecialchars($fieldencrypt); ?>">
</form>
<?php } } ?>
<?php }
} ?>

View File

@ -16,11 +16,6 @@ return [
// Display short view of headers (only subject, name, date)
'short_headers' => true,
// Set to true to disable display and edit of newsgroups
// header when posting
// Default is false (newsgroups will display)
'disable_ngs_edit' => false,
// Log posts?
'enable_post_log' => false,
@ -50,6 +45,18 @@ return [
// If not set, default = 'post'
'allow_ng_header_edit' => 'post',
// How many groups to allow in Newsgroups: header
// Post and Reply may be different.
// Default is post = 3, reply = 12
'max_crosspost_post' => 3,
'max_crosspost_reply' => 6,
// This will disable newsgroups editing entirely if true
// Set to true to disable display and edit of newsgroups
// header when posting
// Default is false (newsgroups will display)
'disable_ngs_edit' => false,
// Reserved aliases
'reserved_names' => array("admin", "sysop", "rslight"),

View File

@ -1,6 +1,6 @@
<?php
include "config.inc.php";
include ("$file_newsportal");
include("$file_newsportal");
// Check timer
$tmr = $spooldir . '/' . $config_name . '-expire-timer';
@ -112,7 +112,7 @@ foreach ($grouplist as $groupline) {
}
}
add_to_history($group, $row['number'], $row['msgid'], $status, $statusdate, $statusreason, $statusnotes);
$i ++;
$i++;
}
$stmt->execute([
':newsgroup' => $group,
@ -179,6 +179,9 @@ if (file_exists($rdns_file)) {
}
}
// Remove posted cache db
unlink($spooldir . '/posted_articles.dat');
unlink($lockfile);
touch($tmr);
@ -217,7 +220,7 @@ function convert_max_articles_to_days($group)
$i = 0;
$found = false;
while ($row = $overview_query->fetch()) {
$i ++;
$i++;
if ($i == $count) {
$found = $row;
}

View File

@ -62,7 +62,8 @@ function interact($msgsock, $use_crypto = false)
}
}
if (isset($command[1])) {}
if (isset($command[1])) {
}
if ($command[0] == 'date') {
$msg = '111 ' . date('YmdHis') . "\r\n";
fwrite($msgsock, $msg, strlen($msg));
@ -248,7 +249,7 @@ function become_daemon()
{
$pid = pcntl_fork();
if ($pid == - 1) {
if ($pid == -1) {
/* fork failed */
echo "fork failure!\n";
exit();
@ -281,26 +282,26 @@ function prepare_post($filename)
foreach ($message as $line) {
if (trim($line) == "" && $lines > 0) {
$is_header = 0;
$lines ++;
$lines++;
}
if ($lines > 0 && $is_header == 0) {
break;
}
if (stripos($line, "From: ") === 0) {
$lines ++;
$lines++;
$head_from = true;
continue;
}
if (stripos($line, "Newsgroups: ") === 0) {
$ngroups = explode(': ', $line);
$lines ++;
$lines++;
$head_newsgroups = true;
continue;
}
if (stripos($line, "Subject: ") === 0) {
$sub = explode(': ', $line);
$subject = $sub[1];
$lines ++;
$lines++;
$head_subject = true;
continue;
}
@ -343,7 +344,15 @@ function prepare_post($filename)
function process_post($message, $group)
{
global $logfile, $spooldir, $config_dir, $CONFIG, $nntp_group;
global $logfile, $spooldir, $config_dir, $logfile, $CONFIG, $nntp_group;
$posted_db = $spooldir . '/posted_articles.dat';
if (file_exists($posted_db)) {
$posted_articles = unserialize(file_get_contents($posted_db));
} else {
$posted_articles = array();
}
$no_mid = 1;
$no_date = 1;
$no_org = 1;
@ -360,9 +369,9 @@ function process_post($message, $group)
$bytes = $bytes + mb_strlen($line, '8bit');
if (trim($line) == "" && $lines > 0) {
$is_header = 0;
$lines ++;
$lines++;
} else {
$lines ++;
$lines++;
}
if ($is_header == 0) {
$body .= $line . "\n";
@ -438,6 +447,26 @@ function process_post($message, $group)
} else {
$msgid = $mid[1];
}
/* Find section for posting */
$section = get_section_by_group($group);
// Get server details for this section
if (file_exists($config_dir . $section . '.inc.php')) {
$config_file = $config_dir . $section . '.inc.php';
} else {
$config_file = $config_dir . 'rslight.inc.php';
}
$THIS_CONFIG = include($config_file);
$this_server = $THIS_CONFIG['remote_server'] . $THIS_CONFIG['remote_port'];
if (isset($posted_articles[$msgid][$this_server])) {
$previously_posted = true;
} else {
$previously_posted = false;
$posted_articles[$msgid][$this_server] = true;
}
/*
* SPAM CHECK
*/
@ -455,11 +484,14 @@ function process_post($message, $group)
$response = "441 Posting failed (Exceeds Spam Score)\r\n";
return $response;
}
/* Find section for posting */
$section = get_section_by_group($group);
@mkdir($spooldir . "/" . $section . "/outgoing", 0755, 'recursive');
$postfilename = $spooldir . '/' . $section . '/outgoing/' . $msgid . '.msg';
if(file_exists($postfilename)) {
$postfilename_previous = true;
} else {
$postfilename_previous = false;
}
$postfilehandle = fopen($postfilename, 'w');
if ($no_date == 1) {
$article_date = time();
@ -485,9 +517,9 @@ function process_post($message, $group)
foreach ($message as $line) {
if (trim($line) == "" && $lines > 0) {
$is_header = 0;
$lines ++;
$lines++;
} else {
$lines ++;
$lines++;
}
if (stripos($line, "Newsgroups: ") === 0 && $is_header == 1) {
fputs($postfilehandle, "Newsgroups: " . $newsgroups . "\r\n");
@ -508,10 +540,25 @@ function process_post($message, $group)
fclose($postfilehandle);
chmod($postfilename, 0600);
unlink($filename);
if ($section == "") {
$response = "441 Posting failed (section not found)\r\n";
file_put_contents($logfile, "\n" . format_log_date() . " " . trim($response) . " for " . $group, FILE_APPEND);
} else {
$response = insert_article($section, $group, $postfilename, $subject, $from[1], $article_date, $date_rep, $msgid, $references, $bytes, $lines, $xref, $body);
// Only add to another section if a different remote server is used
// else only add to local database for next group
if ($previously_posted) {
file_put_contents($logfile, "\n" . format_log_date() . " NOT adding article to: " . $section . "/outgoing - Already Posted", FILE_APPEND);
if(!$postfilename_previous) {
unlink($postfilename);
} else {
file_put_contents($logfile, "\n" . format_log_date() . " NOT DELETING: " . $section . "/outgoing - Already Exists", FILE_APPEND);
}
} else {
file_put_contents($posted_db, serialize($posted_articles));
file_put_contents($logfile, "\n" . format_log_date() . " Adding article to: " . $section . "/outgoing", FILE_APPEND);
}
}
return $response;
}
@ -525,11 +572,11 @@ function get_next($nntp_group)
}
$ok_article = get_article_list($nntp_group);
sort($ok_article);
$last = $ok_article[key(array_slice($ok_article, - 1, 1, true))];
$last = $ok_article[key(array_slice($ok_article, -1, 1, true))];
if (($nntp_article + 1) > $last) {
$response = "421 No next article to retrieve\r\n";
} else {
$nntp_article ++;
$nntp_article++;
$database = $spooldir . '/articles-overview.db3';
$table = 'overview';
$dbh = overview_db_open($database, $table);
@ -556,11 +603,11 @@ function get_last($nntp_group)
}
$ok_article = get_article_list($nntp_group);
rsort($ok_article);
$first = $ok_article[key(array_slice($ok_article, - 1, 1, true))];
$first = $ok_article[key(array_slice($ok_article, -1, 1, true))];
if (($nntp_article - 1) < $first || ! isset($nntp_article)) {
$response = "422 No previous article to retrieve\r\n";
} else {
$nntp_article --;
$nntp_article--;
$database = $spooldir . '/articles-overview.db3';
$table = 'overview';
$dbh = overview_db_open($database, $table);
@ -617,7 +664,7 @@ function get_xhdr($header, $articles)
$ok_article = get_article_list($nntp_group);
// fclose($group_overviewfp);
sort($ok_article);
$last = $ok_article[key(array_slice($ok_article, - 1, 1, true))];
$last = $ok_article[key(array_slice($ok_article, -1, 1, true))];
if (! is_numeric($last))
$last = 0;
} else {
@ -625,7 +672,7 @@ function get_xhdr($header, $articles)
}
}
$msg = "221 Header information for " . $header . " follows (from articles)\r\n";
for ($i = $first; $i <= $last; $i ++) {
for ($i = $first; $i <= $last; $i++) {
$article_full_path = $thisgroup . '/' . strval($i);
$data = extract_header_line($article_full_path, $header, $tmpgroup, $i);
if ($data !== false) {
@ -719,7 +766,7 @@ function get_xover($articles, $msgsock)
if (strpos($articles, "-")) {
$ok_article = get_article_list($nntp_group);
sort($ok_article);
$last = $ok_article[key(array_slice($ok_article, - 1, 1, true))];
$last = $ok_article[key(array_slice($ok_article, -1, 1, true))];
if (! is_numeric($last)) {
$last = 0;
}
@ -737,7 +784,7 @@ function get_xover($articles, $msgsock)
$dbh = overview_db_open($database, $table);
$stmt = $dbh->prepare("SELECT * FROM $table WHERE newsgroup=:thisgroup AND number=:number"); // Why doesn't BETWEEN work properly here?
for ($i = $first; $i <= $last; $i ++) {
for ($i = $first; $i <= $last; $i++) {
$stmt->execute([
'thisgroup' => $nntp_group,
':number' => $i
@ -972,7 +1019,7 @@ function get_listgroup($nntp_group, $msgsock)
// fclose($group_overviewfp);
$count = count($ok_article);
sort($ok_article);
$last = $ok_article[key(array_slice($ok_article, - 1, 1, true))];
$last = $ok_article[key(array_slice($ok_article, -1, 1, true))];
$first = $ok_article[0];
if (! is_numeric($last))
$last = 0;
@ -1009,7 +1056,7 @@ function get_group($change_group)
$ok_article = get_article_list($nntp_group);
$count = count($ok_article);
sort($ok_article);
$last = $ok_article[key(array_slice($ok_article, - 1, 1, true))];
$last = $ok_article[key(array_slice($ok_article, -1, 1, true))];
$first = $ok_article[0];
if (! is_numeric($last))
$last = 0;
@ -1033,7 +1080,7 @@ function get_newgroups($mode)
continue;
$ok_article = get_article_list($nntp_group);
sort($ok_article);
$last = $ok_article[key(array_slice($ok_article, - 1, 1, true))];
$last = $ok_article[key(array_slice($ok_article, -1, 1, true))];
$first = $ok_article[0];
if (! is_numeric($last))
$last = 0;
@ -1092,7 +1139,7 @@ function get_list($mode, $ngroup, $msgsock)
continue;
$ok_article = get_article_list($findgroup);
sort($ok_article);
$last = $ok_article[key(array_slice($ok_article, - 1, 1, true))];
$last = $ok_article[key(array_slice($ok_article, -1, 1, true))];
$first = $ok_article[0];
if (! is_numeric($last)) {
$last = 0;
@ -1279,7 +1326,7 @@ function insert_article($section, $nntp_group, $filename, $subject_i, $from_i, $
// End Overview
$grouplist = file($local_groupfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$saveconfig = fopen($local_groupfile, 'w+');
$local ++;
$local++;
foreach ($grouplist as $savegroup) {
$name = explode(':', $savegroup);
if (strcmp($name[0], $nntp_group) == 0) {
@ -1291,7 +1338,7 @@ function insert_article($section, $nntp_group, $filename, $subject_i, $from_i, $
fclose($saveconfig);
unlink($sn_lockfile);
$return_val = "240 Article received OK (posted)\r\n";
file_put_contents($logfile, "\n" . format_log_date() . " " . $nntp_group . ":" . -- $local . " " . $return_val, FILE_APPEND);
file_put_contents($logfile, "\n" . format_log_date() . " " . $nntp_group . ":" . --$local . " " . trim($return_val), FILE_APPEND);
return ($return_val);
}
@ -1407,4 +1454,3 @@ function create_node_ssl_cert($pemfile)
chmod($pubkeyfile, 0660);
chmod($pubkeytxtfile, 0660);
}
?>

View File

@ -90,7 +90,6 @@ function post_articles($ns, $spooldir)
$response = line_read($ns);
if (strcmp(substr($response, 0, 3), "441") == 0) {
rename($outgoing_dir . $message, $fail_dir . $message);
// $removed = unlink($outgoing_dir . $message);
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " POST Failed: " . $response, FILE_APPEND);
}
if (strcmp(substr($response, 0, 3), "240") == 0) {
@ -101,7 +100,7 @@ function post_articles($ns, $spooldir)
continue;
}
}
prune_dir_by_days($outgoing_dir, 7);
prune_dir_by_days($fail_dir, 7);
return "Messages sent\r\n";
}
?>

View File

@ -33,6 +33,27 @@ echo '<h1 class="np_thread_headline">';
echo '<a href="mail.php" target=' . $frame['menu'] . '>mail</a> / ';
echo htmlspecialchars($_POST['username']) . '</h1>';
$name = '';
$logged_in = false;
if (! isset($_POST['username'])) {
$_POST['username'] = $_COOKIE['mail_name'];
}
$name = trim(strtolower($_POST['username']));
if (! isset($_POST['password'])) {
$_POST['password'] = null;
}
if (! isset($_COOKIE['mail_auth'])) {
$_COOKIE['mail_auth'] = null;
}
$logged_in = verify_logged_in(trim(strtolower($name)));
if(!$logged_in) {
if ((password_verify($name . $keys[0] . get_user_config($name, 'encryptionkey'), $_COOKIE['mail_auth'])) || (password_verify($name . $keys[1] . get_user_config($name, 'encryptionkey'), $_COOKIE['mail_auth']))) {
$logged_in = true;
}
}
echo '<table cellpadding="0" cellspacing="0" class="np_buttonbar"><tr>';
// New Message button
if ($_POST['command'] !== 'Send') {
@ -57,32 +78,12 @@ if (isset($_POST['command']) && $_POST['command'] == 'Message') {
}
echo '<td width=100%></td></tr></table>';
if (isset($_POST['username'])) {
$name = $_POST['username'];
// Save name in cookie
if ($setcookies == true) {
setcookie("mail_name", stripslashes($name), time() + (3600 * 24 * 90), "/");
}
} else {
if ($setcookies) {
if ((isset($_COOKIE["mail_name"])) && (! isset($name))) {
$name = $_COOKIE["mail_name"];
} else {
$name = '';
}
}
}
$logged_in = false;
if(trim($name) != '') {
$logged_in = verify_logged_in(trim(strtolower($name)));
}
if ($logged_in !== true) {
echo '<table border="0" align="center" cellpadding="0" cellspacing="1">';
echo '<form name="form1" method="post" action="user.php" enctype="multipart/form-data">';
// echo '<form name="form1" method="post" action="mail.php" enctype="multipart/form-data">';
echo '<tr><td><strong>Please Login<br /></strong></td></tr>';
echo '<tr><td>Username:</td><td><input name="username" type="text" id="username" value="' . $name . '"></td></tr>';
echo '<tr><td>Username:</td><td><input name="username" type="text" id="username" value="' . $_POST['username'] . '"></td></tr>';
echo '<tr><td>Password:</td><td><input name="password" type="password" id="password"></td></tr>';
echo '<td><input name="command" type="hidden" id="command" value="Login" readonly="readonly"></td>';
echo '<td><input name="source" type="hidden" id="source" value="Mail:mail.php" readonly="readonly"></td>';

View File

@ -88,9 +88,6 @@ if (isset($_FILES['photo'])) {
}
echo '<table border="0" align="center" cellpadding="0" cellspacing="1">';
//echo '<form name="form1" method="post" action="user.php" enctype="multipart/form-data">';
echo '<form name="form1" method="post" action="upload.php" enctype="multipart/form-data">';
if (! isset($_POST['username'])) {
$_POST['username'] = '';
}
@ -98,13 +95,20 @@ if (! isset($_POST['password'])) {
$_POST['password'] = '';
}
if (! $logged_in && ! check_bbs_auth($_POST['username'], $_POST['password'])) {
echo '<tr><td><strong>Please Login to Upload<br /></strong></td></tr>';
echo '<tr><td>Username:</td><td><input name="username" type="text" id="username" value="' . $name . '"></td></tr>';
echo '<form name="form1" method="post" action="user.php" enctype="multipart/form-data">';
echo '<tr><td><strong>Please Login<br /></strong></td></tr>';
echo '<tr><td>Username:</td><td><input name="username" type="text" id="username" value="' . $_POST['username'] . '"></td></tr>';
echo '<tr><td>Password:</td><td><input name="password" type="password" id="password"></td></tr>';
echo '<td><input name="command" type="hidden" id="command" value="Login" readonly="readonly"></td>';
echo '<td><input name="source" type="hidden" id="source" value="Upload:upload.php" readonly="readonly"></td>';
echo '<td><input name="command" type="hidden" id="command" value="Upload" readonly="readonly"></td>';
echo '<input type="hidden" name="key" value="' . password_hash($CONFIG['thissitekey'] . $name, PASSWORD_DEFAULT) . '">';
echo '<td>&nbsp;</td>';
echo '<td><input type="submit" name="Submit" value="Login"></td>';
echo '</tr>';
echo '</form>';
echo '</form>';
} else {
echo '<form name="form1" method="post" action="upload.php" enctype="multipart/form-data">';
echo '<tr><td><strong>Logged in as ' . $_POST['username'] . '<br />(max size=2MB)</strong></td></tr>';
echo '<td><input name="command" type="hidden" id="command" value="Upload" readonly="readonly"></td>';
echo '<input type="hidden" name="key" value="' . password_hash($CONFIG['thissitekey'] . $name, PASSWORD_DEFAULT) . '">';
@ -113,9 +117,9 @@ if (! $logged_in && ! check_bbs_auth($_POST['username'], $_POST['password'])) {
echo '<tr><td><input type="file" name="photo" id="fileSelect" value="fileSelect" accept="image/*,audio/*,text/*,application/*"></td>
';
echo '<td>&nbsp;<input type="submit" name="Submit" value="Upload"></td>';
echo '</form>';
}
echo '</tr>';
echo '</form>';
echo '</table>';
echo '</body></html>';
?>