Skip to content

Commit f5254a5

Browse files
committed
updates to IP logic
1 parent 125076a commit f5254a5

1 file changed

Lines changed: 37 additions & 37 deletions

File tree

bin/abuse_imap_downloader.php

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
<?php
2-
/**
3-
* Abuse IMAP Downloader
4-
* Checks the various configured IMAP accounts and mailboxes for abuse complaints or spam
5-
* and registers them with our system and after matching them up to a specific service
6-
* through its ip, we contact the clients letting them know of the abuse complaint.
7-
*
8-
* @author Joe Huss <detain@interserver.net>
9-
* @copyright 2019
10-
* @package Abuse
11-
* @category Crontab
12-
*/
13-
14-
include_once __DIR__.'/../../../../include/functions.inc.php';
15-
include_once __DIR__.'/../src/ImapAbuseCheck.php';
16-
$GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
17-
$db = $GLOBALS['tf']->db;
18-
$db->query('select abuse_ip,count(abuse_lid) as count from abuse where Year(abuse_time)=Year(now()) and Month(abuse_time)=Month(now()) and Day(abuse_time)=Day(now()) group by abuse_ip');
19-
$abuse_ips = [];
20-
$total_sent = 0;
21-
while ($db->next_record(MYSQL_ASSOC)) {
22-
$total_sent += $db->Record['count'];
23-
$abuse_ips[$db->Record['abuse_ip']] = $db->Record['count'];
24-
}
25-
echo 'Loaded '.$total_sent.' Abuse Records From Today for '.count($abuse_ips).' Unique Email Addresses'.PHP_EOL;
26-
$checks = json_decode(file_get_contents(INCLUDE_ROOT.'/config/abuse.json'), true);
27-
foreach ($checks as $check) {
28-
$abuse = new ImapAbuseCheck('{'.$check['host'].':'.$check['port'].'/imap/ssl}'.$check['mailbox'], ABUSE_IMAP_USER, ABUSE_IMAP_PASS, $db, $check['delete_attachments'], $check['mail_limit']);
29-
foreach ($check['patterns'] as $pattern) {
30-
if ($pattern['type'] == 'match') {
31-
$abuse->register_preg_match($pattern['pattern'], $pattern['what']);
32-
} elseif ($pattern['type'] == 'match_all') {
33-
$abuse->register_preg_match_all($pattern['pattern'], $pattern['what']);
34-
}
35-
}
36-
$abuse->process($check['type'], $check['limit']);
37-
}
1+
<?php
2+
/**
3+
* Abuse IMAP Downloader
4+
* Checks the various configured IMAP accounts and mailboxes for abuse complaints or spam
5+
* and registers them with our system and after matching them up to a specific service
6+
* through its ip, we contact the clients letting them know of the abuse complaint.
7+
*
8+
* @author Joe Huss <detain@interserver.net>
9+
* @copyright 2019
10+
* @package Abuse
11+
* @category Crontab
12+
*/
13+
14+
include_once __DIR__.'/../../../../include/functions.inc.php';
15+
include_once __DIR__.'/../src/ImapAbuseCheck.php';
16+
$GLOBALS['tf']->session->create(160307, 'services', false, 0, false, substr(basename($_SERVER['argv'][0], '.php'), 0, 32));
17+
$db = $GLOBALS['tf']->db;
18+
$db->query('select abuse_ip,count(abuse_lid) as count from abuse where Year(abuse_time)=Year(now()) and Month(abuse_time)=Month(now()) and Day(abuse_time)=Day(now()) group by abuse_ip');
19+
$abuse_ips = [];
20+
$total_sent = 0;
21+
while ($db->next_record(MYSQL_ASSOC)) {
22+
$total_sent += $db->Record['count'];
23+
$abuse_ips[$db->Record['abuse_ip']] = $db->Record['count'];
24+
}
25+
echo 'Loaded '.$total_sent.' Abuse Records From Today for '.count($abuse_ips).' Unique Email Addresses'.PHP_EOL;
26+
$checks = json_decode(file_get_contents(INCLUDE_ROOT.'/config/abuse.json'), true);
27+
foreach ($checks as $check) {
28+
$abuse = new ImapAbuseCheck('{'.$check['host'].':'.$check['port'].'/imap/ssl}'.$check['mailbox'], ABUSE_IMAP_USER, ABUSE_IMAP_PASS, $db, $check['delete_attachments'], $check['mail_limit']);
29+
foreach ($check['patterns'] as $pattern) {
30+
if ($pattern['type'] == 'match') {
31+
$abuse->register_preg_match($pattern['pattern'], $pattern['what']);
32+
} elseif ($pattern['type'] == 'match_all') {
33+
$abuse->register_preg_match_all($pattern['pattern'], $pattern['what']);
34+
}
35+
}
36+
$abuse->process($check['type'], $check['limit']);
37+
}

0 commit comments

Comments
 (0)