tbrehm
2007-05-31 daff5cb75bce6d6b0cbed092c3b807bb04fade9b
diverse updates.
20 files modified
235 ■■■■■ changed files
install/dist/conf/debian40.conf.php 4 ●●●● patch | view | raw | blame | history
install/install.php 4 ●●●● patch | view | raw | blame | history
install/lib/installer_base.lib.php 33 ●●●●● patch | view | raw | blame | history
interface/lib/classes/tform.inc.php 1 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_domain.lng 3 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_user.lng 4 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/module.conf.php 4 ●●●● patch | view | raw | blame | history
interface/web/mail/mail_domain_edit.php 58 ●●●●● patch | view | raw | blame | history
interface/web/mail/mail_get_edit.php 10 ●●●●● patch | view | raw | blame | history
interface/web/mail/mail_user_edit.php 67 ●●●●● patch | view | raw | blame | history
interface/web/mail/spamfilter_blacklist_edit.php 5 ●●●●● patch | view | raw | blame | history
interface/web/mail/spamfilter_whitelist_edit.php 6 ●●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_domain_edit.htm 8 ●●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_get_edit.htm 6 ●●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_user_mailbox_edit.htm 8 ●●●●● patch | view | raw | blame | history
interface/web/mail/templates/spamfilter_blacklist_edit.htm 2 ●●●●● patch | view | raw | blame | history
interface/web/mail/templates/spamfilter_whitelist_edit.htm 2 ●●●●● patch | view | raw | blame | history
server/conf/getmail.conf.master 3 ●●●● patch | view | raw | blame | history
server/lib/classes/modules.inc.php 6 ●●●●● patch | view | raw | blame | history
server/plugins-enabled/getmail_plugin.inc.php 1 ●●●● patch | view | raw | blame | history
install/dist/conf/debian40.conf.php
@@ -31,6 +31,10 @@
$conf["dist_postfix_vmail_groupname"] = "vmail";
$conf["dist_postfix_vmail_mailbox_base"] = "/home/vmail";
// Getmail
$conf["dist_getmail_config_dir"] = "/etc/getmail";
$conf["dist_getmail_program"] = "/usr/bin/getmail";
// Courier
$conf["dist_courier_config_dir"] = "/etc/courier";
install/install.php
@@ -94,6 +94,10 @@
swriteln('Installing ISPConfig');
$inst->install_ispconfig();
// Configure ISPConfig
swriteln('Installing Crontab');
$inst->install_crontab();
/*
Restart services:
install/lib/installer_base.lib.php
@@ -521,6 +521,39 @@
        
    }
    
    function install_crontab() {
        global $conf;
        // Root Crontab
        exec("crontab -u root -l > crontab.txt");
        $existing_root_cron_jobs = file('crontab.txt');
        $root_cron_jobs = array('* * * * * /usr/bin/php -q /usr/local/ispconfig/server/server.php &> /dev/null');
        foreach($root_cron_jobs as $cron_job) {
            if(!in_array($cron_job."\n",$existing_root_cron_jobs)) {
                $existing_root_cron_jobs[] = $cron_job."\n";
            }
        }
        file_put_contents('crontab.txt',$existing_root_cron_jobs);
        exec("crontab -u root crontab.txt &> /dev/null");
        unlink('crontab.txt');
        // Getmail crontab
        exec("crontab -u root -l > crontab.txt");
        $existing_cron_jobs = file('crontab.txt');
        $cron_jobs = array('*/5 * * * * '.$conf["dist_getmail_program"].' -g '.$conf["dist_getmail_config_dir"].' -r '.$conf["dist_getmail_config_dir"].'/*.conf &> /dev/null');
        foreach($cron_jobs as $cron_job) {
            if(!in_array($cron_job."\n",$existing_cron_jobs)) {
                $existing_cron_jobs[] = $cron_job."\n";
            }
        }
        file_put_contents('crontab.txt',$existing_cron_jobs);
        exec("crontab -u root crontab.txt &> /dev/null");
        unlink('crontab.txt');
    }
    
    
}
interface/lib/classes/tform.inc.php
@@ -853,6 +853,7 @@
                
                // Insert the server_id, if the record has a server_id
                $server_id = ($record_old["server_id"] > 0)?$record_old["server_id"]:0;
                if(isset($record_new["server_id"])) $server_id = $record_new["server_id"];
                
                $this->diffrec = $diffrec;
interface/web/mail/lib/lang/en_mail_domain.lng
@@ -10,5 +10,6 @@
$wb["domain_error_regex"] = 'Invalid domain name.';
$wb["client_txt"] = 'Client';
$wb["limit_maildomain_txt"] = 'The max. number of email domains for your account is reached.';
$wb["policy_txt"] = 'Spamfilter';
$wb["no_policy"] = '- not enabled -';
?>
interface/web/mail/lib/lang/en_mail_user.lng
@@ -17,6 +17,10 @@
$wb["maildir_txt"] = 'maildir';
$wb["postfix_txt"] = 'Enable Receiving';
$wb["access_txt"] = 'Enable Access';
$wb["policy_txt"] = 'Spamfilter';
$wb["no_policy"] = '- not enabled -';
$wb["limit_mailbox_txt"] = 'The max. number of mailboxes for your account is reached.';
$wb["limit_mailquota_txt"] = 'The max space for mailboxes is reached. The max. available space in MB is';
$wb["welcome_mail_subject"] = "Welcome to your new email account.";
$wb["welcome_mail_message"] = "Welcome to your new email account.\r\n \r\n Your webmaster.";
?>
interface/web/mail/lib/module.conf.php
@@ -94,11 +94,11 @@
if($_SESSION["s"]["user"]["typ"] == 'admin') {
    $items[] = array( 'title'     => "Whitelist",
    $items[] = array( 'title'     => "Postfix Whitelist",
                      'target'     => 'content',
                      'link'    => 'mail/mail_whitelist_list.php');
    $items[] = array( 'title'     => "Blacklist",
    $items[] = array( 'title'     => "Postfix Blacklist",
                      'target'     => 'content',
                       'link'    => 'mail/mail_blacklist_list.php');
interface/web/mail/mail_domain_edit.php
@@ -92,6 +92,22 @@
        $app->tpl->setVar("client_group_id",$client_select);
        }
        
        // Get the spamfilter policys for the user
        $tmp_user = $app->db->queryOneRecord("SELECT policy_id FROM spamfilter_users WHERE email = '@".$this->dataRecord["domain"]."'");
        $sql = "SELECT id, policy_name FROM spamfilter_policy WHERE ".$app->tform->getAuthSQL('r');
        $policys = $app->db->queryAllRecords($sql);
        $policy_select = "<option value='0'>".$app->tform->wordbook["no_policy"]."</option>";
        if(is_array($policys)) {
            foreach( $policys as $p) {
                $selected = ($p["id"] == $tmp_user["policy_id"])?'SELECTED':'';
                $policy_select .= "<option value='$p[id]' $selected>$p[policy_name]</option>\r\n";
            }
        }
        $app->tpl->setVar("policy",$policy_select);
        unset($policys);
        unset($policy_select);
        unset($tmp_user);
        parent::onShowEnd();
    }
    
@@ -138,6 +154,24 @@
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
        }
        // Spamfilter policy
        $policy_id = intval($this->dataRecord["policy"]);
        if($policy_id > 0) {
            $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".addslashes($this->dataRecord["domain"])."'");
            if($tmp_user["id"] > 0) {
                // There is already a record that we will update
                $sql = "UPDATE spamfilter_users SET policy_id = $ploicy_id WHERE id = ".$tmp_user["id"];
                $app->db->query($sql);
            } else {
                $tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$this->id);
                // We create a new record
                $sql = "INSERT INTO `spamfilter_users` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`)
                        VALUES (".$_SESSION["s"]["user"]["userid"].", ".$tmp_domain["sys_groupid"].", 'riud', 'riud', '', ".$this->dataRecord["server_id"].", 5, ".$policy_id.", '@".addslashes($this->dataRecord["domain"])."', '@".addslashes($this->dataRecord["domain"])."', 'Y')";
                $app->db->query($sql);
                unset($tmp_domain);
            }
        }  // endif spamfilter policy
    }
    
    function onAfterUpdate() {
@@ -149,6 +183,30 @@
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
        }
        // Spamfilter policy
        $policy_id = intval($this->dataRecord["policy"]);
        $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".addslashes($this->dataRecord["domain"])."'");
        if($policy_id > 0) {
            if($tmp_user["id"] > 0) {
                // There is already a record that we will update
                $sql = "UPDATE spamfilter_users SET policy_id = $policy_id WHERE id = ".$tmp_user["id"];
                $app->db->query($sql);
            } else {
                $tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$this->id);
                // We create a new record
                $sql = "INSERT INTO `spamfilter_users` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`)
                        VALUES (".$_SESSION["s"]["user"]["userid"].", ".$tmp_domain["sys_groupid"].", 'riud', 'riud', '', ".$this->dataRecord["server_id"].", 5, ".$policy_id.", '@".addslashes($this->dataRecord["domain"])."', '@".addslashes($this->dataRecord["domain"])."', 'Y')";
                $app->db->query($sql);
                unset($tmp_domain);
            }
        }else {
            if($tmp_user["id"] > 0) {
                // There is already a record but the user shall have no policy, so we delete it
                $sql = "DELETE FROM spamfilter_users WHERE id = ".$tmp_user["id"];
                $app->db->query($sql);
            }
        } // endif spamfilter policy
    }
    
}
interface/web/mail/mail_get_edit.php
@@ -53,6 +53,16 @@
class page_action extends tform_actions {
    
    function onSubmit() {
        global $app, $conf;
        // Set the server ID according to the selected destination
        $tmp = $app->db->queryOneRecord("SELECT server_id FROM mail_user WHERE email = '".addslashes($this->dataRecord["destination"])."'");
        $this->dataRecord["server_id"] = $tmp["server_id"];
        unset($tmp);
        parent::onSubmit();
    }
    
}
interface/web/mail/mail_user_edit.php
@@ -94,9 +94,27 @@
            }
        }
        $app->tpl->setVar("email_domain",$domain_select);
        unset($domains);
        unset($domain_select);
        // Get the spamfilter policys for the user
        $tmp_user = $app->db->queryOneRecord("SELECT policy_id FROM spamfilter_users WHERE email = '".$this->dataRecord["email"]."'");
        $sql = "SELECT id, policy_name FROM spamfilter_policy WHERE ".$app->tform->getAuthSQL('r');
        $policys = $app->db->queryAllRecords($sql);
        $policy_select = "<option value='0'>".$app->tform->wordbook["no_policy"]."</option>";
        if(is_array($policys)) {
            foreach( $policys as $p) {
                $selected = ($p["id"] == $tmp_user["policy_id"])?'SELECTED':'';
                $policy_select .= "<option value='$p[id]' $selected>$p[policy_name]</option>\r\n";
            }
        }
        $app->tpl->setVar("policy",$policy_select);
        unset($policys);
        unset($policy_select);
        unset($tmp_user);
        
        // Convert quota from Bytes to MB
        $app->tpl->setVar("quota",$this->dataRecord["quota"] / 1024/ 1024);
        $app->tpl->setVar("quota",$this->dataRecord["quota"] / 1024 / 1024);
        
        parent::onShowEnd();
    }
@@ -176,16 +194,59 @@
        global $app, $conf;
        
        // Set the domain owner as mailbox owner
        $domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain = '".$app->db->quote($_POST["email_domain"])."' AND ".$app->tform->getAuthSQL('r'));
        $domain = $app->db->queryOneRecord("SELECT sys_groupid, server_id FROM mail_domain WHERE domain = '".$app->db->quote($_POST["email_domain"])."' AND ".$app->tform->getAuthSQL('r'));
        $app->db->query("UPDATE mail_user SET sys_groupid = ".$domain["sys_groupid"]." WHERE mailuser_id = ".$this->id);
        // send a welcome email to create the mailbox
        mail($this->dataRecord["email"],$app->tform->wordbook["welcome_mail_subject"],$app->tform->wordbook["welcome_mail_message"]);
        // Spamfilter policy
        $policy_id = intval($this->dataRecord["policy"]);
        if($policy_id > 0) {
            $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '".addslashes($this->dataRecord["email"])."'");
            if($tmp_user["id"] > 0) {
                // There is already a record that we will update
                $sql = "UPDATE spamfilter_users SET policy_id = $ploicy_id WHERE id = ".$tmp_user["id"];
                $app->db->query($sql);
            } else {
                // We create a new record
                $sql = "INSERT INTO `spamfilter_users` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`)
                        VALUES (".$_SESSION["s"]["user"]["userid"].", ".$domain["sys_groupid"].", 'riud', 'riud', '', ".$domain["server_id"].", 1, ".$policy_id.", '".addslashes($this->dataRecord["email"])."', '".addslashes($this->dataRecord["email"])."', 'Y')";
                $app->db->query($sql);
            }
        }  // endif spamfilter policy
    }
    
    function onAfterUpdate() {
        global $app, $conf;
        
        // Set the domain owner as mailbox owner
        $domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain = '".$app->db->quote($_POST["email_domain"])."' AND ".$app->tform->getAuthSQL('r'));
        $domain = $app->db->queryOneRecord("SELECT sys_groupid, server_id FROM mail_domain WHERE domain = '".$app->db->quote($_POST["email_domain"])."' AND ".$app->tform->getAuthSQL('r'));
        $app->db->query("UPDATE mail_user SET sys_groupid = ".$domain["sys_groupid"]." WHERE mailuser_id = ".$this->id);
        // Spamfilter policy
        $policy_id = intval($this->dataRecord["policy"]);
        $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '".addslashes($this->dataRecord["email"])."'");
        if($policy_id > 0) {
            if($tmp_user["id"] > 0) {
                // There is already a record that we will update
                $sql = "UPDATE spamfilter_users SET policy_id = $policy_id WHERE id = ".$tmp_user["id"];
                $app->db->query($sql);
            } else {
                // We create a new record
                $sql = "INSERT INTO `spamfilter_users` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`)
                        VALUES (".$_SESSION["s"]["user"]["userid"].", ".$domain["sys_groupid"].", 'riud', 'riud', '', ".$domain["server_id"].", 1, ".$policy_id.", '".addslashes($this->dataRecord["email"])."', '".addslashes($this->dataRecord["email"])."', 'Y')";
                $app->db->query($sql);
            }
        }else {
            if($tmp_user["id"] > 0) {
                // There is already a record but the user shall have no policy, so we delete it
                $sql = "DELETE FROM spamfilter_users WHERE id = ".$tmp_user["id"];
                $app->db->query($sql);
            }
        } // endif spamfilter policy
    }
    
}
interface/web/mail/spamfilter_blacklist_edit.php
@@ -93,6 +93,11 @@
            }
        } // end if user is not admin
        
        // Select and set the server_id so it matches the server_id of the spa,filter_users record
        $tmp = $app->db->queryOneRecord("SELECT server_id FROM spamfilter_users WHERE id = ".intval($this->dataRecord["rid"]));
        $this->dataRecord["server_id"] = $tmp["server_id"];
        unset($tmp);
        parent::onSubmit();
    }
}
interface/web/mail/spamfilter_whitelist_edit.php
@@ -93,6 +93,12 @@
            }
        } // end if user is not admin
        
        // Select and set the server_id so it matches the server_id of the spa,filter_users record
        $tmp = $app->db->queryOneRecord("SELECT server_id FROM spamfilter_users WHERE id = ".intval($this->dataRecord["rid"]));
        $this->dataRecord["server_id"] = $tmp["server_id"];
        unset($tmp);
        parent::onSubmit();
    }
}
interface/web/mail/templates/mail_domain_edit.htm
@@ -22,6 +22,14 @@
    <td class="frmText11"><input name="domain" type="text" class="text" value="{tmpl_var name='domain'}" size="30" maxlength="255"></td>
  </tr>
  <tr>
    <td class="frmText11">{tmpl_var name='policy_txt'}:</td>
    <td class="frmText11">
        <select name="policy" class="text">
            {tmpl_var name='policy'}
        </select>
    </td>
  </tr>
  <tr>
    <td class="frmText11">&nbsp;</td>
    <td class="frmText11">{tmpl_var name='active'} &nbsp; {tmpl_var name='active_txt'}</td>
  </tr>
interface/web/mail/templates/mail_get_edit.htm
@@ -1,4 +1,5 @@
<table width="500" border="0" cellspacing="0" cellpadding="2">
  <!--
  <tr>
    <td class="frmText11">{tmpl_var name='server_id_txt'}:</td>
    <td class="frmText11">
@@ -7,6 +8,7 @@
        </select>
    </td>
  </tr>
  -->
  <tr>
    <td class="frmText11">{tmpl_var name='type_txt'}:</td>
    <td class="frmText11">
@@ -51,6 +53,6 @@
    <td><input name="btn_save" type="button" class="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','mail/mail_get_edit.php');"><div class="buttonEnding"></div>&nbsp;
      <input name="btn_cancel" type="button" class="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('mail/mail_get_list.php');"><div class="buttonEnding"></div>
    </td>
  </tr>
</table>
  </tr>
</table>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
interface/web/mail/templates/mail_user_mailbox_edit.htm
@@ -12,6 +12,14 @@
    <td width="366" class="frmText11"><input name="quota" type="text" class="text" value="{tmpl_var name='quota'}" size="5" maxlength="5"> MB</td>
  </tr>
  <tr>
    <td class="frmText11">{tmpl_var name='policy_txt'}:</td>
    <td class="frmText11">
        <select name="policy" class="text">
            {tmpl_var name='policy'}
        </select>
    </td>
  </tr>
  <tr>
    <td width="126" class="frmText11">{tmpl_var name='postfix_txt'}:</td>
    <td width="366" class="frmText11">{tmpl_var name='postfix'}</td>
  </tr>
interface/web/mail/templates/spamfilter_blacklist_edit.htm
@@ -1,4 +1,5 @@
<table width="500" border="0" cellspacing="0" cellpadding="2">
  <!--
  <tr>
    <td class="frmText11">{tmpl_var name='server_id_txt'}:</td>
    <td class="frmText11">
@@ -7,6 +8,7 @@
        </select>
    </td>
  </tr>
  -->
  <tr>
    <td class="frmText11">{tmpl_var name='rid_txt'}:</td>
    <td class="frmText11">
interface/web/mail/templates/spamfilter_whitelist_edit.htm
@@ -1,4 +1,5 @@
<table width="500" border="0" cellspacing="0" cellpadding="2">
<!--
  <tr>
    <td class="frmText11">{tmpl_var name='server_id_txt'}:</td>
    <td class="frmText11">
@@ -7,6 +8,7 @@
        </select>
    </td>
  </tr>
  -->
  <tr>
    <td class="frmText11">{tmpl_var name='rid_txt'}:</td>
    <td class="frmText11">
server/conf/getmail.conf.master
@@ -1,5 +1,6 @@
[options]
message_log = /var/log/getmail.log
# message_log = /var/log/getmail.log
message_log_syslog = 1
delete = {DELETE}
[retriever]
server/lib/classes/modules.inc.php
@@ -78,15 +78,17 @@
    */
    
    function processDatalog() {
        global $app;
        global $app,$conf;
        
        // TODO: process only new entries.
        $sql = "SELECT * FROM sys_datalog WHERE 1";
        $sql = "SELECT * FROM sys_datalog WHERE server_id = ".$conf["server_id"];
        $records = $app->db->queryAllRecords($sql);
        foreach($records as $rec) {
            $data = unserialize(stripslashes($rec["data"]));
            $this->raiseTableHook($rec["dbtable"],$rec["action"],$data);
        }
        $app->db->query("DELETE FROM sys_datalog WHERE datalog_id = ".$rec["datalog_id"]);
        $app->log("Deleting sys_datalog ID ".$rec["datalog_id"],LOGLEVEL_DEBUG);
    }
    
    function raiseTableHook($table_name,$action,$data) {
server/plugins-enabled/getmail_plugin.inc.php
@@ -113,6 +113,7 @@
                // Write the config file.
                file_put_contents($config_file_path,$tpl);
                $app->log("Writing Getmail config file: $config_file_path",LOGLEVEL_DEBUG);
                exec("chmod 400 $config_file_path");
                unset($tpl);
                unset($config_file_path);