diff --git a/Rocksolid_Light/common/head.inc b/Rocksolid_Light/common/head.inc
index 6010a8a..551b5e0 100644
--- a/Rocksolid_Light/common/head.inc
+++ b/Rocksolid_Light/common/head.inc
@@ -1,11 +1,11 @@
-
-
-';
if ($_GET['searchpoint'] == 'Poster') {
@@ -97,7 +97,7 @@ $thissite = '.';
$groupconfig=$config_path."/groups.txt";
-$title.=' - search results for: '.$_POST[terms];
+$title.=' - search results for: '.$_POST['terms'];
include "head.inc";
ob_start();
diff --git a/Rocksolid_Light/rocksolid/tail.inc b/Rocksolid_Light/rocksolid/tail.inc
index b5e66b2..499d884 100644
--- a/Rocksolid_Light/rocksolid/tail.inc
+++ b/Rocksolid_Light/rocksolid/tail.inc
@@ -3,7 +3,7 @@ echo '';
$pubkeyfile = getcwd().'/../tmp/pubkey.txt';
if(is_file($pubkeyfile) && (isset($CONFIG['site_shortname']) && $CONFIG['site_shortname'] != '')) {
echo '';
- echo ''.$CONFIG[site_shortname].'';
+ echo ''.$CONFIG['site_shortname'].'';
echo ' ';
echo '';
}
@@ -15,4 +15,4 @@ echo 'i2p';
echo 'tor';
echo '';
echo '';
-?>
+?>
\ No newline at end of file
diff --git a/Rocksolid_Light/rocksolid/thread.php b/Rocksolid_Light/rocksolid/thread.php
index 7043730..4ba17df 100644
--- a/Rocksolid_Light/rocksolid/thread.php
+++ b/Rocksolid_Light/rocksolid/thread.php
@@ -19,14 +19,19 @@ if(isset($_REQUEST["first"]))
$first=intval($_REQUEST["first"]);
if(isset($_REQUEST["last"]))
$last=intval($_REQUEST["last"]);
-
+// Switch to correct section in case group has been moved and link is to old section
$findsection = get_section_by_group($group);
if(trim($findsection) !== $config_name) {
- $newurl = preg_replace("|/$config_name/|", "/$findsection/", $_SERVER['REQUEST_URI']);
- header("Location: $newurl");
- die();
- }
-
+ if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
+ $link = "https";
+ else $link = "http";
+ $link .= "://";
+ $link .= $_SERVER['HTTP_HOST'];
+ $link .= $_SERVER['REQUEST_URI'];
+ $newurl = preg_replace("|/$config_name/|", "/$findsection/", $link);
+ header("Location:$newurl");
+ die();
+ }
if(isset($_COOKIE['mail_name'])) {
if($userdata = get_user_mail_auth_data($_COOKIE['mail_name'])) {
$userfile=$spooldir.'/'.strtolower($_COOKIE['mail_name']).'-articleviews.dat';
diff --git a/Rocksolid_Light/rslight/scripts/cron.php b/Rocksolid_Light/rslight/scripts/cron.php
index ccb03a4..9c57d88 100755
--- a/Rocksolid_Light/rslight/scripts/cron.php
+++ b/Rocksolid_Light/rslight/scripts/cron.php
@@ -8,7 +8,9 @@
# Start or verify NNTP server
if(isset($CONFIG['enable_nntp']) && $CONFIG['enable_nntp'] == true) {
# Create group list for nntp.php
- $fp1=fopen($spooldir."/".$config_name."/groups.txt", 'w');
+ $fp1=$spooldir."/".$config_name."/groups.txt";
+ unlink($fp1);
+ touch($fp1);
foreach($menulist as $menu) {
if(($menu[0] == '#') || trim($menu) == "") {
continue;
@@ -21,11 +23,10 @@
continue;
}
$ok_group = preg_split("/( |\t)/", trim($ok_group), 2);
- fputs($fp1, $ok_group[0]."\r\n");
+ file_put_contents($fp1, $ok_group[0]."\r\n", FILE_APPEND);
}
}
}
- fclose($fp1);
exec($CONFIG['php_exec']." ".$config_dir."/scripts/nntp.php > /dev/null 2>&1");
if(is_numeric($CONFIG['local_ssl_port'])) {
exec($CONFIG['php_exec']." ".$config_dir."/scripts/nntp-ssl.php > /dev/null 2>&1");
@@ -60,7 +61,7 @@
@mkdir($logdir,0755,'recursive');
@mkdir($lockdir,0755,'recursive');
-
+
if(isset($CONFIG['enable_nocem']) && $CONFIG['enable_nocem'] == true) {
@mkdir($spooldir."nocem",0755,'recursive');
exec($CONFIG['php_exec']." ".$config_dir."/scripts/nocem.php");
diff --git a/Rocksolid_Light/rslight/scripts/nntp-ssl.php b/Rocksolid_Light/rslight/scripts/nntp-ssl.php
index e679cbe..e30b2e0 100755
--- a/Rocksolid_Light/rslight/scripts/nntp-ssl.php
+++ b/Rocksolid_Light/rslight/scripts/nntp-ssl.php
@@ -57,7 +57,7 @@
{
GLOBAL $__server_listening;
GLOBAL
-$CONFIG,$logdir,$lockdir,$ssldir,$webserver_uid,$webserver_gid,$installed_path,
+$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-ssl.lock';
@@ -73,10 +73,10 @@ $config_path,$groupconfig,$workpath,$path,$spooldir,$nntp_group,$auth_ok;
$auth_ok = 0;
$user = "";
$pass = "";
-
- $pemfile = $ssldir.'/server.pem';
- create_node_ssl_cert($pemfile);
-
+ $pemfile = $spooldir.'/server.pem';
+ if(!is_file($pemfile)) {
+ create_certificate($pemfile);
+ }
$context = stream_context_create();
stream_context_set_option($context, 'ssl', 'local_cert', $pemfile);
stream_context_set_option($context, 'ssl', 'allow_self_signed', true);
@@ -159,4 +159,32 @@ $config_path,$groupconfig,$workpath,$path,$spooldir,$nntp_group,$auth_ok;
fclose($csock);
}
}
+
+function create_certificate($pemfile) {
+global $CONFIG;
+$certificateData = array(
+ "countryName" => "US",
+ "stateOrProvinceName" => "New York",
+ "localityName" => "New York City",
+ "organizationName" => "Rocksolid",
+ "organizationalUnitName" => "Rocksolid Light",
+ "commonName" => $CONFIG['organization'],
+ "emailAddress" => "rocksolid@example.com"
+);
+
+// Generate certificate
+$privateKey = openssl_pkey_new();
+$certificate = openssl_csr_new($certificateData, $privateKey);
+$certificate = openssl_csr_sign($certificate, null, $privateKey, 365);
+
+// Generate PEM file
+$pem_passphrase = null; // empty for no passphrase
+$pem = array();
+openssl_x509_export($certificate, $pem[0]);
+openssl_pkey_export($privateKey, $pem[1], $pem_passphrase);
+$pem = implode($pem);
+
+// Save PEM file
+file_put_contents($pemfile, $pem);
+}
?>
diff --git a/Rocksolid_Light/rslight/scripts/rslight-lib.php b/Rocksolid_Light/rslight/scripts/rslight-lib.php
index 023803b..c4d0d8f 100755
--- a/Rocksolid_Light/rslight/scripts/rslight-lib.php
+++ b/Rocksolid_Light/rslight/scripts/rslight-lib.php
@@ -24,7 +24,7 @@
/* Send instructions. */
$msg = "200 Rocksolid Light NNTP Server ready (no posting)\r\n";
fwrite($msgsock, $msg, strlen($msg));
- do {
+ do {
$msg="";
set_time_limit(30);
$buf = fgets($msgsock, 2048);
@@ -216,7 +216,7 @@ set_time_limit(0);
if ($command[0] == 'quit') {
$msg = "205 closing connection - goodbye!\r\n";
fwrite($msgsock, $msg, strlen($msg));
- socket_close($msgsock);
+// socket_close($msgsock);
exit(0);
}
file_put_contents($logfile, "\n".format_log_date()." Syntax error: ".$buf, FILE_APPEND);
@@ -353,7 +353,7 @@ function process_post($message, $group) {
}
}
}
- rewind($message);
+// rewind($message);
/*
* SPAM CHECK
*/
@@ -599,11 +599,11 @@ function get_title($mode) {
$msg="481 descriptions unavailable\r\n";
return $msg;
}
- $title = file_get_contents($spooldir."/".$mode."-title", IGNORE_NEW_LINES);
+ $title = file_get_contents($spooldir."/".$mode."-title");
$msg="282 list of group and description follows\r\n";
$msg.=$title;
- $msg.=".\r\n";
+ $msg.="\r\n.\r\n";
return $msg;
}
@@ -1073,13 +1073,6 @@ $date_i,$mid_i,$references_i,$bytes_i,$lines_i,$xref_i,$body) {
}
$nocem_check="@@NCM";
$article_date=strtotime($date_i);
- # Check if group exists. Open it if it does
- fputs($ns, "group ".$nntp_group."\r\n");
- $response = line_read($ns);
- if (strcmp(substr($response,0,3),"411") == 0) {
- unlink($sn_lockfile);
- return(1);
- }
$grouplist = file($local_groupfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach($grouplist as $findgroup) {
$name = explode(':', $findgroup);
@@ -1218,7 +1211,7 @@ function create_node_ssl_cert($pemfile) {
$uinfo=posix_getpwnam($CONFIG['webserver_user']);
$pubkeyfile = $ssldir.'/pubkey.pem';
$pubkeytxtfile = $webtmp.'/pubkey.txt';
- $ssltime = filectime($letsencrypt['path'])."fullchain.pem";
+ $ssltime = filectime($letsencrypt['path'])."fullchain.pem";
if(isset($letsencrypt['path'])) {
if($ssltime > filectime($pemfile)) {
touch($config_dir.'/ssl.reload');
@@ -1226,53 +1219,53 @@ function create_node_ssl_cert($pemfile) {
}
if(!file_exists($config_dir.'/ssl.reload')) {
- if((is_file($pemfile)) && (is_file($pubkeyfile)) && (is_file($pubkeytxtfile))) {
- if(md5_file($pubkeyfile) == md5_file($pubkeytxtfile)) {
- return;
- }
- }
+ if((is_file($pemfile)) && (is_file($pubkeyfile)) && (is_file($pubkeytxtfile))) {
+ if(md5_file($pubkeyfile) == md5_file($pubkeytxtfile)) {
+ return;
+ }
+ }
}
@unlink($config_dir.'/ssl.reload');
unlink($pemfile);
unlink($pubkeyfile);
unlink($pubkeytxtfile);
-/* Use letsencrypt */
+ /* Use letsencrypt */
if((isset($letsencrypt['server.pem'])) && (isset($letsencrypt['pubkey.pem']))) {
file_put_contents($pemfile, $letsencrypt['server.pem'].$letsencrypt['privkey']);
file_put_contents($pubkeyfile, $letsencrypt['pubkey.pem']);
file_put_contents($pubkeytxtfile, $letsencrypt['pubkey.pem']);
- touch($pemfile, $ssltime);
- touch($pubkeyfile, $ssltime);
- touch($pubkeytxtfile, $ssltime);
+ touch($pemfile, $ssltime);
+ touch($pubkeyfile, $ssltime);
+ touch($pubkeytxtfile, $ssltime);
} else {
-/* Create self signed cert */
- $certificateData = array(
- "countryName" => "US",
- "stateOrProvinceName" => "New York",
- "localityName" => "New York City",
- "organizationName" => "Rocksolid",
- "organizationalUnitName" => "Rocksolid Light",
- "commonName" => $CONFIG['organization'],
- "emailAddress" => "rocksolid@example.com"
- );
-
- // Generate certificate
- $privateKey = openssl_pkey_new();
- $certificate = openssl_csr_new($certificateData, $privateKey);
- $certificate = openssl_csr_sign($certificate, null, $privateKey, 365);
-
- // Generate PEM file
- $pem_passphrase = null; // empty for no passphrase
- $pem = array();
- openssl_x509_export($certificate, $pem[0]);
- openssl_pkey_export($privateKey, $pem[1], $pem_passphrase);
- $pem = implode($pem);
- $pubkey=openssl_pkey_get_details($privateKey);
-
- // Save PEM file
- file_put_contents($pemfile, $pem);
- file_put_contents($pubkeyfile, $pubkey['key']);
- file_put_contents($pubkeytxtfile, $pubkey['key']);
+ /* Create self signed cert */
+ $certificateData = array(
+ "countryName" => "US",
+ "stateOrProvinceName" => "New York",
+ "localityName" => "New York City",
+ "organizationName" => "Rocksolid",
+ "organizationalUnitName" => "Rocksolid Light",
+ "commonName" => $CONFIG['organization'],
+ "emailAddress" => "rocksolid@example.com"
+ );
+
+ // Generate certificate
+ $privateKey = openssl_pkey_new();
+ $certificate = openssl_csr_new($certificateData, $privateKey);
+ $certificate = openssl_csr_sign($certificate, null, $privateKey, 365);
+
+ // Generate PEM file
+ $pem_passphrase = null; // empty for no passphrase
+ $pem = array();
+ openssl_x509_export($certificate, $pem[0]);
+ openssl_pkey_export($privateKey, $pem[1], $pem_passphrase);
+ $pem = implode($pem);
+ $pubkey=openssl_pkey_get_details($privateKey);
+
+ // Save PEM file
+ file_put_contents($pemfile, $pem);
+ file_put_contents($pubkeyfile, $pubkey['key']);
+ file_put_contents($pubkeytxtfile, $pubkey['key']);
}
chown($pemfile, $uinfo["uid"]);
chown($pubkeyfile, $uinfo["uid"]);
diff --git a/Rocksolid_Light/rslight/scripts/send.php b/Rocksolid_Light/rslight/scripts/send.php
index 5052a79..e182802 100755
--- a/Rocksolid_Light/rslight/scripts/send.php
+++ b/Rocksolid_Light/rslight/scripts/send.php
@@ -32,13 +32,11 @@ $logfile=$logdir.'/spoolnews.log';
$lockfile = $lockdir . '/rslight-send.lock';
$pid = file_get_contents($lockfile);
if (posix_getsid($pid) === false || !is_file($lockfile)) {
- file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Starting Send...", FILE_APPEND);
print "Starting Send...\n";
file_put_contents($lockfile, getmypid()); // create lockfile
} else {
- file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Send currently running...", FILE_APPEND);
- print "Send currently running\n";
- exit;
+ print "Send currently running\n";
+ exit;
}
$ns=nntp2_open($CONFIG['remote_server'], $CONFIG['remote_port']);
if($ns == false) {
@@ -49,24 +47,19 @@ echo "\nPosting articles\r\n";
post_articles($ns, $spooldir);
nntp_close($ns);
unlink($lockfile);
-file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Exiting Send...", FILE_APPEND);
echo "\nSend Done\r\n";
function post_articles($ns, $spooldir) {
global $logfile,$config_name;
if(!is_dir($spooldir."/".$config_name."/outgoing/")) {
- file_put_contents($logfile, "\n".format_log_date()." ".$config_name." No messages to send", FILE_APPEND);
- return "No messages to send\r\n";
+ return "No messages to send\r\n";
}
$outgoing_dir = $spooldir."/".$config_name."/outgoing/";
- $failed_dir = $outgoing_dir.'/failed';
- @mkdir($failed_dir);
$messages = scandir($outgoing_dir);
foreach($messages as $message) {
if(!is_file($outgoing_dir.$message)) {
continue;
}
- file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Sending: ".$outgoing_dir.$message, FILE_APPEND);
echo "Sending: ".$outgoing_dir.$message."\r\n";
fputs($ns, "MODE READER\r\n");
$response = line_read($ns);
@@ -92,7 +85,6 @@ function post_articles($ns, $spooldir) {
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Posted: ".$message.": ".$response, FILE_APPEND);
} else {
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Failed to POST: ".$message.": ".$response, FILE_APPEND);
- rename($outgoing_dir.$message, $failed_dir.'/'.$message);
continue;
}
}
diff --git a/Rocksolid_Light/rslight/scripts/setuphelper.php b/Rocksolid_Light/rslight/scripts/setuphelper.php
index 82aa8db..6c2feb7 100644
--- a/Rocksolid_Light/rslight/scripts/setuphelper.php
+++ b/Rocksolid_Light/rslight/scripts/setuphelper.php
@@ -24,7 +24,6 @@ return [
'server_auth_pass' => 'The password for the local server user',
# Site configuration
-'site_shortname' => 'Must be unique from other rslight sites. Blank to disable',
'rslight_title' => 'The tagline at the top of the web page',
'title_full' => 'The site title in the client browser bar',
'hide_email' => 'Truncate email addresses in From header (1=true, blank=false)',
diff --git a/Rocksolid_Light/rslight/scripts/spoolnews.php b/Rocksolid_Light/rslight/scripts/spoolnews.php
index db2af16..ae1374a 100755
--- a/Rocksolid_Light/rslight/scripts/spoolnews.php
+++ b/Rocksolid_Light/rslight/scripts/spoolnews.php
@@ -23,8 +23,6 @@
include "config.inc.php";
include ("$file_newsportal");
-set_time_limit(900);
-
$remote_groupfile=$spooldir."/".$config_name."/".$CONFIG['remote_server'].":".$CONFIG['remote_port'].".txt";
$file_groups=$config_path."groups.txt";
$local_groupfile=$spooldir."/".$config_name."/local_groups.txt";
@@ -57,21 +55,18 @@ if (posix_getsid($pid) === false || !is_file($lockfile)) {
print "Spoolnews currently running\n";
exit;
}
-
$sem = $spooldir."/".$config_name.".reload";
if(is_file($sem)) {
unlink($remote_groupfile);
unlink($sem);
$maxfirstrequest = 20;
}
-
if(filemtime($spooldir.'/'.$config_name.'-thread-timer')+600 < time()) {
$timer=true;
touch($spooldir.'/'.$config_name.'-thread-timer');
} else {
$timer=false;
}
-
# Check for groups file, create if necessary
create_spool_groups($file_groups, $remote_groupfile);
create_spool_groups($file_groups, $local_groupfile);
@@ -195,7 +190,6 @@ function get_articles($ns, $group) {
# Pull articles and save them in our spool
@mkdir($grouppath,0755,'recursive');
$i=0;
- $nsfail=0;
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);
@@ -209,8 +203,9 @@ function get_articles($ns, $group) {
fputs($ns, "stat ".$article."\r\n");
$response = line_read($ns);
$this_msgid = explode(' ', $response);
- $group_overviewfp=fopen($spooldir."/".$group."-overview", 'r');
- while($group_overview=fgets($group_overviewfp, 2048)) {
+ $group_overviewfile = $spooldir."/".$group."-overview";
+ $gover = file($group_overviewfile);
+ foreach($gover as $group_overview) {
$overview_msgid = explode("\t", $group_overview);
if(strpos($overview_msgid[4], $this_msgid[2]) !== false) {
echo "\nDuplicate Message-ID for: ".$CONFIG['remote_server']." ".$group.":".$article."\n";
@@ -220,7 +215,6 @@ function get_articles($ns, $group) {
break;
}
}
- fclose($group_overviewfp);
if($duplicate == 1) {
continue;
}
@@ -314,12 +308,7 @@ function get_articles($ns, $group) {
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Lost connection to ".$CONFIG['remote_server'].":".$CONFIG['remote_port']." retrieving article ".$article, FILE_APPEND);
@fclose($articleHandle);
unlink($grouppath."/".$local);
- $nsfail++;
- if($nsfail > 3){
- break;
- } else {
- continue;
- }
+ continue;
}
$response=str_replace("\n","",str_replace("\r","",$response));
}
@@ -375,14 +364,13 @@ function get_articles($ns, $group) {
fputs($ns, "XGTITLE ".$group."\r\n");
$response = line_read($ns);
if (strcmp(substr($response,0,3),"282") == 0) {
- $overviewHandle = fopen($workpath.$group."-title", 'w');
+ $titlefile = $workpath.$group."-title";
$response = line_read($ns);
while(strcmp($response,".") != 0)
{
- fputs($overviewHandle, $response."\r\n");
+ file_put_contents($titlefile, $response);
$response = line_read($ns);
}
- @fclose($overviewHandle);
}
}
# Save config
@@ -463,15 +451,15 @@ function get_high_watermark($group) {
function get_article_list($thisgroup) {
global $spooldir;
- $group_overviewfp=fopen($spooldir."/".$thisgroup."-overview", 'r');
+ $group_overview_file = $spooldir."/".$thisgroup."-overview";
$ok_article=array();
- while($line = fgets($group_overviewfp)) {
+ $getline = file($group_overview_file);
+ foreach($getline as $line) {
$art=explode("\t", $line);
if(is_numeric($art[0])) {
$ok_article[] = $art[0];
}
}
- fclose($group_overviewfp);
return($ok_article);
}
diff --git a/Rocksolid_Light/spoolnews/files.php b/Rocksolid_Light/spoolnews/files.php
index 633dffe..7e51f21 100644
--- a/Rocksolid_Light/spoolnews/files.php
+++ b/Rocksolid_Light/spoolnews/files.php
@@ -16,14 +16,13 @@ include "newsportal.php";
$getfh = fopen($getfilename, "rb");
$getfile = fread($getfh, filesize($getfilename));
fclose($getfh);
- header('Content-type: '.$_REQUEST[contenttype]);
- header('Content-disposition: filename="'.$_REQUEST[showfilename].'"');
+ header('Content-type: '.$_REQUEST['contenttype']);
+ header('Content-disposition: filename="'.$_REQUEST['showfilename'].'"');
file_put_contents($logfile, "\n".format_log_date()." Requesting: ".$_REQUEST['showfile'], FILE_APPEND);
echo $getfile;
exit(0);
}
-
$title.=' - Browse files';
include "head.inc";
echo '';
$_SESSION['username'] = $user;
unset($user_config);
$userfile=$spooldir.'/'.$user.'-articleviews.dat';
- $userdata = unserialize(file_get_contents($userfile));
- ksort($userdata);
-
+ if(is_file($userfile)) {
+ $userdata = unserialize(file_get_contents($userfile));
+ ksort($userdata);
+ }
// Apply Config
if(isset($_POST['command']) && $_POST['command'] == 'SaveConfig') {
$user_config['signature'] = $_POST['signature'];
@@ -149,7 +150,7 @@ echo '';
file_put_contents($spooldir.'/'.$user.'-articleviews.dat', serialize($newsubs));
$userdata = unserialize(file_get_contents($userfile));
ksort($userdata);
- echo 'Configuration Saved for '.$_POST[username];
+ echo 'Configuration Saved for '.$_POST['username'];
} else {
$user_config = unserialize(file_get_contents($config_dir.'/userconfig/'.$user.'.config'));
}
@@ -163,7 +164,7 @@ echo '';
}
$themes[] = $theme_dir;
}
- closedir($theme_dir);
+ closedir($theme_list);
}
}
sort($themes);
@@ -171,17 +172,17 @@ echo '';
// Show Config
echo '
Configuration:';
echo '';
- echo 'Settings for '.$_POST[username].' (leave blank for none): | ';
+ echo 'Settings for '.$_POST['username'].' (leave blank for none): | ';
echo ' |