summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGunnar Wrobel <wrobel@pardus.de>2010-03-31 19:55:10 (GMT)
committerGunnar Wrobel <wrobel@pardus.de>2010-03-31 19:55:10 (GMT)
commit3d422c58f3a48c2b0e01b193ada93abf0d00cd5e (patch)
treece77452ff96dded5d425bd930480efe74d051bb8 /lib
parent79a0c1fc6f3b6e32db585acffa2911233d936713 (diff)
downloadkolab-webadmin-3d422c58f3a48c2b0e01b193ada93abf0d00cd5e.tar.gz
Move the sieve utilities into the default PHP library location. There is no need to keep the code separate.
Diffstat (limited to 'lib')
-rw-r--r--lib/KolabAdmin/Sieve/Script.php101
1 files changed, 101 insertions, 0 deletions
diff --git a/lib/KolabAdmin/Sieve/Script.php b/lib/KolabAdmin/Sieve/Script.php
new file mode 100644
index 0000000..b1d06d9
--- /dev/null
+++ b/lib/KolabAdmin/Sieve/Script.php
@@ -0,0 +1,101 @@
+<?php
+/*
+ * Copyright (c) 2004 Klarälvdalens Datakonsult AB
+ *
+ * Written by Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You can view the GNU General Public License, online, at the GNU
+ * Project's homepage; see <http://www.gnu.org/licenses/gpl.html>.
+ */
+
+class KolabAdmin_Sieve_Script {
+ // Funny multiline string escaping in Sieve
+ /*static*/ function dotstuff( $str ) {
+ return str_replace( "\n.", "\n..", $str );
+ }
+
+ /*static*/ function undotstuff( $str ) {
+ return str_replace( "\n..", "\n.", $str );
+ }
+
+ /*static*/ function getDeliverFolder( $script ) {
+ $inbox = false;
+ if( preg_match("/fileinto \"INBOX\/([^\"]*)\";/", $script, $regs ) ) {
+ $inbox = $regs[1];
+ }
+ return $inbox;
+ }
+
+ /*static*/ function getVacationAddresses( $script ) {
+ $addresses = false;
+ if( preg_match("/:addresses \\[([^\\]]*)\\]/s", $script, $regs ) ) {
+ $tmp = split(',', $regs[1] );
+ $addresses = array();
+ foreach( $tmp as $a ) {
+ if( ereg('^ *"(.*)" *$', $a, $regs ) ) $addresses[] = $regs[1];
+ else $addresses[] = $a;
+ }
+ }
+ return $addresses;
+ }
+
+ /*static*/ function getMailDomain( $script ) {
+ $maildomain = false;
+ if( preg_match( '/if not address :domain :contains "From" "(.*)" { keep; stop; }/i', $script, $regs ) ) {
+ $maildomain = $regs[1];
+ }
+ return $maildomain;
+ }
+
+ /*static*/ function getReactToSpam( $script ) {
+ $spam = false;
+ if( preg_match('/if header :contains "X-Spam-Flag" "YES" { keep; stop; }/i', $script ) ) {
+ $spam = true;
+ }
+ return $spam;
+ }
+
+ /*static*/ function getVacationDays( $script ) {
+ $days = false;
+ if( preg_match("/:days ([0-9]+)/s", $script, $regs ) ) {
+ $days = $regs[1];
+ }
+ return $days;
+ }
+
+ /*static*/ function getVacationText( $script ) {
+ $text = false;
+ if( preg_match("/text:(.*\r\n)\\.\r\n/s", $script, $regs ) ) {
+ $text = $regs[1];
+ $text = str_replace( '\n', "\r\n", $text );
+ $text = KolabAdmin_Sieve_Script::undotstuff($text);
+ }
+ return $text;
+ }
+
+ /*static*/ function getForwardAddress( $script ) {
+ $address = false;
+ if( preg_match("/redirect \"([^\"]*)\"/s", $script, $regs ) ) {
+ $address = $regs[1];
+ }
+ return $address;
+ }
+
+ /*static*/ function getKeepOnServer( $script ) {
+ return ereg('"; keep;', $script, $regs );
+ }
+
+ function createScript( $scriptname ) {
+ // TODO
+ }
+};