From fdb51429328460e973a6c7fe8f89c3fb38cba47d Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Mon, 22 Feb 2010 11:47:13 -0500
Subject: [PATCH] - Added dovecot Support for opensuse - added installation instructions for opensuse 11.2 with bind and dovecot - fixed a bug in bind plugin. - improved opensuse installer.
---
server/lib/classes/system.inc.php | 96 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 96 insertions(+), 0 deletions(-)
diff --git a/server/lib/classes/system.inc.php b/server/lib/classes/system.inc.php
index da7e2d0..8d62ef1 100644
--- a/server/lib/classes/system.inc.php
+++ b/server/lib/classes/system.inc.php
@@ -1107,6 +1107,102 @@
return false;
}
}
+
+ function replaceLine($filename,$search_pattern,$new_line,$strict = 0,$append = 1) {
+ $lines = @file($filename);
+ $out = '';
+ $found = 0;
+ if(is_array($lines)) {
+ foreach($lines as $line) {
+ if($strict == 0) {
+ if(stristr($line,$search_pattern)) {
+ $out .= $new_line."\n";
+ $found = 1;
+ } else {
+ $out .= $line;
+ }
+ } else {
+ if(trim($line) == $search_pattern) {
+ $out .= $new_line."\n";
+ $found = 1;
+ } else {
+ $out .= $line;
+ }
+ }
+ }
+ }
+
+ if($found == 0) {
+ //* add \n if the last line does not end with \n or \r
+ if(substr($out,-1) != "\n" && substr($out,-1) != "\r") $out .= "\n";
+ //* add the new line at the end of the file
+ if($append == 1) $out .= $new_line."\n";
+ }
+ file_put_contents($filename,$out);
+ }
+
+ function removeLine($filename,$search_pattern,$strict = 0) {
+ if($lines = @file($filename)) {
+ $out = '';
+ foreach($lines as $line) {
+ if($strict == 0) {
+ if(!stristr($line,$search_pattern)) {
+ $out .= $line;
+ }
+ } else {
+ if(!trim($line) == $search_pattern) {
+ $out .= $line;
+ }
+ }
+ }
+ file_put_contents($filename,$out);
+ }
+ }
+
+ function maildirmake($maildir_path, $user = '', $subfolder = '') {
+
+ global $app;
+
+ if($subfolder != '') {
+ $dir = escapeshellarg($maildir_path.'/.'.$subfolder);
+ $dir_cur = escapeshellarg($maildir_path.'/.'.$subfolder.'/cur');
+ $dir_new = escapeshellarg($maildir_path.'/.'.$subfolder.'/new');
+ $dir_tmp = escapeshellarg($maildir_path.'/.'.$subfolder.'/tmp');
+ } else {
+ $dir = escapeshellarg($maildir_path);
+ $dir_cur = escapeshellarg($maildir_path.'/cur');
+ $dir_new = escapeshellarg($maildir_path.'/new');
+ $dir_tmp = escapeshellarg($maildir_path.'/tmp');
+ }
+
+ exec("mkdir -p $dir_cur $dir_new $dir_tmp");
+ exec("chmod 0700 $dir $dir_cur $dir_new $dir_tmp");
+
+ if($user != '' && $this->is_user($user) && $user != 'root') {
+ $user = escapeshellarg($user);
+ exec("chown $user $dir $dir_cur $dir_new $dir_tmp");
+ }
+
+ //* Add the subfolder to the subscriptions and courierimapsubscribed files
+ if($subfolder != '') {
+ // Courier
+ if(!is_file($maildir_path.'/courierimapsubscribed')) {
+ $tmp_file = escapeshellarg($maildir_path.'/courierimapsubscribed');
+ exec("touch $tmp_file && chown vmail:vmail $tmp_file");
+ }
+ $this->replaceLine($maildir_path.'/courierimapsubscribed','INBOX.'.$subfolder,'INBOX.'.$subfolder,1,1);
+
+ // Dovecot
+ if(!is_file($maildir_path.'/subscriptions')) {
+ $tmp_file = escapeshellarg($maildir_path.'/subscriptions');
+ exec("touch $tmp_file && chown vmail:vmail $tmp_file");
+ }
+ $this->replaceLine($maildir_path.'/subscriptions',$subfolder,$subfolder,1,1);
+ }
+
+ $app->log('Created Maildir '.$maildir_path.' with subfolder: '.$subfolder,LOGLEVEL_DEBUG);
+
+ }
}
?>
\ No newline at end of file
--
Gitblit v1.9.1