Merge branch 'devel'

This commit is contained in:
Retro_Guy 2024-06-15 06:27:24 -07:00
commit d3c10082d6
10 changed files with 3161 additions and 3013 deletions

View File

@ -1 +1 @@
0.9.12 0.9.133

View File

@ -185,7 +185,7 @@ function message_parse($rawmessage)
*/ */
function message_read($id, $bodynum = 0, $group = "") function message_read($id, $bodynum = 0, $group = "")
{ {
global $CONFIG, $config_name, $cache_articles, $spooldir, $spoolpath, $logdir, $text_error, $ns; global $CONFIG, $config_dir, $config_name, $cache_articles, $spooldir, $spoolpath, $logdir, $text_error, $ns;
$logfile = $logdir . '/newsportal.log'; $logfile = $logdir . '/newsportal.log';
if (! testGroup($group)) { if (! testGroup($group)) {
echo $text_error["read_access_denied"]; echo $text_error["read_access_denied"];
@ -194,6 +194,24 @@ function message_read($id, $bodynum = 0, $group = "")
if (! is_numeric($id)) { if (! is_numeric($id)) {
return false; return false;
} }
// MEMCACHE if ($id, 0, $group)
if ($bodynum == 0 && $group != "") {
if (file_exists($config_dir . '/cache.inc.php')) {
include $config_dir . '/cache.inc.php';
}
}
if ($enable_cache) {
$cache_key = $cache_key_prefix . '_' . 'message_read-' . $id . '-0-' . $group;
$message_data = cache_get($cache_key, $memcacheD);
if ($message_data) {
if ($message = unserialize(gzuncompress($message_data))) {
if ($enable_cache_logging) {
file_put_contents($cache_log, "\n" . format_log_date() . " (cache hit) $cache_key", FILE_APPEND);
}
return $message;
}
}
}
$message = new messageType(); $message = new messageType();
if ((isset($cache_articles)) && ($cache_articles == true)) { if ((isset($cache_articles)) && ($cache_articles == true)) {
// Try to load a cached article // Try to load a cached article
@ -287,6 +305,13 @@ function message_read($id, $bodynum = 0, $group = "")
} }
} }
} }
// MEMCACHE if ($id, 0, $group)
if ($enable_cache) {
$nicole = cache_add($cache_key, gzcompress(serialize($message)), $cache_ttl, $memcacheD);
if ($enable_cache_logging && $nicole) {
file_put_contents($cache_log, "\n" . format_log_date() . " (cache write) " . $cache_key, FILE_APPEND);
}
}
return $message; return $message;
} }
@ -615,9 +640,7 @@ function display_full_headers($article, $group, $name, $from, $getface = false)
} else { } else {
$message = $current_message; $message = $current_message;
} }
if (isset($sendface)) { $sendface = null;
unlink($sendface);
}
$isface = 0; $isface = 0;
$return = ''; $return = '';
foreach ($message as $line) { foreach ($message as $line) {
@ -805,8 +828,11 @@ function message_show($group, $id, $attachment = 0, $article_data = false, $maxl
} }
if (($block_xnoarchive) && (isset($head->xnoarchive)) && ($head->xnoarchive == "yes")) { if (($block_xnoarchive) && (isset($head->xnoarchive)) && ($head->xnoarchive == "yes")) {
echo $text_article["block-xnoarchive"]; echo '<hr><p class=np_ob_posted_date>' . $text_article["block-xnoarchive"] . '(article #' . $id . ')</p><hr>';
} else if (($head->content_type[$attachment] == "text/plain") && ($attachment == 0)) { return "no-archive";
}
if (($head->content_type[$attachment] == "text/plain") && ($attachment == 0)) {
show_header($head, $group, $local_poster); show_header($head, $group, $local_poster);
// X-Face // X-Face
if (($face = display_full_headers($head->number, $group, $head->name, $head->from, true)) && ($OVERRIDES['disable_xface'] != true)) { if (($face = display_full_headers($head->number, $group, $head->name, $head->from, true)) && ($OVERRIDES['disable_xface'] != true)) {

View File

@ -68,19 +68,22 @@ function thread_pageselect($group, $article_count, $first)
function thread_cache_load($group) function thread_cache_load($group)
{ {
global $spooldir, $config_dir, $logdir, $compress_spoolfiles; global $spooldir, $config_dir, $logdir, $compress_spoolfiles;
if (file_exists($config_dir . '/memcache.inc.php')) { if (file_exists($config_dir . '/cache.inc.php')) {
include $config_dir . '/memcache.inc.php'; include $config_dir . '/cache.inc.php';
} }
// Check memcache // Check memcache
if ($memcacheD) { if ($enable_cache) {
$key = $memcache_key_prefix . '_' . 'thread_cache-' . $group; $cache_key = $cache_key_prefix . '_' . 'thread_cache-' . $group;
if ($headers = unserialize(gzuncompress($memcacheD->get($key)))) { $message_data = cache_get($cache_key, $memcacheD);
if ($enable_memcache_logging) { if ($message_data) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache hit) $key", FILE_APPEND); if ($headers = unserialize(gzuncompress($message_data))) {
if ($enable_cache_logging) {
file_put_contents($cache_log, "\n" . format_log_date() . " (cache hit) $cache_key", FILE_APPEND);
} }
return $headers; return $headers;
} }
} }
}
$database = $spooldir . '/' . $group . '-data.db3'; $database = $spooldir . '/' . $group . '-data.db3';
$table = "threads"; $table = "threads";
@ -93,24 +96,22 @@ function thread_cache_load($group)
} }
$dbh = null; $dbh = null;
} }
if ($memcacheD) { if ($enable_cache) {
$key = $memcache_key_prefix . '_' . 'thread_cache-' . $group;
$add_thread = gzcompress(serialize($headers), 9); $add_thread = gzcompress(serialize($headers), 9);
$thread_bytes = strlen($add_thread); $thread_bytes = strlen($add_thread);
$too_big = false; $too_big = false;
if($thread_bytes < $memcache_maxitemsize) { if ($thread_bytes < $cache_maxitemsize) {
$nicole = $memcacheD->add($key, $add_thread, $memcache_ttl); $nicole = cache_add($cache_key, $add_thread, $cache_ttl, $memcacheD);
} else { } else {
$nicole = false; $nicole = false;
$too_big = true; $too_big = true;
} }
if ($nicole && $enable_memcache_logging) { if ($nicole && $enable_cache_logging) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) $key (" . strlen($add_thread) . " bytes)", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " (cache write) $cache_key (" . strlen($add_thread) . " bytes)", FILE_APPEND);
} }
if ($too_big) { if ($too_big) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " $key too large (" . $thread_bytes . " bytes)", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " $cache_key too large (" . $thread_bytes . " bytes)", FILE_APPEND);
} }
} }
return ($headers); return ($headers);
@ -127,8 +128,8 @@ function thread_cache_save($headers, $group)
global $spooldir, $compress_spoolfiles, $config_dir, $logdir, $config_name; global $spooldir, $compress_spoolfiles, $config_dir, $logdir, $config_name;
$logfile = $logdir . '/newsportal.log'; $logfile = $logdir . '/newsportal.log';
if (file_exists($config_dir . '/memcache.inc.php')) { if (file_exists($config_dir . '/cache.inc.php')) {
include $config_dir . '/memcache.inc.php'; include $config_dir . '/cache.inc.php';
} }
$database = $spooldir . '/' . $group . '-data.db3'; $database = $spooldir . '/' . $group . '-data.db3';
@ -150,27 +151,27 @@ function thread_cache_save($headers, $group)
]); ]);
$dbh->commit(); $dbh->commit();
$dbh = null; $dbh = null;
if ($memcacheD) { if ($enable_cache) {
$key = $memcache_key_prefix . '_' . 'thread_cache-' . $group; $cache_key = $cache_key_prefix . '_' . 'thread_cache-' . $group;
$del = $memcacheD->delete($key); $del = cache_delete($cache_key, $memcacheD);
$add_thread = gzcompress(serialize($headers), 9); $add_thread = gzcompress(serialize($headers), 9);
$thread_bytes = strlen($add_thread); $thread_bytes = strlen($add_thread);
$too_big = false; $too_big = false;
if($thread_bytes < $memcache_maxitemsize) { if ($thread_bytes < $cache_maxitemsize) {
$nicole = $memcacheD->add($key, $add_thread, $memcache_ttl); $nicole = cache_add($cache_key, $add_thread, $cache_ttl, $memcacheD);
} else { } else {
$too_big = true; $too_big = true;
$nicole = false; $nicole = false;
} }
if ($enable_memcache_logging) { if ($enable_cache_logging) {
if ($del) { if ($del) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache delete) $key", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " (cache delete) $cache_key", FILE_APPEND);
} }
if ($nicole) { if ($nicole) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) $key (" . $thread_bytes . " bytes)", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " (cache write) $cache_key (" . $thread_bytes . " bytes)", FILE_APPEND);
} }
if ($too_big) { if ($too_big) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " $key too large (" . $thread_bytes . " bytes)", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " $cache_key too large (" . $thread_bytes . " bytes)", FILE_APPEND);
} }
} }
} }

View File

@ -602,8 +602,8 @@ function groups_show($gruppen)
return; return;
global $file_thread, $text_groups; global $file_thread, $text_groups;
$logfile = $logdir . '/debug.log'; $logfile = $logdir . '/debug.log';
if (file_exists($config_dir . '/memcache.inc.php')) { if (file_exists($config_dir . '/cache.inc.php')) {
include $config_dir . '/memcache.inc.php'; include $config_dir . '/cache.inc.php';
} }
$c = count($gruppen); $c = count($gruppen);
$acttype = "keins"; $acttype = "keins";
@ -639,13 +639,15 @@ function groups_show($gruppen)
$found = 0; $found = 0;
// Get last article info from article database // Get last article info from article database
// First check memcache // First check memcache
if ($memcacheD) { if ($enable_cache) {
$lar_memcache = $memcache_key_prefix . '_' . 'lastarticleinfo-' . $g->name; $memcache_key = $cache_key_prefix . '_' . 'lastarticleinfo-' . $g->name;
$groupfile = $spooldir . '/' . $g->name . '-lastarticleinfo.dat'; $groupfile = $spooldir . '/' . $g->name . '-lastarticleinfo.dat';
if ($lastarticleinfo = unserialize($memcacheD->get($lar_memcache))) { $lar = cache_get($memcache_key, $memcacheD);
if ($lar) {
if ($lastarticleinfo = unserialize($lar)) {
if ($lastarticleinfo && file_exists($groupfile) && filemtime($groupfile) <= $lastarticleinfo['date']) { if ($lastarticleinfo && file_exists($groupfile) && filemtime($groupfile) <= $lastarticleinfo['date']) {
if ($enable_memcache_logging) { if ($enable_cache_logging) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . ' (cache hit) lastarticleinfo for ' . $g->name, FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . ' (cache hit) ' . $memcache_key, FILE_APPEND);
} }
$found = 1; $found = 1;
} else { } else {
@ -653,6 +655,7 @@ function groups_show($gruppen)
} }
} }
} }
}
if (! isset($lastarticleinfo['date'])) { if (! isset($lastarticleinfo['date'])) {
if ($CONFIG['article_database'] == '1') { if ($CONFIG['article_database'] == '1') {
$database = $spooldir . '/' . $g->name . '-articles.db3'; $database = $spooldir . '/' . $g->name . '-articles.db3';
@ -685,15 +688,15 @@ function groups_show($gruppen)
} }
if ($found == 1) { if ($found == 1) {
$lastarticleinfo = $row; $lastarticleinfo = $row;
if ($memcacheD) { if ($enable_cache) {
touch($groupfile, $lastarticleinfo['date']); touch($groupfile, $lastarticleinfo['date']);
$nicole = $memcacheD->delete($lar_memcache); $nicole = cache_delete($memcache_key, $memcacheD);
$memcacheD->add($lar_memcache, serialize($row), $memcache_ttl); cache_add($memcache_key, serialize($row), $cache_ttl, $memcacheD);
if ($enable_memcache_logging) { if ($enable_cache_logging) {
if ($nicole) { if ($nicole) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache update) $lar_memcache", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " (cache update) $memcache_key", FILE_APPEND);
} else { } else {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) $lar_memcache", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " (cache write) $memcache_key", FILE_APPEND);
} }
} }
} }
@ -1619,18 +1622,20 @@ function get_date_interval($value)
function get_newsgroups_by_msgid($msgid, $noarray = false) function get_newsgroups_by_msgid($msgid, $noarray = false)
{ {
global $spooldir, $config_dir, $logdir, $CONFIG; global $spooldir, $config_dir, $logdir, $CONFIG;
if (file_exists($config_dir . '/memcache.inc.php')) { if (file_exists($config_dir . '/cache.inc.php')) {
include $config_dir . '/memcache.inc.php'; include $config_dir . '/cache.inc.php';
} }
if ($memcacheD) { if ($enable_cache) {
$key = $memcache_key_prefix . '_' . 'get_newsgroups_by_msgid-' . $msgid; $memcache_key = $cache_key_prefix . '_' . 'get_newsgroups_by_msgid-' . $msgid;
if ($groups = $memcacheD->get($key)) { if ($getgroups = cache_get($memcache_key, $memcacheD)) {
if ($enable_memcache_logging) { if ($groups = unserialize($getgroups)) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache hit) $key", FILE_APPEND); if ($enable_cache_logging) {
file_put_contents($cache_log, "\n" . format_log_date() . " (cache hit) $memcache_key", FILE_APPEND);
} }
} }
} }
if (! $groups) { }
if (! isset($groups)) {
$database = $spooldir . '/articles-overview.db3'; $database = $spooldir . '/articles-overview.db3';
$table = 'overview'; $table = 'overview';
$overview_dbh = overview_db_open($database, $table); $overview_dbh = overview_db_open($database, $table);
@ -1648,10 +1653,10 @@ function get_newsgroups_by_msgid($msgid, $noarray = false)
$groups = null; $groups = null;
} }
$overview_dbh = null; $overview_dbh = null;
if ($groups && $memcacheD) { if ($groups && $enable_cache) {
$nicole = $memcacheD->add($key, $groups, $memcache_ttl); $nicole = cache_add($memcache_key, serialize($groups), $cache_ttl, $memcacheD);
if ($enable_memcache_logging && $nicole) { if ($enable_cache_logging && $nicole) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) $key", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " (cache write) $memcache_key", FILE_APPEND);
} }
} }
} }
@ -1900,20 +1905,20 @@ function np_get_db_article($article, $group, $makearray = 1, $dbh = null)
global $config_dir, $path, $groupconfig, $config_name, $logdir, $spooldir; global $config_dir, $path, $groupconfig, $config_name, $logdir, $spooldir;
$logfile = $logdir . '/newsportal.log'; $logfile = $logdir . '/newsportal.log';
if (file_exists($config_dir . '/memcache.inc.php')) { if (file_exists($config_dir . '/cache.inc.php')) {
include $config_dir . '/memcache.inc.php'; include $config_dir . '/cache.inc.php';
} }
$msg2 = ""; $msg2 = "";
$closeme = 0; $closeme = 0;
$ok_article = 0; $ok_article = 0;
// Check memcache // Check memcache
if ($memcacheD) { if ($enable_cache) {
$article_key = $memcache_key_prefix . '_' . 'article.db3-' . $group . ':' . $article; $article_key = $cache_key_prefix . '_' . 'article.db3-' . $group . ':' . $article;
if ($msg2 = $memcacheD->get($article_key)) { if ($msg2 = gzuncompress(cache_get($article_key, $memcacheD))) {
$ok_article = 1; $ok_article = 1;
if ($enable_memcache_logging) { if ($enable_cache_logging) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache hit) $article_key", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " (cache hit) $article_key", FILE_APPEND);
} }
} }
} }
@ -1946,10 +1951,10 @@ function np_get_db_article($article, $group, $makearray = 1, $dbh = null)
break; break;
} }
} }
if ($ok_article == 1 && $memcacheD) { if ($ok_article == 1 && $enable_cache) {
$nicole = $memcacheD->add($article_key, $msg2, $memcache_ttl); $nicole = cache_add($article_key, gzcompress($msg2), $cache_ttl, $memcacheD);
if ($enable_memcache_logging && $nicole) { if ($enable_cache_logging && $nicole) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) $article_key", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " (cache write) $article_key", FILE_APPEND);
} }
} }
} }
@ -2094,25 +2099,26 @@ function disable_page_by_user_agent($client_device, $useragent, $script = "Page"
} }
} }
function throttle_hits($client_device) function throttle_hits($client_device = null)
{ {
global $CONFIG, $OVERRIDES, $logdir, $config_name; global $CONFIG, $OVERRIDES, $logdir, $config_name;
$logfile = $logdir . '/newsportal.log'; $logfile = $logdir . '/newsportal.log';
if (! $client_device) {
$client_device = get_client_user_agent_info(); $client_device = get_client_user_agent_info();
}
$client_device = strtolower($client_device); $client_device = strtolower($client_device);
$useragent = strtolower($useragent);
$_SESSION['rsactive'] = true; $_SESSION['rsactive'] = true;
if (isset($OVERRIDES['block_by_user_agent'])) { if (isset($OVERRIDES['block_by_user_agent'])) {
$ua = strtolower($_SERVER["HTTP_USER_AGENT"]); $ua = strtolower($_SERVER["HTTP_USER_AGENT"]);
foreach($OVERRIDES['block_by_user_agent'] as $user_agent) { foreach ($OVERRIDES['block_by_user_agent'] as $user_agent) {
if(stripos($ua, $user_agent) !== false) { if (stripos($ua, $user_agent) !== false) {
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Blocking " . $_SERVER['REMOTE_ADDR'] . " '" . $user_agent . "' listed in block list", FILE_APPEND); file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Blocking " . $_SERVER['REMOTE_ADDR'] . " '" . $user_agent . "' listed in block list", FILE_APPEND);
$_SESSION['throttled'] = true; $_SESSION['throttled'] = true;
header("HTTP/1.0 403 Forbidden"); header("HTTP/1.0 403 Forbidden");
exit; exit();
} }
} }
} }
@ -2469,14 +2475,14 @@ function insert_article_from_array($this_article, $check_duplicates = true)
unlink($grouppath . "/" . $this_article['local']); unlink($grouppath . "/" . $this_article['local']);
$article_dbh = null; $article_dbh = null;
// Add to memcache // Add to memcache
if (file_exists($config_dir . '/memcache.inc.php')) { if (file_exists($config_dir . '/cache.inc.php')) {
include $config_dir . '/memcache.inc.php'; include $config_dir . '/cache.inc.php';
} }
if ($memcacheD) { if ($enable_cache) {
$article_key = $memcache_key_prefix . '_' . 'article.db3-' . $group . ':' . $this_article['local']; $article_key = $cache_key_prefix . '_' . 'article.db3-' . $group . ':' . $this_article['local'];
$nicole = $memcacheD->add($article_key, $this_article['article'], $memcache_ttl); $nicole = cache_add($article_key, gzcompress($this_article['article']), $cache_ttl, $memcacheD);
if ($enable_memcache_logging && $nicole) { if ($enable_cache_logging && $nicole) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) (new) $article_key", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " (cache write) (new) $article_key", FILE_APPEND);
} }
} }
} else { } else {
@ -2548,15 +2554,15 @@ function clear_history_by_group($group)
function get_db_data_from_msgid($msgid, $group) function get_db_data_from_msgid($msgid, $group)
{ {
global $spooldir, $config_dir, $logdir; global $spooldir, $config_dir, $logdir;
if (file_exists($config_dir . '/memcache.inc.php')) { if (file_exists($config_dir . '/cache.inc.php')) {
include $config_dir . '/memcache.inc.php'; include $config_dir . '/cache.inc.php';
} }
if ($memcacheD) { if ($enable_cache) {
$row_cache = $memcache_key_prefix . '_' . 'get_db_data_from_msgid-' . $msgid; $row_cache = $cache_key_prefix . '_' . 'get_db_data_from_msgid-' . $msgid;
if ($row = $memcacheD->get($row_cache)) { if ($row = unserialize(gzuncompress(cache_get($row_cache, $memcacheD)))) {
if ($enable_memcache_logging) { if ($enable_cache_logging) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache hit) $row_cache", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " (cache hit) $row_cache", FILE_APPEND);
} }
return $row; return $row;
} }
@ -2578,10 +2584,10 @@ function get_db_data_from_msgid($msgid, $group)
} }
$dbh = null; $dbh = null;
if ($found) { if ($found) {
if ($memcacheD) { if ($enable_cache) {
$nicole = $memcacheD->add($row_cache, $row, $memcache_ttl); $nicole = cache_add($row_cache, gzcompress(serialize($row)), $cache_ttl, $memcacheD);
if ($enable_memcache_logging && $nicole) { if ($enable_cache_logging && $nicole) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) $row_cache", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " (cache write) $row_cache", FILE_APPEND);
} }
} }
return $row; return $row;
@ -2618,19 +2624,19 @@ function get_group_array_from_msgid($msgid)
function get_data_from_msgid($msgid, $thisgroup = null) function get_data_from_msgid($msgid, $thisgroup = null)
{ {
global $spooldir, $config_dir, $logdir, $CONFIG; global $spooldir, $config_dir, $logdir, $CONFIG;
if (file_exists($config_dir . '/memcache.inc.php')) { if (file_exists($config_dir . '/cache.inc.php')) {
include $config_dir . '/memcache.inc.php'; include $config_dir . '/cache.inc.php';
} }
if ($CONFIG['article_database'] == '1' && isset($thisgroup)) { if ($CONFIG['article_database'] == '1' && isset($thisgroup)) {
return get_db_data_from_msgid($msgid, $thisgroup); return get_db_data_from_msgid($msgid, $thisgroup);
} }
if ($memcacheD) { if ($enable_cache) {
$row_cache = $memcache_key_prefix . '_' . 'get_data_from_msgid-' . $msgid; $row_cache = $cache_key_prefix . '_' . 'get_data_from_msgid-' . $msgid;
if ($row = $memcacheD->get($row_cache)) { if ($row = cache_get($row_cache, $memcacheD)) {
if ($enable_memcache_logging) { if ($enable_cache_logging) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache hit) $row_cache", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " (cache hit) $row_cache", FILE_APPEND);
} }
return $row; return $row;
} }
@ -2657,10 +2663,10 @@ function get_data_from_msgid($msgid, $thisgroup = null)
} }
$dbh = null; $dbh = null;
if ($found) { if ($found) {
if ($memcacheD) { if ($enable_cache) {
$nicole = $memcacheD->add($row_cache, $row, $memcache_ttl); $nicole = cache_add($row_cache, $row, $cache_ttl, $memcacheD);
if ($enable_memcache_logging && $nicole) { if ($enable_cache_logging && $nicole) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " (cache write) $row_cache", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " (cache write) $row_cache", FILE_APPEND);
} }
} }
return $row; return $row;
@ -2743,8 +2749,8 @@ function send_admin_message($admin, $from, $subject, $message)
function delete_message($messageid, $group = null, $overview_dbh = null) function delete_message($messageid, $group = null, $overview_dbh = null)
{ {
global $logfile, $logdir, $config_dir, $spooldir, $CONFIG, $webserver_group; global $logfile, $logdir, $config_dir, $spooldir, $CONFIG, $webserver_group;
if (file_exists($config_dir . '/memcache.inc.php')) { if (file_exists($config_dir . '/cache.inc.php')) {
include $config_dir . '/memcache.inc.php'; include $config_dir . '/cache.inc.php';
} }
if ($group == null) { if ($group == null) {
$grouplist = get_newsgroups_by_msgid($messageid); $grouplist = get_newsgroups_by_msgid($messageid);
@ -2756,7 +2762,7 @@ function delete_message($messageid, $group = null, $overview_dbh = null)
$menulist = file($config_dir . "menu.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $menulist = file($config_dir . "menu.conf", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($grouplist as $group) { foreach ($grouplist as $group) {
$config_name = get_section_by_group($group, true); $config_name = get_section_by_group($group, true);
if(!$config_name) { if (! $config_name) {
file_put_contents($logfile, "\n" . format_log_date() . " Group not found: " . $group, FILE_APPEND); file_put_contents($logfile, "\n" . format_log_date() . " Group not found: " . $group, FILE_APPEND);
continue; continue;
} }
@ -2811,14 +2817,14 @@ function delete_message($messageid, $group = null, $overview_dbh = null)
':msgid' => $messageid ':msgid' => $messageid
]); ]);
// Delete article from memcache // Delete article from memcache
if ($memcacheD) { if ($enable_cache) {
$article_key = $memcache_key_prefix . '_' . 'article.db3-' . $group . ':' . $row['number']; $article_key = $cache_key_prefix . '_' . 'article.db3-' . $group . ':' . $row['number'];
$result = $memcacheD->delete($article_key); $result = cache_delete($article_key, $memcacheD);
if ($enable_memcache_logging) { if ($enable_cache_logging) {
if ($result) { if ($result) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " Deleted $article_key", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " Deleted $article_key", FILE_APPEND);
} else { } else {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . " Failed to delete (or not found) $article_key", FILE_APPEND); file_put_contents($cache_log, "\n" . format_log_date() . " Failed to delete (or not found) $article_key", FILE_APPEND);
} }
} }
} }
@ -2926,6 +2932,7 @@ function delete_message_from_overboard($config_name, $group, $messageid)
$cachefile = $spooldir . "/" . $config_name . "-overboard.dat"; $cachefile = $spooldir . "/" . $config_name . "-overboard.dat";
if (is_file($cachefile)) { if (is_file($cachefile)) {
$cached_overboard = unserialize(file_get_contents($cachefile)); $cached_overboard = unserialize(file_get_contents($cachefile));
if (isset($cached_overboard['msgids'][$messageid])) {
if ($target = $cached_overboard['msgids'][$messageid]) { if ($target = $cached_overboard['msgids'][$messageid]) {
unset($cached_overboard['threads'][$target['date']]); unset($cached_overboard['threads'][$target['date']]);
unset($cached_overboard['msgids'][$messageid]); unset($cached_overboard['msgids'][$messageid]);
@ -2933,9 +2940,11 @@ function delete_message_from_overboard($config_name, $group, $messageid)
file_put_contents($cachefile, serialize($cached_overboard)); file_put_contents($cachefile, serialize($cached_overboard));
} }
} }
}
$cachefile = $spooldir . "/" . $group . "-overboard.dat"; $cachefile = $spooldir . "/" . $group . "-overboard.dat";
if (is_file($cachefile)) { if (is_file($cachefile)) {
$cached_overboard = unserialize(file_get_contents($cachefile)); $cached_overboard = unserialize(file_get_contents($cachefile));
if (isset($cached_overboard['msgids'][$messageid])) {
if ($target = $cached_overboard['msgids'][$messageid]) { if ($target = $cached_overboard['msgids'][$messageid]) {
unset($cached_overboard['threads'][$target['date']]); unset($cached_overboard['threads'][$target['date']]);
unset($cached_overboard['msgids'][$messageid]); unset($cached_overboard['msgids'][$messageid]);
@ -2943,4 +2952,66 @@ function delete_message_from_overboard($config_name, $group, $messageid)
file_put_contents($cachefile, serialize($cached_overboard)); file_put_contents($cachefile, serialize($cached_overboard));
} }
} }
}
}
function cache_add($cache_key, $data, $cache_ttl, $memcacheD = null)
{
global $enable_cache, $cache_dir, $cache_log, $low_spool_disk_space;
$cache_key = base64_encode($cache_key);
if ($enable_cache == 'memcached') {
if ($memcacheD) {
if ($nicole = $memcacheD->add($cache_key, $data, $cache_ttl)) {
return $nicole;
}
}
}
if ($enable_cache == 'diskcache') {
if ($low_spool_disk_space) {
file_put_contents($cache_log, "\n" . format_log_date() . " " . $config_name . " Low Disk Space (less than " . $min_spool_disk_space . "Gb available for cache). Pausing diskcache", FILE_APPEND);
return false;
}
if ($nicole = file_put_contents($cache_dir . '/' . $cache_key, $data)) {
return $nicole;
}
}
return false;
}
function cache_delete($cache_key, $memcacheD = null)
{
global $enable_cache, $cache_dir;
$cache_key = base64_encode($cache_key);
if ($enable_cache == 'memcached') {
if ($memcacheD) {
if ($nicole = $memcacheD->delete($cache_key)) {
return $nicole;
}
}
}
if ($enable_cache == 'diskcache') {
if (file_exists($cache_dir . '/' . $cache_key)) {
return unlink($cache_dir . '/' . $cache_key);
}
}
return false;
}
function cache_get($cache_key, $memcacheD = null)
{
global $enable_cache, $cache_dir;
$cache_key = base64_encode($cache_key);
if ($enable_cache == 'memcached') {
if ($memcacheD) {
if ($nicole = $memcacheD->get($cache_key)) {
return $nicole;
}
}
}
if ($enable_cache == 'diskcache') {
if (file_exists($cache_dir . '/' . $cache_key)) {
return file_get_contents($cache_dir . '/' . $cache_key);
}
}
return false;
} }

View File

@ -308,7 +308,9 @@ function display_threads($threads, $oldest)
$style = 0; $style = 0;
$results = 0; $results = 0;
foreach ($nicole as $key => $value) { foreach ($nicole as $key => $value) {
if (isset($this_overboard['msgids'][$key])) {
$target_head = $this_overboard['msgids'][$key]; $target_head = $this_overboard['msgids'][$key];
}
if (! isset($target_head['msgid'])) { if (! isset($target_head['msgid'])) {
$target_head = get_data_from_msgid($key); $target_head = get_data_from_msgid($key);
} }
@ -333,7 +335,6 @@ function display_threads($threads, $oldest)
} }
} }
$results ++; $results ++;
$lone == '';
$skip = ''; $skip = '';
if ($nohead) { if ($nohead) {
if (($style % 2) == 0) { if (($style % 2) == 0) {

View File

@ -42,7 +42,7 @@ if (! isset($_SESSION['remote_address'])) {
$ip_pass = true; $ip_pass = true;
} }
} }
if ($ip_pass && $_SESSION['pass']) { if ($ip_pass && (isset($_SESSION['pass']) && $_SESSION['pass'] === true)) {
$logged_in = true; $logged_in = true;
} else { } else {
$logged_in = false; $logged_in = false;
@ -141,7 +141,7 @@ if (function_exists("npreg_get_email")) {
if (! strcmp($name, $CONFIG['anonusername']) && (isset($CONFIG['anonuser']))) { if (! strcmp($name, $CONFIG['anonusername']) && (isset($CONFIG['anonuser']))) {
$userpass = $CONFIG['anonuserpass']; $userpass = $CONFIG['anonuserpass'];
$email = $name . $CONFIG['email_tail']; $email = $name . $CONFIG['email_tail'];
$_SESSION['pass'] = '0'; $_SESSION['pass'] = false;
} else { } else {
$userpass = $email; $userpass = $email;
$request = "email"; $request = "email";
@ -262,9 +262,9 @@ if ($type == "post") {
} else { } else {
$message = message_post(quoted_printable_encode($subject), $nemail . " (" . quoted_printable_encode($name) . ")", $newsgroups, $references_array, addslashes($body), $_POST['encryptthis'], $_POST['encryptto'], strtolower($name), $_POST['fromname']); $message = message_post(quoted_printable_encode($subject), $nemail . " (" . quoted_printable_encode($name) . ")", $newsgroups, $references_array, addslashes($body), $_POST['encryptthis'], $_POST['encryptto'], strtolower($name), $_POST['fromname']);
/* /*
$message = message_post(quoted_printable_encode($subject), $nemail . " (" . quoted_printable_encode($name) . ")", $newsgroups, $references_array, addslashes(mb_wordwrap($body, 75)), $_POST['encryptthis'], $_POST['encryptto'], strtolower($name), $_POST['fromname'], null, true); * $message = message_post(quoted_printable_encode($subject), $nemail . " (" . quoted_printable_encode($name) . ")", $newsgroups, $references_array, addslashes(mb_wordwrap($body, 75)), $_POST['encryptthis'], $_POST['encryptto'], strtolower($name), $_POST['fromname'], null, true);
} else { * } else {
$message = message_post(quoted_printable_encode($subject), $nemail . " (" . quoted_printable_encode($name) . ")", $newsgroups, $references_array, addslashes(mb_wordwrap($body, 75)), $_POST['encryptthis'], $_POST['encryptto'], strtolower($name), $_POST['fromname']); * $message = message_post(quoted_printable_encode($subject), $nemail . " (" . quoted_printable_encode($name) . ")", $newsgroups, $references_array, addslashes(mb_wordwrap($body, 75)), $_POST['encryptthis'], $_POST['encryptto'], strtolower($name), $_POST['fromname']);
*/ */
} }
// Article sent without errors, or duplicate? // Article sent without errors, or duplicate?
@ -371,7 +371,7 @@ if ($show == 1) {
$ngroups = preg_split("/[\s,]+/", $newsgroups); $ngroups = preg_split("/[\s,]+/", $newsgroups);
$found = false; $found = false;
foreach ($ngroups as $group) { foreach ($ngroups as $group) {
if(get_section_by_group($group)) { if (get_section_by_group($group)) {
$found = true; $found = true;
break; break;
} }
@ -379,7 +379,7 @@ if ($show == 1) {
// show post form // show post form
$fieldencrypt = md5(rand(1, 10000000)); $fieldencrypt = md5(rand(1, 10000000));
echo '<h1 class="np_post_headline">' . $text_post["group_head"] . group_display_name($newsgroups) . $text_post["group_tail"]; echo '<h1 class="np_post_headline">' . $text_post["group_head"] . group_display_name($newsgroups) . $text_post["group_tail"];
if(!$found) { if (! $found) {
echo ' (posting will fail - no such group)'; echo ' (posting will fail - no such group)';
} }
echo '</h1>'; echo '</h1>';
@ -404,7 +404,7 @@ if ($show == 1) {
echo '<input type="radio" id="hasfollowup" name="fgroups" value="' . $head->followup . '" checked>'; echo '<input type="radio" id="hasfollowup" name="fgroups" value="' . $head->followup . '" checked>';
echo '</td><td>'; echo '</td><td>';
echo '<label for="followup">' . $head->followup . ' (followup-to is set'; echo '<label for="followup">' . $head->followup . ' (followup-to is set';
if(!get_section_by_group($head->followup)) { if (! get_section_by_group($head->followup)) {
echo ' but <b><i>posting will fail - no such group </i></b>'; echo ' but <b><i>posting will fail - no such group </i></b>';
} }
echo ')</label></td>'; echo ')</label></td>';

View File

@ -0,0 +1,81 @@
<?php
global $enable_cache, $rslight_version, $spooldir, $logdir, $cache_dir, $cache_log;
/*
* Set $enable_cache to the cache type you want to use
* memcached and php-memcached must be installed
* if using memcached.
* $enable_cache = 'memcached';
*
* This will use a directory for caching, no memcache
* $enable_cache = 'diskcache';
*
* or set to false (no quotes) to disable caching:
* $enable_cache = false;
*/
// $enable_cache = 'memcached';
// $enable_cache = 'diskcache';
$enable_cache = false;
// Enable logging to file (log file may be large)
$enable_cache_logging = false;
// Server & port details if using memcached
$memcache_server = '127.0.0.1';
$memcache_port = 11211;
/*
* Maximum size of data (in bytes) to save per key in memcache
*
* If using memcached This must be less than or equal to
* MAXITEMSIZE in memcached, which is 1MiB by default
* Increasing this here will not work unless it is also
* increased in memcached configuration
*
* If using diskcache, pruning by size is only done daily
*
* You probably do not need to change this
*/
$cache_maxitemsize = 1024000;
// Time in seconds to cache data
$cache_ttl = 14400;
/*
* A string to prepend to cached key names
* Necessary if using more than one rslight instance
* with one memcache instance
*/
$cache_key_prefix = 'mysite';
// Directory to cache data if using diskcache
$cache_dir = $spooldir . '/cache/';
/* PLEASE DO NOT EDIT BELOW THIS LINE */
$cache_log = $logdir . '/cache.log';
@mkdir($cache_dir);
// Add version to prefix to avoid errors if upgrading
// and not restarting memcached
$cache_key_prefix .= trim(preg_replace('/\./', '', $rslight_version));
/* IF MEMCACHED */
if ($enable_cache == 'memcached') {
$memcacheD = new Memcached('memcacheD');
$memcacheD->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
$memcacheD->setOption(Memcached::OPT_CONNECT_TIMEOUT, 1000);
if (! count($memcacheD->getServerList())) {
if (! $memcacheD->addServers(array(
array(
$memcache_server,
$memcache_port
)
))) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . ' Failed to connect memcache ' . $memcache_server . ':' . $memcache_port, FILE_APPEND);
} else {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . ' Connected memcache ' . $memcache_server . ':' . $memcache_port, FILE_APPEND);
}
}
} else {
$memcacheD = null;
}
/* END IF MEMCACHED */

View File

@ -1,55 +0,0 @@
<?php
/* memcached and php-memcached must be installed */
// Set to true to enable memcache
$enable_memcache = false;
// Server & port details
$memcache_server = '127.0.0.1';
$memcache_port = 11211;
// Enable logging to file (log file may be large)
$enable_memcache_logging = false;
// Time in seconds to cache data
$memcache_ttl = 14400;
/*
* Maximum size of data (in bytes) to save per key in memcache
* This must be less than or equal to
* MAXITEMSIZE in memcached, which is 1MiB by default
* Increasing this here will not work unless it is also
* increased in memcached configuration
* You probably do not need to change this
*/
$memcache_maxitemsize = 1024000;
/*
* A string to prepend to cached key names
* Required if using more than one rslight instance
* with one memcache instance
*/
$memcache_key_prefix = 'rsl';
/* PLEASE DO NOT EDIT BELOW THIS LINE */
if ($enable_memcache) {
$memcacheD = new Memcached('memcacheD');
$memcacheD->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
$memcacheD->setOption(Memcached::OPT_CONNECT_TIMEOUT, 1000);
if (! count($memcacheD->getServerList())) {
if (! $memcacheD->addServers(array(
array(
$memcache_server,
$memcache_port
)
))) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . ' Failed to connect memcache ' . $memcache_server . ':' . $memcache_port, FILE_APPEND);
} else {
if ($enable_memcache_logging) {
file_put_contents($logdir . '/memcache.log', "\n" . format_log_date() . ' Connected memcache ' . $memcache_server . ':' . $memcache_port, FILE_APPEND);
}
}
}
}

View File

@ -12,7 +12,7 @@ if (file_exists($config_dir . '/cron.disable') || file_exists($spooldir . '/cron
chown($logfile, $CONFIG['webserver_user']); chown($logfile, $CONFIG['webserver_user']);
exit(); exit();
} else { } else {
file_put_contents($logfile, "\n" . date('M d H:i:s') . " " . $config_name . " cron ".$pid." started...", FILE_APPEND); file_put_contents($logfile, "\n" . date('M d H:i:s') . " " . $config_name . " cron " . $pid . " started...", FILE_APPEND);
chown($logfile, $CONFIG['webserver_user']); chown($logfile, $CONFIG['webserver_user']);
} }
@ -43,7 +43,7 @@ if (isset($CONFIG['enable_nntp']) && $CONFIG['enable_nntp'] == true) {
$disabled_php = ini_get('disable_functions'); $disabled_php = ini_get('disable_functions');
echo $disabled_php; echo $disabled_php;
if(strpos($disabled_php, 'pcntl_fork') !== false) { if (strpos($disabled_php, 'pcntl_fork') !== false) {
echo "\nERROR: pcntl_fork() disabled in php ini file, cannot fork (nntp server will not start)."; echo "\nERROR: pcntl_fork() disabled in php ini file, cannot fork (nntp server will not start).";
file_put_contents($logfile, "\n" . format_log_date() . " ERROR: pcntl_fork() disabled in php ini file, cannot fork (nntp server will not start).", FILE_APPEND); file_put_contents($logfile, "\n" . format_log_date() . " ERROR: pcntl_fork() disabled in php ini file, cannot fork (nntp server will not start).", FILE_APPEND);
} else { } else {
@ -75,7 +75,7 @@ $keydir = preg_replace('/spoolnews/', 'pubkey/', $cwd);
@chgrp($ssldir, $uinfo["gid"]); @chgrp($ssldir, $uinfo["gid"]);
$alias_file = $config_dir . '/aliases.conf'; $alias_file = $config_dir . '/aliases.conf';
if(!file_exists($alias_file)) { if (! file_exists($alias_file)) {
touch($alias_file); touch($alias_file);
} }
@chown($alias_file, $uinfo["uid"]); @chown($alias_file, $uinfo["uid"]);
@ -142,11 +142,19 @@ foreach ($menulist as $menu) {
echo "Expired articles\n"; echo "Expired articles\n";
} }
# Expire diskcache
if (file_exists($config_dir . '/cache.inc.php')) {
include $config_dir . '/cache.inc.php';
if ($enable_cache == 'diskcache') {
prune_dir_by_days($cache_dir, $cache_ttl / 86400);
}
}
# Run RSS Feeds # Run RSS Feeds
exec($CONFIG['php_exec'] . " " . $config_dir . "/scripts/rss-feeds.php"); exec($CONFIG['php_exec'] . " " . $config_dir . "/scripts/rss-feeds.php");
echo "RSS Feeds updated\n"; echo "RSS Feeds updated\n";
# Reload grouplist # Reload grouplist
if ((filemtime($grouplist_cache_filename) < (time() - ($grouplist_cache_time - 600)) || !file_exists($grouplist_cache_filename))) { if ((filemtime($grouplist_cache_filename) < (time() - ($grouplist_cache_time - 600)) || ! file_exists($grouplist_cache_filename))) {
exec($CONFIG['php_exec'] . " ../common/grouplist.php .RELOAD"); exec($CONFIG['php_exec'] . " ../common/grouplist.php .RELOAD");
echo "Refreshed grouplist\n"; echo "Refreshed grouplist\n";
} }
@ -159,9 +167,10 @@ echo "Keys rotated\n";
# Expire files # Expire files
expire_files(); expire_files();
echo "Removed old files\n"; echo "Removed old files\n";
file_put_contents($logfile, "\n" . date('M d H:i:s') . " " . $config_name . " cron ".$pid." completed...", FILE_APPEND); file_put_contents($logfile, "\n" . date('M d H:i:s') . " " . $config_name . " cron " . $pid . " completed...", FILE_APPEND);
function expire_files() { function expire_files()
{
global $spooldir, $logdir; global $spooldir, $logdir;
$now = time(); $now = time();
// Days to prune // Days to prune
@ -171,12 +180,12 @@ function expire_files() {
// Dirs to prune // Dirs to prune
$nocem_processed = $spooldir . "/nocem/processed/"; $nocem_processed = $spooldir . "/nocem/processed/";
$nocem_failed = $spooldir . "/nocem/failed/"; $nocem_failed = $spooldir . "/nocem/failed/";
if(!is_dir($nocem_processed)) { if (! is_dir($nocem_processed)) {
@mkdir($nocem_processed, 0755, 'recursive'); @mkdir($nocem_processed, 0755, 'recursive');
@chown($nocem_processed, $uinfo["uid"]); @chown($nocem_processed, $uinfo["uid"]);
@chgrp($nocem_processed, $uinfo["gid"]); @chgrp($nocem_processed, $uinfo["gid"]);
} }
if(!is_dir($nocem_failed)) { if (! is_dir($nocem_failed)) {
@mkdir($nocem_failed, 0755, 'recursive'); @mkdir($nocem_failed, 0755, 'recursive');
@chown($nocem_failed, $uinfo["uid"]); @chown($nocem_failed, $uinfo["uid"]);
@chgrp($nocem_failed, $uinfo["gid"]); @chgrp($nocem_failed, $uinfo["gid"]);
@ -187,9 +196,9 @@ function expire_files() {
'..', '..',
'.' '.'
)); ));
foreach($filenames as $one) { foreach ($filenames as $one) {
if(filemtime($nocem_processed.$one) < $nocem) { if (filemtime($nocem_processed . $one) < $nocem) {
unlink($nocem_processed.$one); unlink($nocem_processed . $one);
} }
} }
@ -198,12 +207,11 @@ function expire_files() {
'..', '..',
'.' '.'
)); ));
foreach($filenames as $one) { foreach ($filenames as $one) {
if(filemtime($nocem_failed.$one) < $nocem) { if (filemtime($nocem_failed . $one) < $nocem) {
unlink($nocem_failed.$one); unlink($nocem_failed . $one);
} }
} }
} }
function log_rotate() function log_rotate()

View File

@ -67,6 +67,9 @@ if ($argv[1][0] == '-') {
default: default:
echo "-help: This help page\n"; echo "-help: This help page\n";
echo "-version: Display version\n"; echo "-version: Display version\n";
echo "******************* IMPORTANT **************************\n";
echo "*** PLEASE DISABLE cron.php WHEN RUNNING THIS SCRIPT ***\n";
echo "********************************************************\n";
echo "-clean: Remove extraneous group db3 files\n"; echo "-clean: Remove extraneous group db3 files\n";
echo "-import: Import articles from a .db3 file (-import alt.test-articles)\n"; echo "-import: Import articles from a .db3 file (-import alt.test-articles)\n";
echo " You must first add group name to <config_dir>/<section>/groups.txt manually\n"; echo " You must first add group name to <config_dir>/<section>/groups.txt manually\n";
@ -172,7 +175,8 @@ function reset_group($group, $remove = 0)
$config_location = $spooldir . '/' . $section; $config_location = $spooldir . '/' . $section;
$config_files = array_diff(scandir($config_location), array( $config_files = array_diff(scandir($config_location), array(
'..', '..',
'.' '.',
'outgoing'
)); ));
foreach ($config_files as $config_file) { foreach ($config_files as $config_file) {
@ -200,18 +204,29 @@ function remove_articles($group)
$group = trim($group); $group = trim($group);
# Overview # Overview
$dbh = overview_db_open($spooldir . '/articles-overview.db3'); $overview_dbh = overview_db_open($spooldir . '/articles-overview.db3');
$clear_stmt = $dbh->prepare("DELETE FROM overview WHERE newsgroup=:group");
$clear_stmt->bindParam(':group', $group); $fetch_stmt = $overview_dbh->prepare("SELECT msgid FROM overview WHERE newsgroup=:group");
$clear_stmt->execute(); $fetch_stmt->bindParam(':group', $group);
$dbh = null; $fetch_stmt->execute();
$del_array = array();
while ($row = $fetch_stmt->fetch()) {
if (isset($row['msgid'])) {
$del_array[] = $row['msgid'];
}
}
$overview_dbh = null;
foreach($del_array as $delme) {
delete_message($delme, $group);
echo "Deleting " . $delme . " from " . $group . "\n";
}
# History # History
$dbh = history_db_open($spooldir . '/history.db3'); $history_dbh = history_db_open($spooldir . '/history.db3');
$clear_stmt = $dbh->prepare("DELETE FROM history WHERE newsgroup=:group"); $clear_stmt = $history_dbh->prepare("DELETE FROM history WHERE newsgroup=:group");
$clear_stmt->bindParam(':group', $group); $clear_stmt->bindParam(':group', $group);
$clear_stmt->execute(); $clear_stmt->execute();
$dbh = null; $history_dbh = null;
rename($spooldir . '/' . $group . '-articles.db3', $spooldir . '/' . $group . '-articles.db3-removed'); rename($spooldir . '/' . $group . '-articles.db3', $spooldir . '/' . $group . '-articles.db3-removed');
unlink($spooldir . '/' . $group . '-data.db3'); unlink($spooldir . '/' . $group . '-data.db3');