From 59478e06c25303a790a0840ab2ac30662c4ef781 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Tue, 5 Aug 2014 16:46:22 +0200 Subject: c'est la merde.. --- plugins/markasjunk2/drivers/dir_learn.php | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 plugins/markasjunk2/drivers/dir_learn.php (limited to 'plugins/markasjunk2/drivers/dir_learn.php') diff --git a/plugins/markasjunk2/drivers/dir_learn.php b/plugins/markasjunk2/drivers/dir_learn.php new file mode 100644 index 000000000..88dc7e4eb --- /dev/null +++ b/plugins/markasjunk2/drivers/dir_learn.php @@ -0,0 +1,49 @@ +_do_messagemove($uids, true); + } + + public function ham($uids) + { + $this->_do_messagemove($uids, false); + } + + private function _do_messagemove($uids, $spam) + { + $rcmail = rcube::get_instance(); + + if ($spam) + $dest_dir = unslashify($rcmail->config->get('markasjunk2_spam_dir')); + else + $dest_dir = unslashify($rcmail->config->get('markasjunk2_ham_dir')); + + if (!$dest_dir) + return; + + $filename = $rcmail->config->get('markasjunk2_filename'); + $filename = str_replace('%u', $_SESSION['username'], $filename); + $filename = str_replace('%t', ($spam) ? 'spam' : 'ham', $filename); + $filename = str_replace('%l', $rcmail->user->get_username('local'), $filename); + $filename = str_replace('%d', $rcmail->user->get_username('domain'), $filename); + + foreach (explode(",", $uids) as $uid) { + $tmpfname = tempnam($dest_dir, $filename); + file_put_contents($tmpfname, $rcmail->storage->get_raw_body($uid)); + + if ($rcmail->config->get('markasjunk2_debug')) + rcube::write_log('markasjunk2', $tmpfname); + } + } +} + +?> \ No newline at end of file -- cgit v1.2.3