From 09dfe32eb6b538225686fd6ed0220240010bc574 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 1 Aug 2011 01:22:36 -0400 Subject: initial commit. Partway through a rewrite. I have some old files I didn't want to entirely delete. --- src/plugins/maildir.php | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/plugins/maildir.php (limited to 'src/plugins/maildir.php') diff --git a/src/plugins/maildir.php b/src/plugins/maildir.php new file mode 100644 index 0000000..28211b5 --- /dev/null +++ b/src/plugins/maildir.php @@ -0,0 +1,58 @@ +''); + + public function configList() { + return array('dir'=>'text'); + } + + public function init() {} + + public function get() { + $this->handle_new(); + $this->handle_cur(); + $this->handle_tmp(); + } + + private function handle_new() { + // move files in new to cur + $new = $this->config['dir'].'/new'; + $cur = $this->config['dir'].'/cur'; + $dh = opendir($new); + + while (($file = readdir($dh)) !== false) { + if (substr($file,0,1)!='.' && is_file($new.'/'.$file)) { + rename($new.'/'.$file, + $cur.'/'.$file.':'); + } + } + } + private function handle_cur() { + $cur = $this->config['dir'].'/cur'; + $dh = opendir($cur); + + while (($file = readdir($dh)) !== false) { + if (substr($file,0,1)!='.' && is_file($cur.'/'.$file)) { + + } + } + } + private function handle_tmp() { + // Clean up files that haven't been accessed for 36 hours + $tmp = $this->config['dir'].'/tmp'; + $dh = opendir($cur); + + while (($file = readdir($dh)) !== false) { + if (is_file($tmp.'/'.$file)) { + $atime = fileatime($tmp.'/'.$file); + $time = time(); + if (($time-$atime)>(36*60*60)) { + unlink($tmp.'/'.$file); + } + } + } + } + +} -- cgit v1.2.3-54-g00ecf