tbrehm
2007-04-26 9200ad818fad34e9394a7ec82c10750c0fb83551
Initial checkin of the ISPConfig 3 installer. The installer supports currently just Debain 4.0
22 files added
2539 ■■■■■ changed files
install/dist/conf/debian40.conf.php 59 ●●●●● patch | view | raw | blame | history
install/dist/lib/debian40.lib.php 36 ●●●●● patch | view | raw | blame | history
install/install.php 113 ●●●●● patch | view | raw | blame | history
install/lib/install.lib.php 382 ●●●●● patch | view | raw | blame | history
install/lib/installer_base.lib.php 500 ●●●●● patch | view | raw | blame | history
install/lib/mysql.lib.php 498 ●●●●● patch | view | raw | blame | history
install/sql/ispconfig3.sql 618 ●●●●● patch | view | raw | blame | history
install/tpl/amavisd_user_config.master 55 ●●●●● patch | view | raw | blame | history
install/tpl/authmysqlrc.master 17 ●●●●● patch | view | raw | blame | history
install/tpl/config.inc.php.master 107 ●●●●● patch | view | raw | blame | history
install/tpl/mailfilter.master 63 ●●●●● patch | view | raw | blame | history
install/tpl/master_cf_amavis.master 18 ●●●●● patch | view | raw | blame | history
install/tpl/mysql-virtual_client.cf.master 8 ●●●●● patch | view | raw | blame | history
install/tpl/mysql-virtual_domains.cf.master 7 ●●●●● patch | view | raw | blame | history
install/tpl/mysql-virtual_email2email.cf.master 7 ●●●●● patch | view | raw | blame | history
install/tpl/mysql-virtual_forwardings.cf.master 8 ●●●●● patch | view | raw | blame | history
install/tpl/mysql-virtual_mailboxes.cf.master 8 ●●●●● patch | view | raw | blame | history
install/tpl/mysql-virtual_recipient.cf.master 8 ●●●●● patch | view | raw | blame | history
install/tpl/mysql-virtual_sender.cf.master 8 ●●●●● patch | view | raw | blame | history
install/tpl/mysql-virtual_transports.cf.master 8 ●●●●● patch | view | raw | blame | history
install/tpl/pamd_smtp.master 2 ●●●●● patch | view | raw | blame | history
install/tpl/sasl_smtpd.conf.master 9 ●●●●● patch | view | raw | blame | history
install/dist/conf/debian40.conf.php
New file
@@ -0,0 +1,59 @@
<?php
$conf["language"] = "en";
$conf["distname"] = "debian40";
$conf["hostname"] = "server1.example.com"; // Full hostname
$conf["ispconfig_install_dir"] = "/usr/local/ispconfig";
$conf["ispconfig_config_dir"] = "/usr/local/ispconfig";
/*
    Distribution specific settings
*/
$conf["dist_init_scripts"] = "/etc/init.d";
$conf["dist_runlevel"] = "/etc";
$conf["dist_shells"] = "/etc/shells";
$conf["dist_cron_tab"] = "/var/spool/cron/crontabs/root";
// Apache
$conf["dist_apache_user"] = "www-data";
$conf["dist_apache_group"] = "www-data";
$conf["dist_apache_init_script"] = "apache2";
$conf["dist_apache_version"] = "2.2";
// Postfix
$conf["dist_postfix_config_dir"] = "/etc/postfix";
$conf["dist_postfix_username"] = "postfix";
$conf["dist_postfix_groupname"] = "postfix";
$conf["dist_postfix_vmail_userid"] = "5000";
$conf["dist_postfix_vmail_username"] = "vmail";
$conf["dist_postfix_vmail_groupid"] = "5000";
$conf["dist_postfix_vmail_groupname"] = "vmail";
$conf["dist_postfix_vmail_mailbox_base"] = "/home/vmail";
// Courier
$conf["dist_courier_config_dir"] = "/etc/courier";
// Amavisd
$conf["dist_amavis_config_dir"] = "/etc/amavis";
/*
    MySQL Database settings
*/
$conf["mysql_server_host"] = "localhost";
$conf["mysql_server_ip"] = "127.0.0.1";
$conf["mysql_server_port"] = "3306";
$conf["mysql_server_database"] = "dbispconfig";
$conf["mysql_server_admin_user"] = "root";
$conf["mysql_server_admin_password"] = "";
$conf["mysql_server_ispconfig_user"] = "ispconfig";
$conf["mysql_server_ispconfig_password"] = "5sDrewBhk";
?>
install/dist/lib/debian40.lib.php
New file
@@ -0,0 +1,36 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
class installer extends installer_base {
}
?>
install/install.php
New file
@@ -0,0 +1,113 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
    ISPConfig 3 installer.
*/
// Include the library with the basic installer functions
require_once('lib/install.lib.php');
// Include the base class of the installer class
require_once('lib/installer_base.lib.php');
$distname = get_distname();
// Include the distribution specific installer class library
// and configuration
include_once('dist/lib/'.$distname.'.lib.php');
include_once('dist/conf/'.$distname.'.conf.php');
$inst = new installer();
echo "This application will install ISPConfig 3 on your server.\n";
// $conf["language"] = $inst->request_language();
// TODO: all other queries, for testing I will setup everything in $conf
// Initialize the MySQL server connection
include_once('lib/mysql.lib.php');
$inst->db = new db();
// Create the mysql database
//$inst->configure_database();
// Configure postfix
$inst->configure_postfix();
// Configure saslauthd
swriteln('Configuring SASL');
$inst->configure_saslauthd();
// Configure PAM
swriteln('Configuring PAM');
$inst->configure_pam();
// Configure courier
swriteln('Configuring Courier');
$inst->configure_courier();
// Configure Spamasassin
swriteln('Configuring Spamassassin');
$inst->configure_spamassassin();
// Configure Amavis
swriteln('Configuring Amavisd');
$inst->configure_amavis();
// Configure Amavis
swriteln('Installing ISPConfig');
$inst->install_ispconfig();
/*
Restart services:
saslauthd
all courier
apache2
postfix
amavisd
calmd
spamd
*/
echo "Installation finished.\n";
?>
install/lib/install.lib.php
New file
@@ -0,0 +1,382 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
    This function returns a string that describes the installed
    linux distribution. e.g. debian40 for Debian Linux 4.0
*/
function get_distname() {
    $distname = 'debian40';
    return $distname;
}
function sread() {
    $fp=fopen("/dev/stdin", "r");
    $input=fgets($fp, 255);
    fclose($fp);
    return rtrim($input);
}
function swrite($text) {
    echo $text;
}
function swriteln($text) {
    echo $text."\n";
}
$FILE = realpath("../install.php");
function ilog($msg){
  $logfile = "/var/log/ispconfig_install.log";
  exec("echo `date` \"- [ISPConfig] - \"".$msg." >> ".$logfile);
}
function error($msg){
  ilog($msg);
  die($msg."\n");
}
function caselog($command, $file = '', $line = '', $success = '', $failure = ''){
  exec($command,$arr,$ret_val);
  $arr = NULL;
  if(!empty($file) && !empty($line)){
    $pre = $file.", Line ".$line.": ";
  } else {
    $pre = "";
  }
  if($ret_val != 0){
    if($failure == "") $failure = "could not ".$command;
    ilog($pre."WARNING: ".$failure);
  } else {
    if($success == "") $success = $command;
    ilog($pre.$success);
  }
}
function phpcaselog($ret_val, $msg, $file = '', $line = ''){
  if(!empty($file) && !empty($line)){
    $pre = $file.", Line ".$line.": ";
  } else {
    $pre = "";
  }
  if($ret_val == true){
    ilog($pre.$msg);
  } else {
    ilog($pre."WARNING: could not ".$msg);
  }
  return $ret_val;
}
function mkdirs($strPath, $mode = '0755'){
  if(isset($strPath) && $strPath != ""){
    // Verzeichnisse rekursiv erzeugen
    if(is_dir($strPath)) return true;
    $pStrPath = dirname($strPath);
    if(!mkdirs($pStrPath, $mode)) return false;
    $old_umask = umask(0);
    $ret_val = mkdir($strPath, octdec($mode));
    umask($old_umask);
    return $ret_val;
  } else {
    return false;
  }
}
function rf($file){
  clearstatcache();
  if(!$fp = fopen ($file, "rb")) ilog("WARNING: could not open file ".$file);
  if(filesize($file) > 0){
    $content = fread($fp, filesize($file));
  } else {
    $content = "";
  }
  fclose($fp);
  return $content;
}
function wf($file, $content){
  mkdirs(dirname($file));
  if(!$fp = fopen ($file, "wb")) ilog("WARNING: could not open file ".$file);
  fwrite($fp,$content);
  fclose($fp);
}
function af($file, $content){
  mkdirs(dirname($file));
  if(!$fp = fopen ($file, "ab")) ilog("WARNING: could not open file ".$file);
  fwrite($fp,$content);
  fclose($fp);
}
function aftsl($file, $content){
  if(!$fp = fopen ($file, "ab")) ilog("WARNING: could not open file ".$file);
  fwrite($fp,$content);
  fclose($fp);
}
function unix_nl($input){
  $output = str_replace("\r\n", "\n", $input);
  $output = str_replace("\r", "\n", $output);
  return $output;
}
function remove_blank_lines($input, $file = 1){
  //Leerzeilen l�schen
  if($file){
    $content = unix_nl(rf($input));
  } else {
    $content = $input;
  }
  $lines = explode("\n", $content);
  if(!empty($lines)){
    foreach($lines as $line){
      if(trim($line) != "") $new_lines[] = $line;
    }
  }
  if(is_array($new_lines)){
    $content = implode("\n", $new_lines);
  } else {
    $content = "";
  }
  if($file){
    wf($input, $content);
  } else {
    return $content;
  }
}
function no_comments($file, $comment = '#'){
  $content = unix_nl(rf($file));
  $lines = explode("\n", $content);
  if(!empty($lines)){
    foreach($lines as $line){
      if(strstr($line, $comment)){
        $pos = strpos($line, $comment);
        if($pos != 0){
          $new_lines[] = substr($line,0,$pos);
        } else {
          $new_lines[] = "";
        }
      } else {
        $new_lines[] = $line;
      }
    }
  }
  if(is_array($new_lines)){
    $content_without_comments = implode("\n", $new_lines);
    $new_lines = NULL;
    return $content_without_comments;
  } else {
    return "";
  }
}
function find_includes($file){
  global $httpd_root;
  clearstatcache();
  if(is_file($file) && filesize($file) > 0){
    $includes[] = $file;
    $inhalt = unix_nl(no_comments($file));
    $lines = explode("\n", $inhalt);
    if(!empty($lines)){
      foreach($lines as $line){
        if(stristr($line, "include ")){
          $include_file = str_replace("\n", "", trim(shell_exec("echo \"$line\" | awk '{print \$2}'")));
          if(substr($include_file,0,1) != "/"){
            $include_file = $httpd_root."/".$include_file;
          }
          if(is_file($include_file)){
            if($further_includes = find_includes($include_file)){
              $includes = array_merge($includes, $further_includes);
            }
          } else {
            if(strstr($include_file, "*")){
              $more_files = explode("\n", shell_exec("ls -l $include_file | awk '{print \$9}'"));
              if(!empty($more_files)){
                foreach($more_files as $more_file){
                  if(is_file($more_file)){
                    if($further_includes = find_includes($more_file)){
                      $includes = array_merge($includes, $further_includes);
                    }
                  }
                }
              }
              unset($more_files);
              $more_files = explode("\n", shell_exec("ls -l $include_file | awk '{print \$10}'"));
              if(!empty($more_files)){
                foreach($more_files as $more_file){
                  if(is_file($more_file)){
                    if($further_includes = find_includes($more_file)){
                      $includes = array_merge($includes, $further_includes);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  if(is_array($includes)){
    $includes = array_unique($includes);
    return $includes;
  } else {
    return false;
  }
}
function comment_out($file, $string){
  $inhalt = no_comments($file);
  $gesamt_inhalt = rf($file);
  $modules = explode(",",$string);
  foreach($modules as $val){
    $val = trim($val);
    if(strstr($inhalt, $val)){
      $gesamt_inhalt = str_replace($val, "##ISPConfig INSTALL## ".$val, $gesamt_inhalt);
    }
  }
  wf($file, $gesamt_inhalt);
}
function is_word($string, $text, $params = ''){
  // params: i
  if(preg_match("/\b$string\b/$params", $text)) {
    return true;
  } else {
    return false;
  }
}
function grep($content, $string, $params = ''){
  // params: i, v, w
  $content = unix_nl($content);
  $lines = explode("\n", $content);
  foreach($lines as $line){
    if(!strstr($params, 'w')){
      if(strstr($params, 'i')){
        if(strstr($params, 'v')){
          if(!stristr($line, $string)) $find[] = $line;
        } else {
          if(stristr($line, $string)) $find[] = $line;
        }
      } else {
        if(strstr($params, 'v')){
          if(!strstr($line, $string)) $find[] = $line;
        } else {
          if(strstr($line, $string)) $find[] = $line;
        }
      }
    } else {
      if(strstr($params, 'i')){
        if(strstr($params, 'v')){
          if(!is_word($string, $line, 'i')) $find[] = $line;
        } else {
          if(is_word($string, $line, 'i')) $find[] = $line;
        }
      } else {
        if(strstr($params, 'v')){
          if(!is_word($string, $line)) $find[] = $line;
        } else {
          if(is_word($string, $line)) $find[] = $line;
        }
      }
    }
  }
  if(is_array($find)){
    $ret_val = implode("\n", $find);
    if(substr($ret_val,-1) != "\n") $ret_val .= "\n";
    $find = NULL;
    return $ret_val;
  } else {
    return false;
  }
}
function edit_xinetd_conf($service){
  $xinetd_conf = "/etc/xinetd.conf";
  $contents = unix_nl(rf($xinetd_conf));
  $lines = explode("\n", $contents);
  $j = sizeof($lines);
  for($i=0;$i<sizeof($lines);$i++){
    if(grep($lines[$i], $service, "w")){
      $fundstelle_anfang = $i;
      $j = $i;
      $parts = explode($lines[$i], $contents);
    }
    if($j < sizeof($lines)){
      if(strstr($lines[$i], "}")){
        $fundstelle_ende = $i;
        $j = sizeof($lines);
      }
    }
  }
  if(isset($fundstelle_anfang) && isset($fundstelle_ende)){
    for($i=$fundstelle_anfang;$i<=$fundstelle_ende;$i++){
      if(strstr($lines[$i], "disable")){
        $disable = explode("=", $lines[$i]);
        $disable[1] = " yes";
        $lines[$i] = implode("=", $disable);
      }
    }
  }
  $fundstelle_anfang = NULL;
  $fundstelle_ende = NULL;
  $contents = implode("\n", $lines);
  wf($xinetd_conf, $contents);
}
/*
commandline arguments
$argv[1]
<?
echo "Total argument passed are : $argc \n";
for( $i = 0 ; $i <= $argc -1 ;$i++)
{
echo "Argument $i : $argv[$i] \n";
}
?>
*/
?>
install/lib/installer_base.lib.php
New file
@@ -0,0 +1,500 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
class installer_base {
    var $wb = array();
    var $language = 'en';
    var $db;
    /*
    */
    function lng() {
    }
    function error($msg) {
        die("ERROR: ".$msg."\n");
    }
    function request_language() {
        swriteln(lng('Enter your language'));
        swriteln(lng('de, en'));
        /*
        do {
            $lang = sread(2);
        } while (!$this->check_break($lang) or $this->
        */
    }
    /*
        This function creates the database for ISPConfig
    */
    function configure_database() {
        global $conf;
        // Create the database
        if(!$this->db->query("CREATE DATABASE IF NOT EXISTS ".$conf["mysql_server_database"])) {
            $this->error('Unable to create MySQL database: '.$conf["mysql_server_database"].';');
        }
        // Create the ISPConfig database user
        if(!$this->db->query("GRANT SELECT, INSERT, UPDATE, DELETE ON ".$conf["mysql_server_database"].".* TO '".$conf["mysql_server_ispconfig_user"]."'@'".$conf["mysql_server_host"]."' IDENTIFIED BY '".$conf["mysql_server_ispconfig_password"]."';")) {
            $this->error('Unable to create database user: '.$conf["mysql_server_ispconfig_user"]);
        }
        // Reload database priveliges
        $this->db->query('FLUSH PRIVILEGES;');
        // Set the database name in the DB library
        $this->db->dbName = $conf["mysql_server_database"];
        // loading the database dump into the database, if database is empty
        $db_tables = $this->db->getTables();
        if(count($db_tables) > 0) {
            $this->error('Stopped: Database contains already some tables.');
        } else {
            if($conf["mysql_server_admin_password"] == '') {
                caselog("mysql -h '".$conf["mysql_server_host"]."' -u '".$conf["mysql_server_admin_user"]."' '".$conf["mysql_server_database"]."' < 'sql/ispconfig3.sql' &> /dev/null", $FILE, __LINE__,"read in ispconfig3.sql","could not read in ispconfig3.sql");
            } else {
                caselog("mysql -h '".$conf["mysql_server_host"]."' -u '".$conf["mysql_server_admin_user"]."' -p'".$conf["mysql_server_admin_password"]."' '".$conf["mysql_server_database"]."' < 'sql/ispconfig3.sql' &> /dev/null", $FILE, __LINE__,"read in ispconfig3.sql","could not read in ispconfig3.sql");
            }
            $db_tables = $this->db->getTables();
            if(count($db_tables) == 0) {
                $this->error('Unable to load SQL-Dump into database table.');
            }
        }
    }
    /*
        Create postfix configuration files
    */
    function configure_postfix() {
        global $conf;
        if(!is_dir($conf["dist_postfix_config_dir"])) $this->error("The postfix configuration directory ".$conf["dist_postfix_config_dir"]." does not exist.");
        // mysql-virtual_domains.cf
        $configfile = 'mysql-virtual_domains.cf';
        if(is_file($conf["dist_postfix_config_dir"].'/'.$configfile)) copy($conf["dist_postfix_config_dir"].'/'.$configfile,$conf["dist_postfix_config_dir"].'/'.$configfile.'~');
        $content = rf("tpl/".$configfile.".master");
        $content = str_replace('{mysql_server_ispconfig_user}',$conf["mysql_server_ispconfig_user"],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
        $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
        $content = str_replace('{mysql_server_ip}',$conf["mysql_server_ip"],$content);
        wf($conf["dist_postfix_config_dir"].'/'.$configfile,$content);
        // mysql-virtual_forwardings.cf
        $configfile = 'mysql-virtual_forwardings.cf';
        if(is_file($conf["dist_postfix_config_dir"].'/'.$configfile)) copy($conf["dist_postfix_config_dir"].'/'.$configfile,$conf["dist_postfix_config_dir"].'/'.$configfile.'~');
        $content = rf("tpl/".$configfile.".master");
        $content = str_replace('{mysql_server_ispconfig_user}',$conf["mysql_server_ispconfig_user"],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
        $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
        $content = str_replace('{mysql_server_ip}',$conf["mysql_server_ip"],$content);
        wf($conf["dist_postfix_config_dir"].'/'.$configfile,$content);
        // mysql-virtual_mailboxes.cf
        $configfile = 'mysql-virtual_mailboxes.cf';
        if(is_file($conf["dist_postfix_config_dir"].'/'.$configfile)) copy($conf["dist_postfix_config_dir"].'/'.$configfile,$conf["dist_postfix_config_dir"].'/'.$configfile.'~');
        $content = rf("tpl/".$configfile.".master");
        $content = str_replace('{mysql_server_ispconfig_user}',$conf["mysql_server_ispconfig_user"],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
        $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
        $content = str_replace('{mysql_server_ip}',$conf["mysql_server_ip"],$content);
        wf($conf["dist_postfix_config_dir"].'/'.$configfile,$content);
        // mysql-virtual_email2email.cf
        $configfile = 'mysql-virtual_email2email.cf';
        if(is_file($conf["dist_postfix_config_dir"].'/'.$configfile)) copy($conf["dist_postfix_config_dir"].'/'.$configfile,$conf["dist_postfix_config_dir"].'/'.$configfile.'~');
        $content = rf("tpl/".$configfile.".master");
        $content = str_replace('{mysql_server_ispconfig_user}',$conf["mysql_server_ispconfig_user"],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
        $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
        $content = str_replace('{mysql_server_ip}',$conf["mysql_server_ip"],$content);
        wf($conf["dist_postfix_config_dir"].'/'.$configfile,$content);
        // mysql-virtual_transports.cf
        $configfile = 'mysql-virtual_transports.cf';
        if(is_file($conf["dist_postfix_config_dir"].'/'.$configfile)) copy($conf["dist_postfix_config_dir"].'/'.$configfile,$conf["dist_postfix_config_dir"].'/'.$configfile.'~');
        $content = rf("tpl/".$configfile.".master");
        $content = str_replace('{mysql_server_ispconfig_user}',$conf["mysql_server_ispconfig_user"],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
        $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
        $content = str_replace('{mysql_server_ip}',$conf["mysql_server_ip"],$content);
        wf($conf["dist_postfix_config_dir"].'/'.$configfile,$content);
        // mysql-virtual_recipient.cf
        $configfile = 'mysql-virtual_recipient.cf';
        if(is_file($conf["dist_postfix_config_dir"].'/'.$configfile)) copy($conf["dist_postfix_config_dir"].'/'.$configfile,$conf["dist_postfix_config_dir"].'/'.$configfile.'~');
        $content = rf("tpl/".$configfile.".master");
        $content = str_replace('{mysql_server_ispconfig_user}',$conf["mysql_server_ispconfig_user"],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
        $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
        $content = str_replace('{mysql_server_ip}',$conf["mysql_server_ip"],$content);
        wf($conf["dist_postfix_config_dir"].'/'.$configfile,$content);
        // mysql-virtual_sender.cf
        $configfile = 'mysql-virtual_sender.cf';
        if(is_file($conf["dist_postfix_config_dir"].'/'.$configfile)) copy($conf["dist_postfix_config_dir"].'/'.$configfile,$conf["dist_postfix_config_dir"].'/'.$configfile.'~');
        $content = rf("tpl/".$configfile.".master");
        $content = str_replace('{mysql_server_ispconfig_user}',$conf["mysql_server_ispconfig_user"],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
        $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
        $content = str_replace('{mysql_server_ip}',$conf["mysql_server_ip"],$content);
        wf($conf["dist_postfix_config_dir"].'/'.$configfile,$content);
        // mysql-virtual_client.cf
        $configfile = 'mysql-virtual_client.cf';
        if(is_file($conf["dist_postfix_config_dir"].'/'.$configfile)) copy($conf["dist_postfix_config_dir"].'/'.$configfile,$conf["dist_postfix_config_dir"].'/'.$configfile.'~');
        $content = rf("tpl/".$configfile.".master");
        $content = str_replace('{mysql_server_ispconfig_user}',$conf["mysql_server_ispconfig_user"],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
        $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
        $content = str_replace('{mysql_server_ip}',$conf["mysql_server_ip"],$content);
        wf($conf["dist_postfix_config_dir"].'/'.$configfile,$content);
        // Changing mode and group of the new created config files.
        caselog("chmod o= ".$conf["dist_postfix_config_dir"]."/mysql-virtual_*.cf* &> /dev/null", __FILE__, __LINE__,"chmod on mysql-virtual_*.cf*","chmod on mysql-virtual_*.cf* failed");
        caselog("chgrp ".$conf["dist_postfix_groupname"]." ".$conf["dist_postfix_config_dir"]."/mysql-virtual_*.cf* &> /dev/null", __FILE__, __LINE__,"chgrp on mysql-virtual_*.cf*","chgrp on mysql-virtual_*.cf* failed");
        // Creating virtual mail user and group
        $command = "groupadd -g ".$conf["dist_postfix_vmail_groupid"]." ".$conf["dist_postfix_vmail_groupname"];
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        $command = "useradd -g ".$conf["dist_postfix_vmail_groupname"]." -u ".$conf["dist_postfix_vmail_userid"]." ".$conf["dist_postfix_vmail_username"]." -d ".$conf["dist_postfix_vmail_mailbox_base"]." -m";
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        $postconf_commands = array (
            'myhostname = '.$conf["hostname"],
            'mydestination = '.$conf["hostname"].', localhost, localhost.localdomain',
            'mynetworks = 127.0.0.0/8',
            'virtual_alias_domains =',
            'virtual_alias_maps = proxy:mysql:'.$conf["dist_postfix_config_dir"].'/mysql-virtual_forwardings.cf, mysql:'.$conf["dist_postfix_config_dir"].'/mysql-virtual_email2email.cf',
            'virtual_mailbox_domains = proxy:mysql:'.$conf["dist_postfix_config_dir"].'/mysql-virtual_domains.cf',
            'virtual_mailbox_maps = proxy:mysql:'.$conf["dist_postfix_config_dir"].'/mysql-virtual_mailboxes.cf',
            'virtual_mailbox_base = '.$conf["dist_postfix_vmail_mailbox_base"],
            'virtual_uid_maps = static:'.$conf["dist_postfix_vmail_userid"],
            'virtual_gid_maps = static:'.$conf["dist_postfix_vmail_groupid"],
            'smtpd_sasl_auth_enable = yes',
            'broken_sasl_auth_clients = yes',
            'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:'.$conf["dist_postfix_config_dir"].'/mysql-virtual_recipient.cf, reject_unauth_destination',
            'smtpd_use_tls = yes',
            'smtpd_tls_cert_file = '.$conf["dist_postfix_config_dir"].'/smtpd.cert',
            'smtpd_tls_key_file = '.$conf["dist_postfix_config_dir"].'/smtpd.key',
            'transport_maps = proxy:mysql:'.$conf["dist_postfix_config_dir"].'/mysql-virtual_transports.cf',
            'virtual_create_maildirsize = yes',
            'virtual_mailbox_extended = yes',
            'virtual_mailbox_limit_maps = proxy:mysql:'.$conf["dist_postfix_config_dir"].'/mysql-virtual_mailbox_limit_maps.cf',
            'virtual_mailbox_limit_override = yes',
            'virtual_maildir_limit_message = "The user you are trying to reach is over quota."',
            'virtual_overquota_bounce = yes',
            'proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps',
            'smtpd_sender_restrictions = check_sender_access mysql:'.$conf["dist_postfix_config_dir"].'/mysql-virtual_sender.cf',
            'smtpd_client_restrictions = check_client_access mysql:'.$conf["dist_postfix_config_dir"].'/mysql-virtual_client.cf',
            'maildrop_destination_concurrency_limit = 1',
            'maildrop_destination_recipient_limit   = 1',
            'virtual_transport = maildrop'
        );
        // Make a backup copy of the main.cf file
        copy($conf["dist_postfix_config_dir"].'/main.cf',$conf["dist_postfix_config_dir"].'/main.cf~');
        // Executing the postconf commands
        foreach($postconf_commands as $cmd) {
            $command = "postconf -e '$cmd'";
            caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        }
        // TODO: Change the master.cf file
        /*
        Add:
maildrop  unix  -       n       n       -       -       pipe
  flags=R user=vmail argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}
        */
        // Create the SSL certificate
        $command = "cd ".$conf["dist_postfix_config_dir"]."; openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -x509";
        exec($command);
        $command = "chmod o= ".$conf["dist_postfix_config_dir"]."/smtpd.key";
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        /*
        We have to change the permissions of the courier authdaemon directory
        to make it accessible for maildrop.
        */
        $command = "chmod 755  /var/run/courier/authdaemon/";
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        // Writing the Maildrop mailfilter file
        $configfile = 'mailfilter';
        if(is_file($conf["dist_postfix_vmail_mailbox_base"].'/.'.$configfile)) copy($conf["dist_postfix_vmail_mailbox_base"].'/.'.$configfile,$conf["dist_postfix_vmail_mailbox_base"].'/.'.$configfile.'~');
        $content = rf("tpl/".$configfile.".master");
        $content = str_replace('{dist_postfix_vmail_mailbox_base}',$conf["dist_postfix_vmail_mailbox_base"],$content);
        wf($conf["dist_postfix_vmail_mailbox_base"].'/.'.$configfile,$content);
        // Create the directory for the custom mailfilters
        $command = "mkdir ".$conf["dist_postfix_vmail_mailbox_base"]."/mailfilters";
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        // Chmod and chown the .mailfilter file
        $command = "chown -R ".$conf["dist_postfix_vmail_username"].":".$conf["dist_postfix_vmail_groupname"]." ".$conf["dist_postfix_vmail_mailbox_base"]."/.mailfilter";
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        $command = "chmod -R 600 ".$conf["dist_postfix_vmail_mailbox_base"]."/.mailfilter";
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
    }
    function configure_saslauthd() {
        global $conf;
        /*
        TODO: The example below is for Ubuntu 6.10
        mkdir -p /var/spool/postfix/var/run/saslauthd
Edit /etc/default/saslauthd. Remove the # in front of START=yes and add the line PARAMS="-m /var/spool/postfix/var/run/saslauthd -r".
vi /etc/default/saslauthd
The file should then look like this:
# This needs to be uncommented before saslauthd will be run automatically
START=yes
# You must specify the authentication mechanisms you wish to use.
# This defaults to "pam" for PAM support, but may also include
# "shadow" or "sasldb", like this:
# MECHANISMS="pam shadow"
MECHANISMS="pam"
PARAMS="-m /var/spool/postfix/var/run/saslauthd -r"
We must also edit /etc/init.d/saslauthd and change the location of saslauthd's PID file.
vi /etc/init.d/saslauthd
Change the value of PIDFILE to /var/spool/postfix/var/run/${NAME}/saslauthd.pid:
PIDFILE="/var/spool/postfix/var/run/${NAME}/saslauthd.pid"
Then restart Postfix and Saslauthd:
/etc/init.d/postfix restart
postfix check
/etc/init.d/saslauthd restart
        */
        $configfile = 'sasl_smtpd.conf';
        if(is_file($conf["dist_postfix_config_dir"].'/sasl/smtpd.conf')) copy($conf["dist_postfix_config_dir"].'/sasl/smtpd.conf',$conf["dist_postfix_config_dir"].'/sasl/smtpd.conf~');
        exec('chmod 400 '.$conf["dist_postfix_config_dir"].'/sasl/smtpd.conf~');
        $content = rf("tpl/".$configfile.".master");
        $content = str_replace('{mysql_server_ispconfig_user}',$conf["mysql_server_ispconfig_user"],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
        $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
        $content = str_replace('{mysql_server_ip}',$conf["mysql_server_ip"],$content);
        wf($conf["dist_postfix_config_dir"].'/sasl/smtpd.conf',$content);
        // TODO: Chmod and chown on the config file
    }
    function configure_pam() {
        global $conf;
        // configure pam for SMTP authentication agains the ispconfig database
        $configfile = 'pamd_smtp';
        if(is_file('/etc/pam.d/smtp')) copy('/etc/pam.d/smtp','/etc/pam.d/smtp~');
        exec('chmod 400 /etc/pam.d/smtp~');
        $content = rf("tpl/".$configfile.".master");
        $content = str_replace('{mysql_server_ispconfig_user}',$conf["mysql_server_ispconfig_user"],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
        $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
        $content = str_replace('{mysql_server_ip}',$conf["mysql_server_ip"],$content);
        wf('/etc/pam.d/smtp',$content);
        exec('chmod 660 /etc/pam.d/smtp');
        exec('chown daemon:daemon /etc/pam.d/smtp');
    }
    function configure_courier() {
        global $conf;
        // authmysqlrc
        $configfile = 'authmysqlrc';
        if(is_file($conf["dist_courier_config_dir"].'/'.$configfile)) copy($conf["dist_courier_config_dir"].'/'.$configfile,$conf["dist_courier_config_dir"].'/'.$configfile.'~');
        exec('chmod 400 '.$conf["dist_courier_config_dir"].'/'.$configfile.'~');
        $content = rf("tpl/".$configfile.".master");
        $content = str_replace('{mysql_server_ispconfig_user}',$conf["mysql_server_ispconfig_user"],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
        $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
        $content = str_replace('{mysql_server_host}',$conf["mysql_server_host"],$content);
        wf($conf["dist_courier_config_dir"].'/'.$configfile,$content);
        exec('chmod 660 '.$conf["dist_courier_config_dir"].'/'.$configfile);
        exec('chown daemon:daemon '.$conf["dist_courier_config_dir"].'/'.$configfile);
    }
    function configure_amavis() {
        global $conf;
        // amavisd user config file
        $configfile = 'amavisd_user_config';
        if(is_file($conf["dist_amavis_config_dir"].'/50-user')) copy($conf["dist_amavis_config_dir"].'/50-user',$conf["dist_courier_config_dir"].'/50-user~');
        exec('chmod 400 '.$conf["dist_courier_config_dir"].'/50-user~');
        $content = rf("tpl/".$configfile.".master");
        $content = str_replace('{mysql_server_ispconfig_user}',$conf["mysql_server_ispconfig_user"],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
        $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
        $content = str_replace('{mysql_server_ip}',$conf["mysql_server_ip"],$content);
        wf($conf["dist_amavis_config_dir"].'/50-user',$content);
        // TODO: chmod and chown on the config file
        // Adding the amavisd commands to the postfix configuration
        $postconf_commands = array (
            'content_filter = amavis:[127.0.0.1]:10024',
            'receive_override_options = no_address_mappings'
        );
        // Make a backup copy of the main.cf file
        copy($conf["dist_postfix_config_dir"].'/main.cf',$conf["dist_postfix_config_dir"].'/main.cf~2');
        // Executing the postconf commands
        foreach($postconf_commands as $cmd) {
            $command = "postconf -e '$cmd'";
            caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        }
        // Append the configuration for amavisd to the master.cf file
        if(is_file($conf["dist_postfix_config_dir"].'/master.cf')) copy($conf["dist_postfix_config_dir"].'/master.cf',$conf["dist_postfix_config_dir"].'/master.cf~');
        $content = rf("tpl/master_cf_amavis.master");
        // Only add the content if we had not addded it before
        if(!stristr("127.0.0.1:10025 inet n - - - - smtpd",$content)) {
            af($conf["dist_postfix_config_dir"].'/master.cf',$content);
        }
        // Add the clamav user to the amavis group
        exec('adduser clamav amavis');
    }
    function configure_spamassassin() {
        global $conf;
        // Enable spamasasssin in debian and ubunti
        $configfile = '/etc/default/spamassassin';
        if(is_file($configfile)) copy($configfile,$configfile.'~');
        $content = rf($configfile);
        $content = str_replace('ENABLED=0','ENABLED=1',$content);
        wf($configfile,$content);
    }
    function install_ispconfig() {
        global $conf;
        // Create the ISPConfig installation directory
        $command = "mkdir ".$conf["ispconfig_install_dir"];
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        // Create a ISPConfig user and group
        $command = "groupadd ispconfig";
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        $command = "useradd -g ispconfig -d ".$conf["ispconfig_install_dir"]." ispconfig";
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        // copy the ISPConfig interface part
        $command = "cp -rf ../interface ".$conf["ispconfig_install_dir"];
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        // copy the ISPConfig server part
        $command = "cp -rf ../server ".$conf["ispconfig_install_dir"];
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        // Create a symlink, so ISPConfig is accessible via web
        $command = "ln -s ".$conf["ispconfig_install_dir"]."/interface/web/ /var/www/ispconfig";
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        // Create the config file for ISPConfig
        $configfile = 'config.inc.php';
        if(is_file($conf["ispconfig_install_dir"].'/interface/lib/'.$configfile)) copy($conf["ispconfig_install_dir"].'/interface/lib/'.$configfile,$conf["ispconfig_install_dir"].'/interface/lib/'.$configfile.'~');
        $content = rf("tpl/".$configfile.".master");
        $content = str_replace('{mysql_server_ispconfig_user}',$conf["mysql_server_ispconfig_user"],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
        $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
        $content = str_replace('{mysql_server_host}',$conf["mysql_server_host"],$content);
        wf($conf["ispconfig_install_dir"].'/interface/lib/'.$configfile,$content);
        // Chmod the files
        $command = "chmod -R 750 ".$conf["ispconfig_install_dir"];
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        // chown the files to the ispconfig user and group
        $command = "chown -R ispconfig:ispconfig ".$conf["ispconfig_install_dir"];
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
        // TODO: FIXME: add the www-data user to the ispconfig group. This is just for testing
        // and must be fixed as this will allow the apache user to read the ispconfig files.
        // Later this must run as own apache server or via suexec!
        $command = "adduser www-data ispconfig";
        caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
    }
}
?>
install/lib/mysql.lib.php
New file
@@ -0,0 +1,498 @@
<?php
/*
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
    class db
    {
        var $dbHost = "";        // hostname of the MySQL server
        var $dbName = "";        // logical database name on that server
        var $dbUser = "";        // database authorized user
        var $dbPass = "";        // user's password
        var $linkId = 0;        // last result of mysql_connect()
        var $queryId = 0;        // last result of mysql_query()
        var $record    = array();    // last record fetched
        var $autoCommit = 1;    // Autocommit Transactions
        var $currentRow;        // current row number
        var $errorNumber = 0;    // last error number
        var $errorMessage = "";    // last error message
        var $errorLocation = "";// last error location
        var $show_error_messages = false;
        // constructor
        function db()
        {
            global $conf;
            $this->dbHost = $conf["mysql_server_host"];
            //$this->dbName = $conf["mysql_server_database"];
            $this->dbUser = $conf["mysql_server_admin_user"];
            $this->dbPass = $conf["mysql_server_admin_password"];
            //$this->connect();
        }
        // error handler
        function updateError($location)
        {
            $this->errorNumber = mysql_errno();
            $this->errorMessage = mysql_error();
            $this->errorLocation = $location;
            if($this->errorNumber && $this->show_error_messages)
            {
                echo('<br /><b>'.$this->errorLocation.'</b><br />'.$this->errorMessage);
                flush();
            }
        }
        function connect()
        {
            if($this->linkId == 0)
            {
                $this->linkId = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass);
                if(!$this->linkId)
                {
                    $this->updateError('DB::connect()<br />mysql_connect');
                    return false;
                }
            }
            return true;
        }
        function query($queryString)
        {
            if(!$this->connect())
            {
                return false;
            }
            if($this->dbName != '') {
                if(!mysql_select_db($this->dbName, $this->linkId))
                {
                    $this->updateError('DB::connect()<br />mysql_select_db');
                    return false;
                }
            }
            $this->queryId = @mysql_query($queryString, $this->linkId);
            $this->updateError('DB::query('.$queryString.')<br />mysql_query');
            if(!$this->queryId)
            {
                return false;
            }
            $this->currentRow = 0;
            return $this->queryId;
        }
        // returns all records in an array
        function queryAllRecords($queryString)
        {
            if(!$this->query($queryString))
            {
                return false;
            }
            $ret = array();
            while($line = $this->nextRecord())
            {
                $ret[] = $line;
            }
            return $ret;
        }
        // returns one record in an array
        function queryOneRecord($queryString)
        {
            if(!$this->query($queryString) || $this->numRows() == 0)
            {
                return false;
            }
            return $this->nextRecord();
        }
        // returns the next record in an array
        function nextRecord()
        {
            $this->record = mysql_fetch_assoc($this->queryId);
            $this->updateError('DB::nextRecord()<br />mysql_fetch_array');
            if(!$this->record || !is_array($this->record))
            {
                return false;
            }
            $this->currentRow++;
            return $this->record;
        }
        // returns number of rows returned by the last select query
        function numRows()
        {
            return mysql_num_rows($this->queryId);
        }
        function affectedRows()
        {
            return mysql_affected_rows($this->linkId);
        }
        // returns mySQL insert id
        function insertID()
        {
            return mysql_insert_id($this->linkId);
        }
        // Check der variablen
        // deprecated, now use quote
        function check($formfield)
        {
            return $this->quote($formfield);
        }
        // Check der variablen
        function quote($formfield)
        {
            return addslashes($formfield);
        }
        // Check der variablen
        function unquote($formfield)
        {
            return stripslashes($formfield);
        }
        function toLower($record) {
            if(is_array($record)) {
                foreach($record as $key => $val) {
                    $key = strtolower($key);
                    $out[$key] = $val;
                }
            }
        return $out;
        }
       function insert($tablename,$form,$debug = 0)
       {
         if(is_array($form)){
           foreach($form as $key => $value)
               {
               $sql_key .= "$key, ";
            $sql_value .= "'".$this->check($value)."', ";
               }
           $sql_key = substr($sql_key,0,strlen($sql_key) - 2);
        $sql_value = substr($sql_value,0,strlen($sql_value) - 2);
           $sql = "INSERT INTO $tablename (" . $sql_key . ") VALUES (" . $sql_value .")";
               if($debug == 1) echo "SQL-Statement: ".$sql."<br><br>";
               $this->query($sql);
               if($debug == 1) echo "mySQL Error Message: ".$this->errorMessage;
          }
       }
       function update($tablename,$form,$bedingung,$debug = 0)
       {
         if(is_array($form)){
           foreach($form as $key => $value)
               {
               $insql .= "$key = '".$this->check($value)."', ";
               }
                   $insql = substr($insql,0,strlen($insql) - 2);
                   $sql = "UPDATE $tablename SET " . $insql . " WHERE $bedingung";
               if($debug == 1) echo "SQL-Statement: ".$sql."<br><br>";
               $this->query($sql);
               if($debug == 1) echo "mySQL Error Message: ".$this->errorMessage;
           }
       }
       function closeConn() {
       }
       function freeResult() {
       }
       function delete() {
       }
       function Transaction($action) {
       //action = begin, commit oder rollback
       }
       /*
       $columns = array(action =>   add | alter | drop
                        name =>     Spaltenname
                        name_new => neuer Spaltenname, nur bei 'alter' belegt
                        type =>     42go-Meta-Type: int16, int32, int64, double, char, varchar, text, blob
                        typeValue => Wert z.B. bei Varchar
                        defaultValue =>  Default Wert
                        notNull =>   true | false
                        autoInc =>   true | false
                        option =>   unique | primary | index)
       */
       function createTable($table_name,$columns) {
       $index = "";
       $sql = "CREATE TABLE $table_name (";
       foreach($columns as $col){
            $sql .= $col["name"]." ".$this->mapType($col["type"],$col["typeValue"])." ";
            if($col["defaultValue"] != "") {
                if($col["defaultValue"] == "NULL" or $col["defaultValue"] == "NOT NULL") {
                    $sql .= "DEFAULT ".$col["defaultValue"]." ";
                } else {
                    $sql .= "DEFAULT '".$col["defaultValue"]."' ";
                }
            } elseif($col["defaultValue"] != false) {
                $sql .= "DEFAULT '' ";
            }
            if($col["defaultValue"] != "NULL" && $col["defaultValue"] != "NOT NULL") {
                if($col["notNull"] == true) {
                    $sql .= "NOT NULL ";
                } else {
                    $sql .= "NULL ";
                }
            }
            if($col["autoInc"] == true) $sql .= "auto_increment ";
            $sql.= ",";
            // key Definitionen
            if($col["option"] == "primary") $index .= "PRIMARY KEY (".$col["name"]."),";
            if($col["option"] == "index") $index .= "INDEX (".$col["name"]."),";
            if($col["option"] == "unique") $index .= "UNIQUE (".$col["name"]."),";
       }
       $sql .= $index;
       $sql = substr($sql,0,-1);
       $sql .= ")";
       $this->query($sql);
       return true;
       }
       /*
       $columns = array(action =>   add | alter | drop
                        name =>     Spaltenname
                        name_new => neuer Spaltenname, nur bei 'alter' belegt
                        type =>     42go-Meta-Type: int16, int32, int64, double, char, varchar, text, blob
                        typeValue => Wert z.B. bei Varchar
                        defaultValue =>  Default Wert
                        notNull =>   true | false
                        autoInc =>   true | false
                        option =>   unique | primary | index)
       */
       function alterTable($table_name,$columns) {
       $index = "";
       $sql = "ALTER TABLE $table_name ";
       foreach($columns as $col){
            if($col["action"] == 'add') {
                $sql .= "ADD ".$col["name"]." ".$this->mapType($col["type"],$col["typeValue"])." ";
            } elseif ($col["action"] == 'alter') {
                $sql .= "CHANGE ".$col["name"]." ".$col["name_new"]." ".$this->mapType($col["type"],$col["typeValue"])." ";
            } elseif ($col["action"] == 'drop') {
                $sql .= "DROP ".$col["name"]." ";
            }
            if($col["action"] != 'drop') {
            if($col["defaultValue"] != "") $sql .= "DEFAULT '".$col["defaultValue"]."' ";
            if($col["notNull"] == true) {
                $sql .= "NOT NULL ";
            } else {
                $sql .= "NULL ";
            }
            if($col["autoInc"] == true) $sql .= "auto_increment ";
            $sql.= ",";
            // key Definitionen
            if($col["option"] == "primary") $index .= "PRIMARY KEY (".$col["name"]."),";
            if($col["option"] == "index") $index .= "INDEX (".$col["name"]."),";
            if($col["option"] == "unique") $index .= "UNIQUE (".$col["name"]."),";
            }
       }
       $sql .= $index;
       $sql = substr($sql,0,-1);
       //die($sql);
       $this->query($sql);
       return true;
       }
       function dropTable($table_name) {
       $this->check($table_name);
       $sql = "DROP TABLE '". $table_name."'";
       return $this->query($sql);
       }
       // gibt Array mit Tabellennamen zurück
       function getTables($database_name = '') {
            if($database_name == '') $database_name = $this->dbName;
            $result = mysql_list_tables($database_name);
            for ($i = 0; $i < mysql_num_rows($result); $i++) {
                $tb_names[$i] = mysql_tablename($result, $i);
            }
            return $tb_names;
       }
       // gibt Feldinformationen zur Tabelle zurück
       /*
       $columns = array(action =>   add | alter | drop
                        name =>     Spaltenname
                        name_new => neuer Spaltenname, nur bei 'alter' belegt
                        type =>     42go-Meta-Type: int16, int32, int64, double, char, varchar, text, blob
                        typeValue => Wert z.B. bei Varchar
                        defaultValue =>  Default Wert
                        notNull =>   true | false
                        autoInc =>   true | false
                        option =>   unique | primary | index)
       */
       function tableInfo($table_name) {
       global $go_api,$go_info;
       // Tabellenfelder einlesen
        if($rows = $go_api->db->queryAllRecords("SHOW FIELDS FROM ".$table_name)){
        foreach($rows as $row) {
            $name = $row[0];
            $default = $row[4];
            $key = $row[3];
            $extra = $row[5];
            $isnull = $row[2];
            $type = $row[1];
            $column = array();
            $column["name"] = $name;
            //$column["type"] = $type;
            $column["defaultValue"] = $default;
            if(stristr($key,"PRI")) $column["option"] = "primary";
            if(stristr($isnull,"YES")) {
                $column["notNull"] = false;
            } else {
               $column["notNull"] = true;
            }
            if($extra == 'auto_increment') $column["autoInc"] = true;
            // Type in Metatype umsetzen
            if(stristr($type,"int(")) $metaType = 'int32';
            if(stristr($type,"bigint")) $metaType = 'int64';
            if(stristr($type,"char")) {
                $metaType = 'char';
                $tmp_typeValue = explode('(',$type);
                $column["typeValue"] = substr($tmp_typeValue[1],0,-1);
            }
            if(stristr($type,"varchar")) {
                $metaType = 'varchar';
                $tmp_typeValue = explode('(',$type);
                $column["typeValue"] = substr($tmp_typeValue[1],0,-1);
            }
            if(stristr($type,"text")) $metaType = 'text';
            if(stristr($type,"double")) $metaType = 'double';
            if(stristr($type,"blob")) $metaType = 'blob';
            $column["type"] = $metaType;
        $columns[] = $column;
        }
            return $columns;
        } else {
            return false;
        }
        //$this->createTable('tester',$columns);
        /*
        $result = mysql_list_fields($go_info["server"]["db_name"],$table_name);
        $fields = mysql_num_fields ($result);
        $i = 0;
        $table = mysql_field_table ($result, $i);
        while ($i < $fields) {
            $name  = mysql_field_name  ($result, $i);
            $type  = mysql_field_type  ($result, $i);
            $len   = mysql_field_len   ($result, $i);
            $flags = mysql_field_flags ($result, $i);
            print_r($flags);
            $columns = array(name => $name,
                        type =>     "",
                        defaultValue =>  "",
                        isnull =>   1,
                        option =>   "");
            $returnvar[] = $columns;
            $i++;
        }
        */
       }
       function mapType($metaType,$typeValue) {
       global $go_api;
       $metaType = strtolower($metaType);
       switch ($metaType) {
       case 'int16':
            return 'smallint';
       break;
       case 'int32':
            return 'int';
       break;
       case 'int64':
            return 'bigint';
       break;
       case 'double':
            return 'double';
       break;
       case 'char':
            return 'char';
       break;
       case 'varchar':
            if($typeValue < 1) die("Datenbank Fehler: Für diesen Datentyp ist eine Längenangabe notwendig.");
            return 'varchar('.$typeValue.')';
       break;
       case 'text':
            return 'text';
       break;
       case 'blob':
            return 'blob';
       break;
       }
       }
    }
?>
install/sql/ispconfig3.sql
New file
@@ -0,0 +1,618 @@
-- phpMyAdmin SQL Dump
-- version 2.9.0.3
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Erstellungszeit: 19. April 2007 um 12:05
-- Server Version: 5.0.24
-- PHP-Version: 5.1.4
--
-- Datenbank: `ispconfig3`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `dns_rr`
--
CREATE TABLE `dns_rr` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) NOT NULL,
  `sys_groupid` int(11) NOT NULL,
  `sys_perm_user` varchar(5) NOT NULL,
  `sys_perm_group` varchar(5) NOT NULL,
  `sys_perm_other` varchar(5) NOT NULL,
  `zone` int(10) unsigned NOT NULL,
  `name` char(64) NOT NULL,
  `type` enum('A','AAAA','CNAME','HINFO','MX','NAPTR','NS','PTR','RP','SRV','TXT') default NULL,
  `data` char(128) NOT NULL,
  `aux` int(10) unsigned NOT NULL,
  `ttl` int(10) unsigned NOT NULL default '86400',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `rr` (`zone`,`name`,`type`,`data`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Daten für Tabelle `dns_rr`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `dns_soa`
--
CREATE TABLE `dns_soa` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) NOT NULL,
  `sys_groupid` int(11) NOT NULL,
  `sys_perm_user` varchar(5) NOT NULL,
  `sys_perm_group` varchar(5) NOT NULL,
  `sys_perm_other` varchar(5) NOT NULL,
  `origin` char(255) NOT NULL,
  `ns` char(255) NOT NULL,
  `mbox` char(255) NOT NULL,
  `serial` int(10) unsigned NOT NULL default '1',
  `refresh` int(10) unsigned NOT NULL default '28800',
  `retry` int(10) unsigned NOT NULL default '7200',
  `expire` int(10) unsigned NOT NULL default '604800',
  `minimum` int(10) unsigned NOT NULL default '86400',
  `ttl` int(10) unsigned NOT NULL default '86400',
  `active` enum('Y','N') NOT NULL,
  `xfer` char(255) NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `origin` (`origin`),
  KEY `active` (`active`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Daten für Tabelle `dns_soa`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `mail_access`
--
CREATE TABLE `mail_access` (
  `access_id` int(11) NOT NULL auto_increment,
  `sys_userid` int(11) NOT NULL default '0',
  `sys_groupid` int(11) NOT NULL default '0',
  `sys_perm_user` varchar(5) NOT NULL default '',
  `sys_perm_group` varchar(5) NOT NULL default '',
  `sys_perm_other` varchar(5) NOT NULL default '',
  `server_id` int(11) NOT NULL default '0',
  `source` varchar(255) NOT NULL,
  `access` varchar(255) NOT NULL,
  `type` set('recipient','sender','client') NOT NULL,
  `active` enum('n','y') NOT NULL default 'y',
  PRIMARY KEY  (`access_id`),
  KEY `server_id` (`server_id`,`source`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Daten für Tabelle `mail_access`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `mail_domain`
--
CREATE TABLE `mail_domain` (
  `domain_id` int(11) NOT NULL auto_increment,
  `sys_userid` int(11) NOT NULL default '0',
  `sys_groupid` int(11) NOT NULL default '0',
  `sys_perm_user` varchar(5) NOT NULL default '',
  `sys_perm_group` varchar(5) NOT NULL default '',
  `sys_perm_other` varchar(5) NOT NULL default '',
  `server_id` int(11) NOT NULL default '0',
  `domain` varchar(255) NOT NULL default '',
  `active` enum('y','n') NOT NULL,
  PRIMARY KEY  (`domain_id`),
  KEY `server_id` (`server_id`,`domain`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
-- Daten für Tabelle `mail_domain`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `mail_forwarding`
--
CREATE TABLE `mail_forwarding` (
  `forwarding_id` int(11) NOT NULL auto_increment,
  `sys_userid` int(11) NOT NULL default '0',
  `sys_groupid` int(11) NOT NULL default '0',
  `sys_perm_user` varchar(5) NOT NULL default '',
  `sys_perm_group` varchar(5) NOT NULL default '',
  `sys_perm_other` varchar(5) NOT NULL default '',
  `server_id` int(11) NOT NULL default '0',
  `source` varchar(255) NOT NULL,
  `destination` varchar(255) NOT NULL default '',
  `type` enum('alias','forward','catchall') NOT NULL default 'alias',
  `active` enum('y','n') NOT NULL,
  PRIMARY KEY  (`forwarding_id`),
  KEY `server_id` (`server_id`,`source`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Daten für Tabelle `mail_forwarding`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `mail_greylist`
--
CREATE TABLE `mail_greylist` (
  `greylist_id` int(11) NOT NULL auto_increment,
  `relay_ip` varchar(64) default NULL,
  `from_domain` varchar(255) default NULL,
  `block_expires` datetime NOT NULL default '0000-00-00 00:00:00',
  `record_expires` datetime NOT NULL default '0000-00-00 00:00:00',
  `origin_type` enum('MANUAL','AUTO') NOT NULL default 'AUTO',
  `create_time` datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`greylist_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Daten für Tabelle `mail_greylist`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `mail_mailman_domain`
--
CREATE TABLE `mail_mailman_domain` (
  `mailman_id` int(11) NOT NULL auto_increment,
  `server_id` int(11) NOT NULL default '0',
  `domain` varchar(255) NOT NULL default '',
  `mm_home` varchar(255) NOT NULL default '',
  `mm_wrap` varchar(255) NOT NULL default '',
  `mm_user` varchar(50) NOT NULL default '',
  `mm_group` varchar(50) NOT NULL default '',
  PRIMARY KEY  (`mailman_id`,`server_id`,`domain`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Daten für Tabelle `mail_mailman_domain`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `mail_transport`
--
CREATE TABLE `mail_transport` (
  `transport_id` int(11) NOT NULL auto_increment,
  `sys_userid` int(11) NOT NULL default '0',
  `sys_groupid` int(11) NOT NULL default '0',
  `sys_perm_user` varchar(5) NOT NULL default '',
  `sys_perm_group` varchar(5) NOT NULL default '',
  `sys_perm_other` varchar(5) NOT NULL default '',
  `server_id` int(11) NOT NULL default '0',
  `domain` varchar(255) NOT NULL default '',
  `transport` varchar(255) NOT NULL,
  `sort_order` int(11) NOT NULL default '5',
  `active` enum('y','n') NOT NULL,
  PRIMARY KEY  (`transport_id`),
  KEY `server_id` (`server_id`,`transport`),
  KEY `server_id_2` (`server_id`,`domain`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Daten für Tabelle `mail_transport`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `mail_user`
--
CREATE TABLE `mail_user` (
  `mailuser_id` int(11) NOT NULL auto_increment,
  `sys_userid` int(11) NOT NULL default '0',
  `sys_groupid` int(11) NOT NULL default '0',
  `sys_perm_user` varchar(5) NOT NULL default '',
  `sys_perm_group` varchar(5) NOT NULL default '',
  `sys_perm_other` varchar(5) NOT NULL default '',
  `server_id` int(11) NOT NULL default '0',
  `email` varchar(255) NOT NULL default '',
  `password` varchar(255) NOT NULL,
  `name` varchar(128) NOT NULL default '',
  `uid` int(10) unsigned NOT NULL default '5000',
  `gid` int(10) unsigned NOT NULL default '5000',
  `maildir` varchar(255) NOT NULL default '',
  `quota` int(11) NOT NULL,
  `homedir` varchar(255) NOT NULL,
  `autoresponder` enum('n','y') NOT NULL default 'n',
  `autoresponder_text` tinytext NOT NULL,
  `postfix` enum('y','n') NOT NULL,
  `access` enum('y','n') NOT NULL,
  PRIMARY KEY  (`mailuser_id`),
  KEY `server_id` (`server_id`,`email`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
-- Daten für Tabelle `mail_user`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `reseller`
--
CREATE TABLE `reseller` (
  `reseller_id` bigint(20) NOT NULL auto_increment,
  `sys_userid` int(11) NOT NULL default '0',
  `sys_groupid` int(11) NOT NULL default '0',
  `sys_perm_user` varchar(5) NOT NULL default '',
  `sys_perm_group` varchar(5) NOT NULL default '',
  `sys_perm_other` varchar(5) NOT NULL default '',
  `company` varchar(255) NOT NULL default '',
  `title` varchar(255) NOT NULL default '',
  `firstname` varchar(255) NOT NULL default '',
  `surname` varchar(255) NOT NULL default '',
  `street` varchar(255) NOT NULL default '',
  `zip` varchar(255) NOT NULL default '',
  `city` varchar(255) NOT NULL default '',
  `country` varchar(255) NOT NULL default '',
  `telephone` varchar(255) NOT NULL default '',
  `mobile` varchar(255) NOT NULL default '',
  `fax` varchar(255) NOT NULL default '',
  `email` varchar(255) NOT NULL default '',
  `internet` varchar(255) NOT NULL default '',
  `icq` varchar(255) NOT NULL default '',
  `notes` text NOT NULL,
  `limit_client` int(11) NOT NULL default '-1',
  `limit_domain` int(11) NOT NULL default '-1',
  `limit_subdomain` int(11) NOT NULL default '-1',
  `limit_mailbox` int(11) NOT NULL default '-1',
  `limit_mailalias` int(11) NOT NULL default '-1',
  `limit_webquota` int(11) NOT NULL default '-1',
  `limit_mailquota` int(11) NOT NULL default '-1',
  `limit_database` int(11) NOT NULL default '-1',
  `ip_address` text NOT NULL,
  PRIMARY KEY  (`reseller_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Daten für Tabelle `reseller`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `server`
--
CREATE TABLE `server` (
  `server_id` bigint(20) NOT NULL auto_increment,
  `sys_userid` int(11) NOT NULL default '0',
  `sys_groupid` int(11) NOT NULL default '0',
  `sys_perm_user` varchar(5) NOT NULL default '',
  `sys_perm_group` varchar(5) NOT NULL default '',
  `sys_perm_other` varchar(5) NOT NULL default '',
  `server_name` varchar(255) NOT NULL default '',
  `mail_server` tinyint(4) NOT NULL default '0',
  `web_server` tinyint(4) NOT NULL default '0',
  `dns_server` tinyint(4) NOT NULL default '0',
  `file_server` tinyint(4) NOT NULL default '0',
  `db_server` tinyint(4) NOT NULL default '0',
  `vserver_server` tinyint(4) NOT NULL default '0',
  `config` text NOT NULL,
  `updated` tinyint(4) NOT NULL default '0',
  `active` tinyint(4) NOT NULL default '1',
  PRIMARY KEY  (`server_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Daten für Tabelle `server`
--
INSERT INTO `server` (`server_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`) VALUES
(1, 1, 1, 'riud', 'riud', '', 'Server 1', 1, 1, 1, 1, 1, 1, '[global]\r\nwebserver=apache\r\nmailserver=exim\r\ndnsserver=mydns\r\n\r\n[mail]\r\nmodule=postfix_mysql\r\nmaildir_path=/home/vmail/[domain]/[localpart]/\r\nhomedir_path=/home/vmail/\r\nmailuser_uid=5000\r\nmailuser_gid=5000', 0, 1);
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `spamfilter_policy`
--
CREATE TABLE `spamfilter_policy` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) NOT NULL,
  `sys_groupid` int(11) NOT NULL,
  `sys_perm_user` varchar(5) NOT NULL,
  `sys_perm_group` varchar(5) NOT NULL,
  `sys_perm_other` varchar(5) NOT NULL,
  `policy_name` varchar(32) default NULL,
  `virus_lover` char(1) default NULL,
  `spam_lover` char(1) default NULL,
  `banned_files_lover` char(1) default NULL,
  `bad_header_lover` char(1) default NULL,
  `bypass_virus_checks` char(1) default NULL,
  `bypass_spam_checks` char(1) default NULL,
  `bypass_banned_checks` char(1) default NULL,
  `bypass_header_checks` char(1) default NULL,
  `spam_modifies_subj` char(1) default NULL,
  `virus_quarantine_to` varchar(64) default NULL,
  `spam_quarantine_to` varchar(64) default NULL,
  `banned_quarantine_to` varchar(64) default NULL,
  `bad_header_quarantine_to` varchar(64) default NULL,
  `clean_quarantine_to` varchar(64) default NULL,
  `other_quarantine_to` varchar(64) default NULL,
  `spam_tag_level` float default NULL,
  `spam_tag2_level` float default NULL,
  `spam_kill_level` float default NULL,
  `spam_dsn_cutoff_level` float default NULL,
  `spam_quarantine_cutoff_level` float default NULL,
  `addr_extension_virus` varchar(64) default NULL,
  `addr_extension_spam` varchar(64) default NULL,
  `addr_extension_banned` varchar(64) default NULL,
  `addr_extension_bad_header` varchar(64) default NULL,
  `warnvirusrecip` char(1) default NULL,
  `warnbannedrecip` char(1) default NULL,
  `warnbadhrecip` char(1) default NULL,
  `newvirus_admin` varchar(64) default NULL,
  `virus_admin` varchar(64) default NULL,
  `banned_admin` varchar(64) default NULL,
  `bad_header_admin` varchar(64) default NULL,
  `spam_admin` varchar(64) default NULL,
  `spam_subject_tag` varchar(64) default NULL,
  `spam_subject_tag2` varchar(64) default NULL,
  `message_size_limit` int(11) default NULL,
  `banned_rulenames` varchar(64) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
--
-- Daten für Tabelle `spamfilter_policy`
--
INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`) VALUES
(1, 0, 0, '', '', '', 'Non-paying', 'N', 'N', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, 3, 7, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(2, 0, 0, '', '', '', 'Uncensored', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', NULL, NULL, NULL, NULL, NULL, NULL, 3, 999, 999, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(3, 0, 0, '', '', '', 'Wants all spam', 'N', 'Y', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, 3, 999, 999, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(4, 0, 0, '', '', '', 'Wants viruses', 'Y', 'N', 'Y', 'Y', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, 3, 6.9, 6.9, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(5, 0, 0, '', '', '', 'Normal', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, 3, 6.9, 6.9, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(6, 0, 0, '', '', '', 'Trigger happy', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, 3, 5, 5, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(7, 0, 0, '', '', '', 'Permissive', 'N', 'N', 'N', 'Y', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, 3, 10, 20, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(8, 0, 0, '', '', '', '6.5/7.8', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', NULL, NULL, NULL, NULL, NULL, NULL, 3, 6.5, 7.8, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(9, 0, 0, '', '', '', 'userB', 'N', 'N', 'N', 'Y', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, 3, 6.3, 6.3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(10, 0, 0, '', '', '', 'userC', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', NULL, NULL, NULL, NULL, NULL, NULL, 3, 6, 6, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(11, 0, 0, '', '', '', 'userD', 'Y', 'N', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', NULL, NULL, NULL, NULL, NULL, NULL, 3, 7, 7, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
(12, 1, 0, 'riud', 'riud', '', 'test', 'Y', 'Y', 'N', 'N', 'N', NULL, 'N', 'N', 'N', '', '', '', '', '', '', 0.7, 0, 0, 0, 0, '', '', '', '', 'N', 'N', 'N', '', '', '', '', '', '', '', 0, '');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `spamfilter_users`
--
CREATE TABLE `spamfilter_users` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) NOT NULL,
  `sys_groupid` int(11) NOT NULL,
  `sys_perm_user` varchar(5) NOT NULL,
  `sys_perm_group` varchar(5) NOT NULL,
  `sys_perm_other` varchar(5) NOT NULL,
  `server_id` int(10) unsigned NOT NULL,
  `priority` int(11) NOT NULL default '7',
  `policy_id` int(10) unsigned NOT NULL default '1',
  `email` varchar(255) NOT NULL,
  `fullname` varchar(255) default NULL,
  `local` char(1) default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ;
--
-- Daten für Tabelle `spamfilter_users`
--
INSERT INTO `spamfilter_users` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`) VALUES
(1, 0, 0, '', '', '', 0, 9, 5, 'user1+foo@y.example.com', 'Name1 Surname1', 'Y'),
(2, 0, 0, '', '', '', 0, 7, 5, 'user1@y.example.com', 'Name1 Surname1', 'Y'),
(3, 0, 0, '', '', '', 0, 7, 2, 'user2@y.example.com', 'Name2 Surname2', 'Y'),
(4, 0, 0, '', '', '', 0, 7, 7, 'user3@z.example.com', 'Name3 Surname3', 'Y'),
(5, 0, 0, '', '', '', 0, 7, 7, 'user4@example.com', 'Name4 Surname4', 'Y'),
(6, 0, 0, '', '', '', 0, 7, 1, 'user5@example.com', 'Name5 Surname5', 'Y'),
(7, 0, 0, '', '', '', 0, 5, 0, '@sub1.example.com', NULL, 'Y'),
(8, 0, 0, '', '', '', 0, 5, 7, '@sub2.example.com', NULL, 'Y'),
(9, 0, 0, '', '', '', 0, 5, 5, '@example.com', NULL, 'Y'),
(10, 0, 0, '', '', '', 0, 3, 8, 'userA', 'NameA SurnameA anywhere', 'Y'),
(11, 0, 0, '', '', '', 0, 3, 9, 'userB', 'NameB SurnameB', 'Y'),
(12, 0, 0, '', '', '', 0, 3, 10, 'userC', 'NameC SurnameC', 'Y'),
(13, 0, 0, '', '', '', 0, 3, 11, 'userD', 'NameD SurnameD', 'Y'),
(14, 0, 0, '', '', '', 0, 3, 0, '@sub1.example.net', NULL, 'Y'),
(15, 0, 0, '', '', '', 0, 3, 7, '@sub2.example.net', NULL, 'Y'),
(16, 0, 0, '', '', '', 0, 3, 5, '@example.net', NULL, 'Y'),
(17, 0, 0, '', '', '', 0, 7, 5, 'u1@example.org', 'u1', 'Y'),
(18, 0, 0, '', '', '', 0, 7, 6, 'u2@example.org', 'u2', 'Y'),
(19, 0, 0, '', '', '', 0, 7, 3, 'u3@example.org', 'u3', 'Y'),
(20, 1, 0, 'riud', 'riud', '', 1, 5, 0, '@ensign.de', 'ensign all', 'N');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `spamfilter_wblist`
--
CREATE TABLE `spamfilter_wblist` (
  `wblist_id` int(10) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) NOT NULL,
  `sys_groupid` int(11) NOT NULL,
  `sys_perm_user` varchar(5) NOT NULL,
  `sys_perm_group` varchar(5) NOT NULL,
  `sys_perm_other` varchar(5) NOT NULL,
  `server_id` int(10) unsigned NOT NULL,
  `wb` enum('W','B') NOT NULL default 'W',
  `rid` int(10) unsigned NOT NULL,
  `email` varchar(255) NOT NULL,
  `priority` int(11) NOT NULL,
  `active` enum('y','n') NOT NULL default 'y',
  PRIMARY KEY  (`wblist_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Daten für Tabelle `spamfilter_wblist`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `sys_datalog`
--
CREATE TABLE `sys_datalog` (
  `datalog_id` bigint(20) NOT NULL auto_increment,
  `dbtable` varchar(255) NOT NULL default '',
  `dbidx` varchar(255) NOT NULL default '',
  `action` char(1) NOT NULL default '',
  `tstamp` bigint(20) NOT NULL default '0',
  `user` varchar(255) NOT NULL default '',
  `data` text NOT NULL,
  PRIMARY KEY  (`datalog_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=35 ;
--
-- Daten für Tabelle `sys_datalog`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `sys_dbsync`
--
CREATE TABLE `sys_dbsync` (
  `id` bigint(20) NOT NULL auto_increment,
  `jobname` varchar(255) NOT NULL default '',
  `sync_interval_minutes` int(11) NOT NULL default '0',
  `db_type` varchar(255) NOT NULL default '',
  `db_host` varchar(255) NOT NULL default '',
  `db_name` varchar(255) NOT NULL default '',
  `db_username` varchar(255) NOT NULL default '',
  `db_password` varchar(255) NOT NULL default '',
  `db_tables` varchar(255) NOT NULL default 'admin,forms',
  `empty_datalog` int(11) NOT NULL default '0',
  `sync_datalog_external` int(11) NOT NULL default '0',
  `active` int(11) NOT NULL default '1',
  `last_datalog_id` bigint(20) NOT NULL default '0',
  PRIMARY KEY  (`id`),
  KEY `last_datalog_id` (`last_datalog_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Daten für Tabelle `sys_dbsync`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `sys_filesync`
--
CREATE TABLE `sys_filesync` (
  `id` bigint(20) NOT NULL auto_increment,
  `jobname` varchar(255) NOT NULL default '',
  `sync_interval_minutes` int(11) NOT NULL default '0',
  `ftp_host` varchar(255) NOT NULL default '',
  `ftp_path` varchar(255) NOT NULL default '',
  `ftp_username` varchar(255) NOT NULL default '',
  `ftp_password` varchar(255) NOT NULL default '',
  `local_path` varchar(255) NOT NULL default '',
  `wput_options` varchar(255) NOT NULL default '--timestamping --reupload --dont-continue',
  `active` int(11) NOT NULL default '1',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Daten für Tabelle `sys_filesync`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `sys_group`
--
CREATE TABLE `sys_group` (
  `groupid` int(11) NOT NULL auto_increment,
  `name` varchar(255) NOT NULL default '',
  `description` text NOT NULL,
  PRIMARY KEY  (`groupid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Daten für Tabelle `sys_group`
--
INSERT INTO `sys_group` (`groupid`, `name`, `description`) VALUES
(1, 'admin', 'Administrators group'),
(2, 'user', 'Users Group');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `sys_user`
--
CREATE TABLE `sys_user` (
  `userid` int(11) NOT NULL auto_increment,
  `sys_userid` int(11) NOT NULL default '0',
  `sys_groupid` int(11) NOT NULL default '0',
  `sys_perm_user` varchar(5) NOT NULL default '',
  `sys_perm_group` varchar(5) NOT NULL default '',
  `sys_perm_other` varchar(5) NOT NULL default '',
  `username` varchar(100) NOT NULL default '',
  `passwort` varchar(100) NOT NULL default '',
  `modules` varchar(255) NOT NULL default '',
  `startmodule` varchar(255) NOT NULL default '',
  `app_theme` varchar(100) NOT NULL default 'default',
  `typ` varchar(20) NOT NULL default 'user',
  `active` tinyint(4) NOT NULL default '1',
  `name` varchar(100) NOT NULL default '',
  `vorname` varchar(100) NOT NULL default '',
  `unternehmen` varchar(100) NOT NULL default '',
  `strasse` varchar(100) NOT NULL default '',
  `ort` varchar(100) NOT NULL default '',
  `plz` varchar(10) NOT NULL default '',
  `land` varchar(50) NOT NULL default '',
  `email` varchar(100) NOT NULL default '',
  `url` varchar(255) NOT NULL default '',
  `telefon` varchar(100) NOT NULL default '',
  `fax` varchar(100) NOT NULL default '',
  `language` varchar(10) NOT NULL default 'de',
  `groups` varchar(255) NOT NULL default '',
  `default_group` int(11) NOT NULL default '0',
  PRIMARY KEY  (`userid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Daten für Tabelle `sys_user`
--
INSERT INTO `sys_user` (`userid`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `username`, `passwort`, `modules`, `startmodule`, `app_theme`, `typ`, `active`, `name`, `vorname`, `unternehmen`, `strasse`, `ort`, `plz`, `land`, `email`, `url`, `telefon`, `fax`, `language`, `groups`, `default_group`) VALUES
(1, 1, 0, 'riud', 'riud', '', 'admin', '21232f297a57a5a743894a0e4a801fc3', 'admin,designer,mail', 'mail', 'default', 'admin', 1, '', 'Administrator', '', '', '', '', '', '', '', '', '', 'en', '1,2', 1);
install/tpl/amavisd_user_config.master
New file
@@ -0,0 +1,55 @@
use strict;
#
# Place your configuration directives here.  They will override those in
# earlier files.
#
# See /usr/share/doc/amavisd-new/ for documentation and examples of
# the directives you can use in this file
#
@bypass_virus_checks_maps = (
   \%bypass_virus_checks, \@bypass_virus_checks_acl, \$bypass_virus_checks_re);
@bypass_spam_checks_maps = (
   \%bypass_spam_checks, \@bypass_spam_checks_acl, \$bypass_spam_checks_re);
#
# Database connection settings
#
@lookup_sql_dsn =
   ( ['DBI:mysql:database={mysql_server_database};host={mysql_server_ip};port={mysql_server_port}', '{mysql_server_ispconfig_user}', '{mysql_server_ispconfig_password}'] );
# @storage_sql_dsn = @lookup_sql_dsn;  # none, same, or separate database
#$sql_select_policy = 'SELECT "Y" as local FROM mail_domain WHERE CONCAT("@",domain) IN (%k)';
# $banned_files_quarantine_method = 'sql';
# $spam_quarantine_method         = 'sql';
#
# SQL Select statements
#
$sql_select_policy =
   'SELECT *,spamfilter_users.id'.
   ' FROM spamfilter_users LEFT JOIN spamfilter_policy ON spamfilter_users.policy_id=spamfilter_policy.id'.
   ' WHERE spamfilter_users.email IN (%k) ORDER BY spamfilter_users.priority DESC';
$sql_select_white_black_list = 'SELECT wb FROM spamfilter_wblist'.
    ' WHERE (spamfilter_wblist.rid=?) AND (spamfilter_wblist.email IN (%k))' .
    ' ORDER BY spamfilter_wblist.priority DESC';
#
# Enable Logging
#
$DO_SYSLOG = 1;
$LOGFILE = "/var/log/amavis.log";  # (defaults to empty, no log)
$log_level = 5;                # (defaults to 0)
#------------ Do not modify anything below this line -------------
1;  # insure a defined return
install/tpl/authmysqlrc.master
New file
@@ -0,0 +1,17 @@
MYSQL_SERVER {mysql_server_host}
MYSQL_USERNAME {mysql_server_ispconfig_user}
MYSQL_PASSWORD {mysql_server_ispconfig_password}
MYSQL_PORT 0
MYSQL_DATABASE {mysql_server_database}
MYSQL_USER_TABLE mail_user
MYSQL_CRYPT_PWFIELD password
#MYSQL_CLEAR_PWFIELD password
MYSQL_UID_FIELD uid
MYSQL_GID_FIELD gid
MYSQL_LOGIN_FIELD email
MYSQL_HOME_FIELD homedir
MYSQL_MAILDIR_FIELD maildir
#MYSQL_NAME_FIELD
#MYSQL_QUOTA_FIELD quota
MYSQL_QUOTA_FIELD concat(quota,'S')
MYSQL_WHERE_CLAUSE      access='y'
install/tpl/config.inc.php.master
New file
@@ -0,0 +1,107 @@
<?php
/*
Copyright (c) 2007, Till Brehm, Falko Timme, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
Header("Pragma: no-cache");
Header("Cache-Control: no-store, no-cache, max-age=0, must-revalidate");
Header("Content-Type: text/html");
ini_set('register_globals',0);
$conf["app_title"] = "ISPConfig";
$conf["app_version"] = "3.0.0";
/*
        Database Settings
*/
$conf["db_type"]            = 'mysql';
$conf["db_host"]            = '{mysql_server_host}';
$conf["db_database"]        = '{mysql_server_database}';
$conf["db_user"]            = '{mysql_server_ispconfig_user}';
$conf["db_password"]        = '{mysql_server_ispconfig_password}';
/*
   Path Settings (Do not change!)
*/
$conf["rootpath"]            = substr(dirname(__FILE__),0,-4);
$conf["fs_div"]                = "/"; // File system divider, \\ on windows and / on linux and unix
$conf["classpath"]            = $conf["rootpath"].$conf["fs_div"]."lib".$conf["fs_div"]."classes";
$conf["temppath"]            = $conf["rootpath"].$conf["fs_div"]."temp";
define("DIR_TRENNER",$conf["fs_div"]);
define("SERVER_ROOT",$conf["rootpath"]);
define("INCLUDE_ROOT",SERVER_ROOT.DIR_TRENNER."lib");
define("CLASSES_ROOT",INCLUDE_ROOT.DIR_TRENNER."classes");
define("DB_TYPE",$conf["db_type"]);
define("DB_HOST",$conf["db_host"]);
define("DB_DATABASE",$conf["db_database"]);
define("DB_USER",$conf["db_user"]);
define("DB_PASSWORD",$conf["db_password"]);
/*
        Themes
*/
$conf["theme"]                    = 'default';
$conf["html_content_encoding"]    = 'text/html; charset=iso-8859-1';
$conf["logo"]                     = 'themes/default/images/mydnsconfig_logo.gif';
/*
        Default Language
*/
$conf["language"]                = 'en';
/*
        Auto Load Modules
*/
$conf["start_db"]        = true;
$conf["start_session"]    = true;
/*
        DNS Settings
*/
$conf["auto_create_ptr"]      = 1; // Automatically create PTR records?
$conf["default_ns"]          = 'ns1.example.com.'; // must be set if $conf['auto_create_ptr'] is 1. Don't forget the trailing dot!
$conf["default_mbox"]          = 'admin.example.com.'; // Admin email address. Must be set if $conf['auto_create_ptr'] is 1. Replace "@" with ".". Don't forget the trailing dot!
$conf["default_ttl"]          = 86400;
$conf["default_refresh"]      = 28800;
$conf["default_retry"]          = 7200;
$conf["default_expire"]      = 604800;
$conf["default_minimum_ttl"] = 86400;
?>
install/tpl/mailfilter.master
New file
@@ -0,0 +1,63 @@
#
# Import variables
#
LOGNAME=tolower("$LOGNAME")
EXTENSION="$1"
RECIPIENT=tolower("$2")
USER="$3"
HOST="$4"
SENDER="$5"
DEFAULT="{dist_postfix_vmail_mailbox_base}/$HOST/$USER/."
if ( "$EXTENSION" ne "" )
{
  DELIMITER="+"
}
if (!$SENDER)
{
  SENDER = "<>"
}
#
# Autocreate maildir, if not existant
#
`test -e {dist_postfix_vmail_mailbox_base}/$HOST`
if ( $RETURNCODE != 0 )
{
  `mkdir {dist_postfix_vmail_mailbox_base}/$HOST`
}
`test -e {dist_postfix_vmail_mailbox_base}/$HOST/$USER`
if ( $RETURNCODE != 0 )
{
  `maildirmake {dist_postfix_vmail_mailbox_base}/$HOST/$USER`
  `chmod -R 0700 {dist_postfix_vmail_mailbox_base}/$HOST`
}
#
# Check that user has his own maildrop include,
# if not available, check if $DEFAULT is set
# (newer maildrop get's that from the DB and updates
# it) and deliver or fail temporarily if not available
#
`test -f {dist_postfix_vmail_mailbox_base}/mailfilters/$LOGNAME`
if ( $RETURNCODE == 0 )
{
  include "{dist_postfix_vmail_mailbox_base}/mailfilters/$LOGNAME"
}
else
{
  if ( "$DEFAULT" ne "" )
  {
    to "$DEFAULT"
  }
  else
  {
    EXITCODE=75
    exit
  }
}
install/tpl/master_cf_amavis.master
New file
@@ -0,0 +1,18 @@
amavis unix - - - - 2 smtp
        -o smtp_data_done_timeout=1200
        -o smtp_send_xforward_command=yes
127.0.0.1:10025 inet n - - - - smtpd
        -o content_filter=
        -o local_recipient_maps=
        -o relay_recipient_maps=
        -o smtpd_restriction_classes=
        -o smtpd_client_restrictions=
        -o smtpd_helo_restrictions=
        -o smtpd_sender_restrictions=
        -o smtpd_recipient_restrictions=permit_mynetworks,reject
        -o mynetworks=127.0.0.0/8
        -o strict_rfc821_envelopes=yes
        -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
        -o smtpd_bind_address=127.0.0.1
install/tpl/mysql-virtual_client.cf.master
New file
@@ -0,0 +1,8 @@
user = {mysql_server_ispconfig_user}
password = {mysql_server_ispconfig_password}
dbname = {mysql_server_database}
table        = mail_access
select_field = access
where_field  = source
additional_conditions = and type = 'client' and active = 'y'
hosts = {mysql_server_ip}
install/tpl/mysql-virtual_domains.cf.master
New file
@@ -0,0 +1,7 @@
user = {mysql_server_ispconfig_user}
password = {mysql_server_ispconfig_password}
dbname = {mysql_server_database}
table = mail_domain
select_field = 'virtual'
where_field = domain
hosts = {mysql_server_ip}
install/tpl/mysql-virtual_email2email.cf.master
New file
@@ -0,0 +1,7 @@
user = {mysql_server_ispconfig_user}
password = {mysql_server_ispconfig_password}
dbname = {mysql_server_database}
table = mail_user
select_field = email
where_field = email
hosts = {mysql_server_ip}
install/tpl/mysql-virtual_forwardings.cf.master
New file
@@ -0,0 +1,8 @@
user = {mysql_server_ispconfig_user}
password = {mysql_server_ispconfig_password}
dbname = {mysql_server_database}
table = mail_forwarding
select_field = destination
where_field = source
additional_conditions = and active = 'y'
hosts = {mysql_server_ip}
install/tpl/mysql-virtual_mailboxes.cf.master
New file
@@ -0,0 +1,8 @@
user = {mysql_server_ispconfig_user}
password = {mysql_server_ispconfig_password}
dbname = {mysql_server_database}
table = mail_user
select_field = CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/')
where_field = email
additional_conditions = and postfix = 'y'
hosts = {mysql_server_ip}
install/tpl/mysql-virtual_recipient.cf.master
New file
@@ -0,0 +1,8 @@
user = {mysql_server_ispconfig_user}
password = {mysql_server_ispconfig_password}
dbname = {mysql_server_database}
table        = mail_access
select_field = access
where_field  = source
additional_conditions = and type = 'recipient' and active = 'y'
hosts = {mysql_server_ip}
install/tpl/mysql-virtual_sender.cf.master
New file
@@ -0,0 +1,8 @@
user = {mysql_server_ispconfig_user}
password = {mysql_server_ispconfig_password}
dbname = {mysql_server_database}
table        = mail_access
select_field = access
where_field  = source
additional_conditions = and type = 'sender' and active = 'y'
hosts = {mysql_server_ip}
install/tpl/mysql-virtual_transports.cf.master
New file
@@ -0,0 +1,8 @@
user = {mysql_server_ispconfig_user}
password = {mysql_server_ispconfig_password}
dbname = {mysql_server_database}
table = mail_transport
select_field = transport
where_field = domain
additional_conditions = and active = 'y'
hosts = {mysql_server_ip}
install/tpl/pamd_smtp.master
New file
@@ -0,0 +1,2 @@
auth    required   pam_mysql.so user={mysql_server_ispconfig_user} passwd={mysql_server_ispconfig_password} host={mysql_server_ip} db={mysql_server_database} table=mail_user usercolumn=email passwdcolumn=password crypt=1
account sufficient pam_mysql.so user={mysql_server_ispconfig_user} passwd={mysql_server_ispconfig_password} host={mysql_server_ip} db={mysql_server_database} table=mail_user usercolumn=email passwdcolumn=password crypt=1
install/tpl/sasl_smtpd.conf.master
New file
@@ -0,0 +1,9 @@
pwcheck_method: saslauthd
mech_list: plain login
allow_plaintext: true
auxprop_plugin: mysql
sql_hostnames: {mysql_server_ip}
sql_user: {mysql_server_ispconfig_user}
sql_passwd: {mysql_server_ispconfig_password}
sql_database: {mysql_server_database}
sql_select: select password from mail_user where email = '%u'