diff --git a/Rocksolid_Light/rocksolid/config.inc.php b/Rocksolid_Light/rocksolid/config.inc.php index 9d6a3d6..081deb2 100644 --- a/Rocksolid_Light/rocksolid/config.inc.php +++ b/Rocksolid_Light/rocksolid/config.inc.php @@ -16,7 +16,6 @@ if(file_exists($config_dir.$config_name.'.inc.php')) { } else { $config_file = $config_dir.'rslight.inc.php'; } - $installed_path = getcwd(); /* $config_path is a directory off the $config_dir diff --git a/Rocksolid_Light/rocksolid/lib/thread.inc.php b/Rocksolid_Light/rocksolid/lib/thread.inc.php index dc4ebed..fbcdaad 100644 --- a/Rocksolid_Light/rocksolid/lib/thread.inc.php +++ b/Rocksolid_Light/rocksolid/lib/thread.inc.php @@ -398,6 +398,10 @@ function thread_load_newsserver(&$ns,$groupname,$poll) { // read articles from the newsserver if ($spoolopenmodus != "n") { // order the article overviews from the newsserver + if($firstarticle == 0 && $lastarticle == 0) { + fclose($ns); + return false; + } fputs($ns,"XOVER ".$firstarticle."-".$lastarticle."\r\n"); $tmp=line_read($ns); // have the server accepted our order? diff --git a/Rocksolid_Light/rocksolid/newsportal.php b/Rocksolid_Light/rocksolid/newsportal.php index 5265ce6..d7db592 100644 --- a/Rocksolid_Light/rocksolid/newsportal.php +++ b/Rocksolid_Light/rocksolid/newsportal.php @@ -88,13 +88,15 @@ function nntp_open($nserver=0,$nport=0) { function nntp2_open($nserver=0,$nport=0) { global $text_error,$CONFIG; // echo "
NNTP OPEN
"; - echo "NS: ".$nserver." PORT: ".$nport; $authorize=((isset($CONFIG['remote_auth_user'])) && (isset($CONFIG['remote_auth_pass'])) && ($CONFIG['remote_auth_user'] != "")); if ($nserver==0) $nserver=$CONFIG['remote_server']; if ($nport==0) $nport=$CONFIG['remote_port']; if($CONFIG['remote_ssl']) { - $ns=@fsockopen('ssl://'.$nserver.":".$nport); + var_dump($ns = fsockopen("ssl://".$nserver, $nport, $error, $errorString, 30)); + var_dump($errorString); + var_dump($error); +// $ns=@fsockopen('ssl://'.$nserver.":".$nport); } else { if(isset($CONFIG['socks_host']) && $CONFIG['socks_host'] !== '') { $ns=fsocks4asockopen($CONFIG['socks_host'], $CONFIG['socks_port'], $nserver, $nport); @@ -1595,11 +1597,10 @@ $logfile=$logdir.'/newsportal.log'; $_SESSION['views'] = 0; } $_SESSION['views']++; - // $loadrate = allowed article request per second $loadrate = .15; $rate = fdiv($_SESSION['views'], (time() - $_SESSION['starttime'])); - if (($rate > $loadrate) && ($_SESSION['views'] > 5)) { + if (($rate > $loadrate) && ($_SESSION['views'] > 20)) { header("HTTP/1.0 429 Too Many Requests"); if(!isset($_SESSION['throttled'])) { file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Too many requests from ".$_SERVER['REMOTE_ADDR']." throttling", FILE_APPEND); diff --git a/Rocksolid_Light/rslight/scripts/import-db3.php b/Rocksolid_Light/rslight/scripts/import-db3.php index 7ebe3c9..c24294f 100755 --- a/Rocksolid_Light/rslight/scripts/import-db3.php +++ b/Rocksolid_Light/rslight/scripts/import-db3.php @@ -37,6 +37,28 @@ if (posix_getsid($pid) === false || !is_file($lockfile)) { exit; } +if($argv[1][0] == '-') { + switch ($argv[1]) { + case "-ver": + echo "Version 1.0\n"; + break; + case "-remove": + echo "Removing: ".$argv[2]."\n"; + remove_articles($argv[2]); + reset_group($argv[2], 1); + break; + case "-reset": + echo "Reset: ".$argv[2]."\n"; + remove_articles($argv[2]); + reset_group($argv[2], 0); + break; + } + exit(); +} else { + exit(); +} + +$group_list = get_group_list(); $group = trim($argv[1]); if($group == '') { $group_files = scandir($workpath); @@ -45,14 +67,91 @@ if($group == '') { continue; } $group = preg_replace('/-articles.db3/', '', $this_file); - echo 'Importing: '.$group."\n"; - import_articles($group); + if (in_array($group, $group_list)) { + echo "Importing: ".$group."\n"; + import_articles($group); + } else { + echo "Removing: ".$group."\n"; + remove_articles($group); + } } } else { + echo "Importing: ".$group."\n"; import_articles($group); } echo "\nImport Done\r\n"; +function get_group_list() { + global $config_dir; + $grouplist = array(); + $menulist = file($config_dir."menu.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + foreach($menulist as $menu) { + if($menu[0] == '#') { + continue; + } + $menuitem=explode(':', $menu); + if($menuitem[2] == '0') { + continue; + } + $glist = file($config_dir.$menuitem[0]."/groups.txt"); + foreach($glist as $gl) { + if($gl[0] == ':') { + continue; + } + $group_name = preg_split("/( |\t)/", $gl, 2); + $grouplist[] = trim($group_name[0]); + } + } + return $grouplist; +} + +function reset_group($group, $remove=0) { + global $config_dir, $spooldir; + $group = trim($group); + + if(!$section = get_section_by_group($group)) { + return false; + } + $config_location = $spooldir.'/'.$section; + $config_files = array_diff(scandir($config_location), array('..', '.')); + + foreach($config_files as $config_file) { + $output = array(); + echo $config_location.'/'.$config_file."\n"; + $thisfile = file($config_location.'/'.$config_file); + foreach($thisfile as $thisgroupline) { + $onegroup = explode(':', $thisgroupline); + if(trim($onegroup[0]) == $group) { + echo "FOUND: ".$group." in ".$section."\n"; + if($remove == 0) { + $output[] = $group."\n"; + } + } else { + $output[] = $thisgroupline; + } + } + file_put_contents($config_location.'/'.$config_file, $output); + } +} + +function remove_articles($group) { + global $spooldir, $CONFIG, $workpath, $path, $config_name, $logfile; + $group = trim($group); + $overview_file = $workpath.'/'.$group."-overview"; + # Prepare databases + $dbh = rslight_db_open($spooldir.'/articles-overview.db3'); + $clear_stmt = $dbh->prepare("DELETE FROM overview WHERE newsgroup=:group"); + $clear_stmt->bindParam(':group', $group); + $clear_stmt->execute(); + unlink($overview_file); + rename($spooldir.'/'.$group.'-articles.db3',$spooldir.'/'.$group.'-articles.db3-removed'); + unlink($spooldir.'/'.$group.'-data.dat'); + unlink($spooldir.'/'.$group.'-info.txt'); + unlink($spooldir.'/'.$group.'-cache.txt'); + unlink($spooldir.'/'.$group.'-lastarticleinfo.dat'); + unlink($spooldir.'/'.$group.'-overboard.dat'); +} + function import_articles($group) { global $spooldir, $CONFIG, $workpath, $path, $config_name, $logfile; $overview_file = $workpath.'/'.$group."-overview"; @@ -150,5 +249,8 @@ function import_articles($group) { rename($spooldir.'/'.$group.'-articles.db3-new', $spooldir.'/'.$group.'-articles.db3'); unlink($spooldir.'/'.$group.'-data.dat'); unlink($spooldir.'/'.$group.'-info.txt'); + unlink($spooldir.'/'.$group.'-cache.txt'); + unlink($spooldir.'/'.$group.'-lastarticleinfo.dat'); + unlink($spooldir.'/'.$group.'-overboard.dat'); } ?> diff --git a/Rocksolid_Light/rslight/scripts/rslight-lib.php b/Rocksolid_Light/rslight/scripts/rslight-lib.php index c4d0d8f..b3b0ad9 100755 --- a/Rocksolid_Light/rslight/scripts/rslight-lib.php +++ b/Rocksolid_Light/rslight/scripts/rslight-lib.php @@ -50,7 +50,6 @@ set_time_limit(0); $command = explode(' ', $buf); $command[0] = strtolower($command[0]); if(isset($command[1])) { - $command[1] = strtolower($command[1]); } if ($command[0] == 'date') { $msg = '111 '.date('YmdHis')."\r\n"; @@ -590,7 +589,6 @@ function extract_header_line($article_full_path, $header, $thisgroup, $article) function get_title($mode) { global $nntp_group,$workpath,$spooldir,$path; - $mode = strtolower($mode); if($mode == "active") { $msg="481 descriptions unavailable\r\n"; return $msg; @@ -601,7 +599,7 @@ function get_title($mode) { } $title = file_get_contents($spooldir."/".$mode."-title"); $msg="282 list of group and description follows\r\n"; - $msg.=$title; + $msg.=trim($title); $msg.="\r\n.\r\n"; return $msg; @@ -870,8 +868,6 @@ function get_listgroup($nntp_group, $msgsock) { $count=0; foreach($grouplist as $findgroup) { $name = preg_split("/( |\t)/", $findgroup, 2); - $name[0]=strtolower($name[0]); - $nntp_group=strtolower($nntp_group); if(!strcmp($name[0], $nntp_group)) { $ok_group=true; break; @@ -904,8 +900,6 @@ function get_group($change_group) { $count=0; foreach($grouplist as $findgroup) { $name = preg_split("/( |\t)/", $findgroup, 2); - $name[0]=strtolower($name[0]); - $change_group=strtolower($change_group); if(!strcmp($name[0], $change_group)) { $ok_group=true; break; @@ -933,7 +927,6 @@ function get_group($change_group) { function get_newgroups($mode) { global $path,$groupconfig; $grouplist = file($groupconfig, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); - $mode = strtolower($mode); $mode = "active"; if($mode == "active") { $msg = '231 list of newsgroups follows'."\r\n"; @@ -982,7 +975,6 @@ function get_newgroups($mode) { function get_list($mode, $msgsock) { global $path,$spooldir,$groupconfig; $grouplist = file($groupconfig, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); - $mode = strtolower($mode); if($mode == "headers") { $msg = "215 metadata items supported:\r\n"; $msg.= ":\r\n"; diff --git a/Rocksolid_Light/rslight/scripts/spoolnews.php b/Rocksolid_Light/rslight/scripts/spoolnews.php index 9b3bff7..1d5a80f 100755 --- a/Rocksolid_Light/rslight/scripts/spoolnews.php +++ b/Rocksolid_Light/rslight/scripts/spoolnews.php @@ -55,6 +55,7 @@ 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); @@ -231,7 +232,7 @@ function get_articles($ns, $group) { $local++; } } - $articleHandle = fopen($grouppath."/".$local, 'w+'); + $articleHandle = $grouppath."/".$local; $response = line_read($ns); $lines=0; $bytes=0; @@ -301,24 +302,22 @@ function get_articles($ns, $group) { } else { $body.=$response."\n"; } - fputs($articleHandle, $response."\n"); + file_put_contents($articleHandle, $response."\n", FILE_APPEND); // Check here for broken $ns connection before continuing $response=fgets($ns,1200); if($response == false) { 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); - continue; + break; +// continue; } $response=str_replace("\n","",str_replace("\r","",$response)); } - fputs($articleHandle, $response."\n"); - @fclose($articleHandle); + file_put_contents($articleHandle, $response."\n", FILE_APPEND); $lines=$lines-1; $bytes = $bytes + ($lines * 2); // Don't spool article if $banned=1 if($banned == 1) { -// @fclose($articleHandle); unlink($grouppath."/".$local); file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Skipping: ".$CONFIG['remote_server']." ".$group.":".$article." user: ".$from[1]." is banned", FILE_APPEND); $article++;