Replace nocemlist.php with updated version.
This commit is contained in:
parent
965d77cffa
commit
2640b94be2
|
@ -1,136 +0,0 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
/*
|
||||
* First, configure this file, and nocempost.sh to match
|
||||
* your system and needs.
|
||||
*
|
||||
* Copy messages to add to NoCeM list to $workpath/incoming
|
||||
* One message per file. (Move or delete these files when all
|
||||
* is complete)
|
||||
*
|
||||
* Then run nocemlist.php to create nocem.out and header.out files
|
||||
* You may view these files before sending if you wish to confirm
|
||||
* all is working properly.
|
||||
*
|
||||
* Then run nocempost.sh to send NoCeM message to news server
|
||||
*/
|
||||
|
||||
// Where these scripts reside and messages are created: (end with '/')
|
||||
$workpath = "/home/user/SPAM/";
|
||||
|
||||
$domain = "<your_domain>";
|
||||
$organization = "<your_organization>";
|
||||
$from = "from_address <from@example.com>";
|
||||
$from_email = "<from@example.com";
|
||||
$contact = "your_email_address";
|
||||
|
||||
// Your gpg signing key:
|
||||
$signing_key = "XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX";
|
||||
// URL to view/download key:
|
||||
$key_location = "https://<key_url>";
|
||||
|
||||
// Comma separated list of newsgroups to send this message:
|
||||
$spamgroup = "<where to send this message>";
|
||||
// Statement about the scope of your NoCeM messages:
|
||||
$scope = "The scope of these messages is the <my_hier>.* hierarchy";
|
||||
|
||||
/* END CONFIG */
|
||||
|
||||
$spamdir = $workpath."incoming";
|
||||
$nocem = $workpath."nocem.out";
|
||||
$headerdat = $workpath."header.out";
|
||||
|
||||
$newspam = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($spamdir));
|
||||
$count = 0;
|
||||
$nocem_list = array();
|
||||
$nocem_head = array();
|
||||
|
||||
foreach($newspam as $spam) {
|
||||
if(is_dir($spam)) {
|
||||
continue;
|
||||
}
|
||||
$spam_lines = file($spam);
|
||||
$lines = 0;
|
||||
$is_header = 1;
|
||||
foreach($spam_lines as $response) {
|
||||
if (trim($response) == "" && $lines > 0) {
|
||||
$is_header = 0;
|
||||
}
|
||||
if ($is_header == 1) {
|
||||
$lines ++;
|
||||
$response = str_replace("\t", " ", $response);
|
||||
// Find article date
|
||||
if (stripos($response, "Date: ") === 0) {
|
||||
$date = explode(': ', $response);
|
||||
}
|
||||
// Get overview data
|
||||
if (stripos($response, "Message-ID: ") === 0) {
|
||||
$id = explode(': ', $response);
|
||||
}
|
||||
if (stripos($response, "From: ") === 0) {
|
||||
$sender = explode(': ', $response, 2);
|
||||
}
|
||||
if (stripos($response, "Subject: ") === 0) {
|
||||
$subject = explode('Subject: ', $response, 2);
|
||||
}
|
||||
if (stripos($response, "Newsgroups: ") === 0) {
|
||||
$newsgroups = explode('Newsgroups: ', $response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$nocem_list[] = "# Sender: ".trim($sender[1])."\n# Date: ".trim($date[1])."\n# Subject: ".trim($subject[1])."\n".trim($id[1])." ".trim($newsgroups[1])."\n";;
|
||||
$count++;
|
||||
}
|
||||
$nocem_file = fopen($nocem, "w+");
|
||||
$header_file = fopen($headerdat, "w+");
|
||||
|
||||
$hashtail = hash('crc32', $domain.$organization.$from);
|
||||
$thishash = hash('crc32', serialize($nocem_list)).$hashtail;
|
||||
|
||||
if($count < 2) {
|
||||
$article = "article";
|
||||
} else {
|
||||
$article = "articles";
|
||||
}
|
||||
|
||||
fwrite($header_file, "Message-ID: <$thishash@$domain>\n");
|
||||
fwrite($header_file, "From: $from\n");
|
||||
fwrite($header_file, "Newsgroups: $spamgroup\n");
|
||||
fwrite($header_file, "Subject: @@NCM NoCeM notice $thishash spam/hide ($count $article)\n");
|
||||
fwrite($header_file, "Content-Type: text/plain; charset=utf-8; format=flowed\n");
|
||||
fwrite($header_file, "Content-Transfer-Encoding: 8bit\n");
|
||||
fwrite($header_file, "Organization: $organization\n");
|
||||
fclose($header_file);
|
||||
|
||||
fwrite($nocem_file, "You may use this for hiding articles using NoCeM.\n");
|
||||
fwrite($nocem_file, "$scope.\n");
|
||||
fwrite($nocem_file, "This list is generated by $from_email.\n\n");
|
||||
|
||||
fwrite($nocem_file, "This message was signed using the following key:\n");
|
||||
fwrite($nocem_file, "$signing_key\n\n");
|
||||
|
||||
fwrite($nocem_file, "The GPG key needed to verify the signature of cancels\n");
|
||||
fwrite($nocem_file, "issued by $from_email is available at:\n");
|
||||
fwrite($nocem_file, "$key_location\n\n");
|
||||
|
||||
fwrite($nocem_file, "For information contact $contact.\n\n");
|
||||
|
||||
fwrite($nocem_file, "@@BEGIN NCM HEADERS\n");
|
||||
fwrite($nocem_file, "Version: 0.93\n");
|
||||
fwrite($nocem_file, "Issuer: $from_email\n");
|
||||
fwrite($nocem_file, "Type: spam\n");
|
||||
fwrite($nocem_file, "Action: hide\n");
|
||||
fwrite($nocem_file, "Count: ".$count."\n");
|
||||
fwrite($nocem_file, "Notice-ID: ".$thishash."\n");
|
||||
|
||||
fwrite($nocem_file, "@@BEGIN NCM BODY\n");
|
||||
|
||||
foreach($nocem_list as $list) {
|
||||
fwrite($nocem_file, $list);
|
||||
}
|
||||
|
||||
fwrite($nocem_file, "@@END NCM BODY");
|
||||
fclose($nocem_file);
|
||||
?>
|
|
@ -40,7 +40,6 @@ $scope = "The scope of these messages is the <my_hier>.* hierarchy";
|
|||
$spamdir = $workpath."incoming";
|
||||
$nocem = $workpath."nocem.out";
|
||||
$headerdat = $workpath."header.out";
|
||||
$localeol = PHP_EOL.PHP_EOL;
|
||||
|
||||
$newspam = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($spamdir));
|
||||
$count = 0;
|
||||
|
@ -49,29 +48,39 @@ $nocem_head = array();
|
|||
|
||||
foreach($newspam as $spam) {
|
||||
if(is_dir($spam)) {
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
$articledata = file_get_contents($spam);
|
||||
$bodystart = strpos($articledata, $localeol);
|
||||
$header = substr($articledata, 0, $bodystart);
|
||||
|
||||
preg_match('/Message-ID:.*/i', $header, $result);
|
||||
$id = explode(": ", $result[0]);
|
||||
|
||||
preg_match('/Newsgroups:.*/', $header, $result);
|
||||
$newsgroups = explode("Newsgroups: ", $result[0]);
|
||||
$newsgroups = preg_replace('/,/', ' ', $newsgroups);
|
||||
|
||||
preg_match('/From:.*/', $header, $result);
|
||||
$sender = explode("From: ", $result[0]);
|
||||
|
||||
preg_match('/Date:.*/', $header, $result);
|
||||
$date = explode("Date: ", $result[0]);
|
||||
|
||||
preg_match('/Subject:.*/', $header, $result);
|
||||
$subject = explode("Subject: ", $result[0]);
|
||||
|
||||
$nocem_list[] = "# Sender: ".$sender[1]."\n# Date: ".$date[1]."\n# Subject: ".$subject[1]."\n".$id[1]." ".$newsgroups[1]."\n";;
|
||||
$spam_lines = file($spam);
|
||||
$lines = 0;
|
||||
$is_header = 1;
|
||||
foreach($spam_lines as $response) {
|
||||
if (trim($response) == "" && $lines > 0) {
|
||||
$is_header = 0;
|
||||
}
|
||||
if ($is_header == 1) {
|
||||
$lines ++;
|
||||
$response = str_replace("\t", " ", $response);
|
||||
// Find article date
|
||||
if (stripos($response, "Date: ") === 0) {
|
||||
$date = explode(': ', $response);
|
||||
}
|
||||
// Get overview data
|
||||
if (stripos($response, "Message-ID: ") === 0) {
|
||||
$id = explode(': ', $response);
|
||||
}
|
||||
if (stripos($response, "From: ") === 0) {
|
||||
$sender = explode(': ', $response, 2);
|
||||
}
|
||||
if (stripos($response, "Subject: ") === 0) {
|
||||
$subject = explode('Subject: ', $response, 2);
|
||||
}
|
||||
if (stripos($response, "Newsgroups: ") === 0) {
|
||||
$newsgroups = explode('Newsgroups: ', $response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$nocem_list[] = "# Sender: ".trim($sender[1])."\n# Date: ".trim($date[1])."\n# Subject: ".trim($subject[1])."\n".trim($id[1])." ".trim($newsgroups[1])."\n";;
|
||||
$count++;
|
||||
}
|
||||
$nocem_file = fopen($nocem, "w+");
|
||||
|
|
Loading…
Reference in New Issue