* newsportal.php now allows a force reload of groups.txt, by suppling (force_reload=true) as the third parameter to groups_read();
* spoolnews.php now forces a reload of groups.txt whenever it runs (regardless of caching) and also checks to see if a remote server has been defined before it tries to contact one.
This commit is contained in:
parent
09a1eb340d
commit
1d229d5ad1
|
@ -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");
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in New Issue