2021-04-04 07:40:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once("config.php");
|
|
|
|
|
|
|
|
require(DIR_SYSTEM . "/startup.php");
|
|
|
|
|
|
|
|
$request = new Request();
|
|
|
|
Registry::set("request", $request);
|
|
|
|
|
|
|
|
|
|
|
|
$start = NULL;
|
|
|
|
|
|
|
|
$loader = new Loader();
|
|
|
|
Registry::set('load', $loader);
|
|
|
|
|
|
|
|
$loader->load->model('domain/domain');
|
|
|
|
$loader->load->model('search/search');
|
|
|
|
$loader->load->model('search/message');
|
|
|
|
$loader->load->model('message/attachment');
|
|
|
|
|
|
|
|
|
|
|
|
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PREFIX);
|
|
|
|
Registry::set('db', $db);
|
|
|
|
|
|
|
|
Registry::set('auditor_user', 1);
|
|
|
|
|
|
|
|
$outdir = "/path/to/attachments";
|
2021-04-06 10:24:42 +02:00
|
|
|
|
|
|
|
openlog("export-attachments", LOG_PID, LOG_MAIL);
|
|
|
|
|
2021-04-04 07:40:16 +02:00
|
|
|
|
|
|
|
$domain = new ModelDomainDomain();
|
|
|
|
$attachment = new ModelMessageAttachment();
|
|
|
|
$message = new ModelSearchMessage();
|
|
|
|
|
|
|
|
$domains = $domain->get_mapped_domains();
|
|
|
|
|
2021-04-06 10:24:42 +02:00
|
|
|
$last_id = $attachment->get_last_attachment_id();
|
|
|
|
$start_id = $attachment->get_checkpoint();
|
|
|
|
|
|
|
|
syslog(LOG_INFO, "start: $start, limit: $limit");
|
2021-04-04 07:40:16 +02:00
|
|
|
|
2021-04-06 10:24:42 +02:00
|
|
|
|
|
|
|
for($i=$start_id; $i<$last_id; $i++) {
|
2021-04-04 07:40:16 +02:00
|
|
|
$a = $attachment->get_attachment_by_id($i);
|
|
|
|
$m = $message->get_message_addresses_by_piler_id($a['piler_id'], $domains);
|
|
|
|
|
|
|
|
$attachment->dump_attachment($outdir, "out", $m['sender'], $i, $a);
|
|
|
|
|
|
|
|
foreach($m['rcpt'] as $rcpt) {
|
|
|
|
$attachment->dump_attachment($outdir, "in", $rcpt, $i, $a);
|
|
|
|
}
|
2021-04-06 10:24:42 +02:00
|
|
|
|
|
|
|
if($i % 100 == 0) { $attachment->update_checkpoint($i); }
|
2021-04-04 07:40:16 +02:00
|
|
|
}
|
2021-04-06 10:24:42 +02:00
|
|
|
|
|
|
|
$attachment->update_checkpoint($i);
|