diff --git a/Rocksolid_Light/rocksolid/newsportal.php b/Rocksolid_Light/rocksolid/newsportal.php index 8c38c0d..f8e134f 100644 --- a/Rocksolid_Light/rocksolid/newsportal.php +++ b/Rocksolid_Light/rocksolid/newsportal.php @@ -454,17 +454,22 @@ function address_decode($adrstring,$defaulthost) { /* * Read the groupnames from groups.txt, and get additional informations * of the groups from the newsserver - */ -function groups_read($server,$port,$load=0) { + * + * when load=0, returns cached group list + * when load=1, checks if the cache should be used, and returns nothing + * when force_reload=true, rebuilds group list cache +*/ +function groups_read($server,$port,$load=0,$force_reload=false) { global $gl_age,$file_groups,$spooldir,$config_name,$cache_index; // is there a cached version, and is it actual enough? $cachefile=$spooldir.'/'.$config_name.'-groups.dat'; // if cache is new enough, don't recreate it clearstatcache(TRUE, $cachefile); - if($load == 1 && file_exists($cachefile) && (filemtime($cachefile)+$cache_index>time())) { + if(!$force_reload && $load == 1 && file_exists($cachefile) && (filemtime($cachefile)+$cache_index>time())) { return; } - if(file_exists($cachefile) && $load == 0) { + if(!$force_reload && file_exists($cachefile) && $load == 0) { + echo 'using cached version of groups'; // cached file exists and is new enough, so lets read it out. $file=fopen($cachefile,"r"); $data=""; @@ -473,7 +478,10 @@ function groups_read($server,$port,$load=0) { } fclose($file); $newsgroups=unserialize($data); - } else { + } + else + { + // force a refresh of the group list $ns=nntp_open($server,$port); if ($ns == false) return false; // $gf=fopen($file_groups,"r"); diff --git a/Rocksolid_Light/rslight/scripts/spoolnews.php b/Rocksolid_Light/rslight/scripts/spoolnews.php index 34eafc8..36020ac 100755 --- a/Rocksolid_Light/rslight/scripts/spoolnews.php +++ b/Rocksolid_Light/rslight/scripts/spoolnews.php @@ -71,6 +71,7 @@ if(filemtime($spooldir.'/'.$config_name.'-thread-timer')+600 < time()) { # Check for groups file, create if necessary create_spool_groups($file_groups, $remote_groupfile); create_spool_groups($file_groups, $local_groupfile); + # Iterate through groups $enable_rslight=0; # Refresh group list @@ -81,7 +82,7 @@ $enable_rslight=0; } $menuitem = explode(':', $menu); if(($menuitem[0] == $config_name) && ($menuitem[1] == '1')) { - groups_read($server,$port,1); + groups_read($server,$port,1,true); // 'true' forces a refresh of the group list $enable_rslight = 1; echo "\nLoaded groups"; } @@ -97,31 +98,34 @@ $enable_rslight=0; } } } -$ns=nntp2_open($CONFIG['remote_server'], $CONFIG['remote_port']); -$ns2=nntp_open(); -if(!$ns) { - file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Failed to connect to ".$CONFIG['remote_server'].":".$CONFIG['remote_port'], FILE_APPEND); - exit(); -} -$grouplist = file($config_dir.'/'.$config_name.'/groups.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); -foreach($grouplist as $findgroup) { - if($findgroup[0] == ":") { - continue; +if ($CONFIG['remote_server'] != '') +{ + $ns=nntp2_open($CONFIG['remote_server'], $CONFIG['remote_port']); + $ns2=nntp_open(); + if(!$ns) { + file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Failed to connect to ".$CONFIG['remote_server'].":".$CONFIG['remote_port'], FILE_APPEND); + exit(); } - $name = preg_split("/( |\t)/", $findgroup, 2); - file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Retrieving articles for: ".$name[0]."...", FILE_APPEND); - echo "\nRetrieving articles for: ".$name[0]."..."; - get_articles($ns, $name[0]); + $grouplist = file($config_dir.'/'.$config_name.'/groups.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + foreach($grouplist as $findgroup) { + if($findgroup[0] == ":") { + continue; + } + $name = preg_split("/( |\t)/", $findgroup, 2); + file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Retrieving articles for: ".$name[0]."...", FILE_APPEND); + echo "\nRetrieving articles for: ".$name[0]."..."; + get_articles($ns, $name[0]); - if($enable_rslight == 1) { - if($timer) { - file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Updating threads for: ".$name[0]."...", FILE_APPEND); - thread_load_newsserver($ns2,$name[0],0); + if($enable_rslight == 1) { + if($timer) { + file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Updating threads for: ".$name[0]."...", FILE_APPEND); + thread_load_newsserver($ns2,$name[0],0); + } } } + nntp_close($ns2); + nntp_close($ns); } -nntp_close($ns2); -nntp_close($ns); #expire_overview(); unlink($lockfile); echo "\nSpoolnews Done\n";