Only changes to indentation. No other changes.

This commit is contained in:
Retro_Guy 2023-08-19 15:33:05 -07:00
parent 747227931a
commit 17e8a5dd5e
21 changed files with 5982 additions and 5758 deletions

View File

@ -25,7 +25,8 @@
if (trim($findsection) !== $config_name) {
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
$link = "https";
else $link = "http";
else
$link = "http";
$link .= "://";
$link .= $_SERVER['HTTP_HOST'];
$link .= $_SERVER['REQUEST_URI'];
@ -38,7 +39,9 @@
$database = $spooldir . '/articles-overview.db3';
$articles_dbh = overview_db_open($database);
$articles_query = $articles_dbh->prepare('SELECT * FROM overview WHERE msgid=:messageid');
$articles_query->execute(['messageid' => $id]);
$articles_query->execute([
'messageid' => $id
]);
$found = 0;
while ($row = $articles_query->fetch()) {
$id = $row['number'];
@ -120,14 +123,12 @@ if($message) {
// If no page is set, lets look, if we can calculate the page by
// the message-number
if (! isset($first)) {
$first=intval(array_search($id,$subthread)/$articleflat_articles_per_page)*
$articleflat_articles_per_page+1;
$first = intval(array_search($id, $subthread) / $articleflat_articles_per_page) * $articleflat_articles_per_page + 1;
}
// which articles are exactly on this page?
$pageids = array();
for($i=$first-1; (($i<count($subthread)) &&
($i<$first+$articleflat_articles_per_page-1)); $i++) {
for ($i = $first - 1; (($i < count($subthread)) && ($i < $first + $articleflat_articles_per_page - 1)); $i ++) {
$pageids[] = $subthread[$i];
}
@ -161,13 +162,7 @@ if($message) {
echo '<a name="' . $subid . '"> </a>';
message_show($group, $subid, 0, $message, $articleflat_chars_per_articles);
if ((! $CONFIG['readonly']) && ($message)) {
echo '<form action="'.$file_post.'">'.
'<input type="hidden" name="id" value="'.urlencode($subid).'">'.
'<input type="hidden" name="type" value="reply">'.
'<input type="hidden" name="group" value="'.urlencode($group).'">'.
'<input type="submit" value="'.$text_article["button_answer"].
'">'.
'</form>';
echo '<form action="' . $file_post . '">' . '<input type="hidden" name="id" value="' . urlencode($subid) . '">' . '<input type="hidden" name="type" value="reply">' . '<input type="hidden" name="group" value="' . urlencode($group) . '">' . '<input type="submit" value="' . $text_article["button_answer"] . '">' . '</form>';
}
}
// navigation line

View File

@ -49,10 +49,7 @@ if(isset($frames_on) && $frames_on === true) {
include "head.inc";
// has the user read-rights on this article?
if((function_exists("npreg_group_has_read_access") &&
!npreg_group_has_read_access($group)) ||
(function_exists("npreg_group_is_visible") &&
!npreg_group_is_visible($group))) {
if ((function_exists("npreg_group_has_read_access") && ! npreg_group_has_read_access($group)) || (function_exists("npreg_group_is_visible") && ! npreg_group_is_visible($group))) {
die("access denied");
}

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,8 @@
header("Expires: " . gmdate("D, d M Y H:i:s", time() + (600)) . " GMT");
header("Cache-Control: max-age=100");
header("Pragma: cache");
/* rocksolid overboard - overboard for rslight
/*
* rocksolid overboard - overboard for rslight
* Download: https://news.novabbs.com/getrslight
*
* E-Mail: retroguy@novabbs.com
@ -158,7 +159,9 @@ foreach($grouplist as $findgroup) {
}
$thisgroup = preg_replace('/\./', '/', $findgroup);
if ($dbh) {
$query->execute(['findgroup' => $findgroup]);
$query->execute([
'findgroup' => $findgroup
]);
$i = 0;
while (($overviewline = $query->fetch()) !== false) {
$articles[] = $spoolpath . $thisgroup . '/' . $overviewline['number'];
@ -270,7 +273,8 @@ show_overboard_footer(null, $results, null);
echo '</body></html>';
expire_overboard($cachefile);
function expire_overboard($cachefile) {
function expire_overboard($cachefile)
{
global $article_age, $logfile, $config_name, $prune, $this_overboard;
if (! isset($this_overboard['expire'])) {
$this_overboard['expire'] = time();
@ -293,7 +297,8 @@ function expire_overboard($cachefile) {
}
}
function display_threads($threads, $oldest) {
function display_threads($threads, $oldest)
{
global $CONFIG, $thissite, $logfile, $config_name, $snippetlength, $maxdisplay, $prune, $this_overboard;
echo '<table cellspacing="0" width="100%" class="np_results_table">';
if (! isset($threads)) {
@ -345,7 +350,8 @@ function display_threads($threads, $oldest) {
return ($results);
}
function show_overboard_header($grouplist) {
function show_overboard_header($grouplist)
{
global $text_thread, $frame, $text_article, $file_index, $file_thread, $user_time;
if (isset($_GET['thisgroup'])) {
@ -409,7 +415,8 @@ if (isset($_GET['thisgroup'])) {
}
}
function show_overboard_footer($stats, $results, $iscached) {
function show_overboard_footer($stats, $results, $iscached)
{
global $user_time, $rslight_version;
if (isset($user_time)) {
$recent = 'new';

View File

@ -1,5 +1,6 @@
<?php
/* rslight NNTP<->HTTP Gateway
/*
* rslight NNTP<->HTTP Gateway
* Download: https://news.novabbs.com/getrslight
*
* Based on Newsportal by Florian Amrhein
@ -21,7 +22,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
session_start();
include "config.inc.php";
$CONFIG = include ($config_file);
@ -37,7 +37,8 @@ $CONFIG = include($config_file);
@$abspeichern = $_REQUEST["abspeichern"];
@$references = $_REQUEST["references"];
@$id = $_REQUEST["id"];
if (!isset($group)) $group=$newsgroups;
if (! isset($group))
$group = $newsgroups;
include "auth.inc";
if ($post_captcha)
@ -73,10 +74,7 @@ $returngroup = preg_split("/( |\,)/", $newsgroups, 2);
}
// has the user write-rights on the newsgroups?
if((function_exists("npreg_group_has_read_access") &&
!npreg_group_has_read_access($newsgroups)) ||
(function_exists("npreg_group_has_write_access") &&
!npreg_group_has_write_access($newsgroups))) {
if ((function_exists("npreg_group_has_read_access") && ! npreg_group_has_read_access($newsgroups)) || (function_exists("npreg_group_has_write_access") && ! npreg_group_has_write_access($newsgroups))) {
die("access denied");
}
@ -199,17 +197,12 @@ 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),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), null, 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));
$message = message_post(quoted_printable_encode($subject), $nemail . " (" . quoted_printable_encode($name) . ")", $newsgroups, $references_array, addslashes($body), $_POST['encryptthis'], $_POST['encryptto'], strtolower($name));
}
// 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>';
echo '<p>' . $text_post["message_posted2"] . '</p>';
if (isset($CONFIG['auto_return']) && ($CONFIG['auto_return'] == true)) {
@ -259,11 +252,9 @@ if ($type=="reply") {
// For Synchronet use
$fromname = $bodyzeile;
$bodyzeile=$text_post["wrote_prefix"].$bodyzeile.
$text_post["wrote_suffix"]."\n\n";
$bodyzeile = $text_post["wrote_prefix"] . $bodyzeile . $text_post["wrote_suffix"] . "\n\n";
for ($i = 0; $i <= count($body) - 1; $i ++) {
if((isset($cutsignature)) && ($cutsignature==true) &&
($body[$i]=='-- '))
if ((isset($cutsignature)) && ($cutsignature == true) && ($body[$i] == '-- '))
break;
if (trim($body[$i]) != "") {
if ($body[$i][0] == '>')
@ -306,26 +297,34 @@ if ($type=="retry") {
if ($show == 1) {
if ($newsgroups == "") {
echo $text_post["followup_not_allowed"];
echo " " . $newsgroups;
} else {
// 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"].'</h1>';
echo '<h1 class="np_post_headline">' . $text_post["group_head"] . group_display_name($newsgroups) . $text_post["group_tail"] . '</h1>';
if (isset($error)) echo "<p>$error</p>"; ?>
if (isset($error))
echo "<p>$error</p>";
?>
<form action="<?php echo $file_post?>" method="post" name="postform" enctype="multipart/form-data">
<form action="<?php echo $file_post?>" method="post" name="postform"
enctype="multipart/form-data">
<div class="np_post_header">
<table>
<tr><td align="right"><b><?php echo $text_header["subject"] ?></b></td>
<td><input class="post" type="text" name="<?php echo md5($fieldencrypt."subject")?>" value="<?php
echo htmlspecialchars($subject);?>" size="40" maxlength="80"></td></tr>
<tr><td align="right"><b><?php echo $text_post["name"]?></b></td>
<tr>
<td align="right"><b><?php echo $text_header["subject"] ?></b></td>
<td><input class="post" type="text"
name="<?php echo md5($fieldencrypt."subject")?>"
value="<?php
echo htmlspecialchars($subject);
?>" size="40"
maxlength="80"></td>
</tr>
<tr>
<td align="right"><b><?php echo $text_post["name"]?></b></td>
<td align="left">
<?php
if (! isset($name) && $CONFIG['anonuser'])
@ -334,31 +333,36 @@ echo htmlspecialchars($subject);?>" size="40" maxlength="80"></td></tr>
echo htmlspecialchars($name);
} else {
echo '<input class="post" type="text" name="' . md5($fieldencrypt . "name") . '"';
if (isset($name)) echo 'value="'.
htmlspecialchars(stripslashes($name)).'"';
if (isset($name))
echo 'value="' . htmlspecialchars(stripslashes($name)) . '"';
echo 'size="40" maxlength="40">';
if ($CONFIG['anonuser'])
echo '&nbsp;or "' . $CONFIG['anonusername'] . '" with no password';
}
?>
</td></tr>
<tr><td align="right"><b><?php echo $text_post["password"]?></b></td>
</td>
</tr>
<tr>
<td align="right"><b><?php echo $text_post["password"]?></b></td>
<td align="left">
<?php
echo '<input class="post" type="password" name="' . md5($fieldencrypt . "email") . '"';
// if (isset($email)) echo 'value="'.htmlspecialchars(stripslashes($email)).'"';
echo 'size="40" maxlength="40">';
?>
</td</tr>
</td
</tr>
<?php
// May we post encrypted messages to this group?
if(check_encryption_groups($newsgroups)) { ?>
<tr><td align="left">
<input type="checkbox" name="encryptthis" value="encrypt">
<b>Encrypt to:</b>
</td>
<td><input type="text" name="encryptto" value="<?php echo $fromname;?>"></td>
if (check_encryption_groups($newsgroups)) {
?>
<tr>
<td align="left"><input type="checkbox" name="encryptthis"
value="encrypt"> <b>Encrypt to:</b></td>
<td><input type="text" name="encryptto"
value="<?php echo $fromname;?>"></td>
</tr>
<?php
}
@ -368,19 +372,26 @@ echo htmlspecialchars($subject);?>" size="40" maxlength="80"></td></tr>
<div class="np_post_body">
<table>
<tr><td><b><?php echo $text_post["message"];?></b><br>
<textarea class="postbody" id="postbody" name="<?php echo md5($fieldencrypt."body")?>" wrap="soft"><?php
<tr>
<td><b><?php echo $text_post["message"];?></b><br> <textarea
class="postbody" id="postbody"
name="<?php echo md5($fieldencrypt."body")?>" wrap="soft"><?php
if ((isset($bodyzeile)) && ($post_autoquote))
echo htmlspecialchars($bodyzeile);
if (is_string($body))
echo htmlspecialchars($body);
?>
</textarea></td></tr>
<tr><td>
</textarea></td>
</tr>
<tr>
<td>
<?php if(!$post_autoquote) { ?>
<input type="hidden" id="hidebody" value="<?php
if (isset($bodyzeile)) echo htmlspecialchars(stripslashes($bodyzeile)); ?>">
<input type="hidden" id="hidebody"
value="<?php
if (isset($bodyzeile))
echo htmlspecialchars(stripslashes($bodyzeile));
?>">
<script language="JavaScript">
<!--
@ -395,29 +406,38 @@ function quoten() {
<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="checkbox" name="abspeichern" value="ja" checked>
&nbsp;<input tabindex="100" type="Button" name="quote"
value="<?php echo $text_post["quote"]?>"
onclick="quoten(); this.style.visibility= 'hidden';"> &nbsp;<input
type="checkbox" name="abspeichern" value="ja" checked>
<?php echo $text_post["remember"];?>
<?php } ?>
&nbsp;<input type="file" name="photo" id="fileSelect" value="fileSelect" accept="image/*,audio/*,text/*,application/pdf">
&nbsp;<input type="file" name="photo" id="fileSelect" value="fileSelect"
accept="image/*,audio/*,text/*,application/pdf">
</td>
</tr>
<?php if($post_captcha) {
<?php
if ($post_captcha) {
echo '<tr><td>';
echo captcha::form($text_post["captchainfo1"], $text_post["captchainfo2"]);
echo '</td></tr>';
} ?>
}
?>
</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($head->followup); ?>">
<input type="hidden" name="fielddecrypt" value="<?php echo htmlspecialchars($fieldencrypt);?>">
<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($head->followup); ?>"> <input
type="hidden" name="fielddecrypt"
value="<?php echo htmlspecialchars($fieldencrypt);?>">
</form>
<?php } } ?>

View File

@ -203,7 +203,8 @@ $results=0;
$fromline = address_decode(headerDecode($overviewline['name']), "nowhere");
if (! isset($fromline[0]["personal"])) {
$lastname=$fromline[0]["mailbox"];;
$lastname = $fromline[0]["mailbox"];
;
} else {
$lastname = $fromline[0]["personal"];
}
@ -221,7 +222,8 @@ $results=0;
echo '</p>';
$fromline = address_decode($overviewline['name'], "nowhere");
if (!isset($fromline[0]["host"])) $fromline[0]["host"]="";
if (! isset($fromline[0]["host"]))
$fromline[0]["host"] = "";
$name_from = $fromline[0]["mailbox"] . "@" . $fromline[0]["host"];
$name_username = $fromline[0]["mailbox"];
if (! isset($fromline[0]["personal"])) {
@ -262,7 +264,8 @@ ob_end_clean();
echo $thispage;
function get_body_search($group, $terms) {
function get_body_search($group, $terms)
{
GLOBAL $CONFIG, $config_name, $spooldir, $snippet_size;
$terms = preg_replace("/'/", ' ', $terms);
$terms = trim($terms);
@ -298,17 +301,16 @@ function get_body_search($group, $terms) {
$dbh = null;
}
// do not perform a usort of an empty search result
if ($overview != null)
{
usort($overview,
function($a, $b) {
if ($overview != null) {
usort($overview, function ($a, $b) {
return $a['rank'] <=> $b['rank'];
});
}
return $overview;
}
function get_header_search($group, $terms) {
function get_header_search($group, $terms)
{
GLOBAL $CONFIG, $config_name, $spooldir, $snippet_size;
$terms = preg_replace('/\%/', '\%', $terms);
$searchterms = "%" . $terms . "%";
@ -379,7 +381,8 @@ function get_header_search($group, $terms) {
return $overview;
}
function highlightStr($haystack, $needle) {
function highlightStr($haystack, $needle)
{
preg_match_all("/$needle+/i", $haystack, $matches);
if (is_array($matches[0]) && count($matches[0]) >= 1) {
foreach ($matches[0] as $match) {

View File

@ -23,7 +23,8 @@ if(isset($_REQUEST["last"]))
if (trim($findsection) !== $config_name) {
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
$link = "https";
else $link = "http";
else
$link = "http";
$link .= "://";
$link .= $_SERVER['HTTP_HOST'];
$link .= $_SERVER['REQUEST_URI'];
@ -43,10 +44,7 @@ include "head.inc";
$CONFIG = include ($config_file);
if((!function_exists("npreg_group_has_read_access") ||
npreg_group_has_read_access($group)) &&
(!function_exists("npreg_group_is_visible") ||
npreg_group_is_visible($group))) {
if ((! function_exists("npreg_group_has_read_access") || npreg_group_has_read_access($group)) && (! function_exists("npreg_group_is_visible") || npreg_group_is_visible($group))) {
if (isset($frames_on) && $frames_on === true) {
?>
@ -86,10 +84,7 @@ if(isset($frames_on) && $frames_on === true) {
echo '</form>';
echo '</td>';
}
if (!$CONFIG['readonly'] &&
(!function_exists("npreg_group_has_write_access") ||
npreg_group_has_write_access($group)))
{
if (! $CONFIG['readonly'] && (! function_exists("npreg_group_has_write_access") || npreg_group_has_write_access($group))) {
// New Thread button
echo '<td>';
echo '<form action="' . $file_post . '">';

View File

@ -1,5 +1,4 @@
<?php
include "config.inc.php";
include ("$file_newsportal");
include $config_dir . "/gpg.conf";
@ -13,7 +12,7 @@ if (posix_getsid($pid) === false || !is_file($lockfile)) {
file_put_contents($lockfile, getmypid()); // create lockfile
} else {
print "BBSmail currently running\n";
exit;
exit();
}
$bbsmail_path = $spooldir . "/bbsmail/";
@ -56,9 +55,14 @@ $gnupg_validity = array(
"5" => "Validity: ULTIMATE"
);
/***** Receive mail *****/
/**
* *** Receive mail ****
*/
unset($messages);
$messages = array_diff(scandir($bbsmail_path.'/in/'), array('..', '.'));
$messages = array_diff(scandir($bbsmail_path . '/in/'), array(
'..',
'.'
));
foreach ($messages as $message) {
$filename = explode($bbsmail_path . '/in/', $message);
$filename = $filename[0];
@ -154,7 +158,9 @@ $gnupg_validity = array(
}
}
/***** Send key to group *****/
/**
* *** Send key to group ****
*/
// How often to send key to group
// in seconds (default 1 month)
$mail_update_time = 2592000;
@ -173,7 +179,8 @@ if($do_mail_update == true) {
touch($spooldir . '/bbs-mail-update-timer');
}
function import_user_message($from, $rcpt, $date, $subject, $message) {
function import_user_message($from, $rcpt, $date, $subject, $message)
{
global $config_dir, $spooldir;
if (($to = get_config_value('aliases.conf', strtolower($rcpt))) == false) {
@ -195,13 +202,26 @@ function import_user_message($from, $rcpt, $date, $subject, $message) {
$target = "local";
$mail_viewed = null;
$rcpt_viewed = null;
$q = $stmt->execute([$msgid, $from, $to, $target, intval($date), $subject, $message, null, null, $mail_viewed, $rcpt_viewed]);
$q = $stmt->execute([
$msgid,
$from,
$to,
$target,
intval($date),
$subject,
$message,
null,
null,
$mail_viewed,
$rcpt_viewed
]);
$dbh = null;
return true;
}
function get_key_from_message($res, $inspect, $message) {
function get_key_from_message($res, $inspect, $message)
{
global $logfile, $config_name, $bbsmail_path;
$filename = explode($bbsmail_path . '/in/', $message);
$filename = $filename[0];
@ -254,7 +274,8 @@ function get_key_from_message($res, $inspect, $message) {
}
}
function inspect_bbsmail($res, $plaintext) {
function inspect_bbsmail($res, $plaintext)
{
$bbsmail_header = 0;
$bbsmail_body = 0;
$message_body = 0;
@ -346,7 +367,8 @@ function inspect_bbsmail($res, $plaintext) {
return ($return_data);
}
function inspect_message($message, $filename) {
function inspect_message($message, $filename)
{
global $logfile, $config_name, $bbsmail_path;
$header = array();
@ -448,7 +470,8 @@ function inspect_message($message, $filename) {
return ($return_data);
}
function send_keys_to_group($res, $rslight_gpg) {
function send_keys_to_group($res, $rslight_gpg)
{
global $spooldir, $config_name, $logfile, $mail_update_time, $CONFIG, $rslight_version;
$cwd = getcwd();
@ -467,7 +490,8 @@ function send_keys_to_group($res, $rslight_gpg) {
$begin = "@@BEGIN MAILKEY BODY";
$end = "@@END MAILKEY BODY";
/* Get days since last sent for creating message-id
/*
* Get days since last sent for creating message-id
* (Don't allow posting more than once per day)
*/
$date1 = date_create(date("Y-m-d", time() - $mail_update_time));

View File

@ -6,7 +6,7 @@
clearstatcache(true, $config_dir . "/nntp.disable");
$parent_pid = file_get_contents($lockdir . '/rslight-nntp.lock', IGNORE_NEW_LINES);
posix_kill($parent_pid, SIGTERM);
exit;
exit();
}
/**
* Listens for requests and forks on each connection
@ -36,29 +36,29 @@
*/
function change_identity($uid, $gid)
{
if( !posix_setgid( $gid ) )
{
if (! posix_setgid($gid)) {
print "Unable to setgid to " . $gid . "!\n";
exit;
exit();
}
if( !posix_setuid( $uid ) )
{
if (! posix_setuid($uid)) {
print "Unable to setuid to " . $uid . "!\n";
exit;
exit();
}
}
/**
* Creates a server socket and listens for incoming client connections
* @param string $address The address to listen on
* @param int $port The port to listen on
*
* @param string $address
* The address to listen on
* @param int $port
* The port to listen on
*/
function server_loop($address, $port)
{
GLOBAL $__server_listening;
GLOBAL
$CONFIG,$logdir,$lockdir,$webserver_uid,$webserver_gid,$installed_path,
$config_path,$groupconfig,$workpath,$path,$spooldir,$ssldir,$nntp_group,$auth_ok;
GLOBAL $CONFIG, $logdir, $lockdir, $webserver_uid, $webserver_gid, $installed_path, $config_path, $groupconfig, $workpath, $path, $spooldir, $ssldir, $nntp_group, $auth_ok;
$logfile = $logdir . '/nntp.log';
$lockfile = $lockdir . '/rslight-nntp-ssl.lock';
$pid = file_get_contents($lockfile);
@ -67,7 +67,7 @@ $config_path,$groupconfig,$workpath,$path,$spooldir,$ssldir,$nntp_group,$auth_ok
file_put_contents($lockfile, getmypid()); // create lockfile
} else {
print "Rocksolid Light NNTP Server currently running\n";
exit;
exit();
}
$auth_ok = 0;
@ -83,13 +83,7 @@ $config_path,$groupconfig,$workpath,$path,$spooldir,$ssldir,$nntp_group,$auth_ok
stream_context_set_option($context, 'ssl', 'verify_peer', false);
stream_context_set_option($context, 'ssl', 'verify_peer_name', false);
stream_context_set_option($context, 'ssl', 'ciphers', 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384');
$sock = stream_socket_server(
'tcp://'.$address.':'.$port,
$errno,
$errstr,
STREAM_SERVER_BIND|STREAM_SERVER_LISTEN,
$context
);
$sock = stream_socket_server('tcp://' . $address . ':' . $port, $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context);
/* Change to non root user */
$uinfo = posix_getpwnam($CONFIG['webserver_user']);
change_identity($uinfo["uid"], $uinfo["gid"]);
@ -97,20 +91,16 @@ $config_path,$groupconfig,$workpath,$path,$spooldir,$ssldir,$nntp_group,$auth_ok
echo "waiting for clients to connect\n";
while ($__server_listening)
{
while ($__server_listening) {
$connection = stream_socket_accept($sock);
if ($connection === false)
{
if ($connection === false) {
usleep(100);
}elseif ($connection > 0)
{
} elseif ($connection > 0) {
handle_client($sock, $connection);
}else
{
} else {
echo "error: " . socket_strerror($connection);
file_put_contents($logfile, "\n" . format_log_date() . " error: " . socket_strerror($connection), FILE_APPEND);
die;
die();
}
}
}
@ -120,8 +110,7 @@ $config_path,$groupconfig,$workpath,$path,$spooldir,$ssldir,$nntp_group,$auth_ok
*/
function sig_handler($sig)
{
switch($sig)
{
switch ($sig) {
case SIGTERM:
case SIGINT:
exit();
@ -142,25 +131,23 @@ $config_path,$groupconfig,$workpath,$path,$spooldir,$ssldir,$nntp_group,$auth_ok
$pid = pcntl_fork();
if ($pid == -1)
{
if ($pid == - 1) {
/* fork failed */
echo "fork failure!\n";
die;
}elseif ($pid == 0)
{
die();
} elseif ($pid == 0) {
/* child process */
$__server_listening = false;
fclose($ssock);
interact($csock, true);
fclose($csock);
}else
{
} else {
fclose($csock);
}
}
function create_certificate($pemfile) {
function create_certificate($pemfile)
{
global $CONFIG;
$certificateData = array(
"countryName" => "US",

View File

@ -6,7 +6,7 @@
clearstatcache(true, $config_dir . "/nntp.disable");
$parent_pid = file_get_contents($lockdir . '/rslight-nntp.lock', IGNORE_NEW_LINES);
posix_kill($parent_pid, SIGTERM);
exit;
exit();
}
/**
* Listens for requests and forks on each connection
@ -36,29 +36,29 @@
*/
function change_identity($uid, $gid)
{
if( !posix_setgid( $gid ) )
{
if (! posix_setgid($gid)) {
print "Unable to setgid to " . $gid . "!\n";
exit;
exit();
}
if( !posix_setuid( $uid ) )
{
if (! posix_setuid($uid)) {
print "Unable to setuid to " . $uid . "!\n";
exit;
exit();
}
}
/**
* Creates a server socket and listens for incoming client connections
* @param string $address The address to listen on
* @param int $port The port to listen on
*
* @param string $address
* The address to listen on
* @param int $port
* The port to listen on
*/
function server_loop($address, $port)
{
GLOBAL $__server_listening;
GLOBAL
$CONFIG,$logdir,$lockdir,$webserver_uid,$webserver_gid,$installed_path,
$config_path,$groupconfig,$workpath,$path,$spooldir,$nntp_group,$auth_ok;
GLOBAL $CONFIG, $logdir, $lockdir, $webserver_uid, $webserver_gid, $installed_path, $config_path, $groupconfig, $workpath, $path, $spooldir, $nntp_group, $auth_ok;
$logfile = $logdir . '/nntp.log';
$lockfile = $lockdir . '/rslight-nntp.lock';
$pid = file_get_contents($lockfile);
@ -67,18 +67,13 @@ $config_path,$groupconfig,$workpath,$path,$spooldir,$nntp_group,$auth_ok;
file_put_contents($lockfile, getmypid()); // create lockfile
} else {
print "Rocksolid Light NNTP Server currently running\n";
exit;
exit();
}
$auth_ok = 0;
$user = "";
$pass = "";
$sock = stream_socket_server(
'tcp://'.$address.':'.$port,
$errno,
$errstr,
STREAM_SERVER_BIND|STREAM_SERVER_LISTEN
);
$sock = stream_socket_server('tcp://' . $address . ':' . $port, $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN);
/* Change to non root user */
$uinfo = posix_getpwnam($CONFIG['webserver_user']);
change_identity($uinfo["uid"], $uinfo["gid"]);
@ -86,20 +81,16 @@ $config_path,$groupconfig,$workpath,$path,$spooldir,$nntp_group,$auth_ok;
echo "waiting for clients to connect\n";
while ($__server_listening)
{
while ($__server_listening) {
$connection = stream_socket_accept($sock);
if ($connection === false)
{
if ($connection === false) {
usleep(100);
}elseif ($connection > 0)
{
} elseif ($connection > 0) {
handle_client($sock, $connection);
}else
{
} else {
echo "error: " . socket_strerror($connection);
file_put_contents($logfile, "\n" . format_log_date() . " error: " . socket_strerror($connection), FILE_APPEND);
die;
die();
}
}
}
@ -109,8 +100,7 @@ $config_path,$groupconfig,$workpath,$path,$spooldir,$nntp_group,$auth_ok;
*/
function sig_handler($sig)
{
switch($sig)
{
switch ($sig) {
case SIGTERM:
case SIGINT:
exit();
@ -131,20 +121,17 @@ $config_path,$groupconfig,$workpath,$path,$spooldir,$nntp_group,$auth_ok;
$pid = pcntl_fork();
if ($pid == -1)
{
if ($pid == - 1) {
/* fork failed */
echo "fork failure!\n";
die;
}elseif ($pid == 0)
{
die();
} elseif ($pid == 0) {
/* child process */
$__server_listening = false;
fclose($ssock);
interact($csock, false);
fclose($csock);
}else
{
} else {
fclose($csock);
}
}

View File

@ -1,11 +1,10 @@
<?php
include "config.inc.php";
include ("$file_newsportal");
include $config_dir . "/gpg.conf";
if (! isset($CONFIG['enable_nocem']) || $CONFIG['enable_nocem'] != true) {
exit;
exit();
}
$lockfile = $lockdir . '/rslight-spoolnews.lock';
@ -15,7 +14,7 @@
file_put_contents($lockfile, getmypid()); // create lockfile
} else {
print "nocem currently running\n";
exit;
exit();
}
putenv("GNUPGHOME=" . $rslight_gpg['gnupghome']);
@ -67,9 +66,10 @@
rename($nocem_file, $nocem_path . "processed/" . $message);
}
unlink($lockfile);
exit;
exit();
function delete_message($messageid, $group) {
function delete_message($messageid, $group)
{
global $logfile, $config_dir, $spooldir, $CONFIG, $webserver_group;
/* Find section */
@ -96,7 +96,9 @@ function delete_message($messageid, $group) {
if (is_file($database)) {
$articles_dbh = article_db_open($database);
$articles_query = $articles_dbh->prepare('DELETE FROM articles WHERE msgid=:messageid');
$articles_query->execute(['messageid' => $messageid]);
$articles_query->execute([
'messageid' => $messageid
]);
$articles_dbh = null;
}
}
@ -106,7 +108,10 @@ function delete_message($messageid, $group) {
$dbh = overview_db_open($database);
$stmt_del = $dbh->prepare('DELETE FROM overview WHERE newsgroup=:newsgroup AND msgid=:msgid');
$query = $dbh->prepare('SELECT * FROM overview WHERE newsgroup=:newsgroup AND msgid=:msgid');
$query->execute([':newsgroup' => $group, ':msgid' => $messageid]);
$query->execute([
':newsgroup' => $group,
':msgid' => $messageid
]);
$grouppath = preg_replace('/\./', '/', $group);
$status = "deleted";
$statusdate = time();
@ -120,12 +125,16 @@ function delete_message($messageid, $group) {
add_to_history($group, $row['number'], $row['msgid'], $status, $statusdate, $statusreason, $statusnotes);
thread_cache_removearticle($group, $row['number']);
}
$stmt_del->execute([':newsgroup' => $group, ':msgid' => $messageid]);
$stmt_del->execute([
':newsgroup' => $group,
':msgid' => $messageid
]);
$dbh = null;
return;
}
function delete_message_from_overboard($config_name, $group, $messageid) {
function delete_message_from_overboard($config_name, $group, $messageid)
{
GLOBAL $spooldir;
$cachefile = $spooldir . "/" . $config_name . "-overboard.dat";
if (is_file($cachefile)) {

View File

@ -1,4 +1,5 @@
<?php
function interact($msgsock, $use_crypto = false)
{
global $CONFIG, $logdir, $lockdir, $logfile, $installed_path, $config_path, $config_dir, $groupconfig, $workpath, $path, $spooldir, $nntp_group, $nntp_article, $auth_ok, $user, $pass;
@ -30,7 +31,7 @@ set_time_limit(30);
if (file_exists($config_dir . "/nntp.disable")) {
$parent_pid = file_get_contents($lockdir . '/rslight-nntp.lock', IGNORE_NEW_LINES);
posix_kill($parent_pid, SIGTERM);
exit;
exit();
}
if ($buf === false) {
// file_put_contents($logfile, "\n".format_log_date()." socket read failed: reason: " . socket_strerror(socket_last_error($msgsock)), FILE_APPEND);
@ -48,8 +49,7 @@ set_time_limit(0);
}
$command = explode(' ', $buf);
$command[0] = strtolower($command[0]);
if(isset($command[1])) {
}
if (isset($command[1])) {}
if ($command[0] == 'date') {
$msg = '111 ' . date('YmdHis') . "\r\n";
fwrite($msgsock, $msg, strlen($msg));
@ -231,27 +231,24 @@ set_time_limit(0);
{
$pid = pcntl_fork();
if ($pid == -1)
{
if ($pid == - 1) {
/* fork failed */
echo "fork failure!\n";
exit();
}elseif ($pid)
{
} elseif ($pid) {
/* close the parent */
exit();
}else
{
} else {
/* child becomes our daemon */
posix_setsid();
chdir('/');
umask(0);
return posix_getpid();
}
}
function prepare_post($filename) {
function prepare_post($filename)
{
global $logdir, $spooldir, $config_dir, $rslight_gpg;
$logfile = $logdir . '/nntp.log';
$message = file($filename, FILE_IGNORE_NEW_LINES);
@ -310,7 +307,8 @@ function prepare_post($filename) {
return $response;
}
function process_post($message, $group) {
function process_post($message, $group)
{
global $logfile, $spooldir, $config_dir, $CONFIG, $nntp_group;
// $message = file($filename, FILE_IGNORE_NEW_LINES);
$no_mid = 1;
@ -457,7 +455,10 @@ function process_post($message, $group) {
$table = 'overview';
$dbh = overview_db_open($database, $table);
$stmt = $dbh->prepare("SELECT * FROM $table WHERE newsgroup=:thisgroup AND msgid=:msgid ORDER BY number");
$stmt->execute(['thisgroup' => $group, ':msgid' => $msgid]);
$stmt->execute([
'thisgroup' => $group,
':msgid' => $msgid
]);
while ($found = $stmt->fetch()) {
unlink($postfilename);
file_put_contents($logfile, "\n" . format_log_date() . " " . $section . " Duplicate Message-ID for: " . $msgid, FILE_APPEND);
@ -476,7 +477,8 @@ function process_post($message, $group) {
return $response;
}
function get_next($nntp_group) {
function get_next($nntp_group)
{
global $spooldir, $nntp_article;
if ($nntp_group == "") {
$response = "412 Not in a newsgroup\r\n";
@ -506,7 +508,8 @@ function get_next($nntp_group) {
return $response;
}
function get_last($nntp_group) {
function get_last($nntp_group)
{
global $spooldir, $nntp_article;
if ($nntp_group == "") {
$response = "412 Not in a newsgroup\r\n";
@ -536,7 +539,8 @@ function get_last($nntp_group) {
return $response;
}
function get_xhdr($header, $articles) {
function get_xhdr($header, $articles)
{
global $config_dir, $spooldir, $nntp_group, $nntp_article, $workpath, $path;
$tmpgroup = $nntp_group;
$mid = false;
@ -591,7 +595,8 @@ function get_xhdr($header, $articles) {
return $msg;
}
function extract_header_line($article_full_path, $header, $thisgroup, $article) {
function extract_header_line($article_full_path, $header, $thisgroup, $article)
{
global $CONFIG;
if ($CONFIG['article_database'] == '1') {
$thisarticle = np_get_db_article($article, $thisgroup);
@ -611,7 +616,8 @@ function extract_header_line($article_full_path, $header, $thisgroup, $article)
return (false);
}
function get_title($mode) {
function get_title($mode)
{
global $nntp_group, $workpath, $spooldir, $path;
if ($mode == "active") {
$msg = "481 descriptions unavailable\r\n";
@ -629,7 +635,8 @@ function get_title($mode) {
return $msg;
}
function get_xover($articles, $msgsock) {
function get_xover($articles, $msgsock)
{
global $nntp_group, $nntp_article, $workpath, $path, $spooldir;
// Use article pointer
if (! isset($articles) && is_numeric($nntp_article)) {
@ -686,7 +693,10 @@ function get_xover($articles, $msgsock) {
$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 ++) {
$stmt->execute(['thisgroup' => $nntp_group, ':number' => $i]);
$stmt->execute([
'thisgroup' => $nntp_group,
':number' => $i
]);
while ($row = $stmt->fetch()) {
$msg .= $row['number'] . "\t" . $row['subject'] . "\t" . $row['name'] . "\t" . $row['datestring'] . "\t" . $row['msgid'] . "\t" . $row['refs'] . "\t" . $row['bytes'] . "\t" . $row['lines'] . "\t" . $row['xref'] . "\r\n";
}
@ -696,7 +706,8 @@ function get_xover($articles, $msgsock) {
return $msg;
}
function get_stat($article) {
function get_stat($article)
{
global $nntp_group, $nntp_article, $workpath, $path;
if ($nntp_group == '') {
$msg = "412 Not in a newsgroup\r\n";
@ -717,7 +728,10 @@ function get_stat($article) {
}
$dbh = overview_db_open($database);
$query = $articles_dbh->prepare('SELECT * FROM overview WHERE number=:number AND newsgroup=:newsgroup');
$query->execute(['number' => $article, 'newsgroup' => $nntp_group]);
$query->execute([
'number' => $article,
'newsgroup' => $nntp_group
]);
$found = 0;
while ($row = $query->fetch()) {
$found = 1;
@ -732,7 +746,8 @@ function get_stat($article) {
return $msg;
}
function get_article($article, $nntp_group) {
function get_article($article, $nntp_group)
{
global $CONFIG, $config_dir, $path, $groupconfig, $config_name, $spooldir, $nntp_article;
$msg2 = "";
// Use article pointer
@ -782,7 +797,8 @@ function get_article($article, $nntp_group) {
return $msg . $msg2;
}
function get_header($article, $nntp_group) {
function get_header($article, $nntp_group)
{
global $CONFIG, $nntp_article, $config_dir, $path, $groupconfig, $config_name, $spooldir;
$msg2 = "";
// Use article pointer
@ -834,7 +850,8 @@ function get_header($article, $nntp_group) {
return $msg . $msg2;
}
function get_body($article, $nntp_group) {
function get_body($article, $nntp_group)
{
global $CONFIG, $nntp_article, $config_dir, $path, $groupconfig, $config_name, $spooldir;
$msg2 = "";
// Use article pointer
@ -889,7 +906,8 @@ function get_body($article, $nntp_group) {
return $msg . $msg2;
}
function get_listgroup($nntp_group, $msgsock) {
function get_listgroup($nntp_group, $msgsock)
{
global $spooldir, $path, $nntp_group, $groupconfig;
$grouplist = file($groupconfig, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($nntp_group == '') {
@ -925,7 +943,8 @@ function get_listgroup($nntp_group, $msgsock) {
return $msg;
}
function get_group($change_group) {
function get_group($change_group)
{
global $spooldir, $path, $nntp_group, $nntp_article, $groupconfig;
$grouplist = file($groupconfig, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$ok_group = false;
@ -956,7 +975,8 @@ function get_group($change_group) {
return $msg;
}
function get_newgroups($mode) {
function get_newgroups($mode)
{
global $path, $groupconfig;
$grouplist = file($groupconfig, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$mode = "active";
@ -1004,7 +1024,8 @@ function get_newgroups($mode) {
}
}
function get_list($mode, $msgsock) {
function get_list($mode, $msgsock)
{
global $path, $spooldir, $groupconfig;
$grouplist = file($groupconfig, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($mode == "headers") {
@ -1068,15 +1089,15 @@ function get_list($mode, $msgsock) {
return $msg . ".\r\n";
}
}
/*
function encode_subject($line) {
$newstring=mb_encode_mimeheader(quoted_printable_decode($line));
return $newstring;
}
*/
function insert_article($section,$nntp_group,$filename,$subject_i,$from_i,$article_date,
$date_i,$mid_i,$references_i,$bytes_i,$lines_i,$xref_i,$body) {
/*
* function encode_subject($line) {
* $newstring=mb_encode_mimeheader(quoted_printable_decode($line));
* return $newstring;
* }
*/
function insert_article($section, $nntp_group, $filename, $subject_i, $from_i, $article_date, $date_i, $mid_i, $references_i, $bytes_i, $lines_i, $xref_i, $body)
{
global $enable_rslight, $spooldir, $CONFIG, $logdir, $lockdir, $logfile;
$return_val = "441 Posting failed\r\n";
@ -1152,7 +1173,19 @@ $date_i,$mid_i,$references_i,$bytes_i,$lines_i,$xref_i,$body) {
file_put_contents($logfile, "\n" . format_log_date() . " " . $section . " Connected to database: " . $database, FILE_APPEND);
$sql = 'INSERT INTO overview(newsgroup, number, msgid, date, datestring, name, subject, refs, bytes, lines, xref) VALUES(?,?,?,?,?,?,?,?,?,?,?)';
$stmt = $dbh->prepare($sql);
$stmt->execute([$nntp_group, $local, $mid_i, $article_date, $date_i, $from_i, $subject_i, $references_i, $bytes_i, $lines_i, $xref_i]);
$stmt->execute([
$nntp_group,
$local,
$mid_i,
$article_date,
$date_i,
$from_i,
$subject_i,
$references_i,
$bytes_i,
$lines_i,
$xref_i
]);
$dbh = null;
}
@ -1178,7 +1211,16 @@ $date_i,$mid_i,$references_i,$bytes_i,$lines_i,$xref_i,$body) {
$article_sql = 'INSERT INTO articles(newsgroup, number, msgid, date, name, subject, article, search_snippet) VALUES(?,?,?,?,?,?,?,?)';
$article_stmt = $article_dbh->prepare($article_sql);
$this_article = file_get_contents($tmp_file);
$article_stmt->execute([$nntp_group, $local, $mid_i, $article_date, $from_i, $subject_i, trim($this_article), $this_snippet]);
$article_stmt->execute([
$nntp_group,
$local,
$mid_i,
$article_date,
$from_i,
$subject_i,
trim($this_article),
$this_snippet
]);
unlink($tmp_file);
$article_dbh = null;
}
@ -1205,7 +1247,8 @@ $date_i,$mid_i,$references_i,$bytes_i,$lines_i,$xref_i,$body) {
return ($return_val);
}
function find_article_by_msgid($msgid) {
function find_article_by_msgid($msgid)
{
global $spooldir;
$database = $spooldir . '/articles-overview.db3';
$table = 'overview';
@ -1223,13 +1266,16 @@ function find_article_by_msgid($msgid) {
return $return;
}
function get_article_list($thisgroup) {
function get_article_list($thisgroup)
{
global $spooldir;
$database = $spooldir . "/articles-overview.db3";
$table = 'overview';
$dbh = overview_db_open($database, $table);
$stmt = $dbh->prepare("SELECT * FROM $table WHERE newsgroup=:thisgroup ORDER BY number");
$stmt->execute(['thisgroup' => $thisgroup]);
$stmt->execute([
'thisgroup' => $thisgroup
]);
$ok_article = array();
while ($found = $stmt->fetch()) {
$ok_article[] = $found['number'];
@ -1238,7 +1284,8 @@ function get_article_list($thisgroup) {
return (array_unique($ok_article));
}
function create_node_ssl_cert($pemfile) {
function create_node_ssl_cert($pemfile)
{
global $CONFIG, $ssldir, $webtmp, $logdir, $config_dir;
include $config_dir . '/letsencrypt.inc.php';
$logfile = $logdir . '/nntp.log';
@ -1252,7 +1299,6 @@ function create_node_ssl_cert($pemfile) {
file_put_contents($logfile, "\n" . format_log_date() . " " . $letsencrypt['path'] . "fullchain.pem newer. Reloading cert.", FILE_APPEND);
touch($config_dir . '/ssl.reload');
}
}
if (! file_exists($config_dir . '/ssl.reload')) {
if ((is_file($pemfile)) && (is_file($pubkeyfile)) && (is_file($pubkeytxtfile))) {

View File

@ -10,7 +10,10 @@
if (isset($argv[1])) {
$rssfiles[0] = $argv[1];
} else {
$rssfiles = array_diff(scandir($rssdir), array('..', '.'));
$rssfiles = array_diff(scandir($rssdir), array(
'..',
'.'
));
}
foreach ($rssfiles as $rssfile) {
if (! is_file($config_dir . '/rss/' . $rssfile)) {
@ -34,8 +37,7 @@
} else {
$xmlstart = $xml;
}
foreach($xmlstart->{$RSS['item']} as $item)
{
foreach ($xmlstart->{$RSS['item']} as $item) {
if (trim($item->{$RSS['link']}) == '') {
$item->{$RSS['link']} = $item->{$RSS['link']}[href];
} else {
@ -97,7 +99,8 @@
}
}
function get_rss_config($rssfile) {
function get_rss_config($rssfile)
{
$RSS = include ($rssfile);
return ($RSS);
}

View File

@ -1,5 +1,6 @@
<?php
/* spoolnews NNTP news spool creator
/*
* spoolnews NNTP news spool creator
* Download: https://news.novabbs.com/getrslight
*
* E-Mail: retroguy@novabbs.com
@ -19,7 +20,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
set_time_limit(900);
include "config.inc.php";
@ -39,7 +39,7 @@ if (posix_getsid($pid) === false || !is_file($lockfile)) {
file_put_contents($lockfile, getmypid()); // create lockfile
} else {
print "Send currently running\n";
exit;
exit();
}
$ns = nntp2_open($CONFIG['remote_server'], $CONFIG['remote_port']);
if ($ns == false) {
@ -52,7 +52,8 @@ nntp_close($ns);
unlink($lockfile);
echo "\nSend Done\r\n";
function post_articles($ns, $spooldir) {
function post_articles($ns, $spooldir)
{
global $logfile, $config_name;
if (! is_dir($spooldir . "/" . $config_name . "/outgoing/")) {
return "No messages to send\r\n";

View File

@ -1,7 +1,8 @@
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=<?=$www_charset?>">
<META HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=<?=$www_charset?>">
<?php
if (file_exists('../common/mods/style.css')) {
echo '<link rel="stylesheet" type="text/css" href="../common/mods/style.css">';

View File

@ -1,5 +1,6 @@
<?php
/* spoolnews NNTP news spool creator
/*
* spoolnews NNTP news spool creator
* Download: https://news.novabbs.com/getrslight
*
* E-Mail: retroguy@novabbs.com
@ -19,7 +20,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include "config.inc.php";
include ("$file_newsportal");
include $config_dir . '/gpg.conf';
@ -56,7 +56,7 @@ if (posix_getsid($pid) === false || !is_file($lockfile)) {
file_put_contents($lockfile, getmypid()); // create lockfile
} else {
print "Spoolnews currently running\n";
exit;
exit();
}
$sem = $spooldir . "/" . $config_name . ".reload";
@ -104,8 +104,7 @@ $enable_rslight=0;
}
}
}
if ($CONFIG['remote_server'] != '')
{
if ($CONFIG['remote_server'] != '') {
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " remote_server: " . $CONFIG['remote_server'], FILE_APPEND);
$ns = nntp2_open($CONFIG['remote_server'], $CONFIG['remote_port']);
$ns2 = nntp_open();
@ -137,7 +136,8 @@ if ($CONFIG['remote_server'] != '')
unlink($lockfile);
echo "\nSpoolnews Done\n";
function get_articles($ns, $group) {
function get_articles($ns, $group)
{
global $enable_rslight, $rslight_gpg, $spooldir, $CONFIG, $user_ban_file, $maxarticles_per_run, $maxfirstrequest, $workpath, $path, $remote_groupfile, $local_groupfile, $local, $logdir, $config_name, $logfile;
if ($ns == false) {
@ -148,7 +148,6 @@ function get_articles($ns, $group) {
$grouppath = $path . preg_replace('/\./', '/', $group);
$banned_names = file($user_ban_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$nocem_check = "@@NCM";
$bbsmail_check = "@@RSL";
@ -254,7 +253,8 @@ function get_articles($ns, $group) {
while ($article <= $detail[3]) {
if (! is_numeric($article)) {
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " DEBUG This should show server group:article number: " . $CONFIG['remote_server'] . " " . $group . ":" . $article, FILE_APPEND);
break;;
break;
;
}
if ($CONFIG['enable_nntp'] != true) {
$local = $article;
@ -281,8 +281,7 @@ function get_articles($ns, $group) {
$banned = 0;
$is_header = 1;
$body = "";
while(strcmp($response,".") != 0)
{
while (strcmp($response, ".") != 0) {
$bytes = $bytes + mb_strlen($response, '8bit');
if (trim($response) == "" || $lines > 0) {
$is_header = 0;
@ -377,13 +376,34 @@ function get_articles($ns, $group) {
}
}
// Overview
$stmt->execute([$group, $local, $mid[1], $article_date, $finddate[1], $from[1], $subject[1], $references, $bytes, $lines, $xref]);
$stmt->execute([
$group,
$local,
$mid[1],
$article_date,
$finddate[1],
$from[1],
$subject[1],
$references,
$bytes,
$lines,
$xref
]);
$references = "";
if ($CONFIG['article_database'] == '1') {
$this_article = file_get_contents($grouppath . "/" . $local);
// CREATE SEARCH SNIPPET
$this_snippet = get_search_snippet($body, $content_type[1]);
$article_stmt->execute([$group, $local, $mid[1], $article_date, $from[1], $subject[1], $this_article, $this_snippet]);
$article_stmt->execute([
$group,
$local,
$mid[1],
$article_date,
$from[1],
$subject[1],
$this_article,
$this_snippet
]);
unlink($grouppath . "/" . $local);
} else {
if ($article_date > time())
@ -409,8 +429,7 @@ function get_articles($ns, $group) {
if (strcmp(substr($response, 0, 3), "282") == 0) {
$titlefile = $workpath . $group . "-title";
$response = line_read($ns);
while(strcmp($response,".") != 0)
{
while (strcmp($response, ".") != 0) {
file_put_contents($titlefile, $response);
$response = line_read($ns);
}
@ -445,7 +464,8 @@ function get_articles($ns, $group) {
$dbh = null;
}
function create_spool_groups($in_groups, $out_groups) {
function create_spool_groups($in_groups, $out_groups)
{
$grouplist = file($in_groups, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$groupout = fopen($out_groups, "a+");
foreach ($grouplist as $group) {
@ -470,13 +490,16 @@ function create_spool_groups($in_groups, $out_groups) {
return;
}
function get_article_list($thisgroup) {
function get_article_list($thisgroup)
{
global $spooldir;
$database = $spooldir . "/articles-overview.db3";
$table = 'overview';
$dbh = overview_db_open($database, $table);
$stmt = $dbh->prepare("SELECT * FROM $table WHERE newsgroup=:thisgroup ORDER BY number");
$stmt->execute(['thisgroup' => $thisgroup]);
$stmt->execute([
'thisgroup' => $thisgroup
]);
$ok_article = array();
while ($found = $stmt->fetch()) {
$ok_article[] = $found['number'];

View File

@ -1,5 +1,4 @@
<?php
include "config.inc.php";
include "newsportal.php";
@ -85,7 +84,8 @@ include "head.inc";
display_user_files($_POST['listbox'], $offset);
}
function display_user_files($user, $offset) {
function display_user_files($user, $offset)
{
global $CONFIG, $spooldir, $text_header;
$directory = $spooldir . '/upload/' . $user . '/';
if (is_dir($directory)) {

View File

@ -122,7 +122,9 @@ echo '</table>';
$database = $spooldir . '/mail.db3';
$dbh = mail_db_open($database);
$query = $dbh->prepare('SELECT * FROM messages where id=:id');
$query->execute(['id' => $_POST['id']]);
$query->execute([
'id' => $_POST['id']
]);
while (($row = $query->fetch()) !== false) {
if (($row['mail_from'] != $user) && ($row['rcpt_to'] != $user)) {
continue;
@ -130,11 +132,17 @@ echo '</table>';
$istrue = 'true';
if ($row['mail_from'] == $user) {
$sql_update = $dbh->prepare('UPDATE messages SET from_hide=:from_hide WHERE id=:row_id');
$sql_update->execute(array(':from_hide' => $istrue, ':row_id' => $row['id']));
$sql_update->execute(array(
':from_hide' => $istrue,
':row_id' => $row['id']
));
}
if ($row['rcpt_to'] == $user) {
$sql_update = $dbh->prepare('UPDATE messages SET to_hide=:to_hide WHERE id=:row_id');
$sql_update->execute(array(':to_hide' => $istrue, ':row_id' => $row['id']));
$sql_update->execute(array(
':to_hide' => $istrue,
':row_id' => $row['id']
));
}
}
$dbh = null;
@ -144,7 +152,9 @@ echo '</table>';
$database = $spooldir . '/mail.db3';
$dbh = mail_db_open($database);
$query = $dbh->prepare('SELECT * FROM messages where id=:id');
$query->execute(['id' => $_POST['id']]);
$query->execute([
'id' => $_POST['id']
]);
while (($row = $query->fetch()) !== false) {
$ts = new DateTime(date("D, j M Y H:i T", $row["date"]), new DateTimeZone('UTC'));
$ts->add(DateInterval::createFromDateString($offset . ' minutes'));
@ -177,15 +187,20 @@ echo '</table>';
echo '</div>';
if ($row['mail_from'] == $user) {
$sql_update = $dbh->prepare('UPDATE messages SET mail_viewed=? WHERE msgid=?');
$sql_update->execute(array('true', $row['msgid']));
$sql_update->execute(array(
'true',
$row['msgid']
));
}
if ($row['rcpt_to'] == $user) {
$sql_update = $dbh->prepare('UPDATE messages SET rcpt_viewed=? WHERE msgid=?');
$sql_update->execute(array('true', $row['msgid']));
$sql_update->execute(array(
'true',
$row['msgid']
));
}
}
$dbh = null;
}
if (isset($_POST['sendMessage'])) {
if (isset($_POST['to']) && $_POST['to'] != '' && isset($_POST['from']) && $_POST['from'] != '' && isset($_POST['message']) && $_POST['message'] != '') {
@ -236,7 +251,19 @@ echo '</table>';
$mail_viewed = "true";
$rcpt_viewed = null;
// $remote_target is handled here
if($q = $stmt->execute([$msgid, $from, $to, $target, $date, $subject, $message, null, null, $mail_viewed, $rcpt_viewed])) {
if ($q = $stmt->execute([
$msgid,
$from,
$to,
$target,
$date,
$subject,
$message,
null,
null,
$mail_viewed,
$rcpt_viewed
])) {
if ($remote_target == 1) {
$remote_result = send_external_mail($from, $to, $date, $subject, $message);
if ($remote_result == true) {
@ -261,7 +288,9 @@ echo '</table>';
$database = $spooldir . '/mail.db3';
$dbh = mail_db_open($database);
$query = $dbh->prepare('SELECT * FROM messages where id=:id');
$query->execute(['id' => $_POST['id']]);
$query->execute([
'id' => $_POST['id']
]);
while (($row = $query->fetch()) !== false) {
$mail_to = $row['mail_from'];
if (strpos($row['subject'], 'Re: ') !== 0) {
@ -300,7 +329,9 @@ echo '</table>';
echo '<hr><h1 class="np_thread_headline">My Messages:</h1>';
echo '<table cellspacing="0" width="100%" class="np_results_table">';
$query = $dbh->prepare('SELECT * FROM messages WHERE mail_from=:mail_from OR rcpt_to=:mail_from ORDER BY date DESC');
$query->execute(['mail_from' => $user]);
$query->execute([
'mail_from' => $user
]);
echo '<tr class="np_thread_head"><td class="np_thread_head">Subject</td><td class="np_thread_head">From</td><td class="np_thread_head">To</td><td class="np_thread_head">Date</td></tr>';
$i = 1;
while (($row = $query->fetch()) !== false) {
@ -315,7 +346,8 @@ echo '</table>';
} else {
echo '<tr class="np_result_line2"><td class="np_result_line2" style="word-wrap:break-word";>';
}
$button_link = 'np_mail_button_link';;
$button_link = 'np_mail_button_link';
;
if (($row['mail_from'] == $user) && ($row['mail_viewed'] == 'true')) {
$button_link = 'np_mail_button_read';
} elseif (($row['rcpt_to'] == $user) && ($row['rcpt_viewed'] == 'true')) {
@ -343,7 +375,8 @@ echo '</table>';
echo '</tbody></table><br />';
include "tail.inc";
function send_external_mail($sender, $recipient, $date, $subject, $message) {
function send_external_mail($sender, $recipient, $date, $subject, $message)
{
global $rslight_gpg, $config_name, $spooldir, $rslight_version;
putenv("GNUPGHOME=" . $rslight_gpg['gnupghome']);
$res = gnupg_init();
@ -433,7 +466,8 @@ echo '</table>';
return true;
}
function retrieve_key($res, $domain) {
function retrieve_key($res, $domain)
{
global $config_name, $logfile;
// Let's try to get the key
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " No KEY for posting. Trying to retrieve for " . $domain, FILE_APPEND);

View File

@ -72,9 +72,7 @@ include "head.inc";
</script>
<?php
$logged_in = true;
}
else
{
} else {
echo 'Login failed.';
}
}
@ -250,10 +248,10 @@ echo '</table>';
echo '</textarea></td>';
echo '</tr>';
/*
// Timezone
echo '<td class="np_result_line1" style="word-wrap:break-word";>Timezone offset (+/- hours from UTC):</td>';
echo '</tr><tr><td class="np_result_line1" style="word-wrap:break-word";><input type="text" name="timezone" value="'.$user_config[timezone].'"></td>';
echo '</tr>';
* // Timezone
* echo '<td class="np_result_line1" style="word-wrap:break-word";>Timezone offset (+/- hours from UTC):</td>';
* echo '</tr><tr><td class="np_result_line1" style="word-wrap:break-word";><input type="text" name="timezone" value="'.$user_config[timezone].'"></td>';
* echo '</tr>';
*/
echo '<td class="np_result_line2" style="word-wrap:break-word";>';
echo '<button class="np_button_link" type="submit">Save Configuration</button>';