Partial rewrite to nocem.php to account for multiple groups per msgid.
This commit is contained in:
parent
1459144b8a
commit
5e8a78e6d6
|
@ -47,6 +47,10 @@ foreach ($messages as $message) {
|
||||||
}
|
}
|
||||||
$nocem_list = file($nocem_file, FILE_IGNORE_NEW_LINES);
|
$nocem_list = file($nocem_file, FILE_IGNORE_NEW_LINES);
|
||||||
$start = 0;
|
$start = 0;
|
||||||
|
|
||||||
|
// Open overview database and process list
|
||||||
|
$database = $spooldir . '/articles-overview.db3';
|
||||||
|
$overview_dbh = overview_db_open($database);
|
||||||
foreach ($nocem_list as $nocem_line) {
|
foreach ($nocem_list as $nocem_line) {
|
||||||
if (strpos($nocem_line, $begin) !== false) {
|
if (strpos($nocem_line, $begin) !== false) {
|
||||||
$start = 1;
|
$start = 1;
|
||||||
|
@ -55,25 +59,34 @@ foreach ($messages as $message) {
|
||||||
if (strpos($nocem_line, $end) !== false) {
|
if (strpos($nocem_line, $end) !== false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((isset($nocem_line[0]) && $nocem_line[0] == '<') && $start == 1) {
|
if ($nocem_line[0] == '#') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (($nocem_line[0] == '<') && $start == 1) {
|
||||||
$found = explode(' ', $nocem_line);
|
$found = explode(' ', $nocem_line);
|
||||||
$msgid = $found[0];
|
$i = 0;
|
||||||
foreach ($found as $found_group) {
|
foreach ($found as $group_item) {
|
||||||
delete_message($msgid, $found_group);
|
if ($i == 0) {
|
||||||
|
$i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " TRYING: " . $found[0] . " IN: " . $group_item, FILE_APPEND);
|
||||||
|
delete_message($found[0], trim($group_item), $overview_dbh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$overview_dbh = null;
|
||||||
|
|
||||||
rename($nocem_file, $nocem_path . "processed/" . $message);
|
rename($nocem_file, $nocem_path . "processed/" . $message);
|
||||||
}
|
|
||||||
prune_dir_by_days($nocem_path . "processed/", 30);
|
prune_dir_by_days($nocem_path . "processed/", 30);
|
||||||
prune_dir_by_days($nocem_path . "failed/", 30);
|
prune_dir_by_days($nocem_path . "failed/", 30);
|
||||||
|
}
|
||||||
unlink($lockfile);
|
unlink($lockfile);
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
function delete_message($messageid, $group)
|
function delete_message($messageid, $group, $overview_dbh)
|
||||||
{
|
{
|
||||||
global $logfile, $config_dir, $spooldir, $CONFIG, $webserver_group;
|
global $logfile, $config_dir, $spooldir, $CONFIG, $webserver_group;
|
||||||
|
|
||||||
/* Find section */
|
/* Find section */
|
||||||
$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 ($menulist as $menu) {
|
foreach ($menulist as $menu) {
|
||||||
|
@ -82,12 +95,12 @@ function delete_message($messageid, $group)
|
||||||
}
|
}
|
||||||
$menuitem = explode(':', $menu);
|
$menuitem = explode(':', $menu);
|
||||||
$glfp = fopen($config_dir . $menuitem[0] . "/groups.txt", 'r');
|
$glfp = fopen($config_dir . $menuitem[0] . "/groups.txt", 'r');
|
||||||
$section = "";
|
|
||||||
while ($gl = fgets($glfp)) {
|
while ($gl = fgets($glfp)) {
|
||||||
$group_name = preg_split("/( |\t)/", $gl, 2);
|
$group_name = preg_split("/( |\t)/", $gl, 2);
|
||||||
if (strtolower(trim($group)) == strtolower(trim($group_name[0]))) {
|
if (strtolower(trim($group)) == strtolower(trim($group_name[0]))) {
|
||||||
$config_name = $menuitem[0];
|
$config_name = $menuitem[0];
|
||||||
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " FOUND: " . $messageid . " IN: " . $config_name . '/' . $group, FILE_APPEND);
|
echo "\nFOUND: " . $group . " IN: " . $config_name;
|
||||||
|
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " FOUND: " . $group . " IN: " . $config_name, FILE_APPEND);
|
||||||
break 2;
|
break 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,20 +110,17 @@ function delete_message($messageid, $group)
|
||||||
$database = $spooldir . '/' . $group . '-articles.db3';
|
$database = $spooldir . '/' . $group . '-articles.db3';
|
||||||
if (is_file($database)) {
|
if (is_file($database)) {
|
||||||
$articles_dbh = article_db_open($database);
|
$articles_dbh = article_db_open($database);
|
||||||
$articles_query = $articles_dbh->prepare('DELETE FROM articles WHERE msgid=:messageid');
|
$articles_stmt = $articles_dbh->prepare('DELETE FROM articles WHERE msgid=:messageid');
|
||||||
$articles_query->execute([
|
$articles_stmt->execute([
|
||||||
'messageid' => $messageid
|
'messageid' => $messageid
|
||||||
]);
|
]);
|
||||||
$articles_dbh = null;
|
$articles_dbh = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle overview and history
|
// Handle overview and history
|
||||||
$database = $spooldir . '/articles-overview.db3';
|
$overview_stmt_del = $overview_dbh->prepare('DELETE FROM overview WHERE newsgroup=:newsgroup AND msgid=:msgid');
|
||||||
$dbh = overview_db_open($database);
|
$overview_query = $overview_dbh->prepare('SELECT * FROM overview WHERE newsgroup=:newsgroup AND msgid=:msgid');
|
||||||
$stmt_del = $dbh->prepare('DELETE FROM overview WHERE newsgroup=:newsgroup AND msgid=:msgid');
|
$overview_query->execute([
|
||||||
$query = $dbh->prepare('SELECT * FROM overview WHERE newsgroup=:newsgroup AND msgid=:msgid');
|
|
||||||
$query->execute([
|
|
||||||
':newsgroup' => $group,
|
':newsgroup' => $group,
|
||||||
':msgid' => $messageid
|
':msgid' => $messageid
|
||||||
]);
|
]);
|
||||||
|
@ -119,19 +129,22 @@ function delete_message($messageid, $group)
|
||||||
$statusdate = time();
|
$statusdate = time();
|
||||||
$statusreason = "nocem";
|
$statusreason = "nocem";
|
||||||
$statusnotes = null;
|
$statusnotes = null;
|
||||||
while ($row = $query->fetch()) {
|
while ($row = $overview_query->fetch()) {
|
||||||
|
if (isset($row['number'])) {
|
||||||
|
echo "\nFOUND: " . $messageid . " IN: " . $group;
|
||||||
|
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " DELETING: " . $messageid . " IN: " . $group, FILE_APPEND);
|
||||||
|
}
|
||||||
if (is_file($spooldir . '/articles/' . $grouppath . '/' . $row['number'])) {
|
if (is_file($spooldir . '/articles/' . $grouppath . '/' . $row['number'])) {
|
||||||
unlink($spooldir . '/articles/' . $grouppath . '/' . $row['number']);
|
unlink($spooldir . '/articles/' . $grouppath . '/' . $row['number']);
|
||||||
}
|
}
|
||||||
delete_message_from_overboard($config_name, $group, $messageid);
|
delete_message_from_overboard($config_name, $group, $messageid);
|
||||||
add_to_history($group, $row['number'], $row['msgid'], $status, $statusdate, $statusreason, $statusnotes);
|
add_to_history($group, $row['number'], $row['msgid'], $status, $statusdate, $statusreason, $statusnotes);
|
||||||
thread_cache_removearticle($group, $row['number']);
|
thread_cache_removearticle($group, $row['number']);
|
||||||
}
|
$overview_stmt_del->execute([
|
||||||
$stmt_del->execute([
|
|
||||||
':newsgroup' => $group,
|
':newsgroup' => $group,
|
||||||
':msgid' => $messageid
|
':msgid' => $messageid
|
||||||
]);
|
]);
|
||||||
$dbh = null;
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue