From 860dfa61ca3da38df756a13a906982d7e5a687fb Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Fri, 8 Mar 2024 10:27:35 -0700 Subject: [PATCH] Add and sort by section in grouplist.php. Also update cache from cron.php so no user must wait. --- Rocksolid_Light/common/grouplist.php | 25 ++++++++++++++---------- Rocksolid_Light/rocksolid/config.inc.php | 3 +++ Rocksolid_Light/rslight/scripts/cron.php | 14 +++++++++++++ 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Rocksolid_Light/common/grouplist.php b/Rocksolid_Light/common/grouplist.php index c255d37..538231d 100644 --- a/Rocksolid_Light/common/grouplist.php +++ b/Rocksolid_Light/common/grouplist.php @@ -5,19 +5,22 @@ include "../spoolnews/newsportal.php"; $title .= ' - Available Newsgroups'; include "head.inc"; -$cache_filename = $spooldir . '/grouplist-cache.txt'; echo '
'; echo '

List of Available Newsgroups:

'; + // Use cache if new enough -// 14400 = 4 hours -if (filemtime($cache_filename) > (time() - 14400)) { - echo file_get_contents($cache_filename); - exit(); +if (filemtime($grouplist_cache_filename) > (time() - $grouplist_cache_time)) { + // Allow refresh from cron.php + if($argv[1] != '.RELOAD') { + echo file_get_contents($grouplist_cache_filename); + exit(); + } } ob_start(); echo ''; echo ''; +echo ''; echo ''; echo ''; echo ''; @@ -45,12 +48,11 @@ foreach ($menulist as $menu) { } } } -ksort($groups_array); +//ksort($groups_array); $ns = nntp_open(); foreach ($groups_array as $thisgroup) { - echo ''; - echo ''; echo ''; @@ -78,5 +83,5 @@ echo '
'; include "../spoolnews/tail.inc"; echo ''; echo ''; -file_put_contents($cache_filename, ob_get_contents()); -ob_end_flush(); \ No newline at end of file +file_put_contents($grouplist_cache_filename, ob_get_contents()); +ob_end_flush(); diff --git a/Rocksolid_Light/rocksolid/config.inc.php b/Rocksolid_Light/rocksolid/config.inc.php index 45e0703..9f14576 100644 --- a/Rocksolid_Light/rocksolid/config.inc.php +++ b/Rocksolid_Light/rocksolid/config.inc.php @@ -48,6 +48,9 @@ $lockdir = $spooldir . '/lock'; $ssldir = $spooldir . '/ssl/'; $user_ban_file = $config_dir . '/banned_names.conf'; +$grouplist_cache_filename = $spooldir . '/grouplist-cache.txt'; +$grouplist_cache_time = 14400; + /* Permanent configuration changes */ @mkdir($logdir, 0755, 'recursive'); @mkdir($spooldir . '/upload', 0755, 'recursive'); diff --git a/Rocksolid_Light/rslight/scripts/cron.php b/Rocksolid_Light/rslight/scripts/cron.php index 743d200..9ade0bf 100644 --- a/Rocksolid_Light/rslight/scripts/cron.php +++ b/Rocksolid_Light/rslight/scripts/cron.php @@ -59,6 +59,8 @@ echo "Updated user count\n"; $uinfo = posix_getpwnam($CONFIG['webserver_user']); $cwd = getcwd(); + +// Check permissions on some files $webtmp = preg_replace('/spoolnews/', 'tmp/', $cwd); $keydir = preg_replace('/spoolnews/', 'pubkey/', $cwd); @@ -72,6 +74,13 @@ $keydir = preg_replace('/spoolnews/', 'pubkey/', $cwd); @chown($ssldir, $uinfo["uid"]); @chgrp($ssldir, $uinfo["gid"]); +$alias_file = $config_dir . '/aliases.conf'; +if(!file_exists($alias_file)) { + touch($alias_file); +} +@chown($alias_file, $uinfo["uid"]); +@chgrp($alias_file, $uinfo["gid"]); + $pemfile = $ssldir . '/server.pem'; create_node_ssl_cert($pemfile); @@ -136,6 +145,11 @@ foreach ($menulist as $menu) { # Run RSS Feeds exec($CONFIG['php_exec'] . " " . $config_dir . "/scripts/rss-feeds.php"); echo "RSS Feeds updated\n"; +# Reload grouplist +if ((filemtime($grouplist_cache_filename) < (time() - ($grouplist_cache_time - 600)) || !file_exists($grouplist_cache_filename))) { + exec($CONFIG['php_exec'] . " ../common/grouplist.php .RELOAD"); + echo "Refreshed grouplist\n"; +} # Rotate log files log_rotate(); echo "Log files rotated\n";
SectionGroupDescriptionMessages
'; + $section = explode("/", $thisgroup); $group = explode("group=", $thisgroup); if (is_file($spooldir . '/' . urldecode($group[1]) . '-title')) { $title = file_get_contents($spooldir . '/' . urldecode($group[1]) . '-title'); @@ -58,6 +60,9 @@ foreach ($groups_array as $thisgroup) { } else { $title = ''; } + echo '
'; + echo ' ' . $section[0] . ' '; + echo ''; echo '' . urldecode($group[1]) . "
\r\n"; echo '
' . $title . '