horfic
2011-01-06 07405653f111c4eb8fd1c83d45e66287807036d7
*) Added Mailman integration
14 files added
28 files modified
23737 ■■■■ changed files
install/autoupdate.php 623 ●●●● patch | view | raw | blame | history
install/dist/conf/debian40.conf.php 383 ●●●● patch | view | raw | blame | history
install/dist/conf/debian60.conf.php 383 ●●●● patch | view | raw | blame | history
install/install.php 973 ●●●● patch | view | raw | blame | history
install/lib/installer_base.lib.php 3506 ●●●● patch | view | raw | blame | history
install/sql/incremental/upd_0007.sql 19 ●●●●● patch | view | raw | blame | history
install/sql/ispconfig3.sql 3316 ●●●● patch | view | raw | blame | history
install/tpl/mm_cfg.py.master 106 ●●●●● patch | view | raw | blame | history
install/update.php 711 ●●●● patch | view | raw | blame | history
interface/lib/classes/remoting.inc.php 4815 ●●●● patch | view | raw | blame | history
interface/web/admin/form/remote_user.tform.php 323 ●●●● patch | view | raw | blame | history
interface/web/admin/form/system_config.tform.php 522 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_remote_user.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_system_config.lng 2 ●●●●● patch | view | raw | blame | history
interface/web/admin/templates/system_config_mail_edit.htm 10 ●●●●● patch | view | raw | blame | history
interface/web/client/form/client.tform.php 1706 ●●●● patch | view | raw | blame | history
interface/web/client/form/client_template.tform.php 1034 ●●●● patch | view | raw | blame | history
interface/web/client/form/reseller.tform.php 1608 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/en_client.lng 2 ●●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/en_client_template.lng 2 ●●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/en_reseller.lng 2 ●●●●● patch | view | raw | blame | history
interface/web/client/templates/client_edit_limits.htm 400 ●●●● patch | view | raw | blame | history
interface/web/client/templates/client_template_edit_limits.htm 268 ●●●● patch | view | raw | blame | history
interface/web/client/templates/reseller_edit_limits.htm 370 ●●●● patch | view | raw | blame | history
interface/web/dashboard/dashlets/limits.php 4 ●●●● patch | view | raw | blame | history
interface/web/dashboard/lib/lang/en_dashlet_limits.lng 1 ●●●● patch | view | raw | blame | history
interface/web/mail/form/mail_mailinglist.tform.php 122 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_mailinglist.lng 15 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_mailinglist_list.lng 5 ●●●●● patch | view | raw | blame | history
interface/web/mail/lib/module.conf.php 382 ●●●● patch | view | raw | blame | history
interface/web/mail/list/mail_mailinglist.list.php 67 ●●●●● patch | view | raw | blame | history
interface/web/mail/mail_domain_del.php 188 ●●●● patch | view | raw | blame | history
interface/web/mail/mail_domain_edit.php 735 ●●●● patch | view | raw | blame | history
interface/web/mail/mail_mailinglist_del.php 58 ●●●●● patch | view | raw | blame | history
interface/web/mail/mail_mailinglist_edit.php 256 ●●●●● patch | view | raw | blame | history
interface/web/mail/mail_mailinglist_list.php 44 ●●●●● patch | view | raw | blame | history
interface/web/mail/mailinglist.php 68 ●●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_mailinglist_edit.htm 80 ●●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_mailinglist_list.htm 53 ●●●●● patch | view | raw | blame | history
server/conf/mm_cfg.py.master 106 ●●●●● patch | view | raw | blame | history
server/mods-available/mail_module.inc.php 313 ●●●● patch | view | raw | blame | history
server/plugins-available/mailman_plugin.inc.php 155 ●●●●● patch | view | raw | blame | history
install/autoupdate.php
@@ -1,309 +1,314 @@
<?php
/*
Copyright (c) 2007-2010, 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 updater.
*/
error_reporting(E_ALL|E_STRICT);
/*
 * If the auto-updater flag is not on (the file does not exist) then cancel the auto-update!
*/
if (!file_exists('autoupdate')) {
    //** The banner on the command line
    echo "\n\n".str_repeat('-',80)."\n";
    echo " _____ ___________   _____              __ _         ____
|_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
  | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
 _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
 \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
                                              __/ |
                                             |___/ ";
    echo "\n".str_repeat('-',80)."\n";
    echo "\n\n>>This script is for internal use only! Please use update.php!  \n\n";
    exit;
}
//** Include the library with the basic installer functions
require_once('lib/install.lib.php');
//** Include the library with the basic updater functions
require_once('lib/update.lib.php');
//** Include the base class of the installer class
require_once('lib/installer_base.lib.php');
//** Ensure that current working directory is install directory
$cur_dir = getcwd();
if(realpath(dirname(__FILE__)) != $cur_dir) die("Please run installation/update from _inside_ the install directory!\n");
//** Install logfile
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
//** Get distribution identifier
$dist = get_distname();
include_once("/usr/local/ispconfig/server/lib/config.inc.php");
$conf_old = $conf;
unset($conf);
if($dist['id'] == '') die('Linux distribution or version not recognized.');
//** Include the distribution-specific installer class library and configuration
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php');
include_once('dist/lib/'.$dist['id'].'.lib.php');
include_once('dist/conf/'.$dist['id'].'.conf.php');
//** Get hostname
exec('hostname -f', $tmp_out);
$conf['hostname'] = $tmp_out[0];
unset($tmp_out);
//** Set the mysql login information
$conf["mysql"]["host"] = $conf_old["db_host"];
$conf["mysql"]["database"] = $conf_old["db_database"];
$conf['mysql']['charset'] = 'utf8';
$conf["mysql"]["ispconfig_user"] = $conf_old["db_user"];
$conf["mysql"]["ispconfig_password"] = $conf_old["db_password"];
$conf['language'] = $conf_old['language'];
if($conf['language'] == '{language}') $conf['language'] = 'en';
if(isset($conf_old["dbmaster_host"])) $conf["mysql"]["master_host"] = $conf_old["dbmaster_host"];
if(isset($conf_old["dbmaster_database"])) $conf["mysql"]["master_database"] = $conf_old["dbmaster_database"];
if(isset($conf_old["dbmaster_user"])) $conf["mysql"]["master_ispconfig_user"] = $conf_old["dbmaster_user"];
if(isset($conf_old["dbmaster_password"])) $conf["mysql"]["master_ispconfig_password"] = $conf_old["dbmaster_password"];
//* Check if this is a master / slave setup
$conf['mysql']['master_slave_setup'] = 'n';
if($conf["mysql"]["master_host"] != '' && $conf["mysql"]["host"] != $conf["mysql"]["master_host"]) {
    $conf['mysql']['master_slave_setup'] = 'y';
}
// Resolve the IP address of the mysql hostname.
if(!$conf['mysql']['ip'] = gethostbyname($conf['mysql']['host'])) die('Unable to resolve hostname'.$conf['mysql']['host']);
$conf['server_id'] = intval($conf_old["server_id"]);
$conf['ispconfig_log_priority'] = $conf_old["log_priority"];
$inst = new installer();
$inst->is_update = true;
//** Detect the installed applications
$inst->find_installed_apps();
//** Initialize the MySQL server connection
include_once('lib/mysql.lib.php');
//** Database update is a bit brute force and should be rebuild later ;)
/*
 * Try to read the DB-admin settings
 */
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
include_once("/usr/local/ispconfig/server/lib/mysql_clientdb.conf");
$conf["mysql"]["admin_user"] = $clientdb_user;
$conf["mysql"]["admin_password"] = $clientdb_password;
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
//** There is a error if user for mysql admin_password if empty
if( empty($conf["mysql"]["admin_password"]) ) {
    die("internal error - MYSQL-Root passord not known");
}
/*
 *  Prepare the dump of the database
*/
prepareDBDump();
//* initialize the database
$inst->db = new db();
/*
 * The next line is a bit tricky!
 * At the automated update we have no connection to the master-db (we don't need it, because
 * there are only TWO points, where this is needed)
 * 1) update the rights --> the autoupdater sets the rights of all clients when the server is
 *    autoupdated)
 * 2) update the server-settings (is web installed, is mail installed) --> the autoupdates
 *    doesn't change any of this settings, so there ist no need to update this.
 * This means, the autoupdater did not need any connection to the master-db (only to the local bd
 * of the master-server). To avoid any problems, we set the master-db to the local one.
 */
$inst->dbmaster = $inst->db;
/*
 * If it is NOT a master-slave - Setup then we are at the Master-DB. So set all rights
*/
if($conf['mysql']['master_slave_setup'] != 'y') {
    $inst->grant_master_database_rights();
}
/*
 *  dump the new Database and reconfigure the server.ini
 */
updateDbAndIni();
/*
 * Reconfigure all Services
 */
if($conf['services']['mail'] == true) {
    //** Configure postfix
    swriteln('Configuring Postfix');
    $inst->configure_postfix('dont-create-certs');
    //* Configure Jailkit
    swriteln('Configuring Jailkit');
    $inst->configure_jailkit();
    if($conf['dovecot']['installed'] == true) {
        //* Configure dovecot
        swriteln('Configuring Dovecot');
        $inst->configure_dovecot();
    } else {
        //** 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 Getmail
    swriteln('Configuring Getmail');
    $inst->configure_getmail();
}
if($conf['services']['web'] == true) {
    //** Configure Pureftpd
    swriteln('Configuring Pureftpd');
    $inst->configure_pureftpd();
}
if($conf['services']['dns'] == true) {
    //* Configure DNS
    if($conf['powerdns']['installed'] == true) {
        swriteln('Configuring PowerDNS');
        $inst->configure_powerdns();
    } elseif($conf['bind']['installed'] == true) {
        swriteln('Configuring BIND');
        $inst->configure_bind();
    } else {
        swriteln('Configuring MyDNS');
        $inst->configure_mydns();
    }
}
if($conf['services']['web'] == true) {
    //** Configure Apache
    swriteln('Configuring Apache');
    $inst->configure_apache();
    //** Configure vlogger
    swriteln('Configuring vlogger');
    $inst->configure_vlogger();
    //** Configure apps vhost
    swriteln('Configuring Apps vhost');
    $inst->configure_apps_vhost();
}
//* Configure DBServer
swriteln('Configuring Database');
$inst->configure_dbserver();
//if(@is_dir('/etc/Bastille')) {
//* Configure Firewall
swriteln('Configuring Firewall');
$inst->configure_firewall();
//}
//** Configure ISPConfig
swriteln('Updating ISPConfig');
//** Customise the port ISPConfig runs on
$conf['apache']['vhost_port'] = get_ispconfig_port_number();
$inst->install_ispconfig();
//** Configure Crontab
swriteln('Updating Crontab');
$inst->install_crontab();
//** Restart services:
swriteln('Restarting services ...');
if($conf['mysql']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mysql']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' reload');
if($conf['services']['mail']) {
    if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
    if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
    if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
    if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
    if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
    if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
    if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
    if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
    if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
    if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
}
if($conf['services']['web']) {
    if($conf['apache']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['apache']['init_script']))                 system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
    if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script']))                system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
}
if($conf['services']['dns']) {
    if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
    if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
    if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
}
echo "Update finished.\n";
?>
<?php
/*
Copyright (c) 2007-2010, 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 updater.
*/
error_reporting(E_ALL|E_STRICT);
/*
 * If the auto-updater flag is not on (the file does not exist) then cancel the auto-update!
*/
if (!file_exists('autoupdate')) {
    //** The banner on the command line
    echo "\n\n".str_repeat('-',80)."\n";
    echo " _____ ___________   _____              __ _         ____
|_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
  | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
 _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
 \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
                                              __/ |
                                             |___/ ";
    echo "\n".str_repeat('-',80)."\n";
    echo "\n\n>>This script is for internal use only! Please use update.php!  \n\n";
    exit;
}
//** Include the library with the basic installer functions
require_once('lib/install.lib.php');
//** Include the library with the basic updater functions
require_once('lib/update.lib.php');
//** Include the base class of the installer class
require_once('lib/installer_base.lib.php');
//** Ensure that current working directory is install directory
$cur_dir = getcwd();
if(realpath(dirname(__FILE__)) != $cur_dir) die("Please run installation/update from _inside_ the install directory!\n");
//** Install logfile
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
//** Get distribution identifier
$dist = get_distname();
include_once("/usr/local/ispconfig/server/lib/config.inc.php");
$conf_old = $conf;
unset($conf);
if($dist['id'] == '') die('Linux distribution or version not recognized.');
//** Include the distribution-specific installer class library and configuration
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php');
include_once('dist/lib/'.$dist['id'].'.lib.php');
include_once('dist/conf/'.$dist['id'].'.conf.php');
//** Get hostname
exec('hostname -f', $tmp_out);
$conf['hostname'] = $tmp_out[0];
unset($tmp_out);
//** Set the mysql login information
$conf["mysql"]["host"] = $conf_old["db_host"];
$conf["mysql"]["database"] = $conf_old["db_database"];
$conf['mysql']['charset'] = 'utf8';
$conf["mysql"]["ispconfig_user"] = $conf_old["db_user"];
$conf["mysql"]["ispconfig_password"] = $conf_old["db_password"];
$conf['language'] = $conf_old['language'];
if($conf['language'] == '{language}') $conf['language'] = 'en';
if(isset($conf_old["dbmaster_host"])) $conf["mysql"]["master_host"] = $conf_old["dbmaster_host"];
if(isset($conf_old["dbmaster_database"])) $conf["mysql"]["master_database"] = $conf_old["dbmaster_database"];
if(isset($conf_old["dbmaster_user"])) $conf["mysql"]["master_ispconfig_user"] = $conf_old["dbmaster_user"];
if(isset($conf_old["dbmaster_password"])) $conf["mysql"]["master_ispconfig_password"] = $conf_old["dbmaster_password"];
//* Check if this is a master / slave setup
$conf['mysql']['master_slave_setup'] = 'n';
if($conf["mysql"]["master_host"] != '' && $conf["mysql"]["host"] != $conf["mysql"]["master_host"]) {
    $conf['mysql']['master_slave_setup'] = 'y';
}
// Resolve the IP address of the mysql hostname.
if(!$conf['mysql']['ip'] = gethostbyname($conf['mysql']['host'])) die('Unable to resolve hostname'.$conf['mysql']['host']);
$conf['server_id'] = intval($conf_old["server_id"]);
$conf['ispconfig_log_priority'] = $conf_old["log_priority"];
$inst = new installer();
$inst->is_update = true;
//** Detect the installed applications
$inst->find_installed_apps();
//** Initialize the MySQL server connection
include_once('lib/mysql.lib.php');
//** Database update is a bit brute force and should be rebuild later ;)
/*
 * Try to read the DB-admin settings
 */
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
include_once("/usr/local/ispconfig/server/lib/mysql_clientdb.conf");
$conf["mysql"]["admin_user"] = $clientdb_user;
$conf["mysql"]["admin_password"] = $clientdb_password;
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
//** There is a error if user for mysql admin_password if empty
if( empty($conf["mysql"]["admin_password"]) ) {
    die("internal error - MYSQL-Root passord not known");
}
/*
 *  Prepare the dump of the database
*/
prepareDBDump();
//* initialize the database
$inst->db = new db();
/*
 * The next line is a bit tricky!
 * At the automated update we have no connection to the master-db (we don't need it, because
 * there are only TWO points, where this is needed)
 * 1) update the rights --> the autoupdater sets the rights of all clients when the server is
 *    autoupdated)
 * 2) update the server-settings (is web installed, is mail installed) --> the autoupdates
 *    doesn't change any of this settings, so there ist no need to update this.
 * This means, the autoupdater did not need any connection to the master-db (only to the local bd
 * of the master-server). To avoid any problems, we set the master-db to the local one.
 */
$inst->dbmaster = $inst->db;
/*
 * If it is NOT a master-slave - Setup then we are at the Master-DB. So set all rights
*/
if($conf['mysql']['master_slave_setup'] != 'y') {
    $inst->grant_master_database_rights();
}
/*
 *  dump the new Database and reconfigure the server.ini
 */
updateDbAndIni();
/*
 * Reconfigure all Services
 */
if($conf['services']['mail'] == true) {
    //** Configure postfix
    swriteln('Configuring Postfix');
    $inst->configure_postfix('dont-create-certs');
    //** Configure mailman
    swriteln('Configuring Mailman');
    $inst->configure_mailman('update');
    //* Configure Jailkit
    swriteln('Configuring Jailkit');
    $inst->configure_jailkit();
    if($conf['dovecot']['installed'] == true) {
        //* Configure dovecot
        swriteln('Configuring Dovecot');
        $inst->configure_dovecot();
    } else {
        //** 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 Getmail
    swriteln('Configuring Getmail');
    $inst->configure_getmail();
}
if($conf['services']['web'] == true) {
    //** Configure Pureftpd
    swriteln('Configuring Pureftpd');
    $inst->configure_pureftpd();
}
if($conf['services']['dns'] == true) {
    //* Configure DNS
    if($conf['powerdns']['installed'] == true) {
        swriteln('Configuring PowerDNS');
        $inst->configure_powerdns();
    } elseif($conf['bind']['installed'] == true) {
        swriteln('Configuring BIND');
        $inst->configure_bind();
    } else {
        swriteln('Configuring MyDNS');
        $inst->configure_mydns();
    }
}
if($conf['services']['web'] == true) {
    //** Configure Apache
    swriteln('Configuring Apache');
    $inst->configure_apache();
    //** Configure vlogger
    swriteln('Configuring vlogger');
    $inst->configure_vlogger();
    //** Configure apps vhost
    swriteln('Configuring Apps vhost');
    $inst->configure_apps_vhost();
}
//* Configure DBServer
swriteln('Configuring Database');
$inst->configure_dbserver();
//if(@is_dir('/etc/Bastille')) {
//* Configure Firewall
swriteln('Configuring Firewall');
$inst->configure_firewall();
//}
//** Configure ISPConfig
swriteln('Updating ISPConfig');
//** Customise the port ISPConfig runs on
$conf['apache']['vhost_port'] = get_ispconfig_port_number();
$inst->install_ispconfig();
//** Configure Crontab
swriteln('Updating Crontab');
$inst->install_crontab();
//** Restart services:
swriteln('Restarting services ...');
if($conf['mysql']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mysql']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' reload');
if($conf['services']['mail']) {
    if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
    if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
    if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
    if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
    if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
    if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
    if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
    if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
    if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
    if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
    if($conf['mailman']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mailman']['init_script']))         system($conf['init_scripts'].'/'.$conf['mailman']['init_script'].' restart');
}
if($conf['services']['web']) {
    if($conf['apache']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['apache']['init_script']))                 system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
    if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script']))                system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
}
if($conf['services']['dns']) {
    if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
    if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
    if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
}
echo "Update finished.\n";
?>
install/dist/conf/debian40.conf.php
@@ -1,189 +1,194 @@
<?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.
*/
//***  Debian 4.0 default settings
//* Main
$conf['language'] = 'en';
$conf['distname'] = 'debian40';
$conf['hostname'] = 'server1.domain.tld'; // Full hostname
$conf['ispconfig_install_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_config_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_log_priority'] = 2;  // 0 = Debug, 1 = Warning, 2 = Error
$conf['ispconfig_log_dir'] = '/var/log/ispconfig';
$conf['server_id'] = 1;
$conf['init_scripts'] = '/etc/init.d';
$conf['runlevel'] = '/etc';
$conf['shells'] = '/etc/shells';
$conf['pam'] = '/etc/pam.d';
//* Services provided by this server, this selection will be overridden by the expert mode
$conf['services']['mail'] = true;
$conf['services']['web'] = true;
$conf['services']['dns'] = true;
$conf['services']['file'] = true;
$conf['services']['db'] = true;
$conf['services']['vserver'] = true;
//* MySQL
$conf['mysql']['installed'] = false; // will be detected automatically during installation
$conf['mysql']['init_script'] = 'mysql';
$conf['mysql']['host'] = 'localhost';
$conf['mysql']['ip'] = '127.0.0.1';
$conf['mysql']['port'] = '3306';
$conf['mysql']['database'] = 'dbispconfig';
$conf['mysql']['admin_user'] = 'root';
$conf['mysql']['admin_password'] = '';
$conf['mysql']['charset'] = 'utf8';
$conf['mysql']['ispconfig_user'] = 'ispconfig';
$conf['mysql']['ispconfig_password'] = md5 (uniqid (rand()));
$conf['mysql']['master_slave_setup'] = 'n';
$conf['mysql']['master_host'] = '';
$conf['mysql']['master_database'] = 'dbispconfig';
$conf['mysql']['master_admin_user'] = 'root';
$conf['mysql']['master_admin_password'] = '';
$conf['mysql']['master_ispconfig_user'] = '';
$conf['mysql']['master_ispconfig_password'] = md5 (uniqid (rand()));
//* Apache
$conf['apache']['installed'] = false; // will be detected automatically during installation
$conf['apache']['user'] = 'www-data';
$conf['apache']['group'] = 'www-data';
$conf['apache']['init_script'] = 'apache2';
$conf['apache']['version'] = '2.2';
$conf['apache']['vhost_conf_dir'] = '/etc/apache2/sites-available';
$conf['apache']['vhost_conf_enabled_dir'] = '/etc/apache2/sites-enabled';
$conf['apache']['vhost_port'] = '8080';
$conf['apache']['php_ini_path_apache'] = '/etc/php5/apache2/php.ini';
$conf['apache']['php_ini_path_cgi'] = '/etc/php5/cgi/php.ini';
//* Website base settings
$conf['web']['website_basedir'] = '/var/www';
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
//* Apps base settings
$conf['web']['apps_vhost_ip'] = '_default_';
$conf['web']['apps_vhost_port'] = '8081';
$conf['web']['apps_vhost_servername'] = '';
$conf['web']['apps_vhost_user'] = 'ispapps';
$conf['web']['apps_vhost_group'] = 'ispapps';
//* Fastcgi
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/php5/cgi/';
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';
//* Postfix
$conf['postfix']['installed'] = false; // will be detected automatically during installation
$conf['postfix']['config_dir'] = '/etc/postfix';
$conf['postfix']['init_script'] = 'postfix';
$conf['postfix']['user'] = 'postfix';
$conf['postfix']['group'] = 'postfix';
$conf['postfix']['vmail_userid'] = '5000';
$conf['postfix']['vmail_username'] = 'vmail';
$conf['postfix']['vmail_groupid'] = '5000';
$conf['postfix']['vmail_groupname'] = 'vmail';
$conf['postfix']['vmail_mailbox_base'] = '/var/vmail';
//* Getmail
$conf['getmail']['installed'] = false; // will be detected automatically during installation
$conf['getmail']['config_dir'] = '/etc/getmail';
$conf['getmail']['program'] = '/usr/bin/getmail';
//* Courier
$conf['courier']['installed'] = false; // will be detected automatically during installation
$conf['courier']['config_dir'] = '/etc/courier';
$conf['courier']['courier-authdaemon'] = 'courier-authdaemon';
$conf['courier']['courier-imap'] = 'courier-imap';
$conf['courier']['courier-imap-ssl'] = 'courier-imap-ssl';
$conf['courier']['courier-pop'] = 'courier-pop';
$conf['courier']['courier-pop-ssl'] = 'courier-pop-ssl';
//* Dovecot
$conf['dovecot']['installed'] = false; // will be detected automatically during installation
$conf['dovecot']['config_dir'] = '/etc/dovecot';
$conf['dovecot']['init_script'] = 'dovecot';
//* SASL
$conf['saslauthd']['installed'] = false; // will be detected automatically during installation
$conf['saslauthd']['config'] = '/etc/default/saslauthd';
$conf['saslauthd']['init_script'] = 'saslauthd';
//* Amavisd
$conf['amavis']['installed'] = false; // will be detected automatically during installation
$conf['amavis']['config_dir'] = '/etc/amavis';
$conf['amavis']['init_script'] = 'amavis';
//* ClamAV
$conf['clamav']['installed'] = false; // will be detected automatically during installation
$conf['clamav']['init_script'] = 'clamav-daemon';
//* Pureftpd
$conf['pureftpd']['installed'] = false; // will be detected automatically during installation
$conf['pureftpd']['config_dir'] = '/etc/pure-ftpd';
$conf['pureftpd']['init_script'] = 'pure-ftpd-mysql';
//* MyDNS
$conf['mydns']['installed'] = false; // will be detected automatically during installation
$conf['mydns']['config_dir'] = '/etc';
$conf['mydns']['init_script'] = 'mydns';
//* PowerDNS
$conf['powerdns']['installed'] = false; // will be detected automatically during installation
$conf['powerdns']['database'] = 'powerdns';
$conf["powerdns"]["config_dir"] = '/etc/powerdns/pdns.d';
$conf['powerdns']['init_script'] = 'pdns';
//* BIND DNS Server
$conf['bind']['installed'] = false; // will be detected automatically during installation
$conf['bind']['bind_user'] = 'root';
$conf['bind']['bind_group'] = 'bind';
$conf['bind']['bind_zonefiles_dir'] = '/etc/bind';
$conf['bind']['named_conf_path'] = '/etc/bind/named.conf';
$conf['bind']['named_conf_local_path'] = '/etc/bind/named.conf.local';
$conf['bind']['init_script'] = 'bind9';
//* Jailkit
$conf['jailkit']['installed'] = false; // will be detected automatically during installation
$conf['jailkit']['config_dir'] = '/etc/jailkit';
$conf['jailkit']['jk_init'] = 'jk_init.ini';
$conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini';
$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico';
$conf['jailkit']['jailkit_chroot_cron_programs'] = '/usr/bin/php /usr/bin/perl /usr/share/perl /usr/share/php';
//* vlogger
$conf['vlogger']['config_dir'] = '/etc';
//* cron
$conf['cron']['init_script'] = 'cron';
$conf['cron']['crontab_dir'] = '/etc/cron.d';
$conf['cron']['wget'] = '/usr/bin/wget';
?>
<?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.
*/
//***  Debian 4.0 default settings
//* Main
$conf['language'] = 'en';
$conf['distname'] = 'debian40';
$conf['hostname'] = 'server1.domain.tld'; // Full hostname
$conf['ispconfig_install_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_config_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_log_priority'] = 2;  // 0 = Debug, 1 = Warning, 2 = Error
$conf['ispconfig_log_dir'] = '/var/log/ispconfig';
$conf['server_id'] = 1;
$conf['init_scripts'] = '/etc/init.d';
$conf['runlevel'] = '/etc';
$conf['shells'] = '/etc/shells';
$conf['pam'] = '/etc/pam.d';
//* Services provided by this server, this selection will be overridden by the expert mode
$conf['services']['mail'] = true;
$conf['services']['web'] = true;
$conf['services']['dns'] = true;
$conf['services']['file'] = true;
$conf['services']['db'] = true;
$conf['services']['vserver'] = true;
//* MySQL
$conf['mysql']['installed'] = false; // will be detected automatically during installation
$conf['mysql']['init_script'] = 'mysql';
$conf['mysql']['host'] = 'localhost';
$conf['mysql']['ip'] = '127.0.0.1';
$conf['mysql']['port'] = '3306';
$conf['mysql']['database'] = 'dbispconfig';
$conf['mysql']['admin_user'] = 'root';
$conf['mysql']['admin_password'] = '';
$conf['mysql']['charset'] = 'utf8';
$conf['mysql']['ispconfig_user'] = 'ispconfig';
$conf['mysql']['ispconfig_password'] = md5 (uniqid (rand()));
$conf['mysql']['master_slave_setup'] = 'n';
$conf['mysql']['master_host'] = '';
$conf['mysql']['master_database'] = 'dbispconfig';
$conf['mysql']['master_admin_user'] = 'root';
$conf['mysql']['master_admin_password'] = '';
$conf['mysql']['master_ispconfig_user'] = '';
$conf['mysql']['master_ispconfig_password'] = md5 (uniqid (rand()));
//* Apache
$conf['apache']['installed'] = false; // will be detected automatically during installation
$conf['apache']['user'] = 'www-data';
$conf['apache']['group'] = 'www-data';
$conf['apache']['init_script'] = 'apache2';
$conf['apache']['version'] = '2.2';
$conf['apache']['vhost_conf_dir'] = '/etc/apache2/sites-available';
$conf['apache']['vhost_conf_enabled_dir'] = '/etc/apache2/sites-enabled';
$conf['apache']['vhost_port'] = '8080';
$conf['apache']['php_ini_path_apache'] = '/etc/php5/apache2/php.ini';
$conf['apache']['php_ini_path_cgi'] = '/etc/php5/cgi/php.ini';
//* Website base settings
$conf['web']['website_basedir'] = '/var/www';
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
//* Apps base settings
$conf['web']['apps_vhost_ip'] = '_default_';
$conf['web']['apps_vhost_port'] = '8081';
$conf['web']['apps_vhost_servername'] = '';
$conf['web']['apps_vhost_user'] = 'ispapps';
$conf['web']['apps_vhost_group'] = 'ispapps';
//* Fastcgi
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/php5/cgi/';
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';
//* Postfix
$conf['postfix']['installed'] = false; // will be detected automatically during installation
$conf['postfix']['config_dir'] = '/etc/postfix';
$conf['postfix']['init_script'] = 'postfix';
$conf['postfix']['user'] = 'postfix';
$conf['postfix']['group'] = 'postfix';
$conf['postfix']['vmail_userid'] = '5000';
$conf['postfix']['vmail_username'] = 'vmail';
$conf['postfix']['vmail_groupid'] = '5000';
$conf['postfix']['vmail_groupname'] = 'vmail';
$conf['postfix']['vmail_mailbox_base'] = '/var/vmail';
//* Mailman
$conf['mailman']['installed'] = false; // will be detected automatically during installation
$conf['mailman']['config_dir'] = '/etc/mailman';
$conf['mailman']['init_script'] = 'mailman';
//* Getmail
$conf['getmail']['installed'] = false; // will be detected automatically during installation
$conf['getmail']['config_dir'] = '/etc/getmail';
$conf['getmail']['program'] = '/usr/bin/getmail';
//* Courier
$conf['courier']['installed'] = false; // will be detected automatically during installation
$conf['courier']['config_dir'] = '/etc/courier';
$conf['courier']['courier-authdaemon'] = 'courier-authdaemon';
$conf['courier']['courier-imap'] = 'courier-imap';
$conf['courier']['courier-imap-ssl'] = 'courier-imap-ssl';
$conf['courier']['courier-pop'] = 'courier-pop';
$conf['courier']['courier-pop-ssl'] = 'courier-pop-ssl';
//* Dovecot
$conf['dovecot']['installed'] = false; // will be detected automatically during installation
$conf['dovecot']['config_dir'] = '/etc/dovecot';
$conf['dovecot']['init_script'] = 'dovecot';
//* SASL
$conf['saslauthd']['installed'] = false; // will be detected automatically during installation
$conf['saslauthd']['config'] = '/etc/default/saslauthd';
$conf['saslauthd']['init_script'] = 'saslauthd';
//* Amavisd
$conf['amavis']['installed'] = false; // will be detected automatically during installation
$conf['amavis']['config_dir'] = '/etc/amavis';
$conf['amavis']['init_script'] = 'amavis';
//* ClamAV
$conf['clamav']['installed'] = false; // will be detected automatically during installation
$conf['clamav']['init_script'] = 'clamav-daemon';
//* Pureftpd
$conf['pureftpd']['installed'] = false; // will be detected automatically during installation
$conf['pureftpd']['config_dir'] = '/etc/pure-ftpd';
$conf['pureftpd']['init_script'] = 'pure-ftpd-mysql';
//* MyDNS
$conf['mydns']['installed'] = false; // will be detected automatically during installation
$conf['mydns']['config_dir'] = '/etc';
$conf['mydns']['init_script'] = 'mydns';
//* PowerDNS
$conf['powerdns']['installed'] = false; // will be detected automatically during installation
$conf['powerdns']['database'] = 'powerdns';
$conf["powerdns"]["config_dir"] = '/etc/powerdns/pdns.d';
$conf['powerdns']['init_script'] = 'pdns';
//* BIND DNS Server
$conf['bind']['installed'] = false; // will be detected automatically during installation
$conf['bind']['bind_user'] = 'root';
$conf['bind']['bind_group'] = 'bind';
$conf['bind']['bind_zonefiles_dir'] = '/etc/bind';
$conf['bind']['named_conf_path'] = '/etc/bind/named.conf';
$conf['bind']['named_conf_local_path'] = '/etc/bind/named.conf.local';
$conf['bind']['init_script'] = 'bind9';
//* Jailkit
$conf['jailkit']['installed'] = false; // will be detected automatically during installation
$conf['jailkit']['config_dir'] = '/etc/jailkit';
$conf['jailkit']['jk_init'] = 'jk_init.ini';
$conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini';
$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico';
$conf['jailkit']['jailkit_chroot_cron_programs'] = '/usr/bin/php /usr/bin/perl /usr/share/perl /usr/share/php';
//* vlogger
$conf['vlogger']['config_dir'] = '/etc';
//* cron
$conf['cron']['init_script'] = 'cron';
$conf['cron']['crontab_dir'] = '/etc/cron.d';
$conf['cron']['wget'] = '/usr/bin/wget';
?>
install/dist/conf/debian60.conf.php
@@ -1,189 +1,194 @@
<?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.
*/
//***  Debian 4.0 default settings
//* Main
$conf['language'] = 'en';
$conf['distname'] = 'debian60';
$conf['hostname'] = 'server1.domain.tld'; // Full hostname
$conf['ispconfig_install_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_config_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_log_priority'] = 2;  // 0 = Debug, 1 = Warning, 2 = Error
$conf['ispconfig_log_dir'] = '/var/log/ispconfig';
$conf['server_id'] = 1;
$conf['init_scripts'] = '/etc/init.d';
$conf['runlevel'] = '/etc';
$conf['shells'] = '/etc/shells';
$conf['pam'] = '/etc/pam.d';
//* Services provided by this server, this selection will be overridden by the expert mode
$conf['services']['mail'] = true;
$conf['services']['web'] = true;
$conf['services']['dns'] = true;
$conf['services']['file'] = true;
$conf['services']['db'] = true;
$conf['services']['vserver'] = true;
//* MySQL
$conf['mysql']['installed'] = false; // will be detected automatically during installation
$conf['mysql']['init_script'] = 'mysql';
$conf['mysql']['host'] = 'localhost';
$conf['mysql']['ip'] = '127.0.0.1';
$conf['mysql']['port'] = '3306';
$conf['mysql']['database'] = 'dbispconfig';
$conf['mysql']['admin_user'] = 'root';
$conf['mysql']['admin_password'] = '';
$conf['mysql']['charset'] = 'utf8';
$conf['mysql']['ispconfig_user'] = 'ispconfig';
$conf['mysql']['ispconfig_password'] = md5 (uniqid (rand()));
$conf['mysql']['master_slave_setup'] = 'n';
$conf['mysql']['master_host'] = '';
$conf['mysql']['master_database'] = 'dbispconfig';
$conf['mysql']['master_admin_user'] = 'root';
$conf['mysql']['master_admin_password'] = '';
$conf['mysql']['master_ispconfig_user'] = '';
$conf['mysql']['master_ispconfig_password'] = md5 (uniqid (rand()));
//* Apache
$conf['apache']['installed'] = false; // will be detected automatically during installation
$conf['apache']['user'] = 'www-data';
$conf['apache']['group'] = 'www-data';
$conf['apache']['init_script'] = 'apache2';
$conf['apache']['version'] = '2.2';
$conf['apache']['vhost_conf_dir'] = '/etc/apache2/sites-available';
$conf['apache']['vhost_conf_enabled_dir'] = '/etc/apache2/sites-enabled';
$conf['apache']['vhost_port'] = '8080';
$conf['apache']['php_ini_path_apache'] = '/etc/php5/apache2/php.ini';
$conf['apache']['php_ini_path_cgi'] = '/etc/php5/cgi/php.ini';
//* Website base settings
$conf['web']['website_basedir'] = '/var/www';
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
//* Apps base settings
$conf['web']['apps_vhost_ip'] = '_default_';
$conf['web']['apps_vhost_port'] = '8081';
$conf['web']['apps_vhost_servername'] = '';
$conf['web']['apps_vhost_user'] = 'ispapps';
$conf['web']['apps_vhost_group'] = 'ispapps';
//* Fastcgi
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/php5/cgi/';
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';
//* Postfix
$conf['postfix']['installed'] = false; // will be detected automatically during installation
$conf['postfix']['config_dir'] = '/etc/postfix';
$conf['postfix']['init_script'] = 'postfix';
$conf['postfix']['user'] = 'postfix';
$conf['postfix']['group'] = 'postfix';
$conf['postfix']['vmail_userid'] = '5000';
$conf['postfix']['vmail_username'] = 'vmail';
$conf['postfix']['vmail_groupid'] = '5000';
$conf['postfix']['vmail_groupname'] = 'vmail';
$conf['postfix']['vmail_mailbox_base'] = '/var/vmail';
//* Getmail
$conf['getmail']['installed'] = false; // will be detected automatically during installation
$conf['getmail']['config_dir'] = '/etc/getmail';
$conf['getmail']['program'] = '/usr/bin/getmail';
//* Courier
$conf['courier']['installed'] = false; // will be detected automatically during installation
$conf['courier']['config_dir'] = '/etc/courier';
$conf['courier']['courier-authdaemon'] = 'courier-authdaemon';
$conf['courier']['courier-imap'] = 'courier-imap';
$conf['courier']['courier-imap-ssl'] = 'courier-imap-ssl';
$conf['courier']['courier-pop'] = 'courier-pop';
$conf['courier']['courier-pop-ssl'] = 'courier-pop-ssl';
//* Dovecot
$conf['dovecot']['installed'] = false; // will be detected automatically during installation
$conf['dovecot']['config_dir'] = '/etc/dovecot';
$conf['dovecot']['init_script'] = 'dovecot';
//* SASL
$conf['saslauthd']['installed'] = false; // will be detected automatically during installation
$conf['saslauthd']['config'] = '/etc/default/saslauthd';
$conf['saslauthd']['init_script'] = 'saslauthd';
//* Amavisd
$conf['amavis']['installed'] = false; // will be detected automatically during installation
$conf['amavis']['config_dir'] = '/etc/amavis';
$conf['amavis']['init_script'] = 'amavis';
//* ClamAV
$conf['clamav']['installed'] = false; // will be detected automatically during installation
$conf['clamav']['init_script'] = 'clamav-daemon';
//* Pureftpd
$conf['pureftpd']['installed'] = false; // will be detected automatically during installation
$conf['pureftpd']['config_dir'] = '/etc/pure-ftpd';
$conf['pureftpd']['init_script'] = 'pure-ftpd-mysql';
//* MyDNS
$conf['mydns']['installed'] = false; // will be detected automatically during installation
$conf['mydns']['config_dir'] = '/etc';
$conf['mydns']['init_script'] = 'mydns';
//* PowerDNS
$conf['powerdns']['installed'] = false; // will be detected automatically during installation
$conf['powerdns']['database'] = 'powerdns';
$conf["powerdns"]["config_dir"] = '/etc/powerdns/pdns.d';
$conf['powerdns']['init_script'] = 'pdns';
//* BIND DNS Server
$conf['bind']['installed'] = false; // will be detected automatically during installation
$conf['bind']['bind_user'] = 'root';
$conf['bind']['bind_group'] = 'bind';
$conf['bind']['bind_zonefiles_dir'] = '/etc/bind';
$conf['bind']['named_conf_path'] = '/etc/bind/named.conf';
$conf['bind']['named_conf_local_path'] = '/etc/bind/named.conf.local';
$conf['bind']['init_script'] = 'bind9';
//* Jailkit
$conf['jailkit']['installed'] = false; // will be detected automatically during installation
$conf['jailkit']['config_dir'] = '/etc/jailkit';
$conf['jailkit']['jk_init'] = 'jk_init.ini';
$conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini';
$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico';
$conf['jailkit']['jailkit_chroot_cron_programs'] = '/usr/bin/php /usr/bin/perl /usr/share/perl /usr/share/php';
//* vlogger
$conf['vlogger']['config_dir'] = '/etc';
//* cron
$conf['cron']['init_script'] = 'cron';
$conf['cron']['crontab_dir'] = '/etc/cron.d';
$conf['cron']['wget'] = '/usr/bin/wget';
?>
<?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.
*/
//***  Debian 4.0 default settings
//* Main
$conf['language'] = 'en';
$conf['distname'] = 'debian60';
$conf['hostname'] = 'server1.domain.tld'; // Full hostname
$conf['ispconfig_install_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_config_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_log_priority'] = 2;  // 0 = Debug, 1 = Warning, 2 = Error
$conf['ispconfig_log_dir'] = '/var/log/ispconfig';
$conf['server_id'] = 1;
$conf['init_scripts'] = '/etc/init.d';
$conf['runlevel'] = '/etc';
$conf['shells'] = '/etc/shells';
$conf['pam'] = '/etc/pam.d';
//* Services provided by this server, this selection will be overridden by the expert mode
$conf['services']['mail'] = true;
$conf['services']['web'] = true;
$conf['services']['dns'] = true;
$conf['services']['file'] = true;
$conf['services']['db'] = true;
$conf['services']['vserver'] = true;
//* MySQL
$conf['mysql']['installed'] = false; // will be detected automatically during installation
$conf['mysql']['init_script'] = 'mysql';
$conf['mysql']['host'] = 'localhost';
$conf['mysql']['ip'] = '127.0.0.1';
$conf['mysql']['port'] = '3306';
$conf['mysql']['database'] = 'dbispconfig';
$conf['mysql']['admin_user'] = 'root';
$conf['mysql']['admin_password'] = '';
$conf['mysql']['charset'] = 'utf8';
$conf['mysql']['ispconfig_user'] = 'ispconfig';
$conf['mysql']['ispconfig_password'] = md5 (uniqid (rand()));
$conf['mysql']['master_slave_setup'] = 'n';
$conf['mysql']['master_host'] = '';
$conf['mysql']['master_database'] = 'dbispconfig';
$conf['mysql']['master_admin_user'] = 'root';
$conf['mysql']['master_admin_password'] = '';
$conf['mysql']['master_ispconfig_user'] = '';
$conf['mysql']['master_ispconfig_password'] = md5 (uniqid (rand()));
//* Apache
$conf['apache']['installed'] = false; // will be detected automatically during installation
$conf['apache']['user'] = 'www-data';
$conf['apache']['group'] = 'www-data';
$conf['apache']['init_script'] = 'apache2';
$conf['apache']['version'] = '2.2';
$conf['apache']['vhost_conf_dir'] = '/etc/apache2/sites-available';
$conf['apache']['vhost_conf_enabled_dir'] = '/etc/apache2/sites-enabled';
$conf['apache']['vhost_port'] = '8080';
$conf['apache']['php_ini_path_apache'] = '/etc/php5/apache2/php.ini';
$conf['apache']['php_ini_path_cgi'] = '/etc/php5/cgi/php.ini';
//* Website base settings
$conf['web']['website_basedir'] = '/var/www';
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
//* Apps base settings
$conf['web']['apps_vhost_ip'] = '_default_';
$conf['web']['apps_vhost_port'] = '8081';
$conf['web']['apps_vhost_servername'] = '';
$conf['web']['apps_vhost_user'] = 'ispapps';
$conf['web']['apps_vhost_group'] = 'ispapps';
//* Fastcgi
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/php5/cgi/';
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';
//* Postfix
$conf['postfix']['installed'] = false; // will be detected automatically during installation
$conf['postfix']['config_dir'] = '/etc/postfix';
$conf['postfix']['init_script'] = 'postfix';
$conf['postfix']['user'] = 'postfix';
$conf['postfix']['group'] = 'postfix';
$conf['postfix']['vmail_userid'] = '5000';
$conf['postfix']['vmail_username'] = 'vmail';
$conf['postfix']['vmail_groupid'] = '5000';
$conf['postfix']['vmail_groupname'] = 'vmail';
$conf['postfix']['vmail_mailbox_base'] = '/var/vmail';
//* Mailman
$conf['mailman']['installed'] = false; // will be detected automatically during installation
$conf['mailman']['config_dir'] = '/etc/mailman';
$conf['mailman']['init_script'] = 'mailman';
//* Getmail
$conf['getmail']['installed'] = false; // will be detected automatically during installation
$conf['getmail']['config_dir'] = '/etc/getmail';
$conf['getmail']['program'] = '/usr/bin/getmail';
//* Courier
$conf['courier']['installed'] = false; // will be detected automatically during installation
$conf['courier']['config_dir'] = '/etc/courier';
$conf['courier']['courier-authdaemon'] = 'courier-authdaemon';
$conf['courier']['courier-imap'] = 'courier-imap';
$conf['courier']['courier-imap-ssl'] = 'courier-imap-ssl';
$conf['courier']['courier-pop'] = 'courier-pop';
$conf['courier']['courier-pop-ssl'] = 'courier-pop-ssl';
//* Dovecot
$conf['dovecot']['installed'] = false; // will be detected automatically during installation
$conf['dovecot']['config_dir'] = '/etc/dovecot';
$conf['dovecot']['init_script'] = 'dovecot';
//* SASL
$conf['saslauthd']['installed'] = false; // will be detected automatically during installation
$conf['saslauthd']['config'] = '/etc/default/saslauthd';
$conf['saslauthd']['init_script'] = 'saslauthd';
//* Amavisd
$conf['amavis']['installed'] = false; // will be detected automatically during installation
$conf['amavis']['config_dir'] = '/etc/amavis';
$conf['amavis']['init_script'] = 'amavis';
//* ClamAV
$conf['clamav']['installed'] = false; // will be detected automatically during installation
$conf['clamav']['init_script'] = 'clamav-daemon';
//* Pureftpd
$conf['pureftpd']['installed'] = false; // will be detected automatically during installation
$conf['pureftpd']['config_dir'] = '/etc/pure-ftpd';
$conf['pureftpd']['init_script'] = 'pure-ftpd-mysql';
//* MyDNS
$conf['mydns']['installed'] = false; // will be detected automatically during installation
$conf['mydns']['config_dir'] = '/etc';
$conf['mydns']['init_script'] = 'mydns';
//* PowerDNS
$conf['powerdns']['installed'] = false; // will be detected automatically during installation
$conf['powerdns']['database'] = 'powerdns';
$conf["powerdns"]["config_dir"] = '/etc/powerdns/pdns.d';
$conf['powerdns']['init_script'] = 'pdns';
//* BIND DNS Server
$conf['bind']['installed'] = false; // will be detected automatically during installation
$conf['bind']['bind_user'] = 'root';
$conf['bind']['bind_group'] = 'bind';
$conf['bind']['bind_zonefiles_dir'] = '/etc/bind';
$conf['bind']['named_conf_path'] = '/etc/bind/named.conf';
$conf['bind']['named_conf_local_path'] = '/etc/bind/named.conf.local';
$conf['bind']['init_script'] = 'bind9';
//* Jailkit
$conf['jailkit']['installed'] = false; // will be detected automatically during installation
$conf['jailkit']['config_dir'] = '/etc/jailkit';
$conf['jailkit']['jk_init'] = 'jk_init.ini';
$conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini';
$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico';
$conf['jailkit']['jailkit_chroot_cron_programs'] = '/usr/bin/php /usr/bin/perl /usr/share/perl /usr/share/php';
//* vlogger
$conf['vlogger']['config_dir'] = '/etc';
//* cron
$conf['cron']['init_script'] = 'cron';
$conf['cron']['crontab_dir'] = '/etc/cron.d';
$conf['cron']['wget'] = '/usr/bin/wget';
?>
install/install.php
@@ -1,482 +1,491 @@
<?php
/*
Copyright (c) 2007-2010, 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.
*/
error_reporting(E_ALL|E_STRICT);
//** The banner on the command line
echo "\n\n".str_repeat('-',80)."\n";
echo " _____ ___________   _____              __ _         ____
|_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
  | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
 _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
 \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
                                              __/ |
                                             |___/ ";
echo "\n".str_repeat('-',80)."\n";
echo "\n\n>> Initial configuration  \n\n";
//** 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');
//** Ensure that current working directory is install directory
$cur_dir = getcwd();
if(realpath(dirname(__FILE__)) != $cur_dir) {
    chdir( realpath(dirname(__FILE__)) );
}
//** Install logfile
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
//** Check for existing installation
/*if(is_dir("/usr/local/ispconfig")) {
    die('We will stop here. There is already a ISPConfig installation, use the update script to update this installation.');
}*/
//** Get distribution identifier
$dist = get_distname();
if($dist['id'] == '') die('Linux distribution or version not recognized.');
//** Include the distribution-specific installer class library and configuration
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php');
include_once('dist/lib/'.$dist['id'].'.lib.php');
include_once('dist/conf/'.$dist['id'].'.conf.php');
//****************************************************************************************************
//** Installer Interface
//****************************************************************************************************
$inst = new installer();
swriteln($inst->lng('    Following will be a few questions for primary configuration so be careful.'));
swriteln($inst->lng('    Default values are in [brackets] and can be accepted with <ENTER>.'));
swriteln($inst->lng('    Tap in "quit" (without the quotes) to stop the installer.'."\n\n"));
//** Check log file is writable (probably not root or sudo)
if(!is_writable(dirname(ISPC_LOG_FILE))){
    die("ERROR: Cannot write to the ".dirname(ISPC_LOG_FILE)." directory. Are you root or sudo ?\n\n");
}
if(is_dir('/root/ispconfig') || is_dir('/home/admispconfig')) {
    die('This software cannot be installed on a server wich runs ISPConfig 2.x.');
}
if(is_dir('/usr/local/ispconfig')) {
    die('ISPConfig 3 installation found. Please use update.php instead if install.php to update the installation.');
}
//** Detect the installed applications
$inst->find_installed_apps();
//** Select the language
$conf['language'] = $inst->simple_query('Select language', array('en','de'), 'en');
//** Select installation mode
$install_mode = $inst->simple_query('Installation mode', array('standard','expert'), 'standard');
//** Get the hostname
$tmp_out = array();
exec('hostname -f', $tmp_out);
$conf['hostname'] = $inst->free_query('Full qualified hostname (FQDN) of the server, eg server1.domain.tld ', $tmp_out[0]);
unset($tmp_out);
// Check if the mysql functions are loaded in PHP
if(!function_exists('mysql_connect')) die('No PHP MySQL functions available. Please ensure that the PHP MySQL module is loaded.');
//** Get MySQL root credentials
$finished = false;
do {
    $tmp_mysql_server_host = $inst->free_query('MySQL server hostname', $conf['mysql']['host']);
    $tmp_mysql_server_admin_user = $inst->free_query('MySQL root username', $conf['mysql']['admin_user']);
    $tmp_mysql_server_admin_password = $inst->free_query('MySQL root password', $conf['mysql']['admin_password']);
    $tmp_mysql_server_database = $inst->free_query('MySQL database to create', $conf['mysql']['database']);
    $tmp_mysql_server_charset = $inst->free_query('MySQL charset', $conf['mysql']['charset']);
    //* Initialize the MySQL server connection
    if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
        $conf['mysql']['host'] = $tmp_mysql_server_host;
        $conf['mysql']['admin_user'] = $tmp_mysql_server_admin_user;
        $conf['mysql']['admin_password'] = $tmp_mysql_server_admin_password;
        $conf['mysql']['database'] = $tmp_mysql_server_database;
        $conf['mysql']['charset'] = $tmp_mysql_server_charset;
        $finished = true;
    } else {
        swriteln($inst->lng('Unable to connect to the specified MySQL server').' '.mysql_error());
    }
} while ($finished == false);
unset($finished);
// Resolve the IP address of the MySQL hostname.
$tmp = explode(':',$conf['mysql']['host']);
if(!$conf['mysql']['ip'] = gethostbyname($tmp[0])) die('Unable to resolve hostname'.$tmp[0]);
unset($tmp);
//** Initializing database connection
include_once('lib/mysql.lib.php');
$inst->db = new db();
//** Begin with standard or expert installation
if($install_mode == 'standard') {
    //* Create the MySQL database
    $inst->configure_database();
    //* Insert the Server record into the database
    $inst->add_database_server_record();
    //* Configure Postfix
    $inst->configure_postfix();
    //* Configure jailkit
    swriteln('Configuring Jailkit');
    $inst->configure_jailkit();
    if($conf['dovecot']['installed'] == true) {
        //* Configure Dovecot
        swriteln('Configuring Dovecot');
        $inst->configure_dovecot();
    } else {
        //* 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 Getmail
    swriteln('Configuring Getmail');
    $inst->configure_getmail();
    //* Configure Pureftpd
    swriteln('Configuring Pureftpd');
    $inst->configure_pureftpd();
    //* Configure DNS
    if($conf['powerdns']['installed'] == true) {
        swriteln('Configuring PowerDNS');
        $inst->configure_powerdns();
    } elseif($conf['bind']['installed'] == true) {
        swriteln('Configuring BIND');
        $inst->configure_bind();
    } else {
        swriteln('Configuring MyDNS');
        $inst->configure_mydns();
    }
    //* Configure Apache
    swriteln('Configuring Apache');
    $inst->configure_apache();
    //** Configure Vlogger
    swriteln('Configuring Vlogger');
    $inst->configure_vlogger();
    //** Configure apps vhost
    swriteln('Configuring Apps vhost');
    $inst->configure_apps_vhost();
    //* Configure Firewall
    swriteln('Configuring Firewall');
    $inst->configure_firewall();
    //* Configure ISPConfig
    swriteln('Installing ISPConfig');
    //** Customize the port ISPConfig runs on
    $conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080');
    $inst->install_ispconfig();
    //* Configure DBServer
    swriteln('Configuring DBServer');
    $inst->configure_dbserver();
    //* Configure ISPConfig
    swriteln('Installing ISPConfig crontab');
    $inst->install_crontab();
    swriteln('Restarting services ...');
    if($conf['mysql']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mysql']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' restart');
    if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
    if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
    if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
    if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
    if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
    if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
    if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
    if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
    if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
    if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
    if($conf['apache']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['apache']['init_script']))                 system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
    if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script']))                system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
    if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
    if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
    if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
}else{
    //* In expert mode, we select the services in the following steps, only db is always available
    $conf['services']['mail'] = false;
    $conf['services']['web'] = false;
    $conf['services']['dns'] = false;
    $conf['services']['db'] = true;
    //** Get Server ID
    // $conf['server_id'] = $inst->free_query('Unique Numeric ID of the server','1');
    // Server ID is an autoInc value of the mysql database now
    if(strtolower($inst->simple_query('Shall this server join an existing ISPConfig multiserver setup',array('y','n'),'n')) == 'y') {
        $conf['mysql']['master_slave_setup'] = 'y';
        //** Get MySQL root credentials
        $finished = false;
        do {
            $tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host']);
            $tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user']);
            $tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password']);
            $tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database']);
            //* Initialize the MySQL server connection
            if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
                $conf['mysql']['master_host'] = $tmp_mysql_server_host;
                $conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
                $conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password;
                $conf['mysql']['master_database'] = $tmp_mysql_server_database;
                $finished = true;
            } else {
                swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error());
            }
        } while ($finished == false);
        unset($finished);
        // initialize the connection to the master database
        $inst->dbmaster = new db();
        if($inst->dbmaster->linkId) $inst->dbmaster->closeConn();
        $inst->dbmaster->dbHost = $conf['mysql']["master_host"];
        $inst->dbmaster->dbName = $conf['mysql']["master_database"];
        $inst->dbmaster->dbUser = $conf['mysql']["master_admin_user"];
        $inst->dbmaster->dbPass = $conf['mysql']["master_admin_password"];
    } else {
        // the master DB is the same then the slave DB
        $inst->dbmaster = $inst->db;
    }
    //* Create the mysql database
    $inst->configure_database();
    //* Insert the Server record into the database
    swriteln('Adding ISPConfig server record to database.');
    swriteln('');
    $inst->add_database_server_record();
    if(strtolower($inst->simple_query('Configure Mail', array('y','n') ,'y') ) == 'y') {
        $conf['services']['mail'] = true;
        //* Configure Postfix
        swriteln('Configuring Postfix');
        $inst->configure_postfix();
        if($conf['dovecot']['installed'] == true) {
            //* Configure dovecot
            swriteln('Configuring Dovecot');
            $inst->configure_dovecot();
        } else {
            //* 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 Getmail
        swriteln('Configuring Getmail');
        $inst->configure_getmail();
        if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
        if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
        if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
        if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
        if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
        if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
        if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
        if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
        if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
        if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
    }
    //** Configure Jailkit
    if(strtolower($inst->simple_query('Configure Jailkit', array('y','n'),'y') ) == 'y') {
        swriteln('Configuring Jailkit');
        $inst->configure_jailkit();
    }
    //** Configure Pureftpd
    if(strtolower($inst->simple_query('Configure FTP Server', array('y','n'),'y') ) == 'y') {
        swriteln('Configuring Pureftpd');
        $inst->configure_pureftpd();
        if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'])) system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
    }
    //** Configure DNS
    if(strtolower($inst->simple_query('Configure DNS Server',array('y','n'),'y')) == 'y') {
        $conf['services']['dns'] = true;
        //* Configure DNS
        if($conf['powerdns']['installed'] == true) {
            swriteln('Configuring PowerDNS');
            $inst->configure_powerdns();
            if($conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
        } elseif($conf['bind']['installed'] == true) {
            swriteln('Configuring BIND');
            $inst->configure_bind();
            if($conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
        } else {
            swriteln('Configuring MyDNS');
            $inst->configure_mydns();
            if($conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
        }
    }
    //** Configure Apache
    swriteln("\nHint: If this server shall run the ISPConfig interface, select 'y' in the 'Configure Apache Server' option.\n");
    if(strtolower($inst->simple_query('Configure Apache Server',array('y','n'),'y')) == 'y') {
        $conf['services']['web'] = true;
        swriteln('Configuring Apache');
        $inst->configure_apache();
        //** Configure Vlogger
        swriteln('Configuring Vlogger');
        $inst->configure_vlogger();
        //** Configure apps vhost
        swriteln('Configuring Apps vhost');
        $inst->configure_apps_vhost();
    }
    //** Configure Firewall
    if(strtolower($inst->simple_query('Configure Firewall Server',array('y','n'),'y')) == 'y') {
        swriteln('Configuring Firewall');
        $inst->configure_firewall();
    }
    //** Configure ISPConfig :-)
    if(strtolower($inst->simple_query('Install ISPConfig Web Interface',array('y','n'),'y')) == 'y') {
        swriteln('Installing ISPConfig');
        //** We want to check if the server is a module or cgi based php enabled server
        //** TODO: Don't always ask for this somehow ?
        /*
        $fast_cgi = $inst->simple_query('CGI PHP Enabled Server?', array('yes','no'),'no');
        if($fast_cgi == 'yes') {
             $alias = $inst->free_query('Script Alias', '/php/');
             $path = $inst->free_query('Script Alias Path', '/path/to/cgi/bin');
             $conf['apache']['vhost_cgi_alias'] = sprintf('ScriptAlias %s %s', $alias, $path);
        } else {
             $conf['apache']['vhost_cgi_alias'] = "";
        }
        */
        //** Customise the port ISPConfig runs on
        $conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080');
        if(strtolower($inst->simple_query('Enable SSL for the ISPConfig web interface',array('y','n'),'y')) == 'y') {
            $inst->make_ispconfig_ssl_cert();
        }
        $inst->install_ispconfig_interface = true;
    } else {
        $inst->install_ispconfig_interface = false;
    }
    $inst->install_ispconfig();
    //* Configure DBServer
    swriteln('Configuring DBServer');
    $inst->configure_dbserver();
    //* Configure ISPConfig
    swriteln('Installing ISPConfig crontab');
    $inst->install_crontab();
    if($conf['apache']['init_script'] != '' && @is_file($conf['init_scripts'].'/'.$conf['apache']['init_script'])) system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
} //* << $install_mode / 'Standard' or Genius
echo "Installation completed.\n";
?>
<?php
/*
Copyright (c) 2007-2010, 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.
*/
error_reporting(E_ALL|E_STRICT);
//** The banner on the command line
echo "\n\n".str_repeat('-',80)."\n";
echo " _____ ___________   _____              __ _         ____
|_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
  | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
 _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
 \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
                                              __/ |
                                             |___/ ";
echo "\n".str_repeat('-',80)."\n";
echo "\n\n>> Initial configuration  \n\n";
//** 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');
//** Ensure that current working directory is install directory
$cur_dir = getcwd();
if(realpath(dirname(__FILE__)) != $cur_dir) {
    chdir( realpath(dirname(__FILE__)) );
}
//** Install logfile
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
//** Check for existing installation
/*if(is_dir("/usr/local/ispconfig")) {
    die('We will stop here. There is already a ISPConfig installation, use the update script to update this installation.');
}*/
//** Get distribution identifier
$dist = get_distname();
if($dist['id'] == '') die('Linux distribution or version not recognized.');
//** Include the distribution-specific installer class library and configuration
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php');
include_once('dist/lib/'.$dist['id'].'.lib.php');
include_once('dist/conf/'.$dist['id'].'.conf.php');
//****************************************************************************************************
//** Installer Interface
//****************************************************************************************************
$inst = new installer();
swriteln($inst->lng('    Following will be a few questions for primary configuration so be careful.'));
swriteln($inst->lng('    Default values are in [brackets] and can be accepted with <ENTER>.'));
swriteln($inst->lng('    Tap in "quit" (without the quotes) to stop the installer.'."\n\n"));
//** Check log file is writable (probably not root or sudo)
if(!is_writable(dirname(ISPC_LOG_FILE))){
    die("ERROR: Cannot write to the ".dirname(ISPC_LOG_FILE)." directory. Are you root or sudo ?\n\n");
}
if(is_dir('/root/ispconfig') || is_dir('/home/admispconfig')) {
    die('This software cannot be installed on a server wich runs ISPConfig 2.x.');
}
if(is_dir('/usr/local/ispconfig')) {
    die('ISPConfig 3 installation found. Please use update.php instead if install.php to update the installation.');
}
//** Detect the installed applications
$inst->find_installed_apps();
//** Select the language
$conf['language'] = $inst->simple_query('Select language', array('en','de'), 'en');
//** Select installation mode
$install_mode = $inst->simple_query('Installation mode', array('standard','expert'), 'standard');
//** Get the hostname
$tmp_out = array();
exec('hostname -f', $tmp_out);
$conf['hostname'] = $inst->free_query('Full qualified hostname (FQDN) of the server, eg server1.domain.tld ', $tmp_out[0]);
unset($tmp_out);
// Check if the mysql functions are loaded in PHP
if(!function_exists('mysql_connect')) die('No PHP MySQL functions available. Please ensure that the PHP MySQL module is loaded.');
//** Get MySQL root credentials
$finished = false;
do {
    $tmp_mysql_server_host = $inst->free_query('MySQL server hostname', $conf['mysql']['host']);
    $tmp_mysql_server_admin_user = $inst->free_query('MySQL root username', $conf['mysql']['admin_user']);
    $tmp_mysql_server_admin_password = $inst->free_query('MySQL root password', $conf['mysql']['admin_password']);
    $tmp_mysql_server_database = $inst->free_query('MySQL database to create', $conf['mysql']['database']);
    $tmp_mysql_server_charset = $inst->free_query('MySQL charset', $conf['mysql']['charset']);
    //* Initialize the MySQL server connection
    if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
        $conf['mysql']['host'] = $tmp_mysql_server_host;
        $conf['mysql']['admin_user'] = $tmp_mysql_server_admin_user;
        $conf['mysql']['admin_password'] = $tmp_mysql_server_admin_password;
        $conf['mysql']['database'] = $tmp_mysql_server_database;
        $conf['mysql']['charset'] = $tmp_mysql_server_charset;
        $finished = true;
    } else {
        swriteln($inst->lng('Unable to connect to the specified MySQL server').' '.mysql_error());
    }
} while ($finished == false);
unset($finished);
// Resolve the IP address of the MySQL hostname.
$tmp = explode(':',$conf['mysql']['host']);
if(!$conf['mysql']['ip'] = gethostbyname($tmp[0])) die('Unable to resolve hostname'.$tmp[0]);
unset($tmp);
//** Initializing database connection
include_once('lib/mysql.lib.php');
$inst->db = new db();
//** Begin with standard or expert installation
if($install_mode == 'standard') {
    //* Create the MySQL database
    $inst->configure_database();
    //* Insert the Server record into the database
    $inst->add_database_server_record();
    //* Configure Postfix
    $inst->configure_postfix();
    //* Configure Mailman
    $inst->configure_mailman('install');
    //* Configure jailkit
    swriteln('Configuring Jailkit');
    $inst->configure_jailkit();
    if($conf['dovecot']['installed'] == true) {
        //* Configure Dovecot
        swriteln('Configuring Dovecot');
        $inst->configure_dovecot();
    } else {
        //* 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 Getmail
    swriteln('Configuring Getmail');
    $inst->configure_getmail();
    //* Configure Pureftpd
    swriteln('Configuring Pureftpd');
    $inst->configure_pureftpd();
    //* Configure DNS
    if($conf['powerdns']['installed'] == true) {
        swriteln('Configuring PowerDNS');
        $inst->configure_powerdns();
    } elseif($conf['bind']['installed'] == true) {
        swriteln('Configuring BIND');
        $inst->configure_bind();
    } else {
        swriteln('Configuring MyDNS');
        $inst->configure_mydns();
    }
    //* Configure Apache
    swriteln('Configuring Apache');
    $inst->configure_apache();
    //** Configure Vlogger
    swriteln('Configuring Vlogger');
    $inst->configure_vlogger();
    //** Configure apps vhost
    swriteln('Configuring Apps vhost');
    $inst->configure_apps_vhost();
    //* Configure Firewall
    swriteln('Configuring Firewall');
    $inst->configure_firewall();
    //* Configure ISPConfig
    swriteln('Installing ISPConfig');
    //** Customize the port ISPConfig runs on
    $conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080');
    $inst->install_ispconfig();
    //* Configure DBServer
    swriteln('Configuring DBServer');
    $inst->configure_dbserver();
    //* Configure ISPConfig
    swriteln('Installing ISPConfig crontab');
    $inst->install_crontab();
    swriteln('Restarting services ...');
    if($conf['mysql']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mysql']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' restart');
    if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
    if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
    if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
    if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
    if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
    if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
    if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
    if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
    if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
    if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
    if($conf['mailman']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mailman']['init_script']))         system($conf['init_scripts'].'/'.$conf['mailman']['init_script'].' restart');
    if($conf['apache']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['apache']['init_script']))                 system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
    if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script']))                system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
    if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
    if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
    if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
}else{
    //* In expert mode, we select the services in the following steps, only db is always available
    $conf['services']['mail'] = false;
    $conf['services']['web'] = false;
    $conf['services']['dns'] = false;
    $conf['services']['db'] = true;
    //** Get Server ID
    // $conf['server_id'] = $inst->free_query('Unique Numeric ID of the server','1');
    // Server ID is an autoInc value of the mysql database now
    if(strtolower($inst->simple_query('Shall this server join an existing ISPConfig multiserver setup',array('y','n'),'n')) == 'y') {
        $conf['mysql']['master_slave_setup'] = 'y';
        //** Get MySQL root credentials
        $finished = false;
        do {
            $tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host']);
            $tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user']);
            $tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password']);
            $tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database']);
            //* Initialize the MySQL server connection
            if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
                $conf['mysql']['master_host'] = $tmp_mysql_server_host;
                $conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
                $conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password;
                $conf['mysql']['master_database'] = $tmp_mysql_server_database;
                $finished = true;
            } else {
                swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error());
            }
        } while ($finished == false);
        unset($finished);
        // initialize the connection to the master database
        $inst->dbmaster = new db();
        if($inst->dbmaster->linkId) $inst->dbmaster->closeConn();
        $inst->dbmaster->dbHost = $conf['mysql']["master_host"];
        $inst->dbmaster->dbName = $conf['mysql']["master_database"];
        $inst->dbmaster->dbUser = $conf['mysql']["master_admin_user"];
        $inst->dbmaster->dbPass = $conf['mysql']["master_admin_password"];
    } else {
        // the master DB is the same then the slave DB
        $inst->dbmaster = $inst->db;
    }
    //* Create the mysql database
    $inst->configure_database();
    //* Insert the Server record into the database
    swriteln('Adding ISPConfig server record to database.');
    swriteln('');
    $inst->add_database_server_record();
    if(strtolower($inst->simple_query('Configure Mail', array('y','n') ,'y') ) == 'y') {
        $conf['services']['mail'] = true;
        //* Configure Postfix
        swriteln('Configuring Postfix');
        $inst->configure_postfix();
        //* Configure Mailman
        swriteln('Configuring Mailman');
        $inst->configure_mailman();
        if($conf['dovecot']['installed'] == true) {
            //* Configure dovecot
            swriteln('Configuring Dovecot');
            $inst->configure_dovecot();
        } else {
            //* 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 Getmail
        swriteln('Configuring Getmail');
        $inst->configure_getmail();
        if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
        if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
        if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
        if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
        if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
        if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
        if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
        if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
        if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
        if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
        if($conf['mailman']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mailman']['init_script']))         system($conf['init_scripts'].'/'.$conf['mailman']['init_script'].' restart');
    }
    //** Configure Jailkit
    if(strtolower($inst->simple_query('Configure Jailkit', array('y','n'),'y') ) == 'y') {
        swriteln('Configuring Jailkit');
        $inst->configure_jailkit();
    }
    //** Configure Pureftpd
    if(strtolower($inst->simple_query('Configure FTP Server', array('y','n'),'y') ) == 'y') {
        swriteln('Configuring Pureftpd');
        $inst->configure_pureftpd();
        if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'])) system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
    }
    //** Configure DNS
    if(strtolower($inst->simple_query('Configure DNS Server',array('y','n'),'y')) == 'y') {
        $conf['services']['dns'] = true;
        //* Configure DNS
        if($conf['powerdns']['installed'] == true) {
            swriteln('Configuring PowerDNS');
            $inst->configure_powerdns();
            if($conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
        } elseif($conf['bind']['installed'] == true) {
            swriteln('Configuring BIND');
            $inst->configure_bind();
            if($conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
        } else {
            swriteln('Configuring MyDNS');
            $inst->configure_mydns();
            if($conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
        }
    }
    //** Configure Apache
    swriteln("\nHint: If this server shall run the ISPConfig interface, select 'y' in the 'Configure Apache Server' option.\n");
    if(strtolower($inst->simple_query('Configure Apache Server',array('y','n'),'y')) == 'y') {
        $conf['services']['web'] = true;
        swriteln('Configuring Apache');
        $inst->configure_apache();
        //** Configure Vlogger
        swriteln('Configuring Vlogger');
        $inst->configure_vlogger();
        //** Configure apps vhost
        swriteln('Configuring Apps vhost');
        $inst->configure_apps_vhost();
    }
    //** Configure Firewall
    if(strtolower($inst->simple_query('Configure Firewall Server',array('y','n'),'y')) == 'y') {
        swriteln('Configuring Firewall');
        $inst->configure_firewall();
    }
    //** Configure ISPConfig :-)
    if(strtolower($inst->simple_query('Install ISPConfig Web Interface',array('y','n'),'y')) == 'y') {
        swriteln('Installing ISPConfig');
        //** We want to check if the server is a module or cgi based php enabled server
        //** TODO: Don't always ask for this somehow ?
        /*
        $fast_cgi = $inst->simple_query('CGI PHP Enabled Server?', array('yes','no'),'no');
        if($fast_cgi == 'yes') {
             $alias = $inst->free_query('Script Alias', '/php/');
             $path = $inst->free_query('Script Alias Path', '/path/to/cgi/bin');
             $conf['apache']['vhost_cgi_alias'] = sprintf('ScriptAlias %s %s', $alias, $path);
        } else {
             $conf['apache']['vhost_cgi_alias'] = "";
        }
        */
        //** Customise the port ISPConfig runs on
        $conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080');
        if(strtolower($inst->simple_query('Enable SSL for the ISPConfig web interface',array('y','n'),'y')) == 'y') {
            $inst->make_ispconfig_ssl_cert();
        }
        $inst->install_ispconfig_interface = true;
    } else {
        $inst->install_ispconfig_interface = false;
    }
    $inst->install_ispconfig();
    //* Configure DBServer
    swriteln('Configuring DBServer');
    $inst->configure_dbserver();
    //* Configure ISPConfig
    swriteln('Installing ISPConfig crontab');
    $inst->install_crontab();
    if($conf['apache']['init_script'] != '' && @is_file($conf['init_scripts'].'/'.$conf['apache']['init_script'])) system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
} //* << $install_mode / 'Standard' or Genius
echo "Installation completed.\n";
?>
install/lib/installer_base.lib.php
@@ -1,1726 +1,1780 @@
<?php
/*
Copyright (c) 2007-2010, 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;
    public $conf;
    public $install_ispconfig_interface = true;
    public $is_update = false; // true if it is an update, falsi if it is a new install
    public function __construct() {
        global $conf; //TODO: maybe $conf  should be passed to constructor
        //$this->conf = $conf;
    }
    //: TODO  Implement the translation function and language files for the installer.
    public function lng($text) {
        return $text;
    }
    public function error($msg) {
        die('ERROR: '.$msg."\n");
    }
    public function simple_query($query, $answers, $default) {
        $finished = false;
        do {
            $answers_str = implode(',', $answers);
            swrite($this->lng($query).' ('.$answers_str.') ['.$default.']: ');
            $input = sread();
            //* Stop the installation
            if($input == 'quit') {
                swriteln($this->lng("Installation terminated by user.\n"));
                die();
            }
            //* Select the default
            if($input == '') {
                $answer = $default;
                $finished = true;
            }
            //* Set answer id valid
            if(in_array($input, $answers)) {
                $answer = $input;
                $finished = true;
            }
        } while ($finished == false);
        swriteln();
        return $answer;
    }
    public function free_query($query,$default) {
        swrite($this->lng($query).' ['.$default.']: ');
        $input = sread();
        //* Stop the installation
        if($input == 'quit') {
            swriteln($this->lng("Installation terminated by user.\n"));
            die();
        }
        $answer =  ($input == '') ? $default : $input;
        swriteln();
        return $answer;
    }
    /*
    // TODO: this function is not used atmo I think - pedro
    function request_language(){
        swriteln(lng('Enter your language'));
        swriteln(lng('de, en'));
    }
    */
    //** Detect installed applications
    public function find_installed_apps() {
        global $conf;
        if(is_installed('mysql') || is_installed('mysqld')) $conf['mysql']['installed'] = true;
        if(is_installed('postfix')) $conf['postfix']['installed'] = true;
        if(is_installed('apache') || is_installed('apache2') || is_installed('httpd')) $conf['apache']['installed'] = true;
        if(is_installed('getmail')) $conf['getmail']['installed'] = true;
        if(is_installed('courierlogger')) $conf['courier']['installed'] = true;
        if(is_installed('dovecot')) $conf['dovecot']['installed'] = true;
        if(is_installed('saslsauthd')) $conf['saslauthd']['installed'] = true;
        if(is_installed('amavisd-new')) $conf['amavis']['installed'] = true;
        if(is_installed('clamdscan')) $conf['clamav']['installed'] = true;
        if(is_installed('pure-ftpd') || is_installed('pure-ftpd-wrapper')) $conf['pureftpd']['installed'] = true;
        if(is_installed('mydns') || is_installed('mydns-ng')) $conf['mydns']['installed'] = true;
        if(is_installed('jk_chrootsh')) $conf['jailkit']['installed'] = true;
        if(is_installed('pdns_server') || is_installed('pdns_control')) $conf['powerdns']['installed'] = true;
        if(is_installed('named') || is_installed('bind') || is_installed('bind9')) $conf['bind']['installed'] = true;
    }
    /** Create the database for ISPConfig */
    public function configure_database() {
        global $conf;
        //** Create the database
        if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$conf['mysql']['database'].' DEFAULT CHARACTER SET '.$conf['mysql']['charset'])) {
            $this->error('Unable to create MySQL database: '.$conf['mysql']['database'].'.');
        }
        //* Set the database name in the DB library
        $this->db->dbName = $conf['mysql']['database'];
        //* Load the database dump into the database, if database contains no tables
        $db_tables = $this->db->getTables();
        if(count($db_tables) > 0) {
            $this->error('Stopped: Database already contains some tables.');
        } else {
            if($conf['mysql']['admin_password'] == '') {
                caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' '".$conf['mysql']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null",
                        __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql');
            } else {
                caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' -p'".$conf['mysql']['admin_password']."' '".$conf['mysql']['database']."' < '".ISPC_INSTALL_ROOT."/install/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.');
            }
            //* Load system.ini into the sys_ini table
            $system_ini = $this->db->quote(rf('tpl/system.ini.master'));
            $this->db->query("UPDATE sys_ini SET config = '$system_ini' WHERE sysini_id = 1");
        }
    }
    //** Create the server record in the database
    public function add_database_server_record() {
        global $conf;
        if($conf['mysql']['host'] == 'localhost') {
            $from_host = 'localhost';
        } else {
            $from_host = $conf['hostname'];
        }
        // Delete ISPConfig user in the local database, in case that it exists
        $this->db->query("DELETE FROM mysql.user WHERE User = '".$conf['mysql']['ispconfig_user']."' AND Host = '".$from_host."';");
        $this->db->query("DELETE FROM mysql.db WHERE Db = '".$conf['mysql']['database']."' AND Host = '".$from_host."';");
        $this->db->query('FLUSH PRIVILEGES;');
        //* Create the ISPConfig database user in the local database
        $query = 'GRANT SELECT, INSERT, UPDATE, DELETE ON '.$conf['mysql']['database'].".* "
                ."TO '".$conf['mysql']['ispconfig_user']."'@'".$from_host."' "
                ."IDENTIFIED BY '".$conf['mysql']['ispconfig_password']."';";
        if(!$this->db->query($query)) {
            $this->error('Unable to create database user: '.$conf['mysql']['ispconfig_user'].' Error: '.$this->db->errorMessage);
        }
        //* Reload database privelages
        $this->db->query('FLUSH PRIVILEGES;');
        //* Set the database name in the DB library
        $this->db->dbName = $conf['mysql']['database'];
        $tpl_ini_array = ini_to_array(rf('tpl/server.ini.master'));
        //* Update further distribution specific parameters for server config here
        //* HINT: Every line added here has to be added in update.lib.php too!!
        $tpl_ini_array['web']['vhost_conf_dir'] = $conf['apache']['vhost_conf_dir'];
        $tpl_ini_array['web']['vhost_conf_enabled_dir'] = $conf['apache']['vhost_conf_enabled_dir'];
        $tpl_ini_array['jailkit']['jailkit_chroot_app_programs'] = $conf['jailkit']['jailkit_chroot_app_programs'];
        $tpl_ini_array['fastcgi']['fastcgi_phpini_path'] = $conf['fastcgi']['fastcgi_phpini_path'];
        $tpl_ini_array['fastcgi']['fastcgi_starter_path'] = $conf['fastcgi']['fastcgi_starter_path'];
        $tpl_ini_array['server']['hostname'] = $conf['hostname'];
        $tpl_ini_array['server']['ip_address'] = @gethostbyname($conf['hostname']);
        $tpl_ini_array['web']['website_basedir'] = $conf['web']['website_basedir'];
        $tpl_ini_array['web']['website_path'] = $conf['web']['website_path'];
        $tpl_ini_array['web']['website_symlinks'] = $conf['web']['website_symlinks'];
        $tpl_ini_array['cron']['crontab_dir'] = $conf['cron']['crontab_dir'];
        $tpl_ini_array['web']['security_level'] = 20;
        $tpl_ini_array['web']['user'] = $conf['apache']['user'];
        $tpl_ini_array['web']['group'] = $conf['apache']['group'];
        $tpl_ini_array['web']['php_ini_path_apache'] = $conf['apache']['php_ini_path_apache'];
        $tpl_ini_array['web']['php_ini_path_cgi'] = $conf['apache']['php_ini_path_cgi'];
        $tpl_ini_array['mail']['pop3_imap_daemon'] = ($conf['dovecot']['installed'] == true)?'dovecot':'courier';
        $tpl_ini_array['mail']['mail_filter_syntax'] = ($conf['dovecot']['installed'] == true)?'sieve':'maildrop';
        $tpl_ini_array['dns']['bind_user'] = $conf['bind']['bind_user'];
        $tpl_ini_array['dns']['bind_group'] = $conf['bind']['bind_group'];
        $tpl_ini_array['dns']['bind_zonefiles_dir'] = $conf['bind']['bind_zonefiles_dir'];
        $tpl_ini_array['dns']['named_conf_path'] = $conf['bind']['named_conf_path'];
        $tpl_ini_array['dns']['named_conf_local_path'] = $conf['bind']['named_conf_local_path'];
        if (array_key_exists('awstats', $conf)) {
            foreach ($conf['awstats'] as $aw_sett => $aw_value) {
                $tpl_ini_array['web']['awstats_'.$aw_sett] = $aw_value;
            }
        }
        $server_ini_content = array_to_ini($tpl_ini_array);
        $server_ini_content = mysql_real_escape_string($server_ini_content);
        $mail_server_enabled = ($conf['services']['mail'])?1:0;
        $web_server_enabled = ($conf['services']['web'])?1:0;
        $dns_server_enabled = ($conf['services']['dns'])?1:0;
        $file_server_enabled = ($conf['services']['file'])?1:0;
        $db_server_enabled = ($conf['services']['db'])?1:0;
        $vserver_server_enabled = ($conf['services']['vserver'])?1:0;
        //** Get the database version number based on the patchfiles
        $found = true;
        $current_db_version = 1;
        while($found == true) {
            $next_db_version = intval($current_db_version + 1);
            $patch_filename = realpath(dirname(__FILE__).'/../').'/sql/incremental/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.sql';
            if(is_file($patch_filename)) {
                $current_db_version = $next_db_version;
            } else {
                $found = false;
            }
        }
        $current_db_version = intval($current_db_version);
        if($conf['mysql']['master_slave_setup'] == 'y') {
            //* Insert the server record in master DB
            $sql = "INSERT INTO `server` (`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`, `dbversion`) VALUES (1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version);";
            $this->dbmaster->query($sql);
            $conf['server_id'] = $this->dbmaster->insertID();
            $conf['server_id'] = $conf['server_id'];
            //* Insert the same record in the local DB
            $sql = "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`, `dbversion`) VALUES ('".$conf['server_id']."',1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version);";
            $this->db->query($sql);
            //* username for the ispconfig user
            $conf['mysql']['master_ispconfig_user'] = 'ispcsrv'.$conf['server_id'];
            $this->grant_master_database_rights();
        } else {
            //* Insert the server, if its not a mster / slave setup
            $sql = "INSERT INTO `server` (`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`, `dbversion`) VALUES (1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version);";
            $this->db->query($sql);
            $conf['server_id'] = $this->db->insertID();
            $conf['server_id'] = $conf['server_id'];
        }
    }
    public function grant_master_database_rights() {
        global $conf;
        /*
         * The following code is a little bit tricky:
         * * If we HAVE a master-slave - Setup then the client has to grant the rights for himself
         *   at the master.
         * * If we DO NOT have a master-slave - Setup then we have two possibilities
         *   1) it is a single server
         *   2) it is the MASTER of n clients
        */
        $hosts = array();
        if($conf['mysql']['master_slave_setup'] == 'y') {
            /*
             * it is a master-slave - Setup so the slave has to grant its rights in the master
             * database
             */
            //* insert the ispconfig user in the remote server
            $from_host = $conf['hostname'];
            $from_ip = gethostbyname($conf['hostname']);
            $hosts[$from_host]['user'] = $conf['mysql']['master_ispconfig_user'];
            $hosts[$from_host]['db'] = $conf['mysql']['master_database'];
            $hosts[$from_host]['pwd'] = $conf['mysql']['master_ispconfig_password'];
            $hosts[$from_ip]['user'] = $conf['mysql']['master_ispconfig_user'];
            $hosts[$from_ip]['db'] = $conf['mysql']['master_database'];
            $hosts[$from_ip]['pwd'] = $conf['mysql']['master_ispconfig_password'];
        } else{
            /*
             * it is NOT a master-slave - Setup so we have to find out all clients and their
             * host
             */
            $query = "SELECT Host, User FROM mysql.user WHERE User like 'ispcsrv%' ORDER BY User, Host";
            $data = $this->dbmaster->queryAllRecords($query);
            if($data === false) {
                $this->error('Unable to get the user rights: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            foreach ($data as $item){
                $hosts[$item['Host']]['user'] = $item['User'];
                $hosts[$item['Host']]['db'] = $conf['mysql']['master_database'];
                $hosts[$item['Host']]['pwd'] = ''; // the user already exists, so we need no pwd!
            }
        }
        if(count($hosts) > 0) {
        foreach($hosts as $host => $value) {
            /*
             * If a pwd exists, this means, we have to add the new user (and his pwd).
             * if not, the user already exists and we do not need the pwd
             */
            if ($value['pwd'] != ''){
                $query = "CREATE USER '".$value['user']."'@'".$host."' IDENTIFIED BY '" . $value['pwd'] . "'";
                $this->dbmaster->query($query); // ignore the error
            }
            /*
             *  Try to delete all rights of the user in case that it exists.
             *  In Case that it will not exist, do nothing (ignore the error!)
             */
            $query = "REVOKE ALL PRIVILEGES, GRANT OPTION FROM '".$value['user']."'@'".$host."' ";
            $this->dbmaster->query($query); // ignore the error
            //* Create the ISPConfig database user in the remote database
            $query = "GRANT SELECT ON ".$value['db'].".`server` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT ON ".$value['db'].".`sys_log` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE(`status`) ON ".$value['db'].".`sys_datalog` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE(`status`) ON ".$value['db'].".`software_update_inst` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE(`updated`) ON ".$value['db'].".`server` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE (`ssl_request`, `ssl_cert`, `ssl_action`) ON ".$value['db'].".`web_domain` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT ON ".$value['db'].".`sys_group` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE (`action_state`, `response`) ON ".$value['db'].".`sys_remoteaction` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT , DELETE ON ".$value['db'].".`monitor_data` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT, UPDATE ON ".$value['db'].".`mail_traffic` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT, UPDATE ON ".$value['db'].".`web_traffic` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
        }
        /*
         * It is all done. Relod the rights...
         */
        $this->dbmaster->query('FLUSH PRIVILEGES;');
        }
    }
    //** writes postfix configuration files
    public function process_postfix_config($configfile) {
        global $conf;
        $config_dir = $conf['postfix']['config_dir'].'/';
        $full_file_name = $config_dir.$configfile;
        //* Backup exiting file
        if(is_file($full_file_name)) {
            copy($full_file_name, $config_dir.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        wf($full_file_name, $content);
    }
    public function configure_jailkit() {
        global $conf;
        $cf = $conf['jailkit'];
        $config_dir = $cf['config_dir'];
        $jk_init = $cf['jk_init'];
        $jk_chrootsh = $cf['jk_chrootsh'];
        if (is_dir($config_dir)) {
            if(is_file($config_dir.'/'.$jk_init)) copy($config_dir.'/'.$jk_init, $config_dir.'/'.$jk_init.'~');
            if(is_file($config_dir.'/'.$jk_chrootsh.'.master')) copy($config_dir.'/'.$jk_chrootsh.'.master', $config_dir.'/'.$jk_chrootsh.'~');
            copy('tpl/'.$jk_init.'.master', $config_dir.'/'.$jk_init);
            copy('tpl/'.$jk_chrootsh.'.master', $config_dir.'/'.$jk_chrootsh);
        }
    }
    public function configure_postfix($options = '') {
        global $conf;
        $cf = $conf['postfix'];
        $config_dir = $cf['config_dir'];
        if(!is_dir($config_dir)) {
            $this->error("The postfix configuration directory '$config_dir' does not exist.");
        }
        //* mysql-virtual_domains.cf
        $this->process_postfix_config('mysql-virtual_domains.cf');
        //* mysql-virtual_forwardings.cf
        $this->process_postfix_config('mysql-virtual_forwardings.cf');
        //* mysql-virtual_mailboxes.cf
        $this->process_postfix_config('mysql-virtual_mailboxes.cf');
        //* mysql-virtual_email2email.cf
        $this->process_postfix_config('mysql-virtual_email2email.cf');
        //* mysql-virtual_transports.cf
        $this->process_postfix_config('mysql-virtual_transports.cf');
        //* mysql-virtual_recipient.cf
        $this->process_postfix_config('mysql-virtual_recipient.cf');
        //* mysql-virtual_sender.cf
        $this->process_postfix_config('mysql-virtual_sender.cf');
        //* mysql-virtual_client.cf
        $this->process_postfix_config('mysql-virtual_client.cf');
        //* mysql-virtual_relaydomains.cf
        $this->process_postfix_config('mysql-virtual_relaydomains.cf');
        //* mysql-virtual_relayrecipientmaps.cf
        $this->process_postfix_config('mysql-virtual_relayrecipientmaps.cf');
        //* Changing mode and group of the new created config files.
        caselog('chmod o= '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null',
                __FILE__, __LINE__, 'chmod on mysql-virtual_*.cf*', 'chmod on mysql-virtual_*.cf* failed');
        caselog('chgrp '.$cf['group'].' '.$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 '.$cf['vmail_groupid'].' '.$cf['vmail_groupname'];
        if(!is_group($cf['vmail_groupname'])) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m';
        if(!is_user($cf['vmail_username'])) 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 [::1]/128',
                'virtual_alias_domains =',
                'virtual_alias_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_forwardings.cf, mysql:'.$config_dir.'/mysql-virtual_email2email.cf',
                'virtual_mailbox_domains = proxy:mysql:'.$config_dir.'/mysql-virtual_domains.cf',
                'virtual_mailbox_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_mailboxes.cf',
                'virtual_mailbox_base = '.$cf['vmail_mailbox_base'],
                'virtual_uid_maps = static:'.$cf['vmail_userid'],
                'virtual_gid_maps = static:'.$cf['vmail_groupid'],
                'smtpd_sasl_auth_enable = yes',
                'broken_sasl_auth_clients = yes',
                'smtpd_sasl_authenticated_header = yes',
                'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:'.$config_dir.'/mysql-virtual_recipient.cf, reject_unauth_destination',
                'smtpd_use_tls = yes',
                'smtpd_tls_security_level = may',
                'smtpd_tls_cert_file = '.$config_dir.'/smtpd.cert',
                'smtpd_tls_key_file = '.$config_dir.'/smtpd.key',
                'transport_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_transports.cf',
                'relay_domains = mysql:'.$config_dir.'/mysql-virtual_relaydomains.cf',
                'relay_recipient_maps = mysql:'.$config_dir.'/mysql-virtual_relayrecipientmaps.cf',
                'virtual_create_maildirsize = yes',
                'virtual_maildir_extended = yes',
                'virtual_mailbox_limit_maps = proxy:mysql:'.$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:'.$config_dir.'/mysql-virtual_sender.cf',
                'smtpd_client_restrictions = check_client_access mysql:'.$config_dir.'/mysql-virtual_client.cf',
                'maildrop_destination_concurrency_limit = 1',
                'maildrop_destination_recipient_limit   = 1',
                'virtual_transport = maildrop',
                'header_checks = regexp:'.$config_dir.'/header_checks',
                'mime_header_checks = regexp:'.$config_dir.'/mime_header_checks',
                'nested_header_checks = regexp:'.$config_dir.'/nested_header_checks',
                'body_checks = regexp:'.$config_dir.'/body_checks'
        );
        //* Create the header and body check files
        touch($config_dir.'/header_checks');
        touch($config_dir.'/mime_header_checks');
        touch($config_dir.'/nested_header_checks');
        touch($config_dir.'/body_checks');
        //* Make a backup copy of the main.cf file
        copy($config_dir.'/main.cf', $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);
        }
        if(!stristr($options,'dont-create-certs')) {
            //* Create the SSL certificate
            $command = 'cd '.$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= '.$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/';
        if(is_file('/var/run/courier/authdaemon/')) caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
        //* Changing maildrop lines in posfix master.cf
        if(is_file($config_dir.'/master.cf')) {
            copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
        }
        if(is_file($config_dir.'/master.cf~')) {
            chmod($config_dir.'/master.cf~', 0400);
        }
        $configfile = $config_dir.'/master.cf';
        $content = rf($configfile);
        $content = str_replace('flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}',
                'flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d '.$cf['vmail_username'].' ${extension} ${recipient} ${user} ${nexthop} ${sender}',
                $content);
        wf($configfile, $content);
        //* Writing the Maildrop mailfilter file
        $configfile = 'mailfilter';
        if(is_file($cf['vmail_mailbox_base'].'/.'.$configfile)) {
            copy($cf['vmail_mailbox_base'].'/.'.$configfile, $cf['vmail_mailbox_base'].'/.'.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{dist_postfix_vmail_mailbox_base}', $cf['vmail_mailbox_base'], $content);
        wf($cf['vmail_mailbox_base'].'/.'.$configfile, $content);
        //* Create the directory for the custom mailfilters
        if(!is_dir($cf['vmail_mailbox_base'].'/mailfilters')) {
            $command = 'mkdir '.$cf['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 '.$cf['vmail_username'].':'.$cf['vmail_groupname'].' '.$cf['vmail_mailbox_base'].'/.mailfilter';
        caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'chmod -R 600 '.$cf['vmail_mailbox_base'].'/.mailfilter';
        caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
    }
    public function configure_saslauthd() {
        global $conf;
        $configfile = 'sasl_smtpd.conf';
        if(is_file($conf['postfix']['config_dir'].'/sasl/smtpd.conf')) copy($conf['postfix']['config_dir'].'/sasl/smtpd.conf',$conf['postfix']['config_dir'].'/sasl/smtpd.conf~');
        if(is_file($conf['postfix']['config_dir'].'/sasl/smtpd.conf~')) chmod($conf['postfix']['config_dir'].'/sasl/smtpd.conf~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_ip}',$conf['mysql']['ip'],$content);
        wf($conf['postfix']['config_dir'].'/sasl/smtpd.conf',$content);
        // TODO: Chmod and chown on the config file
        // Recursively create the spool directory
        if(!@is_dir('/var/spool/postfix/var/run/saslauthd')) mkdir('/var/spool/postfix/var/run/saslauthd', 0755, true);
        // Edit the file /etc/default/saslauthd
        $configfile = $conf['saslauthd']['config'];
        if(is_file($configfile)) copy($configfile,$configfile.'~');
        if(is_file($configfile.'~')) chmod($configfile.'~', 0400);
        $content = rf($configfile);
        $content = str_replace('START=no','START=yes',$content);
        // Debian
        $content = str_replace('OPTIONS="-c"','OPTIONS="-m /var/spool/postfix/var/run/saslauthd -r"',$content);
        // Ubuntu
        $content = str_replace('OPTIONS="-c -m /var/run/saslauthd"','OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"',$content);
        wf($configfile,$content);
        // Edit the file /etc/init.d/saslauthd
        $configfile = $conf['init_scripts'].'/'.$conf['saslauthd']['init_script'];
        $content = rf($configfile);
        $content = str_replace('PIDFILE=$RUN_DIR/saslauthd.pid','PIDFILE="/var/spool/postfix/var/run/${NAME}/saslauthd.pid"',$content);
        wf($configfile,$content);
        // add the postfix user to the sasl group (at least necessary for Ubuntu 8.04 and most likely Debian Lenny as well.
        exec('adduser postfix sasl');
    }
    public function configure_pam() {
        global $conf;
        $pam = $conf['pam'];
        //* configure pam for SMTP authentication agains the ispconfig database
        $configfile = 'pamd_smtp';
        if(is_file($pam.'/smtp'))    copy($pam.'/smtp', $pam.'/smtp~');
        if(is_file($pam.'/smtp~'))   chmod($pam.'/smtp~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
        wf($pam.'/smtp', $content);
        // On some OSes smtp is world readable which allows for reading database information.  Removing world readable rights should have no effect.
        if(is_file($pam.'/smtp'))    exec("chmod o= $pam/smtp");
        chmod($pam.'/smtp', 0660);
        chown($pam.'/smtp', 'daemon');
        chgrp($pam.'/smtp', 'daemon');
    }
    public function configure_courier() {
        global $conf;
        $config_dir = $conf['courier']['config_dir'];
        //* authmysqlrc
        $configfile = 'authmysqlrc';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        chmod($config_dir.'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        wf($config_dir.'/'.$configfile, $content);
        chmod($config_dir.'/'.$configfile, 0660);
        chown($config_dir.'/'.$configfile, 'daemon');
        chgrp($config_dir.'/'.$configfile, 'daemon');
        //* authdaemonrc
        $configfile = $config_dir.'/authdaemonrc';
        if(is_file($configfile)) {
            copy($configfile, $configfile.'~');
        }
        if(is_file($configfile.'~')) {
            chmod($configfile.'~', 0400);
        }
        $content = rf($configfile);
        $content = str_replace('authmodulelist="authpam"', 'authmodulelist="authmysql"', $content);
        wf($configfile, $content);
    }
    public function configure_dovecot() {
        global $conf;
        $config_dir = $conf['dovecot']['config_dir'];
        //* Configure master.cf and add a line for deliver
        if(is_file($conf['postfix']['config_dir'].'/master.cf')) {
            copy($conf['postfix']['config_dir'].'/master.cf', $conf['postfix']['config_dir'].'/master.cf~2');
        }
        if(is_file($conf['postfix']['config_dir'].'/master.cf~')) {
            chmod($conf['postfix']['config_dir'].'/master.cf~2', 0400);
        }
        $content = rf($conf['postfix']['config_dir'].'/master.cf');
        // Only add the content if we had not addded it before
        if(!stristr($content,'dovecot/deliver')) {
            $deliver_content = 'dovecot   unix  -       n       n       -       -       pipe'."\n".'  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
            af($conf['postfix']['config_dir'].'/master.cf',$deliver_content);
        }
        unset($content);
        unset($deliver_content);
        //* Reconfigure postfix to use dovecot authentication
        // Adding the amavisd commands to the postfix configuration
        $postconf_commands = array (
                'dovecot_destination_recipient_limit = 1',
                'virtual_transport = dovecot',
                'smtpd_sasl_type = dovecot',
                'smtpd_sasl_path = private/auth'
        );
        // Make a backup copy of the main.cf file
        copy($conf['postfix']['config_dir'].'/main.cf',$conf['postfix']['config_dir'].'/main.cf~3');
        // 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");
        }
        //* copy dovecot.conf
        $configfile = 'dovecot.conf';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        copy('tpl/debian_dovecot.conf.master',$config_dir.'/'.$configfile);
        //* dovecot-sql.conf
        $configfile = 'dovecot-sql.conf';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        chmod($config_dir.'/'.$configfile.'~', 0400);
        $content = rf('tpl/debian_dovecot-sql.conf.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        wf($config_dir.'/'.$configfile, $content);
        chmod($config_dir.'/'.$configfile, 0600);
        chown($config_dir.'/'.$configfile, 'root');
        chgrp($config_dir.'/'.$configfile, 'root');
    }
    public function configure_amavis() {
        global $conf;
        // amavisd user config file
        $configfile = 'amavisd_user_config';
        if(is_file($conf['amavis']['config_dir'].'/conf.d/50-user')) copy($conf['amavis']['config_dir'].'/conf.d/50-user',$conf['amavis']['config_dir'].'/50-user~');
        if(is_file($conf['amavis']['config_dir'].'/conf.d/50-user~')) chmod($conf['amavis']['config_dir'].'/conf.d/50-user~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_port}',$conf['mysql']['port'],$content);
        $content = str_replace('{mysql_server_ip}',$conf['mysql']['ip'],$content);
        wf($conf['amavis']['config_dir'].'/conf.d/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['postfix']['config_dir'].'/main.cf',$conf['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['postfix']['config_dir'].'/master.cf')) copy($conf['postfix']['config_dir'].'/master.cf',$conf['postfix']['config_dir'].'/master.cf~');
        $content = rf($conf['postfix']['config_dir'].'/master.cf');
        // Only add the content if we had not addded it before
        if(!stristr($content,'127.0.0.1:10025')) {
            unset($content);
            $content = rf('tpl/master_cf_amavis.master');
            af($conf['postfix']['config_dir'].'/master.cf',$content);
        }
        unset($content);
        // Add the clamav user to the amavis group
        exec('adduser clamav amavis');
    }
    public function configure_spamassassin() {
        global $conf;
        //* Enable spamasasssin on debian and ubuntu
        $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);
    }
    public function configure_getmail() {
        global $conf;
        $config_dir = $conf['getmail']['config_dir'];
        if(!@is_dir($config_dir)) mkdir(escapeshellcmd($config_dir), 0700, true);
        $command = 'useradd -d '.$config_dir.' getmail';
        if(!is_user('getmail')) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = "chown -R getmail $config_dir";
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = "chmod -R 700 $config_dir";
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
    }
    public function configure_pureftpd() {
        global $conf;
        $config_dir = $conf['pureftpd']['config_dir'];
        //* configure pure-ftpd for MySQL authentication against the ispconfig database
        $configfile = 'db/mysql.conf';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        if(is_file($config_dir.'/'.$configfile.'~')) {
            chmod($config_dir.'/'.$configfile.'~', 0400);
        }
        $content = rf('tpl/pureftpd_mysql.conf.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        wf($config_dir.'/'.$configfile, $content);
        chmod($config_dir.'/'.$configfile, 0600);
        chown($config_dir.'/'.$configfile, 'root');
        chgrp($config_dir.'/'.$configfile, 'root');
        // **enable chrooting
        //exec('mkdir -p '.$config_dir.'/conf/ChrootEveryone');
        exec('echo "yes" > '.$config_dir.'/conf/ChrootEveryone');
        exec('echo "yes" > '.$config_dir.'/conf/BrokenClientsCompatibility');
        exec('echo "yes" > '.$config_dir.'/conf/DisplayDotFiles');
        if(is_file('/etc/default/pure-ftpd-common')) {
            replaceLine('/etc/default/pure-ftpd-common','STANDALONE_OR_INETD=inetd','STANDALONE_OR_INETD=standalone',1,0);
            replaceLine('/etc/default/pure-ftpd-common','VIRTUALCHROOT=false','VIRTUALCHROOT=true',1,0);
        }
        if(is_file('/etc/inetd.conf')) {
            replaceLine('/etc/inetd.conf','/usr/sbin/pure-ftpd-wrapper','#ftp     stream  tcp     nowait  root    /usr/sbin/tcpd /usr/sbin/pure-ftpd-wrapper',0,0);
            if(is_file($conf['init_scripts'].'/'.'openbsd-inetd')) exec($conf['init_scripts'].'/'.'openbsd-inetd restart');
        }
        if(!is_file('/etc/pure-ftpd/conf/DontResolve')) exec('echo "yes" > /etc/pure-ftpd/conf/DontResolve');
    }
    public function configure_mydns() {
        global $conf;
        // configure pam for SMTP authentication agains the ispconfig database
        $configfile = 'mydns.conf';
        if(is_file($conf['mydns']['config_dir'].'/'.$configfile)) copy($conf['mydns']['config_dir'].'/'.$configfile,$conf['mydns']['config_dir'].'/'.$configfile.'~');
        if(is_file($conf['mydns']['config_dir'].'/'.$configfile.'~')) chmod($conf['mydns']['config_dir'].'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        $content = str_replace('{server_id}',$conf['server_id'],$content);
        wf($conf['mydns']['config_dir'].'/'.$configfile,$content);
        chmod($conf['mydns']['config_dir'].'/'.$configfile, 0600);
        chown($conf['mydns']['config_dir'].'/'.$configfile, 'root');
        chgrp($conf['mydns']['config_dir'].'/'.$configfile, 'root');
    }
    public function configure_powerdns() {
        global $conf;
        //* Create the database
        if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$conf['powerdns']['database'].' DEFAULT CHARACTER SET '.$conf['mysql']['charset'])) {
            $this->error('Unable to create MySQL database: '.$conf['powerdns']['database'].'.');
        }
        //* Create the ISPConfig database user in the local database
        $query = "GRANT ALL ON `".$conf['powerdns']['database']."` . * TO '".$conf['mysql']['ispconfig_user']."'@'localhost';";
        if(!$this->db->query($query)) {
            $this->error('Unable to create user for powerdns database Error: '.$this->db->errorMessage);
        }
        //* Reload database privelages
        $this->db->query('FLUSH PRIVILEGES;');
        //* load the powerdns databse dump
        if($conf['mysql']['admin_password'] == '') {
            caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' '".$conf['powerdns']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/powerdns.sql' &> /dev/null",
                    __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in powerdns.sql');
        } else {
            caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' -p'".$conf['mysql']['admin_password']."' '".$conf['powerdns']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/powerdns.sql' &> /dev/null",
                    __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in powerdns.sql');
        }
        //* Create the powerdns config file
        $configfile = 'pdns.local';
        if(is_file($conf['powerdns']['config_dir'].'/'.$configfile)) copy($conf['powerdns']['config_dir'].'/'.$configfile,$conf['powerdns']['config_dir'].'/'.$configfile.'~');
        if(is_file($conf['powerdns']['config_dir'].'/'.$configfile.'~')) chmod($conf['powerdns']['config_dir'].'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{powerdns_database}',$conf['powerdns']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        wf($conf['powerdns']['config_dir'].'/'.$configfile,$content);
        chmod($conf['powerdns']['config_dir'].'/'.$configfile, 0600);
        chown($conf['powerdns']['config_dir'].'/'.$configfile, 'root');
        chgrp($conf['powerdns']['config_dir'].'/'.$configfile, 'root');
    }
    public function configure_bind() {
        global $conf;
        //* Check if the zonefile directory has a slash at the end
        $content=$conf['bind']['bind_zonefiles_dir'];
        if(substr($content,-1,1) != '/') {
            $content .= '/';
        }
        //* Create the slave subdirectory
        $content .= 'slave';
        if(!@is_dir($content)) mkdir($content, 0770, true);
        //* Chown the slave subdirectory to $conf['bind']['bind_user']
        chown($content, $conf['bind']['bind_user']);
        chgrp($content, $conf['bind']['bind_group']);
    }
    public function configure_apache() {
        global $conf;
        //* Create the logging directory for the vhost logfiles
        if(!@is_dir($conf['ispconfig_log_dir'].'/httpd')) mkdir($conf['ispconfig_log_dir'].'/httpd', 0755, true);
        if(is_file('/etc/suphp/suphp.conf')) {
            replaceLine('/etc/suphp/suphp.conf','php=php:/usr/bin','x-httpd-suphp="php:/usr/bin/php-cgi"',0);
            //replaceLine('/etc/suphp/suphp.conf','docroot=','docroot=/var/clients',0);
            replaceLine('/etc/suphp/suphp.conf','umask=0077','umask=0022',0);
        }
        if(is_file('/etc/apache2/sites-enabled/000-default')) {
            replaceLine('/etc/apache2/sites-available/000-default','NameVirtualHost *','NameVirtualHost *:80',1,0);
            replaceLine('/etc/apache2/sites-available/000-default','<VirtualHost *>','<VirtualHost *:80>',1,0);
        }
        if(is_file('/etc/apache2/ports.conf')) {
            // add a line "Listen 443" to ports conf if line does not exist
            replaceLine('/etc/apache2/ports.conf','Listen 443','Listen 443',1);
        }
        //* Copy the ISPConfig configuration include
        $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        // copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf');
        $content = rf('tpl/apache_ispconfig.conf.master');
        $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'");
        if(is_array($records) && count($records) > 0) {
            foreach($records as $rec) {
                $content .= 'NameVirtualHost '.$rec['ip_address'].":80\n";
                $content .= 'NameVirtualHost '.$rec['ip_address'].":443\n";
            }
        }
        $content .= "\n";
        wf($vhost_conf_dir.'/ispconfig.conf',$content);
        if(!@is_link($vhost_conf_enabled_dir.'/000-ispconfig.conf')) {
            symlink($vhost_conf_dir.'/ispconfig.conf',$vhost_conf_enabled_dir.'/000-ispconfig.conf');
        }
        //* make sure that webalizer finds its config file when it is directly in /etc
        if(@is_file('/etc/webalizer.conf') && !@is_dir('/etc/webalizer')) {
            mkdir('/etc/webalizer');
            symlink('/etc/webalizer.conf','/etc/webalizer/webalizer.conf');
        }
        if(is_file('/etc/webalizer/webalizer.conf')) {
            // Change webalizer mode to incremental
            replaceLine('/etc/webalizer/webalizer.conf','#IncrementalName','IncrementalName webalizer.current',0,0);
            replaceLine('/etc/webalizer/webalizer.conf','#Incremental','Incremental     yes',0,0);
            replaceLine('/etc/webalizer/webalizer.conf','#HistoryName','HistoryName     webalizer.hist',0,0);
        }
        // Check the awsatst script
        if(!is_dir('/usr/share/awstats/tools')) exec('mkdir -p /usr/share/awstats/tools');
        if(!file_exists('/usr/share/awstats/tools/awstats_buildstaticpages.pl') && file_exists('/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl')) symlink('/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl','/usr/share/awstats/tools/awstats_buildstaticpages.pl');
        //* add a sshusers group
        $command = 'groupadd sshusers';
        if(!is_group('sshusers')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
    }
    public function configure_firewall() {
        global $conf;
        $dist_init_scripts = $conf['init_scripts'];
        if(is_dir('/etc/Bastille.backup')) caselog('rm -rf /etc/Bastille.backup', __FILE__, __LINE__);
        if(is_dir('/etc/Bastille')) caselog('mv -f /etc/Bastille /etc/Bastille.backup', __FILE__, __LINE__);
        @mkdir('/etc/Bastille', 0700);
        if(is_dir('/etc/Bastille.backup/firewall.d')) caselog('cp -pfr /etc/Bastille.backup/firewall.d /etc/Bastille/', __FILE__, __LINE__);
        caselog('cp -f tpl/bastille-firewall.cfg.master /etc/Bastille/bastille-firewall.cfg', __FILE__, __LINE__);
        caselog('chmod 644 /etc/Bastille/bastille-firewall.cfg', __FILE__, __LINE__);
        $content = rf('/etc/Bastille/bastille-firewall.cfg');
        $content = str_replace('{DNS_SERVERS}', '', $content);
        $tcp_public_services = '';
        $udp_public_services = '';
        $row = $this->db->queryOneRecord('SELECT * FROM '.$conf["mysql"]["database"].'.firewall WHERE server_id = '.intval($conf['server_id']));
        if(trim($row['tcp_port']) != '' || trim($row['udp_port']) != '') {
            $tcp_public_services = trim(str_replace(',',' ',$row['tcp_port']));
            $udp_public_services = trim(str_replace(',',' ',$row['udp_port']));
        } else {
            $tcp_public_services = '21 22 25 53 80 110 143 443 3306 8080 10000';
            $udp_public_services = '53';
        }
        if(!stristr($tcp_public_services, $conf['apache']['vhost_port'])) {
            $tcp_public_services .= ' '.intval($conf['apache']['vhost_port']);
            if($row['tcp_port'] != '') $this->db->query("UPDATE firewall SET tcp_port = tcp_port + ',".intval($conf['apache']['vhost_port'])."' WHERE server_id = ".intval($conf['server_id']));
        }
        $content = str_replace('{TCP_PUBLIC_SERVICES}', $tcp_public_services, $content);
        $content = str_replace('{UDP_PUBLIC_SERVICES}', $udp_public_services, $content);
        wf('/etc/Bastille/bastille-firewall.cfg', $content);
        if(is_file($dist_init_scripts.'/bastille-firewall')) caselog('mv -f '.$dist_init_scripts.'/bastille-firewall '.$dist_init_scripts.'/bastille-firewall.backup', __FILE__, __LINE__);
        caselog('cp -f apps/bastille-firewall '.$dist_init_scripts, __FILE__, __LINE__);
        caselog('chmod 700 '.$dist_init_scripts.'/bastille-firewall', __FILE__, __LINE__);
        if(is_file('/sbin/bastille-ipchains')) caselog('mv -f /sbin/bastille-ipchains /sbin/bastille-ipchains.backup', __FILE__, __LINE__);
        caselog('cp -f apps/bastille-ipchains /sbin', __FILE__, __LINE__);
        caselog('chmod 700 /sbin/bastille-ipchains', __FILE__, __LINE__);
        if(is_file('/sbin/bastille-netfilter')) caselog('mv -f /sbin/bastille-netfilter /sbin/bastille-netfilter.backup', __FILE__, __LINE__);
        caselog('cp -f apps/bastille-netfilter /sbin', __FILE__, __LINE__);
        caselog('chmod 700 /sbin/bastille-netfilter', __FILE__, __LINE__);
        if(!@is_dir('/var/lock/subsys')) caselog('mkdir /var/lock/subsys', __FILE__, __LINE__);
        exec('which ipchains &> /dev/null', $ipchains_location, $ret_val);
        if(!is_file('/sbin/ipchains') && !is_link('/sbin/ipchains') && $ret_val == 0) phpcaselog(@symlink(shell_exec('which ipchains'), '/sbin/ipchains'), 'create symlink', __FILE__, __LINE__);
        unset($ipchains_location);
        exec('which iptables &> /dev/null', $iptables_location, $ret_val);
        if(!is_file('/sbin/iptables') && !is_link('/sbin/iptables') && $ret_val == 0) phpcaselog(@symlink(trim(shell_exec('which iptables')), '/sbin/iptables'), 'create symlink', __FILE__, __LINE__);
        unset($iptables_location);
    }
    public function configure_vlogger() {
        global $conf;
        //** Configure vlogger to use traffic logging to mysql (master) db
        $configfile = 'vlogger-dbi.conf';
        if(is_file($conf['vlogger']['config_dir'].'/'.$configfile)) copy($conf['vlogger']['config_dir'].'/'.$configfile,$conf['vlogger']['config_dir'].'/'.$configfile.'~');
        if(is_file($conf['vlogger']['config_dir'].'/'.$configfile.'~')) chmod($conf['vlogger']['config_dir'].'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        if($conf['mysql']['master_slave_setup'] == 'y') {
            $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['master_ispconfig_user'],$content);
            $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['master_ispconfig_password'], $content);
            $content = str_replace('{mysql_server_database}',$conf['mysql']['master_database'],$content);
            $content = str_replace('{mysql_server_ip}',$conf['mysql']['master_host'],$content);
        } else {
            $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
            $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
            $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
            $content = str_replace('{mysql_server_ip}',$conf['mysql']['host'],$content);
        }
        wf($conf['vlogger']['config_dir'].'/'.$configfile,$content);
        chmod($conf['vlogger']['config_dir'].'/'.$configfile, 0600);
        chown($conf['vlogger']['config_dir'].'/'.$configfile, 'root');
        chgrp($conf['vlogger']['config_dir'].'/'.$configfile, 'root');
    }
    public function configure_apps_vhost() {
        global $conf;
        //* Create the ispconfig apps vhost user and group
        $apps_vhost_user = escapeshellcmd($conf['web']['apps_vhost_user']);
        $apps_vhost_group = escapeshellcmd($conf['web']['apps_vhost_group']);
        $install_dir = escapeshellcmd($conf['web']['website_basedir'].'/apps');
        $command = 'groupadd '.$apps_vhost_user;
        if(!is_group($apps_vhost_group)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'useradd -g '.$apps_vhost_group.' -d '.$install_dir.' '.$apps_vhost_group;
        if(!is_user($apps_vhost_user)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'adduser '.$conf['apache']['user'].' '.$apps_vhost_group;
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        if(!@is_dir($install_dir)) mkdir($install_dir, 0755, true);
        chown($install_dir, $apps_vhost_user);
        chgrp($install_dir, $apps_vhost_group);
        //* Copy the apps vhost file
        $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        $apps_vhost_servername = ($conf['web']['apps_vhost_servername'] == '')?'':'ServerName '.$conf['web']['apps_vhost_servername'];
        // Dont just copy over the virtualhost template but add some custom settings
        $content = rf('tpl/apache_apps.vhost.master');
        $content = str_replace('{apps_vhost_ip}', $conf['web']['apps_vhost_ip'], $content);
        $content = str_replace('{apps_vhost_port}', $conf['web']['apps_vhost_port'], $content);
        $content = str_replace('{apps_vhost_dir}', $conf['web']['website_basedir'].'/apps', $content);
        $content = str_replace('{website_basedir}', $conf['web']['website_basedir'], $content);
        $content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
        // comment out the listen directive if port is 80 or 443
        if($conf['web']['apps_vhost_ip'] == 80 or $conf['web']['apps_vhost_ip'] == 443) {
            $content = str_replace('{vhost_port_listen}', '#', $content);
        } else {
            $content = str_replace('{vhost_port_listen}', '', $content);
        }
        wf($vhost_conf_dir.'/apps.vhost', $content);
        //copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
        //* and create the symlink
        if($this->install_ispconfig_interface == true) {
            if(@is_link($vhost_conf_enabled_dir.'/apps.vhost')) unlink($vhost_conf_enabled_dir.'/apps.vhost');
            if(!@is_link($vhost_conf_enabled_dir.'/000-apps.vhost')) {
                symlink($vhost_conf_dir.'/apps.vhost',$vhost_conf_enabled_dir.'/000-apps.vhost');
            }
        }
        if(!is_file($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter')) {
            mkdir($conf['web']['website_basedir'].'/php-fcgi-scripts/apps', 0755, true);
            copy('tpl/apache_apps_fcgi_starter.master',$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
            exec('chmod +x '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
            exec('chown -R ispapps:ispapps '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps');
        }
    }
    public function make_ispconfig_ssl_cert() {
        global $conf;
        $install_dir = $conf['ispconfig_install_dir'];
        $ssl_crt_file = $install_dir.'/interface/ssl/ispserver.crt';
        $ssl_csr_file = $install_dir.'/interface/ssl/ispserver.csr';
        $ssl_key_file = $install_dir.'/interface/ssl/ispserver.key';
        if(!@is_dir($install_dir.'/interface/ssl')) mkdir($install_dir.'/interface/ssl', 0755, true);
        $ssl_pw = substr(md5(mt_rand()),0,6);
        exec("openssl genrsa -des3 -passout pass:$ssl_pw -out $ssl_key_file 4096");
        exec("openssl req -new -passin pass:$ssl_pw -passout pass:$ssl_pw -key $ssl_key_file -out $ssl_csr_file");
        exec("openssl req -x509 -passin pass:$ssl_pw -passout pass:$ssl_pw -key $ssl_key_file -in $ssl_csr_file -out $ssl_crt_file -days 3650");
        exec("openssl rsa -passin pass:$ssl_pw -in $ssl_key_file -out $ssl_key_file.insecure");
        rename($ssl_key_file,$ssl_key_file.'.secure');
        rename($ssl_key_file.'.insecure',$ssl_key_file);
    }
    public function install_ispconfig() {
        global $conf;
        $install_dir = $conf['ispconfig_install_dir'];
        //* Create the ISPConfig installation directory
        if(!@is_dir($install_dir)) {
            $command = "mkdir $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';
        if(!is_group('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'useradd -g ispconfig -d '.$install_dir.' ispconfig';
        if(!is_user('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* copy the ISPConfig interface part
        $command = 'cp -rf ../interface '.$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 '.$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
        // Replaced by a separate vhost definition for port 8080
        // $command = "ln -s $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 interface
        $configfile = 'config.inc.php';
        if(is_file($install_dir.'/interface/lib/'.$configfile)) {
            copy($install_dir.'/interface/lib/'.$configfile, $install_dir.'/interface/lib/'.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
        $content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
        $content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
        $content = str_replace('{language}', $conf['language'], $content);
        wf($install_dir.'/interface/lib/'.$configfile, $content);
        //* Create the config file for ISPConfig server
        $configfile = 'config.inc.php';
        if(is_file($install_dir.'/server/lib/'.$configfile)) {
            copy($install_dir.'/server/lib/'.$configfile, $install_dir.'/interface/lib/'.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
        $content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
        $content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
        $content = str_replace('{language}', $conf['language'], $content);
        wf($install_dir.'/server/lib/'.$configfile, $content);
        //* Create the config file for remote-actions (but only, if it does not exist, because
        //  the value is a autoinc-value and so changed by the remoteaction_core_module
        if (!file_exists($install_dir.'/server/lib/remote_action.inc.php')) {
            $content = '<?php' . "\n" . '$maxid_remote_action = 0;' . "\n" . '?>';
            wf($install_dir.'/server/lib/remote_action.inc.php', $content);
        }
        //* Enable the server modules and plugins.
        // TODO: Implement a selector which modules and plugins shall be enabled.
        $dir = $install_dir.'/server/mods-available/';
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
                        include_once($install_dir.'/server/mods-available/'.$file);
                        $module_name = substr($file,0,-8);
                        $tmp = new $module_name;
                        if($tmp->onInstall()) {
                            if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) {
                                @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
                                // @symlink($install_dir.'/server/mods-available/'.$file, '../mods-enabled/'.$file);
                            }
                            if (strpos($file, '_core_module') !== false) {
                                if(!@is_link($install_dir.'/server/mods-core/'.$file)) {
                                    @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file);
                                    // @symlink($install_dir.'/server/mods-available/'.$file, '../mods-core/'.$file);
                                }
                            }
                        }
                        unset($tmp);
                    }
                }
                closedir($dh);
            }
        }
        $dir = $install_dir.'/server/plugins-available/';
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
                        include_once($install_dir.'/server/plugins-available/'.$file);
                        $plugin_name = substr($file,0,-8);
                        $tmp = new $plugin_name;
                        if(method_exists($tmp,'onInstall') && $tmp->onInstall()) {
                            if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) {
                                @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
                                //@symlink($install_dir.'/server/plugins-available/'.$file, '../plugins-enabled/'.$file);
                            }
                            if (strpos($file, '_core_plugin') !== false) {
                                if(!@is_link($install_dir.'/server/plugins-core/'.$file)) {
                                    @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
                                    //@symlink($install_dir.'/server/plugins-available/'.$file, '../plugins-core/'.$file);
                                }
                            }
                        }
                        unset($tmp);
                    }
                }
                closedir($dh);
            }
        }
        // Update the server config
        $mail_server_enabled = ($conf['services']['mail'])?1:0;
        $web_server_enabled = ($conf['services']['web'])?1:0;
        $dns_server_enabled = ($conf['services']['dns'])?1:0;
        $file_server_enabled = ($conf['services']['file'])?1:0;
        $db_server_enabled = ($conf['services']['db'])?1:0;
        $vserver_server_enabled = ($conf['services']['vserver'])?1:0;
        $sql = "UPDATE `server` SET mail_server = '$mail_server_enabled', web_server = '$web_server_enabled', dns_server = '$dns_server_enabled', file_server = '$file_server_enabled', db_server = '$db_server_enabled', vserver_server = '$vserver_server_enabled' WHERE server_id = ".intval($conf['server_id']);
        if($conf['mysql']['master_slave_setup'] == 'y') {
            $this->dbmaster->query($sql);
            $this->db->query($sql);
        } else {
            $this->db->query($sql);
        }
        //* Chmod the files
        $command = 'chmod -R 750 '.$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 '.$install_dir;
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* Make the global language file directory group writable
        exec("chmod -R 770 $install_dir/interface/lib/lang");
        //* Make the temp directory for language file exports writable
        if(is_dir($install_dir.'/interface/web/temp')) exec("chmod -R 770 $install_dir/interface/web/temp");
        //* Make all interface language file directories group writable
        $handle = @opendir($install_dir.'/interface/web');
        while ($file = @readdir ($handle)) {
            if ($file != '.' && $file != '..') {
                if(@is_dir($install_dir.'/interface/web'.'/'.$file.'/lib/lang')) {
                    $handle2 = opendir($install_dir.'/interface/web'.'/'.$file.'/lib/lang');
                    chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang',0770);
                    while ($lang_file = @readdir ($handle2)) {
                        if ($lang_file != '.' && $lang_file != '..') {
                            chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang/'.$lang_file,0770);
                        }
                    }
                }
            }
        }
        //* make sure that the server config file (not the interface one) is only readable by the root user
        chmod($install_dir.'/server/lib/'.$configfile, 0600);
        chown($install_dir.'/server/lib/'.$configfile, 'root');
        chgrp($install_dir.'/server/lib/'.$configfile, 'root');
        chmod($install_dir.'/server/lib/remote_action.inc.php', 0600);
        chown($install_dir.'/server/lib/remote_action.inc.php', 'root');
        chgrp($install_dir.'/server/lib/remote_action.inc.php', 'root');
        if(@is_file($install_dir.'/server/lib/mysql_clientdb.conf')) {
            chmod($install_dir.'/server/lib/mysql_clientdb.conf', 0600);
            chown($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
            chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
        }
        // 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");
        //* Make the shell scripts executable
        $command = "chmod +x $install_dir/server/scripts/*.sh";
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* Copy the ISPConfig vhost for the controlpanel
        $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        // Dont just copy over the virtualhost template but add some custom settings
        $content = rf('tpl/apache_ispconfig.vhost.master');
        $content = str_replace('{vhost_port}', $conf['apache']['vhost_port'], $content);
        // comment out the listen directive if port is 80 or 443
        if($conf['apache']['vhost_port'] == 80 or $conf['apache']['vhost_port'] == 443) {
            $content = str_replace('{vhost_port_listen}', '#', $content);
        } else {
            $content = str_replace('{vhost_port_listen}', '', $content);
        }
        if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
            $content = str_replace('{ssl_comment}', '', $content);
        } else {
            $content = str_replace('{ssl_comment}', '#', $content);
        }
        wf($vhost_conf_dir.'/ispconfig.vhost', $content);
        //copy('tpl/apache_ispconfig.vhost.master', $vhost_conf_dir.'/ispconfig.vhost');
        //* and create the symlink
        if($this->install_ispconfig_interface == true && $this->is_update == false) {
            if(@is_link($vhost_conf_enabled_dir.'/ispconfig.vhost')) unlink($vhost_conf_enabled_dir.'/ispconfig.vhost');
            if(!@is_link($vhost_conf_enabled_dir.'/000-ispconfig.vhost')) {
                symlink($vhost_conf_dir.'/ispconfig.vhost',$vhost_conf_enabled_dir.'/000-ispconfig.vhost');
            }
        }
        if(!is_file('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) {
            mkdir('/var/www/php-fcgi-scripts/ispconfig', 0755, true);
            copy('tpl/apache_ispconfig_fcgi_starter.master','/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
            exec('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
            symlink($install_dir.'/interface/web','/var/www/ispconfig');
            exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig');
        }
        //* Install the update script
        if(is_file('/usr/local/bin/ispconfig_update_from_svn.sh')) unlink('/usr/local/bin/ispconfig_update_from_svn.sh');
        chown($install_dir.'/server/scripts/update_from_svn.sh', 'root');
        chmod($install_dir.'/server/scripts/update_from_svn.sh', 0700);
        chown($install_dir.'/server/scripts/update_from_tgz.sh', 'root');
        chmod($install_dir.'/server/scripts/update_from_tgz.sh', 0700);
        chown($install_dir.'/server/scripts/ispconfig_update.sh', 'root');
        chmod($install_dir.'/server/scripts/ispconfig_update.sh', 0700);
        if(!is_link('/usr/local/bin/ispconfig_update_from_svn.sh')) symlink($install_dir.'/server/scripts/ispconfig_update.sh','/usr/local/bin/ispconfig_update_from_svn.sh');
        if(!is_link('/usr/local/bin/ispconfig_update.sh')) symlink($install_dir.'/server/scripts/ispconfig_update.sh','/usr/local/bin/ispconfig_update.sh');
        //* Make the logs readable for the ispconfig user
        if(@is_file('/var/log/mail.log')) exec('chmod +r /var/log/mail.log');
        if(@is_file('/var/log/mail.warn')) exec('chmod +r /var/log/mail.warn');
        if(@is_file('/var/log/mail.err')) exec('chmod +r /var/log/mail.err');
        if(@is_file('/var/log/messages')) exec('chmod +r /var/log/messages');
        if(@is_file('/var/log/clamav/clamav.log')) exec('chmod +r /var/log/clamav/clamav.log');
        if(@is_file('/var/log/clamav/freshclam.log')) exec('chmod +r /var/log/clamav/freshclam.log');
        //* Create the ispconfig log file and directory
        if(!is_file($conf['ispconfig_log_dir'].'/ispconfig.log')) {
            if(!is_dir($conf['ispconfig_log_dir'])) mkdir($conf['ispconfig_log_dir'], 0755);
            touch($conf['ispconfig_log_dir'].'/ispconfig.log');
        }
        rename($install_dir.'/server/scripts/run-getmail.sh','/usr/local/bin/run-getmail.sh');
        if(is_user('getmail')) chown('/usr/local/bin/run-getmail.sh', 'getmail');
        chmod('/usr/local/bin/run-getmail.sh', 0744);
        //* Add Log-Rotation
        if (is_dir('/etc/logrotate.d')) {
            @unlink('/etc/logrotate.d/logispc3'); // ignore, if the file is not there
            /* We rotate these logs in cron_daily.php
            $fh = fopen('/etc/logrotate.d/logispc3', 'w');
            fwrite($fh,
                    "$conf['ispconfig_log_dir']/ispconfig.log { \n" .
                    "    weekly \n" .
                    "    missingok \n" .
                    "    rotate 4 \n" .
                    "    compress \n" .
                    "    delaycompress \n" .
                    "} \n" .
                    "$conf['ispconfig_log_dir']/cron.log { \n" .
                    "    weekly \n" .
                    "    missingok \n" .
                    "    rotate 4 \n" .
                    "    compress \n" .
                    "    delaycompress \n" .
                    "}");
            fclose($fh);
            */
        }
    }
    public function configure_dbserver() {
        global $conf;
        //* If this server shall act as database server for client DB's, we configure this here
        $install_dir = $conf['ispconfig_install_dir'];
        // Create a file with the database login details which
        // are used to create the client databases.
        if(!is_dir($install_dir.'/server/lib')) {
            $command = "mkdir $install_dir/server/lib";
            caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        }
        $content = rf('tpl/mysql_clientdb.conf.master');
        $content = str_replace('{username}',$conf['mysql']['admin_user'],$content);
        $content = str_replace('{password}',$conf['mysql']['admin_password'], $content);
        wf($install_dir.'/server/lib/mysql_clientdb.conf',$content);
        chmod($install_dir.'/server/lib/mysql_clientdb.conf', 0600);
        chown($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
        chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
    }
    public function install_crontab() {
        global $conf;
        $install_dir = $conf['ispconfig_install_dir'];
        //* Root Crontab
        exec('crontab -u root -l > crontab.txt');
        $existing_root_cron_jobs = file('crontab.txt');
        // remove existing ispconfig cronjobs, in case the syntax has changed
        foreach($existing_root_cron_jobs as $key => $val) {
            if(stristr($val,$install_dir)) unset($existing_root_cron_jobs[$key]);
        }
        $root_cron_jobs = array(
                "* * * * * ".$install_dir."/server/server.sh > /dev/null 2>> ".$conf['ispconfig_log_dir']."/cron.log",
                "30 00 * * * ".$install_dir."/server/cron_daily.sh > /dev/null 2>> ".$conf['ispconfig_log_dir']."/cron.log"
        );
        foreach($root_cron_jobs as $cron_job) {
            if(!in_array($cron_job."\n", $existing_root_cron_jobs)) {
                $existing_root_cron_jobs[] = $cron_job."\n";
            }
        }
        file_put_contents('crontab.txt', $existing_root_cron_jobs);
        exec('crontab -u root crontab.txt &> /dev/null');
        unlink('crontab.txt');
        //* Getmail crontab
        if(is_user('getmail')) {
            $cf = $conf['getmail'];
            exec('crontab -u getmail -l > crontab.txt');
            $existing_cron_jobs = file('crontab.txt');
            $cron_jobs = array(
                    '*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> '.$conf['ispconfig_log_dir'].'/cron.log'
            );
            // remove existing ispconfig cronjobs, in case the syntax has changed
            foreach($existing_cron_jobs as $key => $val) {
                if(stristr($val,'getmail')) unset($existing_cron_jobs[$key]);
            }
            foreach($cron_jobs as $cron_job) {
                if(!in_array($cron_job."\n", $existing_cron_jobs)) {
                    $existing_cron_jobs[] = $cron_job."\n";
                }
            }
            file_put_contents('crontab.txt', $existing_cron_jobs);
            exec('crontab -u getmail crontab.txt &> /dev/null');
            unlink('crontab.txt');
        }
        touch($conf['ispconfig_log_dir'].'/cron.log');
        chmod($conf['ispconfig_log_dir'].'/cron.log', 0666);
    }
    /**
     * Helper function - get the path to a template file based on
     * the local part of the filename. Checks first for the existence
     * of a distribution specific file and if not found looks in the
     * base template folder. Optionally the behaviour can be changed
     * by setting the 2nd parameter which will fetch the contents
     * of the template file and return it instead of the path. The 3rd
     * parameter further extends this behaviour by filtering the contents
     * by inserting the ispconfig database credentials using the {} placeholders.
     *
     * @param string $tLocal local part of filename
     * @param bool $tRf
     * @param bool $tDBCred
     * @return string Relative path to the chosen template file
     */
    protected function get_template_file($tLocal, $tRf=false, $tDBCred=false) {
        global $conf, $dist;
        $final_path = '';
        $dist_template = 'dist/tpl/'.strtolower($dist['name'])."/$tLocal.master";
        if (file_exists($dist_template)) {
            $final_path = $dist_template;
        } else {
            $final_path = "tpl/$tLocal.master";
        }
        if (!$tRf) {
            return $final_path;
        } else {
            return (!$tDBCred) ? rf($final_path) : $this->insert_db_credentials(rf($final_path));
        }
    }
    /**
     * Helper function - writes the contents to a config file
     * and performs a backup if the file exist. Additionally
     * if the file exists the new file will be given the
     * same rights and ownership as the original. Optionally the
     * rights and/or ownership can be overriden by appending umask,
     * user and group to the parameters. Providing only uid and gid
     * values will result in only a chown.
     *
     * @param $tConf
     * @param $tContents
     * @return bool
     */
    protected function write_config_file($tConf, $tContents) {
        // Backup config file before writing new contents and stat file
        if ( is_file($tConf) ) {
            $stat = exec('stat -c \'%a %U %G\' '.escapeshellarg($tConf), $output, $res);
            if ($res == 0) { // stat successfull
                list($access, $user, $group) = split(" ", $stat);
            }
            if ( copy($tConf, $tConf.'~') ) {
                chmod($tConf.'~', 0400);
            }
        }
        wf($tConf, $tContents); // write file
        if (func_num_args() >= 4) // override rights and/or ownership
        {
            $args = func_get_args();
            $output = array_slice($args, 2);
            switch (sizeof($output)) {
                case 3:
                    $umask = array_shift($output);
                    if (is_numeric($umask) && preg_match('/^0?[0-7]{3}$/', $umask)) {
                        $access = $umask;
                    }
                case 2:
                    if (is_user($output[0]) && is_group($output[1])) {
                        list($user,$group) = $output;
                    }
                    break;
            }
        }
        if (!empty($user) && !empty($group)) {
            chown($tConf, $user);
            chgrp($tConf, $group);
        }
        if (!empty($access)) {
            exec("chmod $access $tConf");
        }
    }
    /**
     * Helper function - filter the contents of a config
     * file by inserting the common ispconfig database
     * credentials.
     *
     * @param $tContents
     * @return string
     */
    protected function insert_db_credentials($tContents) {
        global $conf;
        $tContents = str_replace('{mysql_server_ispconfig_user}', $conf["mysql"]["ispconfig_user"], $tContents);
        $tContents = str_replace('{mysql_server_ispconfig_password}', $conf["mysql"]["ispconfig_password"], $tContents);
        $tContents = str_replace('{mysql_server_database}', $conf["mysql"]["database"], $tContents);
        $tContents = str_replace('{mysql_server_ip}', $conf["mysql"]["ip"], $tContents);
        $tContents = str_replace('{mysql_server_host}',$conf['mysql']['host'], $tContents);
        $tContents = str_replace('{mysql_server_port}',$conf["mysql"]["port"], $tContents);
        return $tContents;
    }
}
?>
<?php
/*
Copyright (c) 2007-2010, 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;
    public $conf;
    public $install_ispconfig_interface = true;
    public $is_update = false; // true if it is an update, falsi if it is a new install
    public function __construct() {
        global $conf; //TODO: maybe $conf  should be passed to constructor
        //$this->conf = $conf;
    }
    //: TODO  Implement the translation function and language files for the installer.
    public function lng($text) {
        return $text;
    }
    public function error($msg) {
        die('ERROR: '.$msg."\n");
    }
    public function simple_query($query, $answers, $default) {
        $finished = false;
        do {
            $answers_str = implode(',', $answers);
            swrite($this->lng($query).' ('.$answers_str.') ['.$default.']: ');
            $input = sread();
            //* Stop the installation
            if($input == 'quit') {
                swriteln($this->lng("Installation terminated by user.\n"));
                die();
            }
            //* Select the default
            if($input == '') {
                $answer = $default;
                $finished = true;
            }
            //* Set answer id valid
            if(in_array($input, $answers)) {
                $answer = $input;
                $finished = true;
            }
        } while ($finished == false);
        swriteln();
        return $answer;
    }
    public function free_query($query,$default) {
        swrite($this->lng($query).' ['.$default.']: ');
        $input = sread();
        //* Stop the installation
        if($input == 'quit') {
            swriteln($this->lng("Installation terminated by user.\n"));
            die();
        }
        $answer =  ($input == '') ? $default : $input;
        swriteln();
        return $answer;
    }
    /*
    // TODO: this function is not used atmo I think - pedro
    function request_language(){
        swriteln(lng('Enter your language'));
        swriteln(lng('de, en'));
    }
    */
    //** Detect installed applications
    public function find_installed_apps() {
        global $conf;
        if(is_installed('mysql') || is_installed('mysqld')) $conf['mysql']['installed'] = true;
        if(is_installed('postfix')) $conf['postfix']['installed'] = true;
        if(is_installed('mailman')) $conf['mailman']['installed'] = true;
        if(is_installed('apache') || is_installed('apache2') || is_installed('httpd')) $conf['apache']['installed'] = true;
        if(is_installed('getmail')) $conf['getmail']['installed'] = true;
        if(is_installed('courierlogger')) $conf['courier']['installed'] = true;
        if(is_installed('dovecot')) $conf['dovecot']['installed'] = true;
        if(is_installed('saslsauthd')) $conf['saslauthd']['installed'] = true;
        if(is_installed('amavisd-new')) $conf['amavis']['installed'] = true;
        if(is_installed('clamdscan')) $conf['clamav']['installed'] = true;
        if(is_installed('pure-ftpd') || is_installed('pure-ftpd-wrapper')) $conf['pureftpd']['installed'] = true;
        if(is_installed('mydns') || is_installed('mydns-ng')) $conf['mydns']['installed'] = true;
        if(is_installed('jk_chrootsh')) $conf['jailkit']['installed'] = true;
        if(is_installed('pdns_server') || is_installed('pdns_control')) $conf['powerdns']['installed'] = true;
        if(is_installed('named') || is_installed('bind') || is_installed('bind9')) $conf['bind']['installed'] = true;
    }
    /** Create the database for ISPConfig */
    public function configure_database() {
        global $conf;
        //** Create the database
        if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$conf['mysql']['database'].' DEFAULT CHARACTER SET '.$conf['mysql']['charset'])) {
            $this->error('Unable to create MySQL database: '.$conf['mysql']['database'].'.');
        }
        //* Set the database name in the DB library
        $this->db->dbName = $conf['mysql']['database'];
        //* Load the database dump into the database, if database contains no tables
        $db_tables = $this->db->getTables();
        if(count($db_tables) > 0) {
            $this->error('Stopped: Database already contains some tables.');
        } else {
            if($conf['mysql']['admin_password'] == '') {
                caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' '".$conf['mysql']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null",
                        __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql');
            } else {
                caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' -p'".$conf['mysql']['admin_password']."' '".$conf['mysql']['database']."' < '".ISPC_INSTALL_ROOT."/install/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.');
            }
            //* Load system.ini into the sys_ini table
            $system_ini = $this->db->quote(rf('tpl/system.ini.master'));
            $this->db->query("UPDATE sys_ini SET config = '$system_ini' WHERE sysini_id = 1");
        }
    }
    //** Create the server record in the database
    public function add_database_server_record() {
        global $conf;
        if($conf['mysql']['host'] == 'localhost') {
            $from_host = 'localhost';
        } else {
            $from_host = $conf['hostname'];
        }
        // Delete ISPConfig user in the local database, in case that it exists
        $this->db->query("DELETE FROM mysql.user WHERE User = '".$conf['mysql']['ispconfig_user']."' AND Host = '".$from_host."';");
        $this->db->query("DELETE FROM mysql.db WHERE Db = '".$conf['mysql']['database']."' AND Host = '".$from_host."';");
        $this->db->query('FLUSH PRIVILEGES;');
        //* Create the ISPConfig database user in the local database
        $query = 'GRANT SELECT, INSERT, UPDATE, DELETE ON '.$conf['mysql']['database'].".* "
                ."TO '".$conf['mysql']['ispconfig_user']."'@'".$from_host."' "
                ."IDENTIFIED BY '".$conf['mysql']['ispconfig_password']."';";
        if(!$this->db->query($query)) {
            $this->error('Unable to create database user: '.$conf['mysql']['ispconfig_user'].' Error: '.$this->db->errorMessage);
        }
        //* Reload database privelages
        $this->db->query('FLUSH PRIVILEGES;');
        //* Set the database name in the DB library
        $this->db->dbName = $conf['mysql']['database'];
        $tpl_ini_array = ini_to_array(rf('tpl/server.ini.master'));
        //* Update further distribution specific parameters for server config here
        //* HINT: Every line added here has to be added in update.lib.php too!!
        $tpl_ini_array['web']['vhost_conf_dir'] = $conf['apache']['vhost_conf_dir'];
        $tpl_ini_array['web']['vhost_conf_enabled_dir'] = $conf['apache']['vhost_conf_enabled_dir'];
        $tpl_ini_array['jailkit']['jailkit_chroot_app_programs'] = $conf['jailkit']['jailkit_chroot_app_programs'];
        $tpl_ini_array['fastcgi']['fastcgi_phpini_path'] = $conf['fastcgi']['fastcgi_phpini_path'];
        $tpl_ini_array['fastcgi']['fastcgi_starter_path'] = $conf['fastcgi']['fastcgi_starter_path'];
        $tpl_ini_array['server']['hostname'] = $conf['hostname'];
        $tpl_ini_array['server']['ip_address'] = @gethostbyname($conf['hostname']);
        $tpl_ini_array['web']['website_basedir'] = $conf['web']['website_basedir'];
        $tpl_ini_array['web']['website_path'] = $conf['web']['website_path'];
        $tpl_ini_array['web']['website_symlinks'] = $conf['web']['website_symlinks'];
        $tpl_ini_array['cron']['crontab_dir'] = $conf['cron']['crontab_dir'];
        $tpl_ini_array['web']['security_level'] = 20;
        $tpl_ini_array['web']['user'] = $conf['apache']['user'];
        $tpl_ini_array['web']['group'] = $conf['apache']['group'];
        $tpl_ini_array['web']['php_ini_path_apache'] = $conf['apache']['php_ini_path_apache'];
        $tpl_ini_array['web']['php_ini_path_cgi'] = $conf['apache']['php_ini_path_cgi'];
        $tpl_ini_array['mail']['pop3_imap_daemon'] = ($conf['dovecot']['installed'] == true)?'dovecot':'courier';
        $tpl_ini_array['mail']['mail_filter_syntax'] = ($conf['dovecot']['installed'] == true)?'sieve':'maildrop';
        $tpl_ini_array['dns']['bind_user'] = $conf['bind']['bind_user'];
        $tpl_ini_array['dns']['bind_group'] = $conf['bind']['bind_group'];
        $tpl_ini_array['dns']['bind_zonefiles_dir'] = $conf['bind']['bind_zonefiles_dir'];
        $tpl_ini_array['dns']['named_conf_path'] = $conf['bind']['named_conf_path'];
        $tpl_ini_array['dns']['named_conf_local_path'] = $conf['bind']['named_conf_local_path'];
        if (array_key_exists('awstats', $conf)) {
            foreach ($conf['awstats'] as $aw_sett => $aw_value) {
                $tpl_ini_array['web']['awstats_'.$aw_sett] = $aw_value;
            }
        }
        $server_ini_content = array_to_ini($tpl_ini_array);
        $server_ini_content = mysql_real_escape_string($server_ini_content);
        $mail_server_enabled = ($conf['services']['mail'])?1:0;
        $web_server_enabled = ($conf['services']['web'])?1:0;
        $dns_server_enabled = ($conf['services']['dns'])?1:0;
        $file_server_enabled = ($conf['services']['file'])?1:0;
        $db_server_enabled = ($conf['services']['db'])?1:0;
        $vserver_server_enabled = ($conf['services']['vserver'])?1:0;
        //** Get the database version number based on the patchfiles
        $found = true;
        $current_db_version = 1;
        while($found == true) {
            $next_db_version = intval($current_db_version + 1);
            $patch_filename = realpath(dirname(__FILE__).'/../').'/sql/incremental/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.sql';
            if(is_file($patch_filename)) {
                $current_db_version = $next_db_version;
            } else {
                $found = false;
            }
        }
        $current_db_version = intval($current_db_version);
        if($conf['mysql']['master_slave_setup'] == 'y') {
            //* Insert the server record in master DB
            $sql = "INSERT INTO `server` (`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`, `dbversion`) VALUES (1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version);";
            $this->dbmaster->query($sql);
            $conf['server_id'] = $this->dbmaster->insertID();
            $conf['server_id'] = $conf['server_id'];
            //* Insert the same record in the local DB
            $sql = "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`, `dbversion`) VALUES ('".$conf['server_id']."',1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version);";
            $this->db->query($sql);
            //* username for the ispconfig user
            $conf['mysql']['master_ispconfig_user'] = 'ispcsrv'.$conf['server_id'];
            $this->grant_master_database_rights();
        } else {
            //* Insert the server, if its not a mster / slave setup
            $sql = "INSERT INTO `server` (`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`, `dbversion`) VALUES (1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version);";
            $this->db->query($sql);
            $conf['server_id'] = $this->db->insertID();
            $conf['server_id'] = $conf['server_id'];
        }
    }
    public function grant_master_database_rights() {
        global $conf;
        /*
         * The following code is a little bit tricky:
         * * If we HAVE a master-slave - Setup then the client has to grant the rights for himself
         *   at the master.
         * * If we DO NOT have a master-slave - Setup then we have two possibilities
         *   1) it is a single server
         *   2) it is the MASTER of n clients
        */
        $hosts = array();
        if($conf['mysql']['master_slave_setup'] == 'y') {
            /*
             * it is a master-slave - Setup so the slave has to grant its rights in the master
             * database
             */
            //* insert the ispconfig user in the remote server
            $from_host = $conf['hostname'];
            $from_ip = gethostbyname($conf['hostname']);
            $hosts[$from_host]['user'] = $conf['mysql']['master_ispconfig_user'];
            $hosts[$from_host]['db'] = $conf['mysql']['master_database'];
            $hosts[$from_host]['pwd'] = $conf['mysql']['master_ispconfig_password'];
            $hosts[$from_ip]['user'] = $conf['mysql']['master_ispconfig_user'];
            $hosts[$from_ip]['db'] = $conf['mysql']['master_database'];
            $hosts[$from_ip]['pwd'] = $conf['mysql']['master_ispconfig_password'];
        } else{
            /*
             * it is NOT a master-slave - Setup so we have to find out all clients and their
             * host
             */
            $query = "SELECT Host, User FROM mysql.user WHERE User like 'ispcsrv%' ORDER BY User, Host";
            $data = $this->dbmaster->queryAllRecords($query);
            if($data === false) {
                $this->error('Unable to get the user rights: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            foreach ($data as $item){
                $hosts[$item['Host']]['user'] = $item['User'];
                $hosts[$item['Host']]['db'] = $conf['mysql']['master_database'];
                $hosts[$item['Host']]['pwd'] = ''; // the user already exists, so we need no pwd!
            }
        }
        if(count($hosts) > 0) {
        foreach($hosts as $host => $value) {
            /*
             * If a pwd exists, this means, we have to add the new user (and his pwd).
             * if not, the user already exists and we do not need the pwd
             */
            if ($value['pwd'] != ''){
                $query = "CREATE USER '".$value['user']."'@'".$host."' IDENTIFIED BY '" . $value['pwd'] . "'";
                $this->dbmaster->query($query); // ignore the error
            }
            /*
             *  Try to delete all rights of the user in case that it exists.
             *  In Case that it will not exist, do nothing (ignore the error!)
             */
            $query = "REVOKE ALL PRIVILEGES, GRANT OPTION FROM '".$value['user']."'@'".$host."' ";
            $this->dbmaster->query($query); // ignore the error
            //* Create the ISPConfig database user in the remote database
            $query = "GRANT SELECT ON ".$value['db'].".`server` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT ON ".$value['db'].".`sys_log` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE(`status`) ON ".$value['db'].".`sys_datalog` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE(`status`) ON ".$value['db'].".`software_update_inst` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE(`updated`) ON ".$value['db'].".`server` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE (`ssl_request`, `ssl_cert`, `ssl_action`) ON ".$value['db'].".`web_domain` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT ON ".$value['db'].".`sys_group` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE (`action_state`, `response`) ON ".$value['db'].".`sys_remoteaction` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT , DELETE ON ".$value['db'].".`monitor_data` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT, UPDATE ON ".$value['db'].".`mail_traffic` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT, UPDATE ON ".$value['db'].".`web_traffic` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->error('Unable to set rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
        }
        /*
         * It is all done. Relod the rights...
         */
        $this->dbmaster->query('FLUSH PRIVILEGES;');
        }
    }
    //** writes postfix configuration files
    public function process_postfix_config($configfile) {
        global $conf;
        $config_dir = $conf['postfix']['config_dir'].'/';
        $full_file_name = $config_dir.$configfile;
        //* Backup exiting file
        if(is_file($full_file_name)) {
            copy($full_file_name, $config_dir.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        wf($full_file_name, $content);
    }
    public function configure_jailkit() {
        global $conf;
        $cf = $conf['jailkit'];
        $config_dir = $cf['config_dir'];
        $jk_init = $cf['jk_init'];
        $jk_chrootsh = $cf['jk_chrootsh'];
        if (is_dir($config_dir)) {
            if(is_file($config_dir.'/'.$jk_init)) copy($config_dir.'/'.$jk_init, $config_dir.'/'.$jk_init.'~');
            if(is_file($config_dir.'/'.$jk_chrootsh.'.master')) copy($config_dir.'/'.$jk_chrootsh.'.master', $config_dir.'/'.$jk_chrootsh.'~');
            copy('tpl/'.$jk_init.'.master', $config_dir.'/'.$jk_init);
            copy('tpl/'.$jk_chrootsh.'.master', $config_dir.'/'.$jk_chrootsh);
        }
    }
    public function configure_mailman($status = 'insert') {
        global $conf;
        $config_dir = $conf['mailman']['config_dir'].'/';
        $full_file_name = $config_dir.'mm_cfg.py';
        //* Backup exiting file
        if(is_file($full_file_name)) {
            copy($full_file_name, $config_dir.'mm_cfg.py~');
        }
        // load files
        $content = rf('tpl/mm_cfg.py.master');
        $old_file = rf($full_file_name);
        $old_options = array();
        $lines = explode("\n", $old_file);
        foreach ($lines as $line)
        {
            if (strlen($line) && substr($line, 0, 1) != '#')
            {
                list($key, $value) = explode("=", $line);
                if (!empty($value))
                {
                    $key = rtrim($key);
                    $old_options[$key] = trim($value);
                }
            }
        }
        $virtual_domains = '';
        if($status == 'update')
        {
            // create virtual_domains list
            $domainAll = $this->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain");
            foreach($domainAll as $domain)
            {
                if ($domainAll[0]['domain'] == $domain['domain'])
                    $virtual_domains .= "'".$domain['domain']."'";
                else
                    $virtual_domains .= ", '".$domain['domain']."'";
            }
        }
        else
            $virtual_domains = "' '";
        $content = str_replace('{hostname}', $conf['hostname'], $content);
        $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content);
        $content = str_replace('{virtual_domains}', $virtual_domains, $content);
        wf($full_file_name, $content);
    }
    public function configure_postfix($options = '') {
        global $conf;
        $cf = $conf['postfix'];
        $config_dir = $cf['config_dir'];
        if(!is_dir($config_dir)) {
            $this->error("The postfix configuration directory '$config_dir' does not exist.");
        }
        //* mysql-virtual_domains.cf
        $this->process_postfix_config('mysql-virtual_domains.cf');
        //* mysql-virtual_forwardings.cf
        $this->process_postfix_config('mysql-virtual_forwardings.cf');
        //* mysql-virtual_mailboxes.cf
        $this->process_postfix_config('mysql-virtual_mailboxes.cf');
        //* mysql-virtual_email2email.cf
        $this->process_postfix_config('mysql-virtual_email2email.cf');
        //* mysql-virtual_transports.cf
        $this->process_postfix_config('mysql-virtual_transports.cf');
        //* mysql-virtual_recipient.cf
        $this->process_postfix_config('mysql-virtual_recipient.cf');
        //* mysql-virtual_sender.cf
        $this->process_postfix_config('mysql-virtual_sender.cf');
        //* mysql-virtual_client.cf
        $this->process_postfix_config('mysql-virtual_client.cf');
        //* mysql-virtual_relaydomains.cf
        $this->process_postfix_config('mysql-virtual_relaydomains.cf');
        //* mysql-virtual_relayrecipientmaps.cf
        $this->process_postfix_config('mysql-virtual_relayrecipientmaps.cf');
        //* Changing mode and group of the new created config files.
        caselog('chmod o= '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null',
                __FILE__, __LINE__, 'chmod on mysql-virtual_*.cf*', 'chmod on mysql-virtual_*.cf* failed');
        caselog('chgrp '.$cf['group'].' '.$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 '.$cf['vmail_groupid'].' '.$cf['vmail_groupname'];
        if(!is_group($cf['vmail_groupname'])) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m';
        if(!is_user($cf['vmail_username'])) 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 [::1]/128',
                'virtual_alias_domains =',
                'virtual_alias_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_forwardings.cf, mysql:'.$config_dir.'/mysql-virtual_email2email.cf',
                'virtual_mailbox_domains = proxy:mysql:'.$config_dir.'/mysql-virtual_domains.cf',
                'virtual_mailbox_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_mailboxes.cf',
                'virtual_mailbox_base = '.$cf['vmail_mailbox_base'],
                'virtual_uid_maps = static:'.$cf['vmail_userid'],
                'virtual_gid_maps = static:'.$cf['vmail_groupid'],
                'smtpd_sasl_auth_enable = yes',
                'broken_sasl_auth_clients = yes',
                'smtpd_sasl_authenticated_header = yes',
                'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:'.$config_dir.'/mysql-virtual_recipient.cf, reject_unauth_destination',
                'smtpd_use_tls = yes',
                'smtpd_tls_security_level = may',
                'smtpd_tls_cert_file = '.$config_dir.'/smtpd.cert',
                'smtpd_tls_key_file = '.$config_dir.'/smtpd.key',
                'transport_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_transports.cf',
                'relay_domains = mysql:'.$config_dir.'/mysql-virtual_relaydomains.cf',
                'relay_recipient_maps = mysql:'.$config_dir.'/mysql-virtual_relayrecipientmaps.cf',
                'virtual_create_maildirsize = yes',
                'virtual_maildir_extended = yes',
                'virtual_mailbox_limit_maps = proxy:mysql:'.$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:'.$config_dir.'/mysql-virtual_sender.cf',
                'smtpd_client_restrictions = check_client_access mysql:'.$config_dir.'/mysql-virtual_client.cf',
                'maildrop_destination_concurrency_limit = 1',
                'maildrop_destination_recipient_limit   = 1',
                'virtual_transport = maildrop',
                'header_checks = regexp:'.$config_dir.'/header_checks',
                'mime_header_checks = regexp:'.$config_dir.'/mime_header_checks',
                'nested_header_checks = regexp:'.$config_dir.'/nested_header_checks',
                'body_checks = regexp:'.$config_dir.'/body_checks'
        );
        //* Create the header and body check files
        touch($config_dir.'/header_checks');
        touch($config_dir.'/mime_header_checks');
        touch($config_dir.'/nested_header_checks');
        touch($config_dir.'/body_checks');
        //* Make a backup copy of the main.cf file
        copy($config_dir.'/main.cf', $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);
        }
        if(!stristr($options,'dont-create-certs')) {
            //* Create the SSL certificate
            $command = 'cd '.$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= '.$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/';
        if(is_file('/var/run/courier/authdaemon/')) caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
        //* Changing maildrop lines in posfix master.cf
        if(is_file($config_dir.'/master.cf')) {
            copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
        }
        if(is_file($config_dir.'/master.cf~')) {
            chmod($config_dir.'/master.cf~', 0400);
        }
        $configfile = $config_dir.'/master.cf';
        $content = rf($configfile);
        $content = str_replace('flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}',
                'flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d '.$cf['vmail_username'].' ${extension} ${recipient} ${user} ${nexthop} ${sender}',
                $content);
        wf($configfile, $content);
        //* Writing the Maildrop mailfilter file
        $configfile = 'mailfilter';
        if(is_file($cf['vmail_mailbox_base'].'/.'.$configfile)) {
            copy($cf['vmail_mailbox_base'].'/.'.$configfile, $cf['vmail_mailbox_base'].'/.'.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{dist_postfix_vmail_mailbox_base}', $cf['vmail_mailbox_base'], $content);
        wf($cf['vmail_mailbox_base'].'/.'.$configfile, $content);
        //* Create the directory for the custom mailfilters
        if(!is_dir($cf['vmail_mailbox_base'].'/mailfilters')) {
            $command = 'mkdir '.$cf['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 '.$cf['vmail_username'].':'.$cf['vmail_groupname'].' '.$cf['vmail_mailbox_base'].'/.mailfilter';
        caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'chmod -R 600 '.$cf['vmail_mailbox_base'].'/.mailfilter';
        caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
    }
    public function configure_saslauthd() {
        global $conf;
        $configfile = 'sasl_smtpd.conf';
        if(is_file($conf['postfix']['config_dir'].'/sasl/smtpd.conf')) copy($conf['postfix']['config_dir'].'/sasl/smtpd.conf',$conf['postfix']['config_dir'].'/sasl/smtpd.conf~');
        if(is_file($conf['postfix']['config_dir'].'/sasl/smtpd.conf~')) chmod($conf['postfix']['config_dir'].'/sasl/smtpd.conf~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_ip}',$conf['mysql']['ip'],$content);
        wf($conf['postfix']['config_dir'].'/sasl/smtpd.conf',$content);
        // TODO: Chmod and chown on the config file
        // Recursively create the spool directory
        if(!@is_dir('/var/spool/postfix/var/run/saslauthd')) mkdir('/var/spool/postfix/var/run/saslauthd', 0755, true);
        // Edit the file /etc/default/saslauthd
        $configfile = $conf['saslauthd']['config'];
        if(is_file($configfile)) copy($configfile,$configfile.'~');
        if(is_file($configfile.'~')) chmod($configfile.'~', 0400);
        $content = rf($configfile);
        $content = str_replace('START=no','START=yes',$content);
        // Debian
        $content = str_replace('OPTIONS="-c"','OPTIONS="-m /var/spool/postfix/var/run/saslauthd -r"',$content);
        // Ubuntu
        $content = str_replace('OPTIONS="-c -m /var/run/saslauthd"','OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"',$content);
        wf($configfile,$content);
        // Edit the file /etc/init.d/saslauthd
        $configfile = $conf['init_scripts'].'/'.$conf['saslauthd']['init_script'];
        $content = rf($configfile);
        $content = str_replace('PIDFILE=$RUN_DIR/saslauthd.pid','PIDFILE="/var/spool/postfix/var/run/${NAME}/saslauthd.pid"',$content);
        wf($configfile,$content);
        // add the postfix user to the sasl group (at least necessary for Ubuntu 8.04 and most likely Debian Lenny as well.
        exec('adduser postfix sasl');
    }
    public function configure_pam() {
        global $conf;
        $pam = $conf['pam'];
        //* configure pam for SMTP authentication agains the ispconfig database
        $configfile = 'pamd_smtp';
        if(is_file($pam.'/smtp'))    copy($pam.'/smtp', $pam.'/smtp~');
        if(is_file($pam.'/smtp~'))   chmod($pam.'/smtp~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
        wf($pam.'/smtp', $content);
        // On some OSes smtp is world readable which allows for reading database information.  Removing world readable rights should have no effect.
        if(is_file($pam.'/smtp'))    exec("chmod o= $pam/smtp");
        chmod($pam.'/smtp', 0660);
        chown($pam.'/smtp', 'daemon');
        chgrp($pam.'/smtp', 'daemon');
    }
    public function configure_courier() {
        global $conf;
        $config_dir = $conf['courier']['config_dir'];
        //* authmysqlrc
        $configfile = 'authmysqlrc';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        chmod($config_dir.'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        wf($config_dir.'/'.$configfile, $content);
        chmod($config_dir.'/'.$configfile, 0660);
        chown($config_dir.'/'.$configfile, 'daemon');
        chgrp($config_dir.'/'.$configfile, 'daemon');
        //* authdaemonrc
        $configfile = $config_dir.'/authdaemonrc';
        if(is_file($configfile)) {
            copy($configfile, $configfile.'~');
        }
        if(is_file($configfile.'~')) {
            chmod($configfile.'~', 0400);
        }
        $content = rf($configfile);
        $content = str_replace('authmodulelist="authpam"', 'authmodulelist="authmysql"', $content);
        wf($configfile, $content);
    }
    public function configure_dovecot() {
        global $conf;
        $config_dir = $conf['dovecot']['config_dir'];
        //* Configure master.cf and add a line for deliver
        if(is_file($conf['postfix']['config_dir'].'/master.cf')) {
            copy($conf['postfix']['config_dir'].'/master.cf', $conf['postfix']['config_dir'].'/master.cf~2');
        }
        if(is_file($conf['postfix']['config_dir'].'/master.cf~')) {
            chmod($conf['postfix']['config_dir'].'/master.cf~2', 0400);
        }
        $content = rf($conf['postfix']['config_dir'].'/master.cf');
        // Only add the content if we had not addded it before
        if(!stristr($content,'dovecot/deliver')) {
            $deliver_content = 'dovecot   unix  -       n       n       -       -       pipe'."\n".'  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
            af($conf['postfix']['config_dir'].'/master.cf',$deliver_content);
        }
        unset($content);
        unset($deliver_content);
        //* Reconfigure postfix to use dovecot authentication
        // Adding the amavisd commands to the postfix configuration
        $postconf_commands = array (
                'dovecot_destination_recipient_limit = 1',
                'virtual_transport = dovecot',
                'smtpd_sasl_type = dovecot',
                'smtpd_sasl_path = private/auth'
        );
        // Make a backup copy of the main.cf file
        copy($conf['postfix']['config_dir'].'/main.cf',$conf['postfix']['config_dir'].'/main.cf~3');
        // 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");
        }
        //* copy dovecot.conf
        $configfile = 'dovecot.conf';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        copy('tpl/debian_dovecot.conf.master',$config_dir.'/'.$configfile);
        //* dovecot-sql.conf
        $configfile = 'dovecot-sql.conf';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        chmod($config_dir.'/'.$configfile.'~', 0400);
        $content = rf('tpl/debian_dovecot-sql.conf.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        wf($config_dir.'/'.$configfile, $content);
        chmod($config_dir.'/'.$configfile, 0600);
        chown($config_dir.'/'.$configfile, 'root');
        chgrp($config_dir.'/'.$configfile, 'root');
    }
    public function configure_amavis() {
        global $conf;
        // amavisd user config file
        $configfile = 'amavisd_user_config';
        if(is_file($conf['amavis']['config_dir'].'/conf.d/50-user')) copy($conf['amavis']['config_dir'].'/conf.d/50-user',$conf['amavis']['config_dir'].'/50-user~');
        if(is_file($conf['amavis']['config_dir'].'/conf.d/50-user~')) chmod($conf['amavis']['config_dir'].'/conf.d/50-user~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_port}',$conf['mysql']['port'],$content);
        $content = str_replace('{mysql_server_ip}',$conf['mysql']['ip'],$content);
        wf($conf['amavis']['config_dir'].'/conf.d/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['postfix']['config_dir'].'/main.cf',$conf['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['postfix']['config_dir'].'/master.cf')) copy($conf['postfix']['config_dir'].'/master.cf',$conf['postfix']['config_dir'].'/master.cf~');
        $content = rf($conf['postfix']['config_dir'].'/master.cf');
        // Only add the content if we had not addded it before
        if(!stristr($content,'127.0.0.1:10025')) {
            unset($content);
            $content = rf('tpl/master_cf_amavis.master');
            af($conf['postfix']['config_dir'].'/master.cf',$content);
        }
        unset($content);
        // Add the clamav user to the amavis group
        exec('adduser clamav amavis');
    }
    public function configure_spamassassin() {
        global $conf;
        //* Enable spamasasssin on debian and ubuntu
        $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);
    }
    public function configure_getmail() {
        global $conf;
        $config_dir = $conf['getmail']['config_dir'];
        if(!@is_dir($config_dir)) mkdir(escapeshellcmd($config_dir), 0700, true);
        $command = 'useradd -d '.$config_dir.' getmail';
        if(!is_user('getmail')) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = "chown -R getmail $config_dir";
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = "chmod -R 700 $config_dir";
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
    }
    public function configure_pureftpd() {
        global $conf;
        $config_dir = $conf['pureftpd']['config_dir'];
        //* configure pure-ftpd for MySQL authentication against the ispconfig database
        $configfile = 'db/mysql.conf';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        if(is_file($config_dir.'/'.$configfile.'~')) {
            chmod($config_dir.'/'.$configfile.'~', 0400);
        }
        $content = rf('tpl/pureftpd_mysql.conf.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        wf($config_dir.'/'.$configfile, $content);
        chmod($config_dir.'/'.$configfile, 0600);
        chown($config_dir.'/'.$configfile, 'root');
        chgrp($config_dir.'/'.$configfile, 'root');
        // **enable chrooting
        //exec('mkdir -p '.$config_dir.'/conf/ChrootEveryone');
        exec('echo "yes" > '.$config_dir.'/conf/ChrootEveryone');
        exec('echo "yes" > '.$config_dir.'/conf/BrokenClientsCompatibility');
        exec('echo "yes" > '.$config_dir.'/conf/DisplayDotFiles');
        if(is_file('/etc/default/pure-ftpd-common')) {
            replaceLine('/etc/default/pure-ftpd-common','STANDALONE_OR_INETD=inetd','STANDALONE_OR_INETD=standalone',1,0);
            replaceLine('/etc/default/pure-ftpd-common','VIRTUALCHROOT=false','VIRTUALCHROOT=true',1,0);
        }
        if(is_file('/etc/inetd.conf')) {
            replaceLine('/etc/inetd.conf','/usr/sbin/pure-ftpd-wrapper','#ftp     stream  tcp     nowait  root    /usr/sbin/tcpd /usr/sbin/pure-ftpd-wrapper',0,0);
            if(is_file($conf['init_scripts'].'/'.'openbsd-inetd')) exec($conf['init_scripts'].'/'.'openbsd-inetd restart');
        }
        if(!is_file('/etc/pure-ftpd/conf/DontResolve')) exec('echo "yes" > /etc/pure-ftpd/conf/DontResolve');
    }
    public function configure_mydns() {
        global $conf;
        // configure pam for SMTP authentication agains the ispconfig database
        $configfile = 'mydns.conf';
        if(is_file($conf['mydns']['config_dir'].'/'.$configfile)) copy($conf['mydns']['config_dir'].'/'.$configfile,$conf['mydns']['config_dir'].'/'.$configfile.'~');
        if(is_file($conf['mydns']['config_dir'].'/'.$configfile.'~')) chmod($conf['mydns']['config_dir'].'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        $content = str_replace('{server_id}',$conf['server_id'],$content);
        wf($conf['mydns']['config_dir'].'/'.$configfile,$content);
        chmod($conf['mydns']['config_dir'].'/'.$configfile, 0600);
        chown($conf['mydns']['config_dir'].'/'.$configfile, 'root');
        chgrp($conf['mydns']['config_dir'].'/'.$configfile, 'root');
    }
    public function configure_powerdns() {
        global $conf;
        //* Create the database
        if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$conf['powerdns']['database'].' DEFAULT CHARACTER SET '.$conf['mysql']['charset'])) {
            $this->error('Unable to create MySQL database: '.$conf['powerdns']['database'].'.');
        }
        //* Create the ISPConfig database user in the local database
        $query = "GRANT ALL ON `".$conf['powerdns']['database']."` . * TO '".$conf['mysql']['ispconfig_user']."'@'localhost';";
        if(!$this->db->query($query)) {
            $this->error('Unable to create user for powerdns database Error: '.$this->db->errorMessage);
        }
        //* Reload database privelages
        $this->db->query('FLUSH PRIVILEGES;');
        //* load the powerdns databse dump
        if($conf['mysql']['admin_password'] == '') {
            caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' '".$conf['powerdns']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/powerdns.sql' &> /dev/null",
                    __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in powerdns.sql');
        } else {
            caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' -p'".$conf['mysql']['admin_password']."' '".$conf['powerdns']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/powerdns.sql' &> /dev/null",
                    __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in powerdns.sql');
        }
        //* Create the powerdns config file
        $configfile = 'pdns.local';
        if(is_file($conf['powerdns']['config_dir'].'/'.$configfile)) copy($conf['powerdns']['config_dir'].'/'.$configfile,$conf['powerdns']['config_dir'].'/'.$configfile.'~');
        if(is_file($conf['powerdns']['config_dir'].'/'.$configfile.'~')) chmod($conf['powerdns']['config_dir'].'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{powerdns_database}',$conf['powerdns']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        wf($conf['powerdns']['config_dir'].'/'.$configfile,$content);
        chmod($conf['powerdns']['config_dir'].'/'.$configfile, 0600);
        chown($conf['powerdns']['config_dir'].'/'.$configfile, 'root');
        chgrp($conf['powerdns']['config_dir'].'/'.$configfile, 'root');
    }
    public function configure_bind() {
        global $conf;
        //* Check if the zonefile directory has a slash at the end
        $content=$conf['bind']['bind_zonefiles_dir'];
        if(substr($content,-1,1) != '/') {
            $content .= '/';
        }
        //* Create the slave subdirectory
        $content .= 'slave';
        if(!@is_dir($content)) mkdir($content, 0770, true);
        //* Chown the slave subdirectory to $conf['bind']['bind_user']
        chown($content, $conf['bind']['bind_user']);
        chgrp($content, $conf['bind']['bind_group']);
    }
    public function configure_apache() {
        global $conf;
        //* Create the logging directory for the vhost logfiles
        if(!@is_dir($conf['ispconfig_log_dir'].'/httpd')) mkdir($conf['ispconfig_log_dir'].'/httpd', 0755, true);
        if(is_file('/etc/suphp/suphp.conf')) {
            replaceLine('/etc/suphp/suphp.conf','php=php:/usr/bin','x-httpd-suphp="php:/usr/bin/php-cgi"',0);
            //replaceLine('/etc/suphp/suphp.conf','docroot=','docroot=/var/clients',0);
            replaceLine('/etc/suphp/suphp.conf','umask=0077','umask=0022',0);
        }
        if(is_file('/etc/apache2/sites-enabled/000-default')) {
            replaceLine('/etc/apache2/sites-available/000-default','NameVirtualHost *','NameVirtualHost *:80',1,0);
            replaceLine('/etc/apache2/sites-available/000-default','<VirtualHost *>','<VirtualHost *:80>',1,0);
        }
        if(is_file('/etc/apache2/ports.conf')) {
            // add a line "Listen 443" to ports conf if line does not exist
            replaceLine('/etc/apache2/ports.conf','Listen 443','Listen 443',1);
        }
        //* Copy the ISPConfig configuration include
        $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        // copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf');
        $content = rf('tpl/apache_ispconfig.conf.master');
        $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'");
        if(is_array($records) && count($records) > 0) {
            foreach($records as $rec) {
                $content .= 'NameVirtualHost '.$rec['ip_address'].":80\n";
                $content .= 'NameVirtualHost '.$rec['ip_address'].":443\n";
            }
        }
        $content .= "\n";
        wf($vhost_conf_dir.'/ispconfig.conf',$content);
        if(!@is_link($vhost_conf_enabled_dir.'/000-ispconfig.conf')) {
            symlink($vhost_conf_dir.'/ispconfig.conf',$vhost_conf_enabled_dir.'/000-ispconfig.conf');
        }
        //* make sure that webalizer finds its config file when it is directly in /etc
        if(@is_file('/etc/webalizer.conf') && !@is_dir('/etc/webalizer')) {
            mkdir('/etc/webalizer');
            symlink('/etc/webalizer.conf','/etc/webalizer/webalizer.conf');
        }
        if(is_file('/etc/webalizer/webalizer.conf')) {
            // Change webalizer mode to incremental
            replaceLine('/etc/webalizer/webalizer.conf','#IncrementalName','IncrementalName webalizer.current',0,0);
            replaceLine('/etc/webalizer/webalizer.conf','#Incremental','Incremental     yes',0,0);
            replaceLine('/etc/webalizer/webalizer.conf','#HistoryName','HistoryName     webalizer.hist',0,0);
        }
        // Check the awsatst script
        if(!is_dir('/usr/share/awstats/tools')) exec('mkdir -p /usr/share/awstats/tools');
        if(!file_exists('/usr/share/awstats/tools/awstats_buildstaticpages.pl') && file_exists('/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl')) symlink('/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl','/usr/share/awstats/tools/awstats_buildstaticpages.pl');
        //* add a sshusers group
        $command = 'groupadd sshusers';
        if(!is_group('sshusers')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
    }
    public function configure_firewall() {
        global $conf;
        $dist_init_scripts = $conf['init_scripts'];
        if(is_dir('/etc/Bastille.backup')) caselog('rm -rf /etc/Bastille.backup', __FILE__, __LINE__);
        if(is_dir('/etc/Bastille')) caselog('mv -f /etc/Bastille /etc/Bastille.backup', __FILE__, __LINE__);
        @mkdir('/etc/Bastille', 0700);
        if(is_dir('/etc/Bastille.backup/firewall.d')) caselog('cp -pfr /etc/Bastille.backup/firewall.d /etc/Bastille/', __FILE__, __LINE__);
        caselog('cp -f tpl/bastille-firewall.cfg.master /etc/Bastille/bastille-firewall.cfg', __FILE__, __LINE__);
        caselog('chmod 644 /etc/Bastille/bastille-firewall.cfg', __FILE__, __LINE__);
        $content = rf('/etc/Bastille/bastille-firewall.cfg');
        $content = str_replace('{DNS_SERVERS}', '', $content);
        $tcp_public_services = '';
        $udp_public_services = '';
        $row = $this->db->queryOneRecord('SELECT * FROM '.$conf["mysql"]["database"].'.firewall WHERE server_id = '.intval($conf['server_id']));
        if(trim($row['tcp_port']) != '' || trim($row['udp_port']) != '') {
            $tcp_public_services = trim(str_replace(',',' ',$row['tcp_port']));
            $udp_public_services = trim(str_replace(',',' ',$row['udp_port']));
        } else {
            $tcp_public_services = '21 22 25 53 80 110 143 443 3306 8080 10000';
            $udp_public_services = '53';
        }
        if(!stristr($tcp_public_services, $conf['apache']['vhost_port'])) {
            $tcp_public_services .= ' '.intval($conf['apache']['vhost_port']);
            if($row['tcp_port'] != '') $this->db->query("UPDATE firewall SET tcp_port = tcp_port + ',".intval($conf['apache']['vhost_port'])."' WHERE server_id = ".intval($conf['server_id']));
        }
        $content = str_replace('{TCP_PUBLIC_SERVICES}', $tcp_public_services, $content);
        $content = str_replace('{UDP_PUBLIC_SERVICES}', $udp_public_services, $content);
        wf('/etc/Bastille/bastille-firewall.cfg', $content);
        if(is_file($dist_init_scripts.'/bastille-firewall')) caselog('mv -f '.$dist_init_scripts.'/bastille-firewall '.$dist_init_scripts.'/bastille-firewall.backup', __FILE__, __LINE__);
        caselog('cp -f apps/bastille-firewall '.$dist_init_scripts, __FILE__, __LINE__);
        caselog('chmod 700 '.$dist_init_scripts.'/bastille-firewall', __FILE__, __LINE__);
        if(is_file('/sbin/bastille-ipchains')) caselog('mv -f /sbin/bastille-ipchains /sbin/bastille-ipchains.backup', __FILE__, __LINE__);
        caselog('cp -f apps/bastille-ipchains /sbin', __FILE__, __LINE__);
        caselog('chmod 700 /sbin/bastille-ipchains', __FILE__, __LINE__);
        if(is_file('/sbin/bastille-netfilter')) caselog('mv -f /sbin/bastille-netfilter /sbin/bastille-netfilter.backup', __FILE__, __LINE__);
        caselog('cp -f apps/bastille-netfilter /sbin', __FILE__, __LINE__);
        caselog('chmod 700 /sbin/bastille-netfilter', __FILE__, __LINE__);
        if(!@is_dir('/var/lock/subsys')) caselog('mkdir /var/lock/subsys', __FILE__, __LINE__);
        exec('which ipchains &> /dev/null', $ipchains_location, $ret_val);
        if(!is_file('/sbin/ipchains') && !is_link('/sbin/ipchains') && $ret_val == 0) phpcaselog(@symlink(shell_exec('which ipchains'), '/sbin/ipchains'), 'create symlink', __FILE__, __LINE__);
        unset($ipchains_location);
        exec('which iptables &> /dev/null', $iptables_location, $ret_val);
        if(!is_file('/sbin/iptables') && !is_link('/sbin/iptables') && $ret_val == 0) phpcaselog(@symlink(trim(shell_exec('which iptables')), '/sbin/iptables'), 'create symlink', __FILE__, __LINE__);
        unset($iptables_location);
    }
    public function configure_vlogger() {
        global $conf;
        //** Configure vlogger to use traffic logging to mysql (master) db
        $configfile = 'vlogger-dbi.conf';
        if(is_file($conf['vlogger']['config_dir'].'/'.$configfile)) copy($conf['vlogger']['config_dir'].'/'.$configfile,$conf['vlogger']['config_dir'].'/'.$configfile.'~');
        if(is_file($conf['vlogger']['config_dir'].'/'.$configfile.'~')) chmod($conf['vlogger']['config_dir'].'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        if($conf['mysql']['master_slave_setup'] == 'y') {
            $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['master_ispconfig_user'],$content);
            $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['master_ispconfig_password'], $content);
            $content = str_replace('{mysql_server_database}',$conf['mysql']['master_database'],$content);
            $content = str_replace('{mysql_server_ip}',$conf['mysql']['master_host'],$content);
        } else {
            $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
            $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
            $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
            $content = str_replace('{mysql_server_ip}',$conf['mysql']['host'],$content);
        }
        wf($conf['vlogger']['config_dir'].'/'.$configfile,$content);
        chmod($conf['vlogger']['config_dir'].'/'.$configfile, 0600);
        chown($conf['vlogger']['config_dir'].'/'.$configfile, 'root');
        chgrp($conf['vlogger']['config_dir'].'/'.$configfile, 'root');
    }
    public function configure_apps_vhost() {
        global $conf;
        //* Create the ispconfig apps vhost user and group
        $apps_vhost_user = escapeshellcmd($conf['web']['apps_vhost_user']);
        $apps_vhost_group = escapeshellcmd($conf['web']['apps_vhost_group']);
        $install_dir = escapeshellcmd($conf['web']['website_basedir'].'/apps');
        $command = 'groupadd '.$apps_vhost_user;
        if(!is_group($apps_vhost_group)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'useradd -g '.$apps_vhost_group.' -d '.$install_dir.' '.$apps_vhost_group;
        if(!is_user($apps_vhost_user)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'adduser '.$conf['apache']['user'].' '.$apps_vhost_group;
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        if(!@is_dir($install_dir)) mkdir($install_dir, 0755, true);
        chown($install_dir, $apps_vhost_user);
        chgrp($install_dir, $apps_vhost_group);
        //* Copy the apps vhost file
        $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        $apps_vhost_servername = ($conf['web']['apps_vhost_servername'] == '')?'':'ServerName '.$conf['web']['apps_vhost_servername'];
        // Dont just copy over the virtualhost template but add some custom settings
        $content = rf('tpl/apache_apps.vhost.master');
        $content = str_replace('{apps_vhost_ip}', $conf['web']['apps_vhost_ip'], $content);
        $content = str_replace('{apps_vhost_port}', $conf['web']['apps_vhost_port'], $content);
        $content = str_replace('{apps_vhost_dir}', $conf['web']['website_basedir'].'/apps', $content);
        $content = str_replace('{website_basedir}', $conf['web']['website_basedir'], $content);
        $content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
        // comment out the listen directive if port is 80 or 443
        if($conf['web']['apps_vhost_ip'] == 80 or $conf['web']['apps_vhost_ip'] == 443) {
            $content = str_replace('{vhost_port_listen}', '#', $content);
        } else {
            $content = str_replace('{vhost_port_listen}', '', $content);
        }
        wf($vhost_conf_dir.'/apps.vhost', $content);
        //copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
        //* and create the symlink
        if($this->install_ispconfig_interface == true) {
            if(@is_link($vhost_conf_enabled_dir.'/apps.vhost')) unlink($vhost_conf_enabled_dir.'/apps.vhost');
            if(!@is_link($vhost_conf_enabled_dir.'/000-apps.vhost')) {
                symlink($vhost_conf_dir.'/apps.vhost',$vhost_conf_enabled_dir.'/000-apps.vhost');
            }
        }
        if(!is_file($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter')) {
            mkdir($conf['web']['website_basedir'].'/php-fcgi-scripts/apps', 0755, true);
            copy('tpl/apache_apps_fcgi_starter.master',$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
            exec('chmod +x '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
            exec('chown -R ispapps:ispapps '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps');
        }
    }
    public function make_ispconfig_ssl_cert() {
        global $conf;
        $install_dir = $conf['ispconfig_install_dir'];
        $ssl_crt_file = $install_dir.'/interface/ssl/ispserver.crt';
        $ssl_csr_file = $install_dir.'/interface/ssl/ispserver.csr';
        $ssl_key_file = $install_dir.'/interface/ssl/ispserver.key';
        if(!@is_dir($install_dir.'/interface/ssl')) mkdir($install_dir.'/interface/ssl', 0755, true);
        $ssl_pw = substr(md5(mt_rand()),0,6);
        exec("openssl genrsa -des3 -passout pass:$ssl_pw -out $ssl_key_file 4096");
        exec("openssl req -new -passin pass:$ssl_pw -passout pass:$ssl_pw -key $ssl_key_file -out $ssl_csr_file");
        exec("openssl req -x509 -passin pass:$ssl_pw -passout pass:$ssl_pw -key $ssl_key_file -in $ssl_csr_file -out $ssl_crt_file -days 3650");
        exec("openssl rsa -passin pass:$ssl_pw -in $ssl_key_file -out $ssl_key_file.insecure");
        rename($ssl_key_file,$ssl_key_file.'.secure');
        rename($ssl_key_file.'.insecure',$ssl_key_file);
    }
    public function install_ispconfig() {
        global $conf;
        $install_dir = $conf['ispconfig_install_dir'];
        //* Create the ISPConfig installation directory
        if(!@is_dir($install_dir)) {
            $command = "mkdir $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';
        if(!is_group('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'useradd -g ispconfig -d '.$install_dir.' ispconfig';
        if(!is_user('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* copy the ISPConfig interface part
        $command = 'cp -rf ../interface '.$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 '.$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
        // Replaced by a separate vhost definition for port 8080
        // $command = "ln -s $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 interface
        $configfile = 'config.inc.php';
        if(is_file($install_dir.'/interface/lib/'.$configfile)) {
            copy($install_dir.'/interface/lib/'.$configfile, $install_dir.'/interface/lib/'.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
        $content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
        $content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
        $content = str_replace('{language}', $conf['language'], $content);
        wf($install_dir.'/interface/lib/'.$configfile, $content);
        //* Create the config file for ISPConfig server
        $configfile = 'config.inc.php';
        if(is_file($install_dir.'/server/lib/'.$configfile)) {
            copy($install_dir.'/server/lib/'.$configfile, $install_dir.'/interface/lib/'.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
        $content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
        $content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
        $content = str_replace('{language}', $conf['language'], $content);
        wf($install_dir.'/server/lib/'.$configfile, $content);
        //* Create the config file for remote-actions (but only, if it does not exist, because
        //  the value is a autoinc-value and so changed by the remoteaction_core_module
        if (!file_exists($install_dir.'/server/lib/remote_action.inc.php')) {
            $content = '<?php' . "\n" . '$maxid_remote_action = 0;' . "\n" . '?>';
            wf($install_dir.'/server/lib/remote_action.inc.php', $content);
        }
        //* Enable the server modules and plugins.
        // TODO: Implement a selector which modules and plugins shall be enabled.
        $dir = $install_dir.'/server/mods-available/';
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
                        include_once($install_dir.'/server/mods-available/'.$file);
                        $module_name = substr($file,0,-8);
                        $tmp = new $module_name;
                        if($tmp->onInstall()) {
                            if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) {
                                @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
                                // @symlink($install_dir.'/server/mods-available/'.$file, '../mods-enabled/'.$file);
                            }
                            if (strpos($file, '_core_module') !== false) {
                                if(!@is_link($install_dir.'/server/mods-core/'.$file)) {
                                    @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file);
                                    // @symlink($install_dir.'/server/mods-available/'.$file, '../mods-core/'.$file);
                                }
                            }
                        }
                        unset($tmp);
                    }
                }
                closedir($dh);
            }
        }
        $dir = $install_dir.'/server/plugins-available/';
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
                        include_once($install_dir.'/server/plugins-available/'.$file);
                        $plugin_name = substr($file,0,-8);
                        $tmp = new $plugin_name;
                        if(method_exists($tmp,'onInstall') && $tmp->onInstall()) {
                            if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) {
                                @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
                                //@symlink($install_dir.'/server/plugins-available/'.$file, '../plugins-enabled/'.$file);
                            }
                            if (strpos($file, '_core_plugin') !== false) {
                                if(!@is_link($install_dir.'/server/plugins-core/'.$file)) {
                                    @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
                                    //@symlink($install_dir.'/server/plugins-available/'.$file, '../plugins-core/'.$file);
                                }
                            }
                        }
                        unset($tmp);
                    }
                }
                closedir($dh);
            }
        }
        // Update the server config
        $mail_server_enabled = ($conf['services']['mail'])?1:0;
        $web_server_enabled = ($conf['services']['web'])?1:0;
        $dns_server_enabled = ($conf['services']['dns'])?1:0;
        $file_server_enabled = ($conf['services']['file'])?1:0;
        $db_server_enabled = ($conf['services']['db'])?1:0;
        $vserver_server_enabled = ($conf['services']['vserver'])?1:0;
        $sql = "UPDATE `server` SET mail_server = '$mail_server_enabled', web_server = '$web_server_enabled', dns_server = '$dns_server_enabled', file_server = '$file_server_enabled', db_server = '$db_server_enabled', vserver_server = '$vserver_server_enabled' WHERE server_id = ".intval($conf['server_id']);
        if($conf['mysql']['master_slave_setup'] == 'y') {
            $this->dbmaster->query($sql);
            $this->db->query($sql);
        } else {
            $this->db->query($sql);
        }
        //* Chmod the files
        $command = 'chmod -R 750 '.$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 '.$install_dir;
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* Make the global language file directory group writable
        exec("chmod -R 770 $install_dir/interface/lib/lang");
        //* Make the temp directory for language file exports writable
        if(is_dir($install_dir.'/interface/web/temp')) exec("chmod -R 770 $install_dir/interface/web/temp");
        //* Make all interface language file directories group writable
        $handle = @opendir($install_dir.'/interface/web');
        while ($file = @readdir ($handle)) {
            if ($file != '.' && $file != '..') {
                if(@is_dir($install_dir.'/interface/web'.'/'.$file.'/lib/lang')) {
                    $handle2 = opendir($install_dir.'/interface/web'.'/'.$file.'/lib/lang');
                    chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang',0770);
                    while ($lang_file = @readdir ($handle2)) {
                        if ($lang_file != '.' && $lang_file != '..') {
                            chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang/'.$lang_file,0770);
                        }
                    }
                }
            }
        }
        //* make sure that the server config file (not the interface one) is only readable by the root user
        chmod($install_dir.'/server/lib/'.$configfile, 0600);
        chown($install_dir.'/server/lib/'.$configfile, 'root');
        chgrp($install_dir.'/server/lib/'.$configfile, 'root');
        chmod($install_dir.'/server/lib/remote_action.inc.php', 0600);
        chown($install_dir.'/server/lib/remote_action.inc.php', 'root');
        chgrp($install_dir.'/server/lib/remote_action.inc.php', 'root');
        if(@is_file($install_dir.'/server/lib/mysql_clientdb.conf')) {
            chmod($install_dir.'/server/lib/mysql_clientdb.conf', 0600);
            chown($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
            chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
        }
        // 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");
        //* Make the shell scripts executable
        $command = "chmod +x $install_dir/server/scripts/*.sh";
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* Copy the ISPConfig vhost for the controlpanel
        $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        // Dont just copy over the virtualhost template but add some custom settings
        $content = rf('tpl/apache_ispconfig.vhost.master');
        $content = str_replace('{vhost_port}', $conf['apache']['vhost_port'], $content);
        // comment out the listen directive if port is 80 or 443
        if($conf['apache']['vhost_port'] == 80 or $conf['apache']['vhost_port'] == 443) {
            $content = str_replace('{vhost_port_listen}', '#', $content);
        } else {
            $content = str_replace('{vhost_port_listen}', '', $content);
        }
        if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
            $content = str_replace('{ssl_comment}', '', $content);
        } else {
            $content = str_replace('{ssl_comment}', '#', $content);
        }
        wf($vhost_conf_dir.'/ispconfig.vhost', $content);
        //copy('tpl/apache_ispconfig.vhost.master', $vhost_conf_dir.'/ispconfig.vhost');
        //* and create the symlink
        if($this->install_ispconfig_interface == true && $this->is_update == false) {
            if(@is_link($vhost_conf_enabled_dir.'/ispconfig.vhost')) unlink($vhost_conf_enabled_dir.'/ispconfig.vhost');
            if(!@is_link($vhost_conf_enabled_dir.'/000-ispconfig.vhost')) {
                symlink($vhost_conf_dir.'/ispconfig.vhost',$vhost_conf_enabled_dir.'/000-ispconfig.vhost');
            }
        }
        if(!is_file('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) {
            mkdir('/var/www/php-fcgi-scripts/ispconfig', 0755, true);
            copy('tpl/apache_ispconfig_fcgi_starter.master','/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
            exec('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
            symlink($install_dir.'/interface/web','/var/www/ispconfig');
            exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig');
        }
        //* Install the update script
        if(is_file('/usr/local/bin/ispconfig_update_from_svn.sh')) unlink('/usr/local/bin/ispconfig_update_from_svn.sh');
        chown($install_dir.'/server/scripts/update_from_svn.sh', 'root');
        chmod($install_dir.'/server/scripts/update_from_svn.sh', 0700);
        chown($install_dir.'/server/scripts/update_from_tgz.sh', 'root');
        chmod($install_dir.'/server/scripts/update_from_tgz.sh', 0700);
        chown($install_dir.'/server/scripts/ispconfig_update.sh', 'root');
        chmod($install_dir.'/server/scripts/ispconfig_update.sh', 0700);
        if(!is_link('/usr/local/bin/ispconfig_update_from_svn.sh')) symlink($install_dir.'/server/scripts/ispconfig_update.sh','/usr/local/bin/ispconfig_update_from_svn.sh');
        if(!is_link('/usr/local/bin/ispconfig_update.sh')) symlink($install_dir.'/server/scripts/ispconfig_update.sh','/usr/local/bin/ispconfig_update.sh');
        //* Make the logs readable for the ispconfig user
        if(@is_file('/var/log/mail.log')) exec('chmod +r /var/log/mail.log');
        if(@is_file('/var/log/mail.warn')) exec('chmod +r /var/log/mail.warn');
        if(@is_file('/var/log/mail.err')) exec('chmod +r /var/log/mail.err');
        if(@is_file('/var/log/messages')) exec('chmod +r /var/log/messages');
        if(@is_file('/var/log/clamav/clamav.log')) exec('chmod +r /var/log/clamav/clamav.log');
        if(@is_file('/var/log/clamav/freshclam.log')) exec('chmod +r /var/log/clamav/freshclam.log');
        //* Create the ispconfig log file and directory
        if(!is_file($conf['ispconfig_log_dir'].'/ispconfig.log')) {
            if(!is_dir($conf['ispconfig_log_dir'])) mkdir($conf['ispconfig_log_dir'], 0755);
            touch($conf['ispconfig_log_dir'].'/ispconfig.log');
        }
        rename($install_dir.'/server/scripts/run-getmail.sh','/usr/local/bin/run-getmail.sh');
        if(is_user('getmail')) chown('/usr/local/bin/run-getmail.sh', 'getmail');
        chmod('/usr/local/bin/run-getmail.sh', 0744);
        //* Add Log-Rotation
        if (is_dir('/etc/logrotate.d')) {
            @unlink('/etc/logrotate.d/logispc3'); // ignore, if the file is not there
            /* We rotate these logs in cron_daily.php
            $fh = fopen('/etc/logrotate.d/logispc3', 'w');
            fwrite($fh,
                    "$conf['ispconfig_log_dir']/ispconfig.log { \n" .
                    "    weekly \n" .
                    "    missingok \n" .
                    "    rotate 4 \n" .
                    "    compress \n" .
                    "    delaycompress \n" .
                    "} \n" .
                    "$conf['ispconfig_log_dir']/cron.log { \n" .
                    "    weekly \n" .
                    "    missingok \n" .
                    "    rotate 4 \n" .
                    "    compress \n" .
                    "    delaycompress \n" .
                    "}");
            fclose($fh);
            */
        }
    }
    public function configure_dbserver() {
        global $conf;
        //* If this server shall act as database server for client DB's, we configure this here
        $install_dir = $conf['ispconfig_install_dir'];
        // Create a file with the database login details which
        // are used to create the client databases.
        if(!is_dir($install_dir.'/server/lib')) {
            $command = "mkdir $install_dir/server/lib";
            caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        }
        $content = rf('tpl/mysql_clientdb.conf.master');
        $content = str_replace('{username}',$conf['mysql']['admin_user'],$content);
        $content = str_replace('{password}',$conf['mysql']['admin_password'], $content);
        wf($install_dir.'/server/lib/mysql_clientdb.conf',$content);
        chmod($install_dir.'/server/lib/mysql_clientdb.conf', 0600);
        chown($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
        chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
    }
    public function install_crontab() {
        global $conf;
        $install_dir = $conf['ispconfig_install_dir'];
        //* Root Crontab
        exec('crontab -u root -l > crontab.txt');
        $existing_root_cron_jobs = file('crontab.txt');
        // remove existing ispconfig cronjobs, in case the syntax has changed
        foreach($existing_root_cron_jobs as $key => $val) {
            if(stristr($val,$install_dir)) unset($existing_root_cron_jobs[$key]);
        }
        $root_cron_jobs = array(
                "* * * * * ".$install_dir."/server/server.sh > /dev/null 2>> ".$conf['ispconfig_log_dir']."/cron.log",
                "30 00 * * * ".$install_dir."/server/cron_daily.sh > /dev/null 2>> ".$conf['ispconfig_log_dir']."/cron.log"
        );
        foreach($root_cron_jobs as $cron_job) {
            if(!in_array($cron_job."\n", $existing_root_cron_jobs)) {
                $existing_root_cron_jobs[] = $cron_job."\n";
            }
        }
        file_put_contents('crontab.txt', $existing_root_cron_jobs);
        exec('crontab -u root crontab.txt &> /dev/null');
        unlink('crontab.txt');
        //* Getmail crontab
        if(is_user('getmail')) {
            $cf = $conf['getmail'];
            exec('crontab -u getmail -l > crontab.txt');
            $existing_cron_jobs = file('crontab.txt');
            $cron_jobs = array(
                    '*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> '.$conf['ispconfig_log_dir'].'/cron.log'
            );
            // remove existing ispconfig cronjobs, in case the syntax has changed
            foreach($existing_cron_jobs as $key => $val) {
                if(stristr($val,'getmail')) unset($existing_cron_jobs[$key]);
            }
            foreach($cron_jobs as $cron_job) {
                if(!in_array($cron_job."\n", $existing_cron_jobs)) {
                    $existing_cron_jobs[] = $cron_job."\n";
                }
            }
            file_put_contents('crontab.txt', $existing_cron_jobs);
            exec('crontab -u getmail crontab.txt &> /dev/null');
            unlink('crontab.txt');
        }
        touch($conf['ispconfig_log_dir'].'/cron.log');
        chmod($conf['ispconfig_log_dir'].'/cron.log', 0666);
    }
    /**
     * Helper function - get the path to a template file based on
     * the local part of the filename. Checks first for the existence
     * of a distribution specific file and if not found looks in the
     * base template folder. Optionally the behaviour can be changed
     * by setting the 2nd parameter which will fetch the contents
     * of the template file and return it instead of the path. The 3rd
     * parameter further extends this behaviour by filtering the contents
     * by inserting the ispconfig database credentials using the {} placeholders.
     *
     * @param string $tLocal local part of filename
     * @param bool $tRf
     * @param bool $tDBCred
     * @return string Relative path to the chosen template file
     */
    protected function get_template_file($tLocal, $tRf=false, $tDBCred=false) {
        global $conf, $dist;
        $final_path = '';
        $dist_template = 'dist/tpl/'.strtolower($dist['name'])."/$tLocal.master";
        if (file_exists($dist_template)) {
            $final_path = $dist_template;
        } else {
            $final_path = "tpl/$tLocal.master";
        }
        if (!$tRf) {
            return $final_path;
        } else {
            return (!$tDBCred) ? rf($final_path) : $this->insert_db_credentials(rf($final_path));
        }
    }
    /**
     * Helper function - writes the contents to a config file
     * and performs a backup if the file exist. Additionally
     * if the file exists the new file will be given the
     * same rights and ownership as the original. Optionally the
     * rights and/or ownership can be overriden by appending umask,
     * user and group to the parameters. Providing only uid and gid
     * values will result in only a chown.
     *
     * @param $tConf
     * @param $tContents
     * @return bool
     */
    protected function write_config_file($tConf, $tContents) {
        // Backup config file before writing new contents and stat file
        if ( is_file($tConf) ) {
            $stat = exec('stat -c \'%a %U %G\' '.escapeshellarg($tConf), $output, $res);
            if ($res == 0) { // stat successfull
                list($access, $user, $group) = split(" ", $stat);
            }
            if ( copy($tConf, $tConf.'~') ) {
                chmod($tConf.'~', 0400);
            }
        }
        wf($tConf, $tContents); // write file
        if (func_num_args() >= 4) // override rights and/or ownership
        {
            $args = func_get_args();
            $output = array_slice($args, 2);
            switch (sizeof($output)) {
                case 3:
                    $umask = array_shift($output);
                    if (is_numeric($umask) && preg_match('/^0?[0-7]{3}$/', $umask)) {
                        $access = $umask;
                    }
                case 2:
                    if (is_user($output[0]) && is_group($output[1])) {
                        list($user,$group) = $output;
                    }
                    break;
            }
        }
        if (!empty($user) && !empty($group)) {
            chown($tConf, $user);
            chgrp($tConf, $group);
        }
        if (!empty($access)) {
            exec("chmod $access $tConf");
        }
    }
    /**
     * Helper function - filter the contents of a config
     * file by inserting the common ispconfig database
     * credentials.
     *
     * @param $tContents
     * @return string
     */
    protected function insert_db_credentials($tContents) {
        global $conf;
        $tContents = str_replace('{mysql_server_ispconfig_user}', $conf["mysql"]["ispconfig_user"], $tContents);
        $tContents = str_replace('{mysql_server_ispconfig_password}', $conf["mysql"]["ispconfig_password"], $tContents);
        $tContents = str_replace('{mysql_server_database}', $conf["mysql"]["database"], $tContents);
        $tContents = str_replace('{mysql_server_ip}', $conf["mysql"]["ip"], $tContents);
        $tContents = str_replace('{mysql_server_host}',$conf['mysql']['host'], $tContents);
        $tContents = str_replace('{mysql_server_port}',$conf["mysql"]["port"], $tContents);
        return $tContents;
    }
}
?>
install/sql/incremental/upd_0007.sql
New file
@@ -0,0 +1,19 @@
ALTER TABLE client ADD COLUMN limit_mailmailinglist int(11) NOT NULL default '-1';
ALTER TABLE client_template ADD COLUMN limit_mailmailinglist int(11) NOT NULL default '-1';
CREATE TABLE IF NOT EXISTS `mail_mailinglist` (
  `mailinglist_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) NOT NULL,
  `sys_perm_group` varchar(5) character set ucs2 NOT NULL,
  `sys_perm_other` varchar(5) NOT NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `domain` varchar(255) NOT NULL,
  `listname` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  PRIMARY KEY  (`mailinglist_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
DROP TABLE `mail_mailman_domain`;
install/sql/ispconfig3.sql
@@ -1,1655 +1,1661 @@
/*
Copyright (c) 2007-2010, 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
-- DB-Version: 3.0.0.9
--
SET FOREIGN_KEY_CHECKS = 0;
-- --------------------------------------------------------
-- --------------------------------------------------------
-- DB-STRUCTURE
-- --------------------------------------------------------
-- --------------------------------------------------------
--
-- Table structure for table  `client`
--
CREATE TABLE `client` (
  `client_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `company_name` varchar(64) default NULL,
  `contact_name` varchar(64) default NULL,
  `customer_no` varchar(64) default NULL,
  `vat_id` varchar(64) default NULL,
  `street` varchar(255) default NULL,
  `zip` varchar(32) default NULL,
  `city` varchar(64) default NULL,
  `state` varchar(32) default NULL,
  `country` char(2) default NULL,
  `telephone` varchar(32) default NULL,
  `mobile` varchar(32) default NULL,
  `fax` varchar(32) default NULL,
  `email` varchar(255) default NULL,
  `internet` varchar(255) NOT NULL,
  `icq` varchar(16) default NULL,
  `notes` text,
  `default_mailserver` int(11) unsigned NOT NULL default '1',
  `limit_maildomain` int(11) NOT NULL default '-1',
  `limit_mailbox` int(11) NOT NULL default '-1',
  `limit_mailalias` int(11) NOT NULL default '-1',
  `limit_mailaliasdomain` int(11) NOT NULL default '-1',
  `limit_mailforward` int(11) NOT NULL default '-1',
  `limit_mailcatchall` int(11) NOT NULL default '-1',
  `limit_mailrouting` int(11) NOT NULL default '0',
  `limit_mailfilter` int(11) NOT NULL default '-1',
  `limit_fetchmail` int(11) NOT NULL default '-1',
  `limit_mailquota` int(11) NOT NULL default '-1',
  `limit_spamfilter_wblist` int(11) NOT NULL default '0',
  `limit_spamfilter_user` int(11) NOT NULL default '0',
  `limit_spamfilter_policy` int(11) NOT NULL default '0',
  `default_webserver` int(11) unsigned NOT NULL default '1',
  `limit_web_ip` text,
  `limit_web_domain` int(11) NOT NULL default '-1',
  `limit_web_quota` int(11) NOT NULL default '-1',
  `web_php_options` varchar(255) NOT NULL default 'no,fast-cgi,cgi,mod,suphp',
  `limit_web_subdomain` int(11) NOT NULL default '-1',
  `limit_web_aliasdomain` int(11) NOT NULL default '-1',
  `limit_ftp_user` int(11) NOT NULL default '-1',
  `limit_shell_user` int(11) NOT NULL default '0',
  `ssh_chroot` varchar(255) NOT NULL DEFAULT 'no,jailkit,ssh-chroot',
  `limit_webdav_user` int(11) NOT NULL default '0',
  `default_dnsserver` int(11) unsigned NOT NULL default '1',
  `limit_dns_zone` int(11) NOT NULL default '-1',
  `limit_dns_slave_zone` int(11) NOT NULL default '-1',
  `limit_dns_record` int(11) NOT NULL default '-1',
  `default_dbserver` int(11) NOT NULL default '1',
  `limit_database` int(11) NOT NULL default '-1',
  `limit_cron` int(11) NOT NULL default '0',
  `limit_cron_type` enum('url','chrooted','full') NOT NULL default 'url',
  `limit_cron_frequency` int(11) NOT NULL default '5',
  `limit_traffic_quota` int(11) NOT NULL default '-1',
  `limit_client` int(11) NOT NULL default '0',
  `parent_client_id` int(11) unsigned NOT NULL default '0',
  `username` varchar(64) default NULL,
  `password` varchar(64) default NULL,
  `language` char(2) NOT NULL default 'en',
  `usertheme` varchar(32) NOT NULL default 'default',
  `template_master` int(11) unsigned NOT NULL default '0',
  `template_additional` varchar(255) NOT NULL default '',
  `created_at` bigint(20) DEFAULT NULL,
  PRIMARY KEY  (`client_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `client_template`
--
CREATE TABLE `client_template` (
  `template_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `template_name` varchar(64) NOT NULL,
  `template_type` varchar(1) NOT NULL default 'm',
  `limit_maildomain` int(11) NOT NULL default '-1',
  `limit_mailbox` int(11) NOT NULL default '-1',
  `limit_mailalias` int(11) NOT NULL default '-1',
  `limit_mailaliasdomain` int(11) NOT NULL default '-1',
  `limit_mailforward` int(11) NOT NULL default '-1',
  `limit_mailcatchall` int(11) NOT NULL default '-1',
  `limit_mailrouting` int(11) NOT NULL default '0',
  `limit_mailfilter` int(11) NOT NULL default '-1',
  `limit_fetchmail` int(11) NOT NULL default '-1',
  `limit_mailquota` int(11) NOT NULL default '-1',
  `limit_spamfilter_wblist` int(11) NOT NULL default '0',
  `limit_spamfilter_user` int(11) NOT NULL default '0',
  `limit_spamfilter_policy` int(11) NOT NULL default '0',
  `limit_web_ip` text,
  `limit_web_domain` int(11) NOT NULL default '-1',
  `limit_web_quota` int(11) NOT NULL default '-1',
  `limit_web_subdomain` int(11) NOT NULL default '-1',
  `limit_web_aliasdomain` int(11) NOT NULL default '-1',
  `limit_ftp_user` int(11) NOT NULL default '-1',
  `limit_shell_user` int(11) NOT NULL default '0',
  `limit_webdav_user` int(11) NOT NULL default '0',
  `limit_dns_zone` int(11) NOT NULL default '-1',
  `limit_dns_slave_zone` int(11) NOT NULL default '-1',
  `limit_dns_record` int(11) NOT NULL default '-1',
  `limit_database` int(11) NOT NULL default '-1',
  `limit_cron` int(11) NOT NULL default '0',
  `limit_cron_type` enum('url','chrooted','full') NOT NULL default 'url',
  `limit_cron_frequency` int(11) NOT NULL default '5',
  `limit_traffic_quota` int(11) NOT NULL default '-1',
  `limit_client` int(11) NOT NULL default '0',
  PRIMARY KEY  (`template_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `cron`
--
CREATE TABLE `cron` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) NULL default NULL,
  `sys_perm_group` varchar(5) NULL default NULL,
  `sys_perm_other` varchar(5) NULL default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `parent_domain_id` int(11) unsigned NOT NULL default '0',
  `type` enum('url','chrooted','full') NOT NULL default 'url',
  `command` varchar(255) NOT NULL,
  `run_min` varchar(100) NULL,
  `run_hour` varchar(100) NULL,
  `run_mday` varchar(100) NULL,
  `run_month` varchar(100) NULL,
  `run_wday` varchar(100) NULL,
  `active` enum('n','y') NOT NULL default 'y',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `dns_rr`
--
CREATE TABLE `dns_rr` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL,
  `sys_groupid` int(11) unsigned 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(11) NOT NULL default '1',
  `zone` int(11) unsigned NOT NULL,
  `name` varchar(64) NOT NULL,
  `type` enum('A','AAAA','ALIAS','CNAME','HINFO','MX','NAPTR','NS','PTR','RP','SRV','TXT') default NULL,
  `data` varchar(255) NOT NULL,
  `aux` int(11) unsigned NOT NULL default '0',
  `ttl` int(11) unsigned NOT NULL default '86400',
  `active` enum('N','Y') NOT NULL default 'Y',
  `stamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `serial` int(10) unsigned default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `rr` (`zone`,`name`,`type`,`data`)
) ENGINE=MyISAM  AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `dns_soa`
--
CREATE TABLE `dns_soa` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL,
  `sys_groupid` int(11) unsigned 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(11) NOT NULL default '1',
  `origin` varchar(255) NOT NULL,
  `ns` varchar(255) NOT NULL,
  `mbox` varchar(255) NOT NULL,
  `serial` int(11) unsigned NOT NULL default '1',
  `refresh` int(11) unsigned NOT NULL default '28800',
  `retry` int(11) unsigned NOT NULL default '7200',
  `expire` int(11) unsigned NOT NULL default '604800',
  `minimum` int(11) unsigned NOT NULL default '86400',
  `ttl` int(11) unsigned NOT NULL default '86400',
  `active` enum('N','Y') NOT NULL,
  `xfer` varchar(255) NOT NULL,
  `also_notify` varchar(255) default NULL,
  `update_acl` varchar(255) default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `origin` (`origin`),
  KEY `active` (`active`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `dns_slave`
--
CREATE TABLE `dns_slave` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL,
  `sys_groupid` int(11) unsigned 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(11) NOT NULL default '1',
  `origin` varchar(255) NOT NULL,
  `ns` varchar(255) NOT NULL,
  `active` enum('N','Y') NOT NULL,
  `xfer` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `origin` (`origin`),
  KEY `active` (`active`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `dns_template`
--
CREATE TABLE `dns_template` (
  `template_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `name` varchar(64) default NULL,
  `fields` varchar(255) default NULL,
  `template` text,
  `visible` enum('N','Y') NOT NULL default 'Y',
  PRIMARY KEY  (`template_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
--
-- Tabellenstruktur für Tabelle `domain`
--
CREATE TABLE `domain` (
  `domain_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned 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 '',
  `domain` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`domain_id`),
  UNIQUE KEY `domain` (`domain`)
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- Table structure for table  `firewall`
--
CREATE TABLE `firewall` (
  `firewall_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `tcp_port` varchar(255) default NULL,
  `udp_port` varchar(255) default NULL,
  `active` enum('n','y') NOT NULL default 'y',
  PRIMARY KEY  (`firewall_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `ftp_user`
--
CREATE TABLE `ftp_user` (
  `ftp_user_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `parent_domain_id` int(11) unsigned NOT NULL default '0',
  `username` varchar(64) default NULL,
  `password` varchar(64) default NULL,
  `quota_size` bigint(20) NOT NULL default '-1',
  `active` enum('n','y') NOT NULL default 'y',
  `uid` varchar(64) default NULL,
  `gid` varchar(64) default NULL,
  `dir` varchar(255) default NULL,
  `quota_files` bigint(20) NOT NULL default '-1',
  `ul_ratio` int(11) NOT NULL default '-1',
  `dl_ratio` int(11) NOT NULL default '-1',
  `ul_bandwidth` int(11) NOT NULL default '-1',
  `dl_bandwidth` int(11) NOT NULL default '-1',
  PRIMARY KEY  (`ftp_user_id`),
  KEY `active` (`active`),
  KEY `server_id` (`server_id`),
  KEY `username` (`username`),
  KEY `quota_files` (`quota_files`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_access`
--
CREATE TABLE `mail_access` (
  `access_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned 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 AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_content_filter`
--
CREATE TABLE `mail_content_filter` (
  `content_filter_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) NOT NULL default '0',
  `type` varchar(255) default NULL,
  `pattern` varchar(255) default NULL,
  `data` varchar(255) default NULL,
  `action` varchar(255) default NULL,
  `active` varchar(255) NOT NULL default 'y',
  PRIMARY KEY  (`content_filter_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_domain`
--
CREATE TABLE `mail_domain` (
  `domain_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned 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) unsigned NOT NULL default '0',
  `domain` varchar(255) NOT NULL default '',
  `active` enum('n','y') NOT NULL,
  PRIMARY KEY  (`domain_id`),
  KEY `server_id` (`server_id`,`domain`),
  KEY `domain_active` (`domain`,`active`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_forwarding`
--
CREATE TABLE `mail_forwarding` (
  `forwarding_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned 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) unsigned NOT NULL default '0',
  `source` varchar(255) NOT NULL,
  `destination` text,
  `type` enum('alias','aliasdomain','forward','catchall') NOT NULL default 'alias',
  `active` enum('n','y') NOT NULL,
  PRIMARY KEY  (`forwarding_id`),
  KEY `server_id` (`server_id`,`source`),
  KEY `type` (`type`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_get`
--
CREATE TABLE `mail_get` (
  `mailget_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `type` varchar(255) default NULL,
  `source_server` varchar(255) default NULL,
  `source_username` varchar(255) default NULL,
  `source_password` varchar(64) default NULL,
  `source_delete` varchar(255) NOT NULL default 'y',
  `destination` varchar(255) default NULL,
  `active` varchar(255) NOT NULL default 'y',
  PRIMARY KEY  (`mailget_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_greylist`
--
CREATE TABLE `mail_greylist` (
  `greylist_id` int(11) unsigned NOT NULL auto_increment,
  `relay_ip` varchar(39) 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 AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_mailman_domain`
--
CREATE TABLE `mail_mailman_domain` (
  `mailman_id` int(11) unsigned NOT NULL auto_increment,
  `server_id` int(11) unsigned 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 AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for Table `mail_relay_recipient`
--
CREATE TABLE IF NOT EXISTS `mail_relay_recipient` (
  `relay_recipient_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) DEFAULT NULL,
  `sys_perm_group` varchar(5) DEFAULT NULL,
  `sys_perm_other` varchar(5) DEFAULT NULL,
  `server_id` int(11) NOT NULL DEFAULT '0',
  `source` varchar(255) DEFAULT NULL,
  `access` varchar(255) NOT NULL DEFAULT 'OK',
  `active` varchar(255) NOT NULL DEFAULT 'y',
  PRIMARY KEY (`relay_recipient_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_traffic`
--
CREATE TABLE `mail_traffic` (
  `traffic_id` int(11) unsigned NOT NULL auto_increment,
  `mailuser_id` int(11) unsigned NOT NULL,
  `month` char(7) NOT NULL,
  `traffic` bigint(20) unsigned NOT NULL,
  PRIMARY KEY  (`traffic_id`),
  KEY `mailuser_id` (`mailuser_id`,`month`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_transport`
--
CREATE TABLE `mail_transport` (
  `transport_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned 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) unsigned NOT NULL default '0',
  `domain` varchar(255) NOT NULL default '',
  `transport` varchar(255) NOT NULL,
  `sort_order` int(11) unsigned NOT NULL default '5',
  `active` enum('n','y') NOT NULL,
  PRIMARY KEY  (`transport_id`),
  KEY `server_id` (`server_id`,`transport`),
  KEY `server_id_2` (`server_id`,`domain`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_user`
--
CREATE TABLE `mail_user` (
  `mailuser_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned 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) unsigned NOT NULL default '0',
  `email` varchar(255) NOT NULL default '',
  `password` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL default '',
  `uid` int(11) unsigned NOT NULL default '5000',
  `gid` int(11) unsigned NOT NULL default '5000',
  `maildir` varchar(255) NOT NULL default '',
  `quota` bigint(20) NOT NULL default '-1',
  `cc` varchar(255) NOT NULL default '',
  `homedir` varchar(255) NOT NULL,
  `autoresponder` enum('n','y') NOT NULL default 'n',
  `autoresponder_start_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `autoresponder_end_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `autoresponder_text` mediumtext NULL,
  `move_junk` enum('n','y') NOT NULL default 'n',
  `custom_mailfilter` mediumtext,
  `postfix` enum('n','y') NOT NULL,
  `access` enum('n','y') NOT NULL,
  `disableimap` enum('n','y') NOT NULL default 'n',
  `disablepop3` enum('n','y') NOT NULL default 'n',
  `disabledeliver` enum('n','y') NOT NULL default 'n',
  `disablesmtp` enum('n','y') NOT NULL default 'n',
  PRIMARY KEY  (`mailuser_id`),
  KEY `server_id` (`server_id`,`email`),
  KEY `email_access` (`email`,`access`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_user_filter`
--
CREATE TABLE `mail_user_filter` (
  `filter_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `mailuser_id` int(11) unsigned NOT NULL default '0',
  `rulename` varchar(64) default NULL,
  `source` varchar(255) default NULL,
  `searchterm` varchar(255) default NULL,
  `op` varchar(255) default NULL,
  `action` varchar(255) default NULL,
  `target` varchar(255) default NULL,
  `active` enum('n','y') NOT NULL default 'y',
  PRIMARY KEY  (`filter_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `remote_session`
--
CREATE TABLE `remote_session` (
  `remote_session` varchar(64) NOT NULL,
  `remote_userid` int(11) unsigned NOT NULL,
  `remote_functions` text NOT NULL,
  `tstamp` int(10) unsigned NOT NULL,
  PRIMARY KEY  (`remote_session`)
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- Table structure for table  `remote_user`
--
CREATE TABLE `remote_user` (
  `remote_userid` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `remote_username` varchar(64) NOT NULL,
  `remote_password` varchar(64) NOT NULL,
  `remote_functions` text NOT NULL,
  PRIMARY KEY  (`remote_userid`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `server`
--
CREATE TABLE `server` (
  `server_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned 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(1) NOT NULL default '0',
  `web_server` tinyint(1) NOT NULL default '0',
  `dns_server` tinyint(1) NOT NULL default '0',
  `file_server` tinyint(1) NOT NULL default '0',
  `db_server` tinyint(1) NOT NULL default '0',
  `vserver_server` tinyint(1) NOT NULL default '0',
  `config` text NOT NULL,
  `updated` bigint(20) unsigned NOT NULL default '0',
  `mirror_server_id` int(11) unsigned NOT NULL default '0',
  `dbversion` int(11) unsigned NOT NULL default '1',
  `active` tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (`server_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `server_ip`
--
CREATE TABLE `server_ip` (
  `server_ip_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `ip_address` varchar(39) default NULL,
  `virtualhost` enum('n','y') NOT NULL default 'y',
  PRIMARY KEY  (`server_ip_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
CREATE TABLE `shell_user` (
  `shell_user_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `parent_domain_id` int(11) unsigned NOT NULL default '0',
  `username` varchar(64) default NULL,
  `password` varchar(64) default NULL,
  `quota_size` bigint(20) NOT NULL default '-1',
  `active` enum('n','y') NOT NULL default 'y',
  `puser` varchar(255) default NULL,
  `pgroup` varchar(255) default NULL,
  `shell` varchar(255) NOT NULL default '/bin/bash',
  `dir` varchar(255) default NULL,
  `chroot` varchar(255) NOT NULL,
  PRIMARY KEY  (`shell_user_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `software_package`
--
CREATE TABLE `software_package` (
  `package_id` int(11) unsigned NOT NULL auto_increment,
  `software_repo_id` int(11) unsigned NOT NULL,
  `package_name` varchar(64) NOT NULL,
  `package_title` varchar(64) NOT NULL,
  `package_description` text,
  `package_version` varchar(8) default NULL,
  `package_type` enum('ispconfig','app','web') NOT NULL default 'app',
  `package_installable` enum('yes','no','key') NOT NULL default 'yes',
  `package_requires_db` enum('no','mysql') NOT NULL default 'no',
  `package_remote_functions` text,
  `package_key` varchar(255) NOT NULL,
  `package_config` text,
  PRIMARY KEY  (`package_id`),
  UNIQUE KEY `package_name` (`package_name`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `software_repo`
--
CREATE TABLE `software_repo` (
  `software_repo_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `repo_name` varchar(64) default NULL,
  `repo_url` varchar(255) default NULL,
  `repo_username` varchar(64) default NULL,
  `repo_password` varchar(64) default NULL,
  `active` enum('n','y') NOT NULL default 'y',
  PRIMARY KEY  (`software_repo_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `software_update`
--
CREATE TABLE `software_update` (
  `software_update_id` int(11) unsigned NOT NULL auto_increment,
  `software_repo_id` int(11) unsigned NOT NULL,
  `package_name` varchar(64) NOT NULL,
  `update_url` varchar(255) NOT NULL,
  `update_md5` varchar(255) NOT NULL,
  `update_dependencies` varchar(255) NOT NULL,
  `update_title` varchar(64) NOT NULL,
  `v1` tinyint(1) NOT NULL default '0',
  `v2` tinyint(1) NOT NULL default '0',
  `v3` tinyint(1) NOT NULL default '0',
  `v4` tinyint(1) NOT NULL default '0',
  `type` enum('full','update') NOT NULL default 'full',
  PRIMARY KEY  (`software_update_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `software_update_inst`
--
CREATE TABLE `software_update_inst` (
  `software_update_inst_id` int(11) unsigned NOT NULL auto_increment,
  `software_update_id` int(11) unsigned NOT NULL default '0',
  `package_name` varchar(64) NOT NULL,
  `server_id` int(11) unsigned NOT NULL,
  `status` enum('none','installing','installed','deleting','deleted','failed') NOT NULL default 'none',
  PRIMARY KEY  (`software_update_inst_id`),
  UNIQUE KEY `software_update_id` (`software_update_id`,`package_name`,`server_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `spamfilter_policy`
--
CREATE TABLE `spamfilter_policy` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL,
  `sys_groupid` int(11) unsigned 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(64) default NULL,
  `virus_lover` enum('N','Y') default NULL,
  `spam_lover` enum('N','Y') default NULL,
  `banned_files_lover` enum('N','Y') default NULL,
  `bad_header_lover` enum('N','Y') default NULL,
  `bypass_virus_checks` enum('N','Y') default NULL,
  `bypass_spam_checks` enum('N','Y') default NULL,
  `bypass_banned_checks` enum('N','Y') default NULL,
  `bypass_header_checks` enum('N','Y') default NULL,
  `spam_modifies_subj` enum('N','Y') default NULL,
  `virus_quarantine_to` varchar(255) default NULL,
  `spam_quarantine_to` varchar(255) default NULL,
  `banned_quarantine_to` varchar(255) default NULL,
  `bad_header_quarantine_to` varchar(255) default NULL,
  `clean_quarantine_to` varchar(255) default NULL,
  `other_quarantine_to` varchar(255) 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` enum('N','Y') default NULL,
  `warnbannedrecip` enum('N','Y') default NULL,
  `warnbadhrecip` enum('N','Y') 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) unsigned default NULL,
  `banned_rulenames` varchar(64) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table  `spamfilter_users`
--
CREATE TABLE `spamfilter_users` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL,
  `sys_groupid` int(11) unsigned 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(11) unsigned NOT NULL,
  `priority` tinyint(3) unsigned NOT NULL default '7',
  `policy_id` int(11) unsigned NOT NULL default '1',
  `email` varchar(255) NOT NULL,
  `fullname` varchar(64) default NULL,
  `local` varchar(1) default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `spamfilter_wblist`
--
CREATE TABLE `spamfilter_wblist` (
  `wblist_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL,
  `sys_groupid` int(11) unsigned 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(11) unsigned NOT NULL,
  `wb` enum('W','B') NOT NULL default 'W',
  `rid` int(11) unsigned NOT NULL,
  `email` varchar(255) NOT NULL,
  `priority` tinyint(3) unsigned NOT NULL,
  `active` enum('y','n') NOT NULL default 'y',
  PRIMARY KEY  (`wblist_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `support_message`
--
CREATE TABLE `support_message` (
  `support_message_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `recipient_id` int(11) unsigned NOT NULL default '0',
  `sender_id` int(11) unsigned NOT NULL default '0',
  `subject` varchar(255) default NULL,
  `message` text default NULL,
  `tstamp` int(11) NOT NULL default '0',
  PRIMARY KEY  (`support_message_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_datalog`
--
CREATE TABLE `sys_datalog` (
  `datalog_id` int(11) unsigned NOT NULL auto_increment,
  `server_id` int(11) unsigned NOT NULL,
  `dbtable` varchar(255) NOT NULL default '',
  `dbidx` varchar(255) NOT NULL default '',
  `action` char(1) NOT NULL default '',
  `tstamp` int(11) NOT NULL default '0',
  `user` varchar(255) NOT NULL default '',
  `data` longtext NOT NULL,
  `status` set('pending','ok','warning','error') NOT NULL default 'pending',
  PRIMARY KEY  (`datalog_id`),
  KEY `server_id` (`server_id`,`status`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_dbsync`
--
CREATE TABLE `sys_dbsync` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `jobname` varchar(64) NOT NULL default '',
  `sync_interval_minutes` int(11) unsigned NOT NULL default '0',
  `db_type` varchar(16) NOT NULL default '',
  `db_host` varchar(255) NOT NULL default '',
  `db_name` varchar(64) NOT NULL default '',
  `db_username` varchar(64) NOT NULL default '',
  `db_password` varchar(64) NOT NULL default '',
  `db_tables` varchar(255) NOT NULL default 'admin,forms',
  `empty_datalog` int(11) unsigned NOT NULL default '0',
  `sync_datalog_external` int(11) unsigned NOT NULL default '0',
  `active` tinyint(1) NOT NULL default '1',
  `last_datalog_id` int(11) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`),
  KEY `last_datalog_id` (`last_datalog_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_filesync`
--
CREATE TABLE `sys_filesync` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `jobname` varchar(64) NOT NULL default '',
  `sync_interval_minutes` int(11) unsigned NOT NULL default '0',
  `ftp_host` varchar(255) NOT NULL default '',
  `ftp_path` varchar(255) NOT NULL default '',
  `ftp_username` varchar(64) NOT NULL default '',
  `ftp_password` varchar(64) NOT NULL default '',
  `local_path` varchar(255) NOT NULL default '',
  `wput_options` varchar(255) NOT NULL default '--timestamping --reupload --dont-continue',
  `active` tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_group`
--
CREATE TABLE `sys_group` (
  `groupid` int(11) unsigned NOT NULL auto_increment,
  `name` varchar(64) NOT NULL default '',
  `description` text NOT NULL,
  `client_id` int(11) unsigned NOT NULL default '0',
  PRIMARY KEY  (`groupid`)
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_ini`
--
CREATE TABLE `sys_ini` (
  `sysini_id` int(11) unsigned NOT NULL auto_increment,
  `config` longtext NOT NULL,
  PRIMARY KEY  (`sysini_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_log`
--
CREATE TABLE `sys_log` (
  `syslog_id` int(11) unsigned NOT NULL auto_increment,
  `server_id` int(11) unsigned NOT NULL default '0',
  `datalog_id` int(11) unsigned NOT NULL default '0',
  `loglevel` tinyint(4) NOT NULL default '0',
  `tstamp` int(11) unsigned NOT NULL,
  `message` text,
  PRIMARY KEY  (`syslog_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_user`
--
CREATE TABLE `sys_user` (
  `userid` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '1',
  `sys_groupid` int(11) unsigned NOT NULL default '1',
  `sys_perm_user` varchar(5) NOT NULL default 'riud',
  `sys_perm_group` varchar(5) NOT NULL default 'riud',
  `sys_perm_other` varchar(5) NOT NULL default '',
  `username` varchar(64) NOT NULL default '',
  `passwort` varchar(64) NOT NULL default '',
  `modules` varchar(255) NOT NULL default '',
  `startmodule` varchar(255) NOT NULL default '',
  `app_theme` varchar(32) NOT NULL default 'default',
  `typ` varchar(16) NOT NULL default 'user',
  `active` tinyint(1) NOT NULL default '1',
  `language` varchar(2) NOT NULL default 'de',
  `groups` varchar(255) NOT NULL default '',
  `default_group` int(11) unsigned NOT NULL default '0',
  `client_id` int(11) unsigned NOT NULL default '0',
  PRIMARY KEY  (`userid`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_session`
--
CREATE TABLE `sys_session` (
  `session_id` varchar(32) NOT NULL default '',
  `date_created` datetime NOT NULL default '0000-00-00 00:00:00',
  `last_updated` datetime NOT NULL default '0000-00-00 00:00:00',
  `session_data` longtext,
  PRIMARY KEY  (`session_id`),
  KEY `last_updated` (`last_updated`)
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- Table structure for table  `web_domain`
--
CREATE TABLE `web_domain` (
  `domain_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `ip_address` varchar(39) default NULL,
  `domain` varchar(255) default NULL,
  `type` varchar(32) default NULL,
  `parent_domain_id` int(11) unsigned NOT NULL default '0',
  `vhost_type` varchar(32) default NULL,
  `document_root` varchar(255) default NULL,
  `system_user` varchar(255) default NULL,
  `system_group` varchar(255) default NULL,
  `hd_quota` bigint(20) NOT NULL default '0',
  `traffic_quota` bigint(20) NOT NULL default '-1',
  `cgi` enum('n','y') NOT NULL default 'y',
  `ssi` enum('n','y') NOT NULL default 'y',
  `suexec` enum('n','y') NOT NULL default 'y',
  `errordocs` tinyint(1) NOT NULL default '1',
  `is_subdomainwww` tinyint(1) NOT NULL default '1',
  `subdomain` enum('none','www','*') NOT NULL default 'none',
  `php` varchar(32) NOT NULL default 'y',
  `ruby` enum('n','y') NOT NULL default 'n',
  `redirect_type` varchar(255) default NULL,
  `redirect_path` varchar(255) default NULL,
  `ssl` enum('n','y') NOT NULL default 'n',
  `ssl_state` varchar(255) NULL,
  `ssl_locality` varchar(255) NULL,
  `ssl_organisation` varchar(255) NULL,
  `ssl_organisation_unit` varchar(255) NULL,
  `ssl_country` varchar(255) NULL,
  `ssl_domain` varchar(255) NULL,
  `ssl_request` mediumtext NULL,
  `ssl_cert` mediumtext NULL,
  `ssl_bundle` mediumtext NULL,
  `ssl_action` varchar(16) NULL,
  `stats_password` varchar(255) default NULL,
  `stats_type` varchar(255) default 'webalizer',
  `allow_override` varchar(255) NOT NULL default 'All',
  `apache_directives` mediumtext,
  `php_open_basedir` mediumtext,
  `custom_php_ini` mediumtext,
  `backup_interval` VARCHAR( 255 ) NOT NULL DEFAULT 'none',
  `backup_copies` INT NOT NULL DEFAULT '1',
  `active` enum('n','y') NOT NULL default 'y',
  `traffic_quota_lock` enum('n','y') NOT NULL default 'n',
  PRIMARY KEY  (`domain_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `web_database`
--
CREATE TABLE `web_database` (
  `database_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `type` varchar(16) NOT NULL default 'y',
  `database_name` varchar(64) default NULL,
  `database_user` varchar(64) default NULL,
  `database_password` varchar(64) default NULL,
  `database_charset` varchar(64) default NULL,
  `remote_access` enum('n','y') NOT NULL default 'y',
  `remote_ips` text NOT NULL,
  `active` enum('n','y') NOT NULL default 'y',
  PRIMARY KEY  (`database_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `web_traffic`
--
CREATE TABLE `web_traffic` (
  `hostname` varchar(255) NOT NULL,
  `traffic_date` date NOT NULL,
  `traffic_bytes` bigint(32) unsigned NOT NULL default '0',
  PRIMARY KEY  (`hostname`,`traffic_date`)
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- Table structure for table  `webdav_user`
--
CREATE TABLE `webdav_user` (
  `webdav_user_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `parent_domain_id` int(11) unsigned NOT NULL default '0',
  `username` varchar(64) default NULL,
  `password` varchar(64) default NULL,
  `active` enum('n','y') NOT NULL default 'y',
  `dir` varchar(255) default NULL,
  PRIMARY KEY  (`webdav_user_id`)
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- Table structure for table  `attempts_login`
--
CREATE TABLE `attempts_login` (
  `ip` varchar(39) NOT NULL,
  `times` int(11) default NULL,
  `login_time` timestamp
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- Table structure for table  `monitor_data`
--
CREATE TABLE `monitor_data` (
  `server_id` int(11) unsigned NOT NULL,
  `type` varchar(255) NOT NULL,
  `created` int(11) unsigned NOT NULL,
  `data` mediumtext NOT NULL,
  `state` enum('no_state', 'unknown', 'ok', 'info', 'warning', 'critical', 'error') NOT NULL default 'unknown',
  PRIMARY KEY  (`server_id`,`type`,`created`)
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_config`
--
CREATE TABLE `sys_config` (
  `config_id` int(11) unsigned NOT NULL,
  `group` varchar(64) NOT NULL,
  `name` varchar(64) NOT NULL,
  `value` varchar(255) NOT NULL
) ENGINE=MyISAM;
--
-- Tabellenstruktur für Tabelle `sys_remoteaction`
--
CREATE TABLE `sys_remoteaction` (
  `action_id` int(11) unsigned NOT NULL auto_increment,
  `server_id` int(11) unsigned NOT NULL,
  `tstamp` int(11) NOT NULL,
  `action_type` varchar(20) NOT NULL,
  `action_param` mediumtext NOT NULL,
  `action_state` enum('pending','ok','warning','error') NOT NULL,
  `response` mediumtext NOT NULL,
  PRIMARY KEY  (`action_id`),
  KEY `server_id` (`server_id`)
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- iso_country_list.sql
--
-- This will create and then populate a MySQL table with a list of the names and
-- ISO 3166 codes for countries in existence as of the date below.
--
-- For updates to this file, see http://27.org/isocountrylist/
-- For more about ISO 3166, see http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
--
-- Created by getisocountrylist.pl on Sun Nov  2 14:59:20 2003.
-- Wm. Rhodes <iso_country_list@27.org>
--
--
-- Table structure for table `country`
--
CREATE TABLE `country` (
  `iso` char(2) NOT NULL PRIMARY KEY,
  `name` varchar(64) NOT NULL,
  `printable_name` varchar(64) NOT NULL,
  `iso3` char(3),
  `numcode` SMALLINT
) ENGINE=MyISAM;
-- --------------------------------------------------------
-- --------------------------------------------------------
-- DB-DATA
-- --------------------------------------------------------
-- --------------------------------------------------------
--
-- Dumping data for table `dns_template`
--
INSERT INTO `dns_template` (`template_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `name`, `fields`, `template`, `visible`) VALUES (1, 1, 1, 'riud', 'riud', '', 'Default', 'DOMAIN,IP,NS1,NS2,EMAIL', '[ZONE]\norigin={DOMAIN}.\nns={NS1}.\nmbox={EMAIL}.\nrefresh=28800\nretry=7200\nexpire=604800\nminimum=86400\nttl=86400\n\n[DNS_RECORDS]\nA|{DOMAIN}.|{IP}|0|86400\nA|www|{IP}|0|86400\nA|mail|{IP}|0|86400\nNS|{DOMAIN}.|{NS1}.|0|86400\nNS|{DOMAIN}.|{NS2}.|0|86400\nMX|{DOMAIN}.|mail.{DOMAIN}.|10|86400', 'y');
-- --------------------------------------------------------
--
-- Dumping data for table `software_repo`
--
INSERT INTO `software_repo` (`software_repo_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `repo_name`, `repo_url`, `repo_username`, `repo_password`, `active`) VALUES (1, 1, 1, 'riud', 'riud', '', 'ISPConfig Addons', 'http://repo.ispconfig.org/addons/', '', '', 'n');
-- --------------------------------------------------------
--
-- Dumping data for table `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, 1, 0, 'riud', 'riud', 'r', 'Non-paying', 'N', 'N', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'Y', '', '', '', '', '', '', 3, 7, 10, 0, 0, '', '', '', '', 'N', 'N', 'N', '', '', '', '', '', '', '', 0, '');
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(2, 1, 0, 'riud', 'riud', 'r', '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);
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(3, 1, 0, 'riud', 'riud', 'r', '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);
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(4, 1, 0, 'riud', 'riud', 'r', '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);
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(5, 1, 0, 'riud', 'riud', 'r', 'Normal', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', '', '', '', '', '', '', 1, 4.5, 50, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '', '***SPAM***', NULL, NULL);
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(6, 1, 0, 'riud', 'riud', 'r', '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);
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(7, 1, 0, 'riud', 'riud', 'r', '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);
-- --------------------------------------------------------
--
-- Dumping data for table `sys_group`
--
INSERT INTO `sys_group` (`groupid`, `name`, `description`, `client_id`) VALUES (1, 'admin', 'Administrators group', 0);
-- --------------------------------------------------------
--
-- Dumping data for table `sys_ini`
--
INSERT INTO `sys_ini` (`sysini_id`, `config`) VALUES (1, '');
-- --------------------------------------------------------
--
-- Dumping data for table `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`, `language`, `groups`, `default_group`, `client_id`) VALUES (1, 1, 0, 'riud', 'riud', '', 'admin', '21232f297a57a5a743894a0e4a801fc3', 'dashboard,admin,client,mail,monitor,sites,dns,tools,help', 'dashboard', 'default', 'admin', 1, 'en', '1,2', 1, 0);
-- --------------------------------------------------------
--
-- Dumping data for table `sys_config`
--
INSERT INTO sys_config VALUES ('1','db','db_version','3.0.3.1');
-- --------------------------------------------------------
--
-- iso_country_list.sql
--
-- This will create and then populate a MySQL table with a list of the names and
-- ISO 3166 codes for countries in existence as of the date below.
--
-- For updates to this file, see http://27.org/isocountrylist/
-- For more about ISO 3166, see http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
--
-- Created by getisocountrylist.pl on Sun Nov  2 14:59:20 2003.
-- Wm. Rhodes <iso_country_list@27.org>
--
--
-- Dumping data for table `country`
--
INSERT INTO `country` (`iso`, `name`, `printable_name`, `iso3`, `numcode`) VALUES
('AF', 'AFGHANISTAN', 'Afghanistan', 'AFG', 4),
('AL', 'ALBANIA', 'Albania', 'ALB', 8),
('DZ', 'ALGERIA', 'Algeria', 'DZA', 12),
('AS', 'AMERICAN SAMOA', 'American Samoa', 'ASM', 16),
('AD', 'ANDORRA', 'Andorra', 'AND', 20),
('AO', 'ANGOLA', 'Angola', 'AGO', 24),
('AI', 'ANGUILLA', 'Anguilla', 'AIA', 660),
('AQ', 'ANTARCTICA', 'Antarctica', NULL, NULL),
('AG', 'ANTIGUA AND BARBUDA', 'Antigua and Barbuda', 'ATG', 28),
('AR', 'ARGENTINA', 'Argentina', 'ARG', 32),
('AM', 'ARMENIA', 'Armenia', 'ARM', 51),
('AW', 'ARUBA', 'Aruba', 'ABW', 533),
('AU', 'AUSTRALIA', 'Australia', 'AUS', 36),
('AT', 'AUSTRIA', 'Austria', 'AUT', 40),
('AZ', 'AZERBAIJAN', 'Azerbaijan', 'AZE', 31),
('BS', 'BAHAMAS', 'Bahamas', 'BHS', 44),
('BH', 'BAHRAIN', 'Bahrain', 'BHR', 48),
('BD', 'BANGLADESH', 'Bangladesh', 'BGD', 50),
('BB', 'BARBADOS', 'Barbados', 'BRB', 52),
('BY', 'BELARUS', 'Belarus', 'BLR', 112),
('BE', 'BELGIUM', 'Belgium', 'BEL', 56),
('BZ', 'BELIZE', 'Belize', 'BLZ', 84),
('BJ', 'BENIN', 'Benin', 'BEN', 204),
('BM', 'BERMUDA', 'Bermuda', 'BMU', 60),
('BT', 'BHUTAN', 'Bhutan', 'BTN', 64),
('BO', 'BOLIVIA', 'Bolivia', 'BOL', 68),
('BA', 'BOSNIA AND HERZEGOVINA', 'Bosnia and Herzegovina', 'BIH', 70),
('BW', 'BOTSWANA', 'Botswana', 'BWA', 72),
('BV', 'BOUVET ISLAND', 'Bouvet Island', NULL, NULL),
('BR', 'BRAZIL', 'Brazil', 'BRA', 76),
('IO', 'BRITISH INDIAN OCEAN TERRITORY', 'British Indian Ocean Territory', NULL, NULL),
('BN', 'BRUNEI DARUSSALAM', 'Brunei Darussalam', 'BRN', 96),
('BG', 'BULGARIA', 'Bulgaria', 'BGR', 100),
('BF', 'BURKINA FASO', 'Burkina Faso', 'BFA', 854),
('BI', 'BURUNDI', 'Burundi', 'BDI', 108),
('KH', 'CAMBODIA', 'Cambodia', 'KHM', 116),
('CM', 'CAMEROON', 'Cameroon', 'CMR', 120),
('CA', 'CANADA', 'Canada', 'CAN', 124),
('CV', 'CAPE VERDE', 'Cape Verde', 'CPV', 132),
('KY', 'CAYMAN ISLANDS', 'Cayman Islands', 'CYM', 136),
('CF', 'CENTRAL AFRICAN REPUBLIC', 'Central African Republic', 'CAF', 140),
('TD', 'CHAD', 'Chad', 'TCD', 148),
('CL', 'CHILE', 'Chile', 'CHL', 152),
('CN', 'CHINA', 'China', 'CHN', 156),
('CX', 'CHRISTMAS ISLAND', 'Christmas Island', NULL, NULL),
('CC', 'COCOS (KEELING) ISLANDS', 'Cocos (Keeling) Islands', NULL, NULL),
('CO', 'COLOMBIA', 'Colombia', 'COL', 170),
('KM', 'COMOROS', 'Comoros', 'COM', 174),
('CG', 'CONGO', 'Congo', 'COG', 178),
('CD', 'CONGO, THE DEMOCRATIC REPUBLIC OF THE', 'Congo, the Democratic Republic of the', 'COD', 180),
('CK', 'COOK ISLANDS', 'Cook Islands', 'COK', 184),
('CR', 'COSTA RICA', 'Costa Rica', 'CRI', 188),
('CI', 'COTE D''IVOIRE', 'Cote D''Ivoire', 'CIV', 384),
('HR', 'CROATIA', 'Croatia', 'HRV', 191),
('CU', 'CUBA', 'Cuba', 'CUB', 192),
('CY', 'CYPRUS', 'Cyprus', 'CYP', 196),
('CZ', 'CZECH REPUBLIC', 'Czech Republic', 'CZE', 203),
('DK', 'DENMARK', 'Denmark', 'DNK', 208),
('DJ', 'DJIBOUTI', 'Djibouti', 'DJI', 262),
('DM', 'DOMINICA', 'Dominica', 'DMA', 212),
('DO', 'DOMINICAN REPUBLIC', 'Dominican Republic', 'DOM', 214),
('EC', 'ECUADOR', 'Ecuador', 'ECU', 218),
('EG', 'EGYPT', 'Egypt', 'EGY', 818),
('SV', 'EL SALVADOR', 'El Salvador', 'SLV', 222),
('GQ', 'EQUATORIAL GUINEA', 'Equatorial Guinea', 'GNQ', 226),
('ER', 'ERITREA', 'Eritrea', 'ERI', 232),
('EE', 'ESTONIA', 'Estonia', 'EST', 233),
('ET', 'ETHIOPIA', 'Ethiopia', 'ETH', 231),
('FK', 'FALKLAND ISLANDS (MALVINAS)', 'Falkland Islands (Malvinas)', 'FLK', 238),
('FO', 'FAROE ISLANDS', 'Faroe Islands', 'FRO', 234),
('FJ', 'FIJI', 'Fiji', 'FJI', 242),
('FI', 'FINLAND', 'Finland', 'FIN', 246),
('FR', 'FRANCE', 'France', 'FRA', 250),
('GF', 'FRENCH GUIANA', 'French Guiana', 'GUF', 254),
('PF', 'FRENCH POLYNESIA', 'French Polynesia', 'PYF', 258),
('TF', 'FRENCH SOUTHERN TERRITORIES', 'French Southern Territories', NULL, NULL),
('GA', 'GABON', 'Gabon', 'GAB', 266),
('GM', 'GAMBIA', 'Gambia', 'GMB', 270),
('GE', 'GEORGIA', 'Georgia', 'GEO', 268),
('DE', 'GERMANY', 'Germany', 'DEU', 276),
('GH', 'GHANA', 'Ghana', 'GHA', 288),
('GI', 'GIBRALTAR', 'Gibraltar', 'GIB', 292),
('GR', 'GREECE', 'Greece', 'GRC', 300),
('GL', 'GREENLAND', 'Greenland', 'GRL', 304),
('GD', 'GRENADA', 'Grenada', 'GRD', 308),
('GP', 'GUADELOUPE', 'Guadeloupe', 'GLP', 312),
('GU', 'GUAM', 'Guam', 'GUM', 316),
('GT', 'GUATEMALA', 'Guatemala', 'GTM', 320),
('GN', 'GUINEA', 'Guinea', 'GIN', 324),
('GW', 'GUINEA-BISSAU', 'Guinea-Bissau', 'GNB', 624),
('GY', 'GUYANA', 'Guyana', 'GUY', 328),
('HT', 'HAITI', 'Haiti', 'HTI', 332),
('HM', 'HEARD ISLAND AND MCDONALD ISLANDS', 'Heard Island and Mcdonald Islands', NULL, NULL),
('VA', 'HOLY SEE (VATICAN CITY STATE)', 'Holy See (Vatican City State)', 'VAT', 336),
('HN', 'HONDURAS', 'Honduras', 'HND', 340),
('HK', 'HONG KONG', 'Hong Kong', 'HKG', 344),
('HU', 'HUNGARY', 'Hungary', 'HUN', 348),
('IS', 'ICELAND', 'Iceland', 'ISL', 352),
('IN', 'INDIA', 'India', 'IND', 356),
('ID', 'INDONESIA', 'Indonesia', 'IDN', 360),
('IR', 'IRAN, ISLAMIC REPUBLIC OF', 'Iran, Islamic Republic of', 'IRN', 364),
('IQ', 'IRAQ', 'Iraq', 'IRQ', 368),
('IE', 'IRELAND', 'Ireland', 'IRL', 372),
('IL', 'ISRAEL', 'Israel', 'ISR', 376),
('IT', 'ITALY', 'Italy', 'ITA', 380),
('JM', 'JAMAICA', 'Jamaica', 'JAM', 388),
('JP', 'JAPAN', 'Japan', 'JPN', 392),
('JO', 'JORDAN', 'Jordan', 'JOR', 400),
('KZ', 'KAZAKHSTAN', 'Kazakhstan', 'KAZ', 398),
('KE', 'KENYA', 'Kenya', 'KEN', 404),
('KI', 'KIRIBATI', 'Kiribati', 'KIR', 296),
('KP', 'KOREA, DEMOCRATIC PEOPLE''S REPUBLIC OF', 'Korea, Democratic People''s Republic of', 'PRK', 408),
('KR', 'KOREA, REPUBLIC OF', 'Korea, Republic of', 'KOR', 410),
('KW', 'KUWAIT', 'Kuwait', 'KWT', 414),
('KG', 'KYRGYZSTAN', 'Kyrgyzstan', 'KGZ', 417),
('LA', 'LAO PEOPLE''S DEMOCRATIC REPUBLIC', 'Lao People''s Democratic Republic', 'LAO', 418),
('LV', 'LATVIA', 'Latvia', 'LVA', 428),
('LB', 'LEBANON', 'Lebanon', 'LBN', 422),
('LS', 'LESOTHO', 'Lesotho', 'LSO', 426),
('LR', 'LIBERIA', 'Liberia', 'LBR', 430),
('LY', 'LIBYAN ARAB JAMAHIRIYA', 'Libyan Arab Jamahiriya', 'LBY', 434),
('LI', 'LIECHTENSTEIN', 'Liechtenstein', 'LIE', 438),
('LT', 'LITHUANIA', 'Lithuania', 'LTU', 440),
('LU', 'LUXEMBOURG', 'Luxembourg', 'LUX', 442),
('MO', 'MACAO', 'Macao', 'MAC', 446),
('MK', 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF', 'Macedonia, the Former Yugoslav Republic of', 'MKD', 807),
('MG', 'MADAGASCAR', 'Madagascar', 'MDG', 450),
('MW', 'MALAWI', 'Malawi', 'MWI', 454),
('MY', 'MALAYSIA', 'Malaysia', 'MYS', 458),
('MV', 'MALDIVES', 'Maldives', 'MDV', 462),
('ML', 'MALI', 'Mali', 'MLI', 466),
('MT', 'MALTA', 'Malta', 'MLT', 470),
('MH', 'MARSHALL ISLANDS', 'Marshall Islands', 'MHL', 584),
('MQ', 'MARTINIQUE', 'Martinique', 'MTQ', 474),
('MR', 'MAURITANIA', 'Mauritania', 'MRT', 478),
('MU', 'MAURITIUS', 'Mauritius', 'MUS', 480),
('YT', 'MAYOTTE', 'Mayotte', NULL, NULL),
('MX', 'MEXICO', 'Mexico', 'MEX', 484),
('FM', 'MICRONESIA, FEDERATED STATES OF', 'Micronesia, Federated States of', 'FSM', 583),
('MD', 'MOLDOVA, REPUBLIC OF', 'Moldova, Republic of', 'MDA', 498),
('MC', 'MONACO', 'Monaco', 'MCO', 492),
('MN', 'MONGOLIA', 'Mongolia', 'MNG', 496),
('MS', 'MONTSERRAT', 'Montserrat', 'MSR', 500),
('MA', 'MOROCCO', 'Morocco', 'MAR', 504),
('MZ', 'MOZAMBIQUE', 'Mozambique', 'MOZ', 508),
('MM', 'MYANMAR', 'Myanmar', 'MMR', 104),
('NA', 'NAMIBIA', 'Namibia', 'NAM', 516),
('NR', 'NAURU', 'Nauru', 'NRU', 520),
('NP', 'NEPAL', 'Nepal', 'NPL', 524),
('NL', 'NETHERLANDS', 'Netherlands', 'NLD', 528),
('AN', 'NETHERLANDS ANTILLES', 'Netherlands Antilles', 'ANT', 530),
('NC', 'NEW CALEDONIA', 'New Caledonia', 'NCL', 540),
('NZ', 'NEW ZEALAND', 'New Zealand', 'NZL', 554),
('NI', 'NICARAGUA', 'Nicaragua', 'NIC', 558),
('NE', 'NIGER', 'Niger', 'NER', 562),
('NG', 'NIGERIA', 'Nigeria', 'NGA', 566),
('NU', 'NIUE', 'Niue', 'NIU', 570),
('NF', 'NORFOLK ISLAND', 'Norfolk Island', 'NFK', 574),
('MP', 'NORTHERN MARIANA ISLANDS', 'Northern Mariana Islands', 'MNP', 580),
('NO', 'NORWAY', 'Norway', 'NOR', 578),
('OM', 'OMAN', 'Oman', 'OMN', 512),
('PK', 'PAKISTAN', 'Pakistan', 'PAK', 586),
('PW', 'PALAU', 'Palau', 'PLW', 585),
('PS', 'PALESTINIAN TERRITORY, OCCUPIED', 'Palestinian Territory, Occupied', NULL, NULL),
('PA', 'PANAMA', 'Panama', 'PAN', 591),
('PG', 'PAPUA NEW GUINEA', 'Papua New Guinea', 'PNG', 598),
('PY', 'PARAGUAY', 'Paraguay', 'PRY', 600),
('PE', 'PERU', 'Peru', 'PER', 604),
('PH', 'PHILIPPINES', 'Philippines', 'PHL', 608),
('PN', 'PITCAIRN', 'Pitcairn', 'PCN', 612),
('PL', 'POLAND', 'Poland', 'POL', 616),
('PT', 'PORTUGAL', 'Portugal', 'PRT', 620),
('PR', 'PUERTO RICO', 'Puerto Rico', 'PRI', 630),
('QA', 'QATAR', 'Qatar', 'QAT', 634),
('RE', 'REUNION', 'Reunion', 'REU', 638),
('RO', 'ROMANIA', 'Romania', 'ROM', 642),
('RU', 'RUSSIAN FEDERATION', 'Russian Federation', 'RUS', 643),
('RW', 'RWANDA', 'Rwanda', 'RWA', 646),
('SH', 'SAINT HELENA', 'Saint Helena', 'SHN', 654),
('KN', 'SAINT KITTS AND NEVIS', 'Saint Kitts and Nevis', 'KNA', 659),
('LC', 'SAINT LUCIA', 'Saint Lucia', 'LCA', 662),
('PM', 'SAINT PIERRE AND MIQUELON', 'Saint Pierre and Miquelon', 'SPM', 666),
('VC', 'SAINT VINCENT AND THE GRENADINES', 'Saint Vincent and the Grenadines', 'VCT', 670),
('WS', 'SAMOA', 'Samoa', 'WSM', 882),
('SM', 'SAN MARINO', 'San Marino', 'SMR', 674),
('ST', 'SAO TOME AND PRINCIPE', 'Sao Tome and Principe', 'STP', 678),
('SA', 'SAUDI ARABIA', 'Saudi Arabia', 'SAU', 682),
('SN', 'SENEGAL', 'Senegal', 'SEN', 686),
('CS', 'SERBIA AND MONTENEGRO', 'Serbia and Montenegro', NULL, NULL),
('SC', 'SEYCHELLES', 'Seychelles', 'SYC', 690),
('SL', 'SIERRA LEONE', 'Sierra Leone', 'SLE', 694),
('SG', 'SINGAPORE', 'Singapore', 'SGP', 702),
('SK', 'SLOVAKIA', 'Slovakia', 'SVK', 703),
('SI', 'SLOVENIA', 'Slovenia', 'SVN', 705),
('SB', 'SOLOMON ISLANDS', 'Solomon Islands', 'SLB', 90),
('SO', 'SOMALIA', 'Somalia', 'SOM', 706),
('ZA', 'SOUTH AFRICA', 'South Africa', 'ZAF', 710),
('GS', 'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS', 'South Georgia and the South Sandwich Islands', NULL, NULL),
('ES', 'SPAIN', 'Spain', 'ESP', 724),
('LK', 'SRI LANKA', 'Sri Lanka', 'LKA', 144),
('SD', 'SUDAN', 'Sudan', 'SDN', 736),
('SR', 'SURINAME', 'Suriname', 'SUR', 740),
('SJ', 'SVALBARD AND JAN MAYEN', 'Svalbard and Jan Mayen', 'SJM', 744),
('SZ', 'SWAZILAND', 'Swaziland', 'SWZ', 748),
('SE', 'SWEDEN', 'Sweden', 'SWE', 752),
('CH', 'SWITZERLAND', 'Switzerland', 'CHE', 756),
('SY', 'SYRIAN ARAB REPUBLIC', 'Syrian Arab Republic', 'SYR', 760),
('TW', 'TAIWAN, PROVINCE OF CHINA', 'Taiwan, Province of China', 'TWN', 158),
('TJ', 'TAJIKISTAN', 'Tajikistan', 'TJK', 762),
('TZ', 'TANZANIA, UNITED REPUBLIC OF', 'Tanzania, United Republic of', 'TZA', 834),
('TH', 'THAILAND', 'Thailand', 'THA', 764),
('TL', 'TIMOR-LESTE', 'Timor-Leste', NULL, NULL),
('TG', 'TOGO', 'Togo', 'TGO', 768),
('TK', 'TOKELAU', 'Tokelau', 'TKL', 772),
('TO', 'TONGA', 'Tonga', 'TON', 776),
('TT', 'TRINIDAD AND TOBAGO', 'Trinidad and Tobago', 'TTO', 780),
('TN', 'TUNISIA', 'Tunisia', 'TUN', 788),
('TR', 'TURKEY', 'Turkey', 'TUR', 792),
('TM', 'TURKMENISTAN', 'Turkmenistan', 'TKM', 795),
('TC', 'TURKS AND CAICOS ISLANDS', 'Turks and Caicos Islands', 'TCA', 796),
('TV', 'TUVALU', 'Tuvalu', 'TUV', 798),
('UG', 'UGANDA', 'Uganda', 'UGA', 800),
('UA', 'UKRAINE', 'Ukraine', 'UKR', 804),
('AE', 'UNITED ARAB EMIRATES', 'United Arab Emirates', 'ARE', 784),
('GB', 'UNITED KINGDOM', 'United Kingdom', 'GBR', 826),
('US', 'UNITED STATES', 'United States', 'USA', 840),
('UM', 'UNITED STATES MINOR OUTLYING ISLANDS', 'United States Minor Outlying Islands', NULL, NULL),
('UY', 'URUGUAY', 'Uruguay', 'URY', 858),
('UZ', 'UZBEKISTAN', 'Uzbekistan', 'UZB', 860),
('VU', 'VANUATU', 'Vanuatu', 'VUT', 548),
('VE', 'VENEZUELA', 'Venezuela', 'VEN', 862),
('VN', 'VIET NAM', 'Viet Nam', 'VNM', 704),
('VG', 'VIRGIN ISLANDS, BRITISH', 'Virgin Islands, British', 'VGB', 92),
('VI', 'VIRGIN ISLANDS, U.S.', 'Virgin Islands, U.s.', 'VIR', 850),
('WF', 'WALLIS AND FUTUNA', 'Wallis and Futuna', 'WLF', 876),
('EH', 'WESTERN SAHARA', 'Western Sahara', 'ESH', 732),
('YE', 'YEMEN', 'Yemen', 'YEM', 887),
('ZM', 'ZAMBIA', 'Zambia', 'ZMB', 894),
('ZW', 'ZIMBABWE', 'Zimbabwe', 'ZWE', 716);
-- --------------------------------------------------------
-- tables for the FAQ module
CREATE TABLE `help_faq_sections` (
  `hfs_id` int(11) NOT NULL AUTO_INCREMENT,
  `hfs_name` varchar(255) DEFAULT NULL,
  `hfs_order` int(11) DEFAULT '0',
  `sys_userid` int(11) DEFAULT NULL,
  `sys_groupid` int(11) DEFAULT NULL,
  `sys_perm_user` varchar(5) DEFAULT NULL,
  `sys_perm_group` varchar(5) DEFAULT NULL,
  `sys_perm_other` varchar(5) DEFAULT NULL,
  PRIMARY KEY (`hfs_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
INSERT INTO `help_faq_sections` VALUES (1,'General',0,NULL,NULL,NULL,NULL,NULL);
CREATE TABLE `help_faq` (
  `hf_id` int(11) NOT NULL AUTO_INCREMENT,
  `hf_section` int(11) DEFAULT NULL,
  `hf_order` int(11) DEFAULT '0',
  `hf_question` text,
  `hf_answer` text,
  `sys_userid` int(11) DEFAULT NULL,
  `sys_groupid` int(11) DEFAULT NULL,
  `sys_perm_user` varchar(5) DEFAULT NULL,
  `sys_perm_group` varchar(5) DEFAULT NULL,
  `sys_perm_other` varchar(5) DEFAULT NULL,
  PRIMARY KEY (`hf_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
INSERT INTO `help_faq` VALUES (1,1,0,'I\'d like to know ...','Yes, of course.',1,1,'riud','riud','r');
ALTER TABLE client ADD COLUMN company_id varchar(30);
-- --------------------------------------------------------
SET FOREIGN_KEY_CHECKS = 1;
/*
Copyright (c) 2007-2010, 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
-- DB-Version: 3.0.0.9
--
SET FOREIGN_KEY_CHECKS = 0;
-- --------------------------------------------------------
-- --------------------------------------------------------
-- DB-STRUCTURE
-- --------------------------------------------------------
-- --------------------------------------------------------
--
-- Table structure for table  `client`
--
CREATE TABLE `client` (
  `client_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `company_name` varchar(64) default NULL,
  `contact_name` varchar(64) default NULL,
  `customer_no` varchar(64) default NULL,
  `vat_id` varchar(64) default NULL,
  `street` varchar(255) default NULL,
  `zip` varchar(32) default NULL,
  `city` varchar(64) default NULL,
  `state` varchar(32) default NULL,
  `country` char(2) default NULL,
  `telephone` varchar(32) default NULL,
  `mobile` varchar(32) default NULL,
  `fax` varchar(32) default NULL,
  `email` varchar(255) default NULL,
  `internet` varchar(255) NOT NULL,
  `icq` varchar(16) default NULL,
  `notes` text,
  `default_mailserver` int(11) unsigned NOT NULL default '1',
  `limit_maildomain` int(11) NOT NULL default '-1',
  `limit_mailbox` int(11) NOT NULL default '-1',
  `limit_mailalias` int(11) NOT NULL default '-1',
  `limit_mailaliasdomain` int(11) NOT NULL default '-1',
  `limit_mailforward` int(11) NOT NULL default '-1',
  `limit_mailcatchall` int(11) NOT NULL default '-1',
  `limit_mailrouting` int(11) NOT NULL default '0',
  `limit_mailfilter` int(11) NOT NULL default '-1',
  `limit_fetchmail` int(11) NOT NULL default '-1',
  `limit_mailquota` int(11) NOT NULL default '-1',
  `limit_spamfilter_wblist` int(11) NOT NULL default '0',
  `limit_spamfilter_user` int(11) NOT NULL default '0',
  `limit_spamfilter_policy` int(11) NOT NULL default '0',
  `default_webserver` int(11) unsigned NOT NULL default '1',
  `limit_web_ip` text,
  `limit_web_domain` int(11) NOT NULL default '-1',
  `limit_web_quota` int(11) NOT NULL default '-1',
  `web_php_options` varchar(255) NOT NULL default 'no,fast-cgi,cgi,mod,suphp',
  `limit_web_subdomain` int(11) NOT NULL default '-1',
  `limit_web_aliasdomain` int(11) NOT NULL default '-1',
  `limit_ftp_user` int(11) NOT NULL default '-1',
  `limit_shell_user` int(11) NOT NULL default '0',
  `ssh_chroot` varchar(255) NOT NULL DEFAULT 'no,jailkit,ssh-chroot',
  `limit_webdav_user` int(11) NOT NULL default '0',
  `default_dnsserver` int(11) unsigned NOT NULL default '1',
  `limit_dns_zone` int(11) NOT NULL default '-1',
  `limit_dns_slave_zone` int(11) NOT NULL default '-1',
  `limit_dns_record` int(11) NOT NULL default '-1',
  `default_dbserver` int(11) NOT NULL default '1',
  `limit_database` int(11) NOT NULL default '-1',
  `limit_cron` int(11) NOT NULL default '0',
  `limit_cron_type` enum('url','chrooted','full') NOT NULL default 'url',
  `limit_cron_frequency` int(11) NOT NULL default '5',
  `limit_traffic_quota` int(11) NOT NULL default '-1',
  `limit_client` int(11) NOT NULL default '0',
  `limit_mailmailinglist` int(11) NOT NULL default '-1',
  `parent_client_id` int(11) unsigned NOT NULL default '0',
  `username` varchar(64) default NULL,
  `password` varchar(64) default NULL,
  `language` char(2) NOT NULL default 'en',
  `usertheme` varchar(32) NOT NULL default 'default',
  `template_master` int(11) unsigned NOT NULL default '0',
  `template_additional` varchar(255) NOT NULL default '',
  `created_at` bigint(20) DEFAULT NULL,
  PRIMARY KEY  (`client_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `client_template`
--
CREATE TABLE `client_template` (
  `template_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `template_name` varchar(64) NOT NULL,
  `template_type` varchar(1) NOT NULL default 'm',
  `limit_maildomain` int(11) NOT NULL default '-1',
  `limit_mailbox` int(11) NOT NULL default '-1',
  `limit_mailalias` int(11) NOT NULL default '-1',
  `limit_mailaliasdomain` int(11) NOT NULL default '-1',
  `limit_mailforward` int(11) NOT NULL default '-1',
  `limit_mailcatchall` int(11) NOT NULL default '-1',
  `limit_mailrouting` int(11) NOT NULL default '0',
  `limit_mailfilter` int(11) NOT NULL default '-1',
  `limit_fetchmail` int(11) NOT NULL default '-1',
  `limit_mailquota` int(11) NOT NULL default '-1',
  `limit_spamfilter_wblist` int(11) NOT NULL default '0',
  `limit_spamfilter_user` int(11) NOT NULL default '0',
  `limit_spamfilter_policy` int(11) NOT NULL default '0',
  `limit_web_ip` text,
  `limit_web_domain` int(11) NOT NULL default '-1',
  `limit_web_quota` int(11) NOT NULL default '-1',
  `limit_web_subdomain` int(11) NOT NULL default '-1',
  `limit_web_aliasdomain` int(11) NOT NULL default '-1',
  `limit_ftp_user` int(11) NOT NULL default '-1',
  `limit_shell_user` int(11) NOT NULL default '0',
  `limit_webdav_user` int(11) NOT NULL default '0',
  `limit_dns_zone` int(11) NOT NULL default '-1',
  `limit_dns_slave_zone` int(11) NOT NULL default '-1',
  `limit_dns_record` int(11) NOT NULL default '-1',
  `limit_database` int(11) NOT NULL default '-1',
  `limit_cron` int(11) NOT NULL default '0',
  `limit_cron_type` enum('url','chrooted','full') NOT NULL default 'url',
  `limit_cron_frequency` int(11) NOT NULL default '5',
  `limit_traffic_quota` int(11) NOT NULL default '-1',
  `limit_client` int(11) NOT NULL default '0',
  `limit_mailmailinglist` int(11) NOT NULL default '-1',
  PRIMARY KEY  (`template_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `cron`
--
CREATE TABLE `cron` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) NULL default NULL,
  `sys_perm_group` varchar(5) NULL default NULL,
  `sys_perm_other` varchar(5) NULL default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `parent_domain_id` int(11) unsigned NOT NULL default '0',
  `type` enum('url','chrooted','full') NOT NULL default 'url',
  `command` varchar(255) NOT NULL,
  `run_min` varchar(100) NULL,
  `run_hour` varchar(100) NULL,
  `run_mday` varchar(100) NULL,
  `run_month` varchar(100) NULL,
  `run_wday` varchar(100) NULL,
  `active` enum('n','y') NOT NULL default 'y',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `dns_rr`
--
CREATE TABLE `dns_rr` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL,
  `sys_groupid` int(11) unsigned 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(11) NOT NULL default '1',
  `zone` int(11) unsigned NOT NULL,
  `name` varchar(64) NOT NULL,
  `type` enum('A','AAAA','ALIAS','CNAME','HINFO','MX','NAPTR','NS','PTR','RP','SRV','TXT') default NULL,
  `data` varchar(255) NOT NULL,
  `aux` int(11) unsigned NOT NULL default '0',
  `ttl` int(11) unsigned NOT NULL default '86400',
  `active` enum('N','Y') NOT NULL default 'Y',
  `stamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `serial` int(10) unsigned default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `rr` (`zone`,`name`,`type`,`data`)
) ENGINE=MyISAM  AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `dns_soa`
--
CREATE TABLE `dns_soa` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL,
  `sys_groupid` int(11) unsigned 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(11) NOT NULL default '1',
  `origin` varchar(255) NOT NULL,
  `ns` varchar(255) NOT NULL,
  `mbox` varchar(255) NOT NULL,
  `serial` int(11) unsigned NOT NULL default '1',
  `refresh` int(11) unsigned NOT NULL default '28800',
  `retry` int(11) unsigned NOT NULL default '7200',
  `expire` int(11) unsigned NOT NULL default '604800',
  `minimum` int(11) unsigned NOT NULL default '86400',
  `ttl` int(11) unsigned NOT NULL default '86400',
  `active` enum('N','Y') NOT NULL,
  `xfer` varchar(255) NOT NULL,
  `also_notify` varchar(255) default NULL,
  `update_acl` varchar(255) default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `origin` (`origin`),
  KEY `active` (`active`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `dns_slave`
--
CREATE TABLE `dns_slave` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL,
  `sys_groupid` int(11) unsigned 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(11) NOT NULL default '1',
  `origin` varchar(255) NOT NULL,
  `ns` varchar(255) NOT NULL,
  `active` enum('N','Y') NOT NULL,
  `xfer` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `origin` (`origin`),
  KEY `active` (`active`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `dns_template`
--
CREATE TABLE `dns_template` (
  `template_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `name` varchar(64) default NULL,
  `fields` varchar(255) default NULL,
  `template` text,
  `visible` enum('N','Y') NOT NULL default 'Y',
  PRIMARY KEY  (`template_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
--
-- Tabellenstruktur für Tabelle `domain`
--
CREATE TABLE `domain` (
  `domain_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned 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 '',
  `domain` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`domain_id`),
  UNIQUE KEY `domain` (`domain`)
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- Table structure for table  `firewall`
--
CREATE TABLE `firewall` (
  `firewall_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `tcp_port` varchar(255) default NULL,
  `udp_port` varchar(255) default NULL,
  `active` enum('n','y') NOT NULL default 'y',
  PRIMARY KEY  (`firewall_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `ftp_user`
--
CREATE TABLE `ftp_user` (
  `ftp_user_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `parent_domain_id` int(11) unsigned NOT NULL default '0',
  `username` varchar(64) default NULL,
  `password` varchar(64) default NULL,
  `quota_size` bigint(20) NOT NULL default '-1',
  `active` enum('n','y') NOT NULL default 'y',
  `uid` varchar(64) default NULL,
  `gid` varchar(64) default NULL,
  `dir` varchar(255) default NULL,
  `quota_files` bigint(20) NOT NULL default '-1',
  `ul_ratio` int(11) NOT NULL default '-1',
  `dl_ratio` int(11) NOT NULL default '-1',
  `ul_bandwidth` int(11) NOT NULL default '-1',
  `dl_bandwidth` int(11) NOT NULL default '-1',
  PRIMARY KEY  (`ftp_user_id`),
  KEY `active` (`active`),
  KEY `server_id` (`server_id`),
  KEY `username` (`username`),
  KEY `quota_files` (`quota_files`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_access`
--
CREATE TABLE `mail_access` (
  `access_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned 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 AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_content_filter`
--
CREATE TABLE `mail_content_filter` (
  `content_filter_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) NOT NULL default '0',
  `type` varchar(255) default NULL,
  `pattern` varchar(255) default NULL,
  `data` varchar(255) default NULL,
  `action` varchar(255) default NULL,
  `active` varchar(255) NOT NULL default 'y',
  PRIMARY KEY  (`content_filter_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_domain`
--
CREATE TABLE `mail_domain` (
  `domain_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned 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) unsigned NOT NULL default '0',
  `domain` varchar(255) NOT NULL default '',
  `active` enum('n','y') NOT NULL,
  PRIMARY KEY  (`domain_id`),
  KEY `server_id` (`server_id`,`domain`),
  KEY `domain_active` (`domain`,`active`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_forwarding`
--
CREATE TABLE `mail_forwarding` (
  `forwarding_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned 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) unsigned NOT NULL default '0',
  `source` varchar(255) NOT NULL,
  `destination` text,
  `type` enum('alias','aliasdomain','forward','catchall') NOT NULL default 'alias',
  `active` enum('n','y') NOT NULL,
  PRIMARY KEY  (`forwarding_id`),
  KEY `server_id` (`server_id`,`source`),
  KEY `type` (`type`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_get`
--
CREATE TABLE `mail_get` (
  `mailget_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `type` varchar(255) default NULL,
  `source_server` varchar(255) default NULL,
  `source_username` varchar(255) default NULL,
  `source_password` varchar(64) default NULL,
  `source_delete` varchar(255) NOT NULL default 'y',
  `destination` varchar(255) default NULL,
  `active` varchar(255) NOT NULL default 'y',
  PRIMARY KEY  (`mailget_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_greylist`
--
CREATE TABLE `mail_greylist` (
  `greylist_id` int(11) unsigned NOT NULL auto_increment,
  `relay_ip` varchar(39) 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 AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `mail_mailinglist`
--
CREATE TABLE `mail_mailinglist` (
  `mailinglist_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) NOT NULL,
  `sys_perm_group` varchar(5) NOT NULL,
  `sys_perm_other` varchar(5) NOT NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `domain` varchar(255) NOT NULL,
  `listname` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  PRIMARY KEY  (`mailinglist_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for Table `mail_relay_recipient`
--
CREATE TABLE IF NOT EXISTS `mail_relay_recipient` (
  `relay_recipient_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) DEFAULT NULL,
  `sys_perm_group` varchar(5) DEFAULT NULL,
  `sys_perm_other` varchar(5) DEFAULT NULL,
  `server_id` int(11) NOT NULL DEFAULT '0',
  `source` varchar(255) DEFAULT NULL,
  `access` varchar(255) NOT NULL DEFAULT 'OK',
  `active` varchar(255) NOT NULL DEFAULT 'y',
  PRIMARY KEY (`relay_recipient_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_traffic`
--
CREATE TABLE `mail_traffic` (
  `traffic_id` int(11) unsigned NOT NULL auto_increment,
  `mailuser_id` int(11) unsigned NOT NULL,
  `month` char(7) NOT NULL,
  `traffic` bigint(20) unsigned NOT NULL,
  PRIMARY KEY  (`traffic_id`),
  KEY `mailuser_id` (`mailuser_id`,`month`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_transport`
--
CREATE TABLE `mail_transport` (
  `transport_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned 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) unsigned NOT NULL default '0',
  `domain` varchar(255) NOT NULL default '',
  `transport` varchar(255) NOT NULL,
  `sort_order` int(11) unsigned NOT NULL default '5',
  `active` enum('n','y') NOT NULL,
  PRIMARY KEY  (`transport_id`),
  KEY `server_id` (`server_id`,`transport`),
  KEY `server_id_2` (`server_id`,`domain`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_user`
--
CREATE TABLE `mail_user` (
  `mailuser_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned 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) unsigned NOT NULL default '0',
  `email` varchar(255) NOT NULL default '',
  `password` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL default '',
  `uid` int(11) unsigned NOT NULL default '5000',
  `gid` int(11) unsigned NOT NULL default '5000',
  `maildir` varchar(255) NOT NULL default '',
  `quota` bigint(20) NOT NULL default '-1',
  `cc` varchar(255) NOT NULL default '',
  `homedir` varchar(255) NOT NULL,
  `autoresponder` enum('n','y') NOT NULL default 'n',
  `autoresponder_start_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `autoresponder_end_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `autoresponder_text` mediumtext NULL,
  `move_junk` enum('n','y') NOT NULL default 'n',
  `custom_mailfilter` mediumtext,
  `postfix` enum('n','y') NOT NULL,
  `access` enum('n','y') NOT NULL,
  `disableimap` enum('n','y') NOT NULL default 'n',
  `disablepop3` enum('n','y') NOT NULL default 'n',
  `disabledeliver` enum('n','y') NOT NULL default 'n',
  `disablesmtp` enum('n','y') NOT NULL default 'n',
  PRIMARY KEY  (`mailuser_id`),
  KEY `server_id` (`server_id`,`email`),
  KEY `email_access` (`email`,`access`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `mail_user_filter`
--
CREATE TABLE `mail_user_filter` (
  `filter_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `mailuser_id` int(11) unsigned NOT NULL default '0',
  `rulename` varchar(64) default NULL,
  `source` varchar(255) default NULL,
  `searchterm` varchar(255) default NULL,
  `op` varchar(255) default NULL,
  `action` varchar(255) default NULL,
  `target` varchar(255) default NULL,
  `active` enum('n','y') NOT NULL default 'y',
  PRIMARY KEY  (`filter_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `remote_session`
--
CREATE TABLE `remote_session` (
  `remote_session` varchar(64) NOT NULL,
  `remote_userid` int(11) unsigned NOT NULL,
  `remote_functions` text NOT NULL,
  `tstamp` int(10) unsigned NOT NULL,
  PRIMARY KEY  (`remote_session`)
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- Table structure for table  `remote_user`
--
CREATE TABLE `remote_user` (
  `remote_userid` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `remote_username` varchar(64) NOT NULL,
  `remote_password` varchar(64) NOT NULL,
  `remote_functions` text NOT NULL,
  PRIMARY KEY  (`remote_userid`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `server`
--
CREATE TABLE `server` (
  `server_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned 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(1) NOT NULL default '0',
  `web_server` tinyint(1) NOT NULL default '0',
  `dns_server` tinyint(1) NOT NULL default '0',
  `file_server` tinyint(1) NOT NULL default '0',
  `db_server` tinyint(1) NOT NULL default '0',
  `vserver_server` tinyint(1) NOT NULL default '0',
  `config` text NOT NULL,
  `updated` bigint(20) unsigned NOT NULL default '0',
  `mirror_server_id` int(11) unsigned NOT NULL default '0',
  `dbversion` int(11) unsigned NOT NULL default '1',
  `active` tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (`server_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `server_ip`
--
CREATE TABLE `server_ip` (
  `server_ip_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `ip_address` varchar(39) default NULL,
  `virtualhost` enum('n','y') NOT NULL default 'y',
  PRIMARY KEY  (`server_ip_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
CREATE TABLE `shell_user` (
  `shell_user_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `parent_domain_id` int(11) unsigned NOT NULL default '0',
  `username` varchar(64) default NULL,
  `password` varchar(64) default NULL,
  `quota_size` bigint(20) NOT NULL default '-1',
  `active` enum('n','y') NOT NULL default 'y',
  `puser` varchar(255) default NULL,
  `pgroup` varchar(255) default NULL,
  `shell` varchar(255) NOT NULL default '/bin/bash',
  `dir` varchar(255) default NULL,
  `chroot` varchar(255) NOT NULL,
  PRIMARY KEY  (`shell_user_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `software_package`
--
CREATE TABLE `software_package` (
  `package_id` int(11) unsigned NOT NULL auto_increment,
  `software_repo_id` int(11) unsigned NOT NULL,
  `package_name` varchar(64) NOT NULL,
  `package_title` varchar(64) NOT NULL,
  `package_description` text,
  `package_version` varchar(8) default NULL,
  `package_type` enum('ispconfig','app','web') NOT NULL default 'app',
  `package_installable` enum('yes','no','key') NOT NULL default 'yes',
  `package_requires_db` enum('no','mysql') NOT NULL default 'no',
  `package_remote_functions` text,
  `package_key` varchar(255) NOT NULL,
  `package_config` text,
  PRIMARY KEY  (`package_id`),
  UNIQUE KEY `package_name` (`package_name`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `software_repo`
--
CREATE TABLE `software_repo` (
  `software_repo_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `repo_name` varchar(64) default NULL,
  `repo_url` varchar(255) default NULL,
  `repo_username` varchar(64) default NULL,
  `repo_password` varchar(64) default NULL,
  `active` enum('n','y') NOT NULL default 'y',
  PRIMARY KEY  (`software_repo_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `software_update`
--
CREATE TABLE `software_update` (
  `software_update_id` int(11) unsigned NOT NULL auto_increment,
  `software_repo_id` int(11) unsigned NOT NULL,
  `package_name` varchar(64) NOT NULL,
  `update_url` varchar(255) NOT NULL,
  `update_md5` varchar(255) NOT NULL,
  `update_dependencies` varchar(255) NOT NULL,
  `update_title` varchar(64) NOT NULL,
  `v1` tinyint(1) NOT NULL default '0',
  `v2` tinyint(1) NOT NULL default '0',
  `v3` tinyint(1) NOT NULL default '0',
  `v4` tinyint(1) NOT NULL default '0',
  `type` enum('full','update') NOT NULL default 'full',
  PRIMARY KEY  (`software_update_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `software_update_inst`
--
CREATE TABLE `software_update_inst` (
  `software_update_inst_id` int(11) unsigned NOT NULL auto_increment,
  `software_update_id` int(11) unsigned NOT NULL default '0',
  `package_name` varchar(64) NOT NULL,
  `server_id` int(11) unsigned NOT NULL,
  `status` enum('none','installing','installed','deleting','deleted','failed') NOT NULL default 'none',
  PRIMARY KEY  (`software_update_inst_id`),
  UNIQUE KEY `software_update_id` (`software_update_id`,`package_name`,`server_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `spamfilter_policy`
--
CREATE TABLE `spamfilter_policy` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL,
  `sys_groupid` int(11) unsigned 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(64) default NULL,
  `virus_lover` enum('N','Y') default NULL,
  `spam_lover` enum('N','Y') default NULL,
  `banned_files_lover` enum('N','Y') default NULL,
  `bad_header_lover` enum('N','Y') default NULL,
  `bypass_virus_checks` enum('N','Y') default NULL,
  `bypass_spam_checks` enum('N','Y') default NULL,
  `bypass_banned_checks` enum('N','Y') default NULL,
  `bypass_header_checks` enum('N','Y') default NULL,
  `spam_modifies_subj` enum('N','Y') default NULL,
  `virus_quarantine_to` varchar(255) default NULL,
  `spam_quarantine_to` varchar(255) default NULL,
  `banned_quarantine_to` varchar(255) default NULL,
  `bad_header_quarantine_to` varchar(255) default NULL,
  `clean_quarantine_to` varchar(255) default NULL,
  `other_quarantine_to` varchar(255) 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` enum('N','Y') default NULL,
  `warnbannedrecip` enum('N','Y') default NULL,
  `warnbadhrecip` enum('N','Y') 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) unsigned default NULL,
  `banned_rulenames` varchar(64) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table  `spamfilter_users`
--
CREATE TABLE `spamfilter_users` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL,
  `sys_groupid` int(11) unsigned 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(11) unsigned NOT NULL,
  `priority` tinyint(3) unsigned NOT NULL default '7',
  `policy_id` int(11) unsigned NOT NULL default '1',
  `email` varchar(255) NOT NULL,
  `fullname` varchar(64) default NULL,
  `local` varchar(1) default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `spamfilter_wblist`
--
CREATE TABLE `spamfilter_wblist` (
  `wblist_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL,
  `sys_groupid` int(11) unsigned 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(11) unsigned NOT NULL,
  `wb` enum('W','B') NOT NULL default 'W',
  `rid` int(11) unsigned NOT NULL,
  `email` varchar(255) NOT NULL,
  `priority` tinyint(3) unsigned NOT NULL,
  `active` enum('y','n') NOT NULL default 'y',
  PRIMARY KEY  (`wblist_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `support_message`
--
CREATE TABLE `support_message` (
  `support_message_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `recipient_id` int(11) unsigned NOT NULL default '0',
  `sender_id` int(11) unsigned NOT NULL default '0',
  `subject` varchar(255) default NULL,
  `message` text default NULL,
  `tstamp` int(11) NOT NULL default '0',
  PRIMARY KEY  (`support_message_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_datalog`
--
CREATE TABLE `sys_datalog` (
  `datalog_id` int(11) unsigned NOT NULL auto_increment,
  `server_id` int(11) unsigned NOT NULL,
  `dbtable` varchar(255) NOT NULL default '',
  `dbidx` varchar(255) NOT NULL default '',
  `action` char(1) NOT NULL default '',
  `tstamp` int(11) NOT NULL default '0',
  `user` varchar(255) NOT NULL default '',
  `data` longtext NOT NULL,
  `status` set('pending','ok','warning','error') NOT NULL default 'pending',
  PRIMARY KEY  (`datalog_id`),
  KEY `server_id` (`server_id`,`status`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_dbsync`
--
CREATE TABLE `sys_dbsync` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `jobname` varchar(64) NOT NULL default '',
  `sync_interval_minutes` int(11) unsigned NOT NULL default '0',
  `db_type` varchar(16) NOT NULL default '',
  `db_host` varchar(255) NOT NULL default '',
  `db_name` varchar(64) NOT NULL default '',
  `db_username` varchar(64) NOT NULL default '',
  `db_password` varchar(64) NOT NULL default '',
  `db_tables` varchar(255) NOT NULL default 'admin,forms',
  `empty_datalog` int(11) unsigned NOT NULL default '0',
  `sync_datalog_external` int(11) unsigned NOT NULL default '0',
  `active` tinyint(1) NOT NULL default '1',
  `last_datalog_id` int(11) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`),
  KEY `last_datalog_id` (`last_datalog_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_filesync`
--
CREATE TABLE `sys_filesync` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `jobname` varchar(64) NOT NULL default '',
  `sync_interval_minutes` int(11) unsigned NOT NULL default '0',
  `ftp_host` varchar(255) NOT NULL default '',
  `ftp_path` varchar(255) NOT NULL default '',
  `ftp_username` varchar(64) NOT NULL default '',
  `ftp_password` varchar(64) NOT NULL default '',
  `local_path` varchar(255) NOT NULL default '',
  `wput_options` varchar(255) NOT NULL default '--timestamping --reupload --dont-continue',
  `active` tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_group`
--
CREATE TABLE `sys_group` (
  `groupid` int(11) unsigned NOT NULL auto_increment,
  `name` varchar(64) NOT NULL default '',
  `description` text NOT NULL,
  `client_id` int(11) unsigned NOT NULL default '0',
  PRIMARY KEY  (`groupid`)
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_ini`
--
CREATE TABLE `sys_ini` (
  `sysini_id` int(11) unsigned NOT NULL auto_increment,
  `config` longtext NOT NULL,
  PRIMARY KEY  (`sysini_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_log`
--
CREATE TABLE `sys_log` (
  `syslog_id` int(11) unsigned NOT NULL auto_increment,
  `server_id` int(11) unsigned NOT NULL default '0',
  `datalog_id` int(11) unsigned NOT NULL default '0',
  `loglevel` tinyint(4) NOT NULL default '0',
  `tstamp` int(11) unsigned NOT NULL,
  `message` text,
  PRIMARY KEY  (`syslog_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_user`
--
CREATE TABLE `sys_user` (
  `userid` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '1',
  `sys_groupid` int(11) unsigned NOT NULL default '1',
  `sys_perm_user` varchar(5) NOT NULL default 'riud',
  `sys_perm_group` varchar(5) NOT NULL default 'riud',
  `sys_perm_other` varchar(5) NOT NULL default '',
  `username` varchar(64) NOT NULL default '',
  `passwort` varchar(64) NOT NULL default '',
  `modules` varchar(255) NOT NULL default '',
  `startmodule` varchar(255) NOT NULL default '',
  `app_theme` varchar(32) NOT NULL default 'default',
  `typ` varchar(16) NOT NULL default 'user',
  `active` tinyint(1) NOT NULL default '1',
  `language` varchar(2) NOT NULL default 'de',
  `groups` varchar(255) NOT NULL default '',
  `default_group` int(11) unsigned NOT NULL default '0',
  `client_id` int(11) unsigned NOT NULL default '0',
  PRIMARY KEY  (`userid`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_session`
--
CREATE TABLE `sys_session` (
  `session_id` varchar(32) NOT NULL default '',
  `date_created` datetime NOT NULL default '0000-00-00 00:00:00',
  `last_updated` datetime NOT NULL default '0000-00-00 00:00:00',
  `session_data` longtext,
  PRIMARY KEY  (`session_id`),
  KEY `last_updated` (`last_updated`)
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- Table structure for table  `web_domain`
--
CREATE TABLE `web_domain` (
  `domain_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `ip_address` varchar(39) default NULL,
  `domain` varchar(255) default NULL,
  `type` varchar(32) default NULL,
  `parent_domain_id` int(11) unsigned NOT NULL default '0',
  `vhost_type` varchar(32) default NULL,
  `document_root` varchar(255) default NULL,
  `system_user` varchar(255) default NULL,
  `system_group` varchar(255) default NULL,
  `hd_quota` bigint(20) NOT NULL default '0',
  `traffic_quota` bigint(20) NOT NULL default '-1',
  `cgi` enum('n','y') NOT NULL default 'y',
  `ssi` enum('n','y') NOT NULL default 'y',
  `suexec` enum('n','y') NOT NULL default 'y',
  `errordocs` tinyint(1) NOT NULL default '1',
  `is_subdomainwww` tinyint(1) NOT NULL default '1',
  `subdomain` enum('none','www','*') NOT NULL default 'none',
  `php` varchar(32) NOT NULL default 'y',
  `ruby` enum('n','y') NOT NULL default 'n',
  `redirect_type` varchar(255) default NULL,
  `redirect_path` varchar(255) default NULL,
  `ssl` enum('n','y') NOT NULL default 'n',
  `ssl_state` varchar(255) NULL,
  `ssl_locality` varchar(255) NULL,
  `ssl_organisation` varchar(255) NULL,
  `ssl_organisation_unit` varchar(255) NULL,
  `ssl_country` varchar(255) NULL,
  `ssl_domain` varchar(255) NULL,
  `ssl_request` mediumtext NULL,
  `ssl_cert` mediumtext NULL,
  `ssl_bundle` mediumtext NULL,
  `ssl_action` varchar(16) NULL,
  `stats_password` varchar(255) default NULL,
  `stats_type` varchar(255) default 'webalizer',
  `allow_override` varchar(255) NOT NULL default 'All',
  `apache_directives` mediumtext,
  `php_open_basedir` mediumtext,
  `custom_php_ini` mediumtext,
  `backup_interval` VARCHAR( 255 ) NOT NULL DEFAULT 'none',
  `backup_copies` INT NOT NULL DEFAULT '1',
  `active` enum('n','y') NOT NULL default 'y',
  `traffic_quota_lock` enum('n','y') NOT NULL default 'n',
  PRIMARY KEY  (`domain_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `web_database`
--
CREATE TABLE `web_database` (
  `database_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `type` varchar(16) NOT NULL default 'y',
  `database_name` varchar(64) default NULL,
  `database_user` varchar(64) default NULL,
  `database_password` varchar(64) default NULL,
  `database_charset` varchar(64) default NULL,
  `remote_access` enum('n','y') NOT NULL default 'y',
  `remote_ips` text NOT NULL,
  `active` enum('n','y') NOT NULL default 'y',
  PRIMARY KEY  (`database_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
-- --------------------------------------------------------
--
-- Table structure for table  `web_traffic`
--
CREATE TABLE `web_traffic` (
  `hostname` varchar(255) NOT NULL,
  `traffic_date` date NOT NULL,
  `traffic_bytes` bigint(32) unsigned NOT NULL default '0',
  PRIMARY KEY  (`hostname`,`traffic_date`)
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- Table structure for table  `webdav_user`
--
CREATE TABLE `webdav_user` (
  `webdav_user_id` int(11) unsigned NOT NULL auto_increment,
  `sys_userid` int(11) unsigned NOT NULL default '0',
  `sys_groupid` int(11) unsigned NOT NULL default '0',
  `sys_perm_user` varchar(5) default NULL,
  `sys_perm_group` varchar(5) default NULL,
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `parent_domain_id` int(11) unsigned NOT NULL default '0',
  `username` varchar(64) default NULL,
  `password` varchar(64) default NULL,
  `active` enum('n','y') NOT NULL default 'y',
  `dir` varchar(255) default NULL,
  PRIMARY KEY  (`webdav_user_id`)
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- Table structure for table  `attempts_login`
--
CREATE TABLE `attempts_login` (
  `ip` varchar(39) NOT NULL,
  `times` int(11) default NULL,
  `login_time` timestamp
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- Table structure for table  `monitor_data`
--
CREATE TABLE `monitor_data` (
  `server_id` int(11) unsigned NOT NULL,
  `type` varchar(255) NOT NULL,
  `created` int(11) unsigned NOT NULL,
  `data` mediumtext NOT NULL,
  `state` enum('no_state', 'unknown', 'ok', 'info', 'warning', 'critical', 'error') NOT NULL default 'unknown',
  PRIMARY KEY  (`server_id`,`type`,`created`)
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- Table structure for table  `sys_config`
--
CREATE TABLE `sys_config` (
  `config_id` int(11) unsigned NOT NULL,
  `group` varchar(64) NOT NULL,
  `name` varchar(64) NOT NULL,
  `value` varchar(255) NOT NULL
) ENGINE=MyISAM;
--
-- Tabellenstruktur für Tabelle `sys_remoteaction`
--
CREATE TABLE `sys_remoteaction` (
  `action_id` int(11) unsigned NOT NULL auto_increment,
  `server_id` int(11) unsigned NOT NULL,
  `tstamp` int(11) NOT NULL,
  `action_type` varchar(20) NOT NULL,
  `action_param` mediumtext NOT NULL,
  `action_state` enum('pending','ok','warning','error') NOT NULL,
  `response` mediumtext NOT NULL,
  PRIMARY KEY  (`action_id`),
  KEY `server_id` (`server_id`)
) ENGINE=MyISAM;
-- --------------------------------------------------------
--
-- iso_country_list.sql
--
-- This will create and then populate a MySQL table with a list of the names and
-- ISO 3166 codes for countries in existence as of the date below.
--
-- For updates to this file, see http://27.org/isocountrylist/
-- For more about ISO 3166, see http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
--
-- Created by getisocountrylist.pl on Sun Nov  2 14:59:20 2003.
-- Wm. Rhodes <iso_country_list@27.org>
--
--
-- Table structure for table `country`
--
CREATE TABLE `country` (
  `iso` char(2) NOT NULL PRIMARY KEY,
  `name` varchar(64) NOT NULL,
  `printable_name` varchar(64) NOT NULL,
  `iso3` char(3),
  `numcode` SMALLINT
) ENGINE=MyISAM;
-- --------------------------------------------------------
-- --------------------------------------------------------
-- DB-DATA
-- --------------------------------------------------------
-- --------------------------------------------------------
--
-- Dumping data for table `dns_template`
--
INSERT INTO `dns_template` (`template_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `name`, `fields`, `template`, `visible`) VALUES (1, 1, 1, 'riud', 'riud', '', 'Default', 'DOMAIN,IP,NS1,NS2,EMAIL', '[ZONE]\norigin={DOMAIN}.\nns={NS1}.\nmbox={EMAIL}.\nrefresh=28800\nretry=7200\nexpire=604800\nminimum=86400\nttl=86400\n\n[DNS_RECORDS]\nA|{DOMAIN}.|{IP}|0|86400\nA|www|{IP}|0|86400\nA|mail|{IP}|0|86400\nNS|{DOMAIN}.|{NS1}.|0|86400\nNS|{DOMAIN}.|{NS2}.|0|86400\nMX|{DOMAIN}.|mail.{DOMAIN}.|10|86400', 'y');
-- --------------------------------------------------------
--
-- Dumping data for table `software_repo`
--
INSERT INTO `software_repo` (`software_repo_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `repo_name`, `repo_url`, `repo_username`, `repo_password`, `active`) VALUES (1, 1, 1, 'riud', 'riud', '', 'ISPConfig Addons', 'http://repo.ispconfig.org/addons/', '', '', 'n');
-- --------------------------------------------------------
--
-- Dumping data for table `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, 1, 0, 'riud', 'riud', 'r', 'Non-paying', 'N', 'N', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'Y', '', '', '', '', '', '', 3, 7, 10, 0, 0, '', '', '', '', 'N', 'N', 'N', '', '', '', '', '', '', '', 0, '');
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(2, 1, 0, 'riud', 'riud', 'r', '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);
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(3, 1, 0, 'riud', 'riud', 'r', '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);
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(4, 1, 0, 'riud', 'riud', 'r', '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);
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(5, 1, 0, 'riud', 'riud', 'r', 'Normal', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', '', '', '', '', '', '', 1, 4.5, 50, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '', '***SPAM***', NULL, NULL);
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(6, 1, 0, 'riud', 'riud', 'r', '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);
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(7, 1, 0, 'riud', 'riud', 'r', '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);
-- --------------------------------------------------------
--
-- Dumping data for table `sys_group`
--
INSERT INTO `sys_group` (`groupid`, `name`, `description`, `client_id`) VALUES (1, 'admin', 'Administrators group', 0);
-- --------------------------------------------------------
--
-- Dumping data for table `sys_ini`
--
INSERT INTO `sys_ini` (`sysini_id`, `config`) VALUES (1, '');
-- --------------------------------------------------------
--
-- Dumping data for table `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`, `language`, `groups`, `default_group`, `client_id`) VALUES (1, 1, 0, 'riud', 'riud', '', 'admin', '21232f297a57a5a743894a0e4a801fc3', 'dashboard,admin,client,mail,monitor,sites,dns,tools,help', 'dashboard', 'default', 'admin', 1, 'en', '1,2', 1, 0);
-- --------------------------------------------------------
--
-- Dumping data for table `sys_config`
--
INSERT INTO sys_config VALUES ('1','db','db_version','3.0.3.1');
-- --------------------------------------------------------
--
-- iso_country_list.sql
--
-- This will create and then populate a MySQL table with a list of the names and
-- ISO 3166 codes for countries in existence as of the date below.
--
-- For updates to this file, see http://27.org/isocountrylist/
-- For more about ISO 3166, see http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
--
-- Created by getisocountrylist.pl on Sun Nov  2 14:59:20 2003.
-- Wm. Rhodes <iso_country_list@27.org>
--
--
-- Dumping data for table `country`
--
INSERT INTO `country` (`iso`, `name`, `printable_name`, `iso3`, `numcode`) VALUES
('AF', 'AFGHANISTAN', 'Afghanistan', 'AFG', 4),
('AL', 'ALBANIA', 'Albania', 'ALB', 8),
('DZ', 'ALGERIA', 'Algeria', 'DZA', 12),
('AS', 'AMERICAN SAMOA', 'American Samoa', 'ASM', 16),
('AD', 'ANDORRA', 'Andorra', 'AND', 20),
('AO', 'ANGOLA', 'Angola', 'AGO', 24),
('AI', 'ANGUILLA', 'Anguilla', 'AIA', 660),
('AQ', 'ANTARCTICA', 'Antarctica', NULL, NULL),
('AG', 'ANTIGUA AND BARBUDA', 'Antigua and Barbuda', 'ATG', 28),
('AR', 'ARGENTINA', 'Argentina', 'ARG', 32),
('AM', 'ARMENIA', 'Armenia', 'ARM', 51),
('AW', 'ARUBA', 'Aruba', 'ABW', 533),
('AU', 'AUSTRALIA', 'Australia', 'AUS', 36),
('AT', 'AUSTRIA', 'Austria', 'AUT', 40),
('AZ', 'AZERBAIJAN', 'Azerbaijan', 'AZE', 31),
('BS', 'BAHAMAS', 'Bahamas', 'BHS', 44),
('BH', 'BAHRAIN', 'Bahrain', 'BHR', 48),
('BD', 'BANGLADESH', 'Bangladesh', 'BGD', 50),
('BB', 'BARBADOS', 'Barbados', 'BRB', 52),
('BY', 'BELARUS', 'Belarus', 'BLR', 112),
('BE', 'BELGIUM', 'Belgium', 'BEL', 56),
('BZ', 'BELIZE', 'Belize', 'BLZ', 84),
('BJ', 'BENIN', 'Benin', 'BEN', 204),
('BM', 'BERMUDA', 'Bermuda', 'BMU', 60),
('BT', 'BHUTAN', 'Bhutan', 'BTN', 64),
('BO', 'BOLIVIA', 'Bolivia', 'BOL', 68),
('BA', 'BOSNIA AND HERZEGOVINA', 'Bosnia and Herzegovina', 'BIH', 70),
('BW', 'BOTSWANA', 'Botswana', 'BWA', 72),
('BV', 'BOUVET ISLAND', 'Bouvet Island', NULL, NULL),
('BR', 'BRAZIL', 'Brazil', 'BRA', 76),
('IO', 'BRITISH INDIAN OCEAN TERRITORY', 'British Indian Ocean Territory', NULL, NULL),
('BN', 'BRUNEI DARUSSALAM', 'Brunei Darussalam', 'BRN', 96),
('BG', 'BULGARIA', 'Bulgaria', 'BGR', 100),
('BF', 'BURKINA FASO', 'Burkina Faso', 'BFA', 854),
('BI', 'BURUNDI', 'Burundi', 'BDI', 108),
('KH', 'CAMBODIA', 'Cambodia', 'KHM', 116),
('CM', 'CAMEROON', 'Cameroon', 'CMR', 120),
('CA', 'CANADA', 'Canada', 'CAN', 124),
('CV', 'CAPE VERDE', 'Cape Verde', 'CPV', 132),
('KY', 'CAYMAN ISLANDS', 'Cayman Islands', 'CYM', 136),
('CF', 'CENTRAL AFRICAN REPUBLIC', 'Central African Republic', 'CAF', 140),
('TD', 'CHAD', 'Chad', 'TCD', 148),
('CL', 'CHILE', 'Chile', 'CHL', 152),
('CN', 'CHINA', 'China', 'CHN', 156),
('CX', 'CHRISTMAS ISLAND', 'Christmas Island', NULL, NULL),
('CC', 'COCOS (KEELING) ISLANDS', 'Cocos (Keeling) Islands', NULL, NULL),
('CO', 'COLOMBIA', 'Colombia', 'COL', 170),
('KM', 'COMOROS', 'Comoros', 'COM', 174),
('CG', 'CONGO', 'Congo', 'COG', 178),
('CD', 'CONGO, THE DEMOCRATIC REPUBLIC OF THE', 'Congo, the Democratic Republic of the', 'COD', 180),
('CK', 'COOK ISLANDS', 'Cook Islands', 'COK', 184),
('CR', 'COSTA RICA', 'Costa Rica', 'CRI', 188),
('CI', 'COTE D''IVOIRE', 'Cote D''Ivoire', 'CIV', 384),
('HR', 'CROATIA', 'Croatia', 'HRV', 191),
('CU', 'CUBA', 'Cuba', 'CUB', 192),
('CY', 'CYPRUS', 'Cyprus', 'CYP', 196),
('CZ', 'CZECH REPUBLIC', 'Czech Republic', 'CZE', 203),
('DK', 'DENMARK', 'Denmark', 'DNK', 208),
('DJ', 'DJIBOUTI', 'Djibouti', 'DJI', 262),
('DM', 'DOMINICA', 'Dominica', 'DMA', 212),
('DO', 'DOMINICAN REPUBLIC', 'Dominican Republic', 'DOM', 214),
('EC', 'ECUADOR', 'Ecuador', 'ECU', 218),
('EG', 'EGYPT', 'Egypt', 'EGY', 818),
('SV', 'EL SALVADOR', 'El Salvador', 'SLV', 222),
('GQ', 'EQUATORIAL GUINEA', 'Equatorial Guinea', 'GNQ', 226),
('ER', 'ERITREA', 'Eritrea', 'ERI', 232),
('EE', 'ESTONIA', 'Estonia', 'EST', 233),
('ET', 'ETHIOPIA', 'Ethiopia', 'ETH', 231),
('FK', 'FALKLAND ISLANDS (MALVINAS)', 'Falkland Islands (Malvinas)', 'FLK', 238),
('FO', 'FAROE ISLANDS', 'Faroe Islands', 'FRO', 234),
('FJ', 'FIJI', 'Fiji', 'FJI', 242),
('FI', 'FINLAND', 'Finland', 'FIN', 246),
('FR', 'FRANCE', 'France', 'FRA', 250),
('GF', 'FRENCH GUIANA', 'French Guiana', 'GUF', 254),
('PF', 'FRENCH POLYNESIA', 'French Polynesia', 'PYF', 258),
('TF', 'FRENCH SOUTHERN TERRITORIES', 'French Southern Territories', NULL, NULL),
('GA', 'GABON', 'Gabon', 'GAB', 266),
('GM', 'GAMBIA', 'Gambia', 'GMB', 270),
('GE', 'GEORGIA', 'Georgia', 'GEO', 268),
('DE', 'GERMANY', 'Germany', 'DEU', 276),
('GH', 'GHANA', 'Ghana', 'GHA', 288),
('GI', 'GIBRALTAR', 'Gibraltar', 'GIB', 292),
('GR', 'GREECE', 'Greece', 'GRC', 300),
('GL', 'GREENLAND', 'Greenland', 'GRL', 304),
('GD', 'GRENADA', 'Grenada', 'GRD', 308),
('GP', 'GUADELOUPE', 'Guadeloupe', 'GLP', 312),
('GU', 'GUAM', 'Guam', 'GUM', 316),
('GT', 'GUATEMALA', 'Guatemala', 'GTM', 320),
('GN', 'GUINEA', 'Guinea', 'GIN', 324),
('GW', 'GUINEA-BISSAU', 'Guinea-Bissau', 'GNB', 624),
('GY', 'GUYANA', 'Guyana', 'GUY', 328),
('HT', 'HAITI', 'Haiti', 'HTI', 332),
('HM', 'HEARD ISLAND AND MCDONALD ISLANDS', 'Heard Island and Mcdonald Islands', NULL, NULL),
('VA', 'HOLY SEE (VATICAN CITY STATE)', 'Holy See (Vatican City State)', 'VAT', 336),
('HN', 'HONDURAS', 'Honduras', 'HND', 340),
('HK', 'HONG KONG', 'Hong Kong', 'HKG', 344),
('HU', 'HUNGARY', 'Hungary', 'HUN', 348),
('IS', 'ICELAND', 'Iceland', 'ISL', 352),
('IN', 'INDIA', 'India', 'IND', 356),
('ID', 'INDONESIA', 'Indonesia', 'IDN', 360),
('IR', 'IRAN, ISLAMIC REPUBLIC OF', 'Iran, Islamic Republic of', 'IRN', 364),
('IQ', 'IRAQ', 'Iraq', 'IRQ', 368),
('IE', 'IRELAND', 'Ireland', 'IRL', 372),
('IL', 'ISRAEL', 'Israel', 'ISR', 376),
('IT', 'ITALY', 'Italy', 'ITA', 380),
('JM', 'JAMAICA', 'Jamaica', 'JAM', 388),
('JP', 'JAPAN', 'Japan', 'JPN', 392),
('JO', 'JORDAN', 'Jordan', 'JOR', 400),
('KZ', 'KAZAKHSTAN', 'Kazakhstan', 'KAZ', 398),
('KE', 'KENYA', 'Kenya', 'KEN', 404),
('KI', 'KIRIBATI', 'Kiribati', 'KIR', 296),
('KP', 'KOREA, DEMOCRATIC PEOPLE''S REPUBLIC OF', 'Korea, Democratic People''s Republic of', 'PRK', 408),
('KR', 'KOREA, REPUBLIC OF', 'Korea, Republic of', 'KOR', 410),
('KW', 'KUWAIT', 'Kuwait', 'KWT', 414),
('KG', 'KYRGYZSTAN', 'Kyrgyzstan', 'KGZ', 417),
('LA', 'LAO PEOPLE''S DEMOCRATIC REPUBLIC', 'Lao People''s Democratic Republic', 'LAO', 418),
('LV', 'LATVIA', 'Latvia', 'LVA', 428),
('LB', 'LEBANON', 'Lebanon', 'LBN', 422),
('LS', 'LESOTHO', 'Lesotho', 'LSO', 426),
('LR', 'LIBERIA', 'Liberia', 'LBR', 430),
('LY', 'LIBYAN ARAB JAMAHIRIYA', 'Libyan Arab Jamahiriya', 'LBY', 434),
('LI', 'LIECHTENSTEIN', 'Liechtenstein', 'LIE', 438),
('LT', 'LITHUANIA', 'Lithuania', 'LTU', 440),
('LU', 'LUXEMBOURG', 'Luxembourg', 'LUX', 442),
('MO', 'MACAO', 'Macao', 'MAC', 446),
('MK', 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF', 'Macedonia, the Former Yugoslav Republic of', 'MKD', 807),
('MG', 'MADAGASCAR', 'Madagascar', 'MDG', 450),
('MW', 'MALAWI', 'Malawi', 'MWI', 454),
('MY', 'MALAYSIA', 'Malaysia', 'MYS', 458),
('MV', 'MALDIVES', 'Maldives', 'MDV', 462),
('ML', 'MALI', 'Mali', 'MLI', 466),
('MT', 'MALTA', 'Malta', 'MLT', 470),
('MH', 'MARSHALL ISLANDS', 'Marshall Islands', 'MHL', 584),
('MQ', 'MARTINIQUE', 'Martinique', 'MTQ', 474),
('MR', 'MAURITANIA', 'Mauritania', 'MRT', 478),
('MU', 'MAURITIUS', 'Mauritius', 'MUS', 480),
('YT', 'MAYOTTE', 'Mayotte', NULL, NULL),
('MX', 'MEXICO', 'Mexico', 'MEX', 484),
('FM', 'MICRONESIA, FEDERATED STATES OF', 'Micronesia, Federated States of', 'FSM', 583),
('MD', 'MOLDOVA, REPUBLIC OF', 'Moldova, Republic of', 'MDA', 498),
('MC', 'MONACO', 'Monaco', 'MCO', 492),
('MN', 'MONGOLIA', 'Mongolia', 'MNG', 496),
('MS', 'MONTSERRAT', 'Montserrat', 'MSR', 500),
('MA', 'MOROCCO', 'Morocco', 'MAR', 504),
('MZ', 'MOZAMBIQUE', 'Mozambique', 'MOZ', 508),
('MM', 'MYANMAR', 'Myanmar', 'MMR', 104),
('NA', 'NAMIBIA', 'Namibia', 'NAM', 516),
('NR', 'NAURU', 'Nauru', 'NRU', 520),
('NP', 'NEPAL', 'Nepal', 'NPL', 524),
('NL', 'NETHERLANDS', 'Netherlands', 'NLD', 528),
('AN', 'NETHERLANDS ANTILLES', 'Netherlands Antilles', 'ANT', 530),
('NC', 'NEW CALEDONIA', 'New Caledonia', 'NCL', 540),
('NZ', 'NEW ZEALAND', 'New Zealand', 'NZL', 554),
('NI', 'NICARAGUA', 'Nicaragua', 'NIC', 558),
('NE', 'NIGER', 'Niger', 'NER', 562),
('NG', 'NIGERIA', 'Nigeria', 'NGA', 566),
('NU', 'NIUE', 'Niue', 'NIU', 570),
('NF', 'NORFOLK ISLAND', 'Norfolk Island', 'NFK', 574),
('MP', 'NORTHERN MARIANA ISLANDS', 'Northern Mariana Islands', 'MNP', 580),
('NO', 'NORWAY', 'Norway', 'NOR', 578),
('OM', 'OMAN', 'Oman', 'OMN', 512),
('PK', 'PAKISTAN', 'Pakistan', 'PAK', 586),
('PW', 'PALAU', 'Palau', 'PLW', 585),
('PS', 'PALESTINIAN TERRITORY, OCCUPIED', 'Palestinian Territory, Occupied', NULL, NULL),
('PA', 'PANAMA', 'Panama', 'PAN', 591),
('PG', 'PAPUA NEW GUINEA', 'Papua New Guinea', 'PNG', 598),
('PY', 'PARAGUAY', 'Paraguay', 'PRY', 600),
('PE', 'PERU', 'Peru', 'PER', 604),
('PH', 'PHILIPPINES', 'Philippines', 'PHL', 608),
('PN', 'PITCAIRN', 'Pitcairn', 'PCN', 612),
('PL', 'POLAND', 'Poland', 'POL', 616),
('PT', 'PORTUGAL', 'Portugal', 'PRT', 620),
('PR', 'PUERTO RICO', 'Puerto Rico', 'PRI', 630),
('QA', 'QATAR', 'Qatar', 'QAT', 634),
('RE', 'REUNION', 'Reunion', 'REU', 638),
('RO', 'ROMANIA', 'Romania', 'ROM', 642),
('RU', 'RUSSIAN FEDERATION', 'Russian Federation', 'RUS', 643),
('RW', 'RWANDA', 'Rwanda', 'RWA', 646),
('SH', 'SAINT HELENA', 'Saint Helena', 'SHN', 654),
('KN', 'SAINT KITTS AND NEVIS', 'Saint Kitts and Nevis', 'KNA', 659),
('LC', 'SAINT LUCIA', 'Saint Lucia', 'LCA', 662),
('PM', 'SAINT PIERRE AND MIQUELON', 'Saint Pierre and Miquelon', 'SPM', 666),
('VC', 'SAINT VINCENT AND THE GRENADINES', 'Saint Vincent and the Grenadines', 'VCT', 670),
('WS', 'SAMOA', 'Samoa', 'WSM', 882),
('SM', 'SAN MARINO', 'San Marino', 'SMR', 674),
('ST', 'SAO TOME AND PRINCIPE', 'Sao Tome and Principe', 'STP', 678),
('SA', 'SAUDI ARABIA', 'Saudi Arabia', 'SAU', 682),
('SN', 'SENEGAL', 'Senegal', 'SEN', 686),
('CS', 'SERBIA AND MONTENEGRO', 'Serbia and Montenegro', NULL, NULL),
('SC', 'SEYCHELLES', 'Seychelles', 'SYC', 690),
('SL', 'SIERRA LEONE', 'Sierra Leone', 'SLE', 694),
('SG', 'SINGAPORE', 'Singapore', 'SGP', 702),
('SK', 'SLOVAKIA', 'Slovakia', 'SVK', 703),
('SI', 'SLOVENIA', 'Slovenia', 'SVN', 705),
('SB', 'SOLOMON ISLANDS', 'Solomon Islands', 'SLB', 90),
('SO', 'SOMALIA', 'Somalia', 'SOM', 706),
('ZA', 'SOUTH AFRICA', 'South Africa', 'ZAF', 710),
('GS', 'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS', 'South Georgia and the South Sandwich Islands', NULL, NULL),
('ES', 'SPAIN', 'Spain', 'ESP', 724),
('LK', 'SRI LANKA', 'Sri Lanka', 'LKA', 144),
('SD', 'SUDAN', 'Sudan', 'SDN', 736),
('SR', 'SURINAME', 'Suriname', 'SUR', 740),
('SJ', 'SVALBARD AND JAN MAYEN', 'Svalbard and Jan Mayen', 'SJM', 744),
('SZ', 'SWAZILAND', 'Swaziland', 'SWZ', 748),
('SE', 'SWEDEN', 'Sweden', 'SWE', 752),
('CH', 'SWITZERLAND', 'Switzerland', 'CHE', 756),
('SY', 'SYRIAN ARAB REPUBLIC', 'Syrian Arab Republic', 'SYR', 760),
('TW', 'TAIWAN, PROVINCE OF CHINA', 'Taiwan, Province of China', 'TWN', 158),
('TJ', 'TAJIKISTAN', 'Tajikistan', 'TJK', 762),
('TZ', 'TANZANIA, UNITED REPUBLIC OF', 'Tanzania, United Republic of', 'TZA', 834),
('TH', 'THAILAND', 'Thailand', 'THA', 764),
('TL', 'TIMOR-LESTE', 'Timor-Leste', NULL, NULL),
('TG', 'TOGO', 'Togo', 'TGO', 768),
('TK', 'TOKELAU', 'Tokelau', 'TKL', 772),
('TO', 'TONGA', 'Tonga', 'TON', 776),
('TT', 'TRINIDAD AND TOBAGO', 'Trinidad and Tobago', 'TTO', 780),
('TN', 'TUNISIA', 'Tunisia', 'TUN', 788),
('TR', 'TURKEY', 'Turkey', 'TUR', 792),
('TM', 'TURKMENISTAN', 'Turkmenistan', 'TKM', 795),
('TC', 'TURKS AND CAICOS ISLANDS', 'Turks and Caicos Islands', 'TCA', 796),
('TV', 'TUVALU', 'Tuvalu', 'TUV', 798),
('UG', 'UGANDA', 'Uganda', 'UGA', 800),
('UA', 'UKRAINE', 'Ukraine', 'UKR', 804),
('AE', 'UNITED ARAB EMIRATES', 'United Arab Emirates', 'ARE', 784),
('GB', 'UNITED KINGDOM', 'United Kingdom', 'GBR', 826),
('US', 'UNITED STATES', 'United States', 'USA', 840),
('UM', 'UNITED STATES MINOR OUTLYING ISLANDS', 'United States Minor Outlying Islands', NULL, NULL),
('UY', 'URUGUAY', 'Uruguay', 'URY', 858),
('UZ', 'UZBEKISTAN', 'Uzbekistan', 'UZB', 860),
('VU', 'VANUATU', 'Vanuatu', 'VUT', 548),
('VE', 'VENEZUELA', 'Venezuela', 'VEN', 862),
('VN', 'VIET NAM', 'Viet Nam', 'VNM', 704),
('VG', 'VIRGIN ISLANDS, BRITISH', 'Virgin Islands, British', 'VGB', 92),
('VI', 'VIRGIN ISLANDS, U.S.', 'Virgin Islands, U.s.', 'VIR', 850),
('WF', 'WALLIS AND FUTUNA', 'Wallis and Futuna', 'WLF', 876),
('EH', 'WESTERN SAHARA', 'Western Sahara', 'ESH', 732),
('YE', 'YEMEN', 'Yemen', 'YEM', 887),
('ZM', 'ZAMBIA', 'Zambia', 'ZMB', 894),
('ZW', 'ZIMBABWE', 'Zimbabwe', 'ZWE', 716);
-- --------------------------------------------------------
-- tables for the FAQ module
CREATE TABLE `help_faq_sections` (
  `hfs_id` int(11) NOT NULL AUTO_INCREMENT,
  `hfs_name` varchar(255) DEFAULT NULL,
  `hfs_order` int(11) DEFAULT '0',
  `sys_userid` int(11) DEFAULT NULL,
  `sys_groupid` int(11) DEFAULT NULL,
  `sys_perm_user` varchar(5) DEFAULT NULL,
  `sys_perm_group` varchar(5) DEFAULT NULL,
  `sys_perm_other` varchar(5) DEFAULT NULL,
  PRIMARY KEY (`hfs_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
INSERT INTO `help_faq_sections` VALUES (1,'General',0,NULL,NULL,NULL,NULL,NULL);
CREATE TABLE `help_faq` (
  `hf_id` int(11) NOT NULL AUTO_INCREMENT,
  `hf_section` int(11) DEFAULT NULL,
  `hf_order` int(11) DEFAULT '0',
  `hf_question` text,
  `hf_answer` text,
  `sys_userid` int(11) DEFAULT NULL,
  `sys_groupid` int(11) DEFAULT NULL,
  `sys_perm_user` varchar(5) DEFAULT NULL,
  `sys_perm_group` varchar(5) DEFAULT NULL,
  `sys_perm_other` varchar(5) DEFAULT NULL,
  PRIMARY KEY (`hf_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
INSERT INTO `help_faq` VALUES (1,1,0,'I\'d like to know ...','Yes, of course.',1,1,'riud','riud','r');
ALTER TABLE client ADD COLUMN company_id varchar(30);
-- --------------------------------------------------------
SET FOREIGN_KEY_CHECKS = 1;
install/tpl/mm_cfg.py.master
New file
@@ -0,0 +1,106 @@
# -*- python -*-
# Copyright (C) 1998,1999,2000 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
"""This is the module which takes your site-specific settings.
From a raw distribution it should be copied to mm_cfg.py.  If you
already have an mm_cfg.py, be careful to add in only the new settings
you want.  The complete set of distributed defaults, with annotation,
are in ./Defaults.  In mm_cfg, override only those you want to
change, after the
  from Defaults import *
line (see below).
Note that these are just default settings - many can be overridden via the
admin and user interfaces on a per-list or per-user basis.
Note also that some of the settings are resolved against the active list
setting by using the value as a format string against the
list-instance-object's dictionary - see the distributed value of
DEFAULT_MSG_FOOTER for an example."""
#######################################################
#    Here's where we get the distributed defaults.    #
from Defaults import *
##############################################################
# Put YOUR site-specific configuration below, in mm_cfg.py . #
# See Defaults.py for explanations of the values.            #
#-------------------------------------------------------------
# The name of the list Mailman uses to send password reminders
# and similar. Don't change if you want mailman-owner to be
# a valid local part.
MAILMAN_SITE_LIST = 'mailman'
#-------------------------------------------------------------
# If you change these, you have to configure your http server
# accordingly (Alias and ScriptAlias directives in most httpds)
DEFAULT_URL_PATTERN = 'http://%s/cgi-bin/mailman/'
PRIVATE_ARCHIVE_URL = '/cgi-bin/mailman/private'
IMAGE_LOGOS         = '/images/mailman/'
#-------------------------------------------------------------
# Default domain for email addresses of newly created MLs
DEFAULT_EMAIL_HOST = '{hostname}'
#-------------------------------------------------------------
# Default host for web interface of newly created MLs
DEFAULT_URL_HOST   = '{hostname}'
#-------------------------------------------------------------
# Required when setting any of its arguments.
add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)
#-------------------------------------------------------------
# The default language for this server.
DEFAULT_SERVER_LANGUAGE = {default_language}
#-------------------------------------------------------------
# Iirc this was used in pre 2.1, leave it for now
USE_ENVELOPE_SENDER    = 0              # Still used?
#-------------------------------------------------------------
# Unset send_reminders on newly created lists
DEFAULT_SEND_REMINDERS = 0
#-------------------------------------------------------------
# Uncomment this if you configured your MTA such that it
# automatically recognizes newly created lists.
# (see /usr/share/doc/mailman/README.Exim4.Debian or
# /usr/share/mailman/postfix-to-mailman.py)
# MTA=None   # Misnomer, suppresses alias output on newlist
#-------------------------------------------------------------
# Uncomment if you use Postfix virtual domains (but not
# postfix-to-mailman.py), but be sure to see
# /usr/share/doc/mailman/README.Debian first.
MTA='Postfix'
POSTFIX_STYLE_VIRTUAL_DOMAINS = [{virtual_domains}]
#-------------------------------------------------------------
# Uncomment if you want to filter mail with SpamAssassin. For
# more information please visit this website:
# http://www.jamesh.id.au/articles/mailman-spamassassin/
# GLOBAL_PIPELINE.insert(1, 'SpamAssassin')
# Note - if you're looking for something that is imported from mm_cfg, but you
# didn't find it above, it's probably in /usr/lib/mailman/Mailman/Defaults.py.
install/update.php
@@ -1,353 +1,358 @@
<?php
/*
Copyright (c) 2007-2010, 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 updater.
*/
error_reporting(E_ALL|E_STRICT);
//** The banner on the command line
echo "\n\n".str_repeat('-',80)."\n";
echo " _____ ___________   _____              __ _         ____
|_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
  | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
 _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
 \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
                                              __/ |
                                             |___/ ";
echo "\n".str_repeat('-',80)."\n";
echo "\n\n>> Update  \n\n";
//** Include the library with the basic installer functions
require_once('lib/install.lib.php');
//** Include the library with the basic updater functions
require_once('lib/update.lib.php');
//** Include the base class of the installer class
require_once('lib/installer_base.lib.php');
//** Ensure that current working directory is install directory
$cur_dir = getcwd();
if(realpath(dirname(__FILE__)) != $cur_dir) die("Please run installation/update from _inside_ the install directory!\n");
//** Install logfile
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
//** Check for ISPConfig 2.x versions
if(is_dir('/root/ispconfig') || is_dir('/home/admispconfig')) {
    die('This software cannot be installed on a server wich runs ISPConfig 2.x.');
}
//** Get distribution identifier
$dist = get_distname();
include_once("/usr/local/ispconfig/server/lib/config.inc.php");
$conf_old = $conf;
unset($conf);
if($dist['id'] == '') die('Linux distribution or version not recognized.');
//** Include the distribution-specific installer class library and configuration
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php');
include_once('dist/lib/'.$dist['id'].'.lib.php');
include_once('dist/conf/'.$dist['id'].'.conf.php');
//** Get hostname
exec('hostname -f', $tmp_out);
$conf['hostname'] = $tmp_out[0];
unset($tmp_out);
//** Set the mysql login information
$conf["mysql"]["host"] = $conf_old["db_host"];
$conf["mysql"]["database"] = $conf_old["db_database"];
$conf['mysql']['charset'] = 'utf8';
$conf["mysql"]["ispconfig_user"] = $conf_old["db_user"];
$conf["mysql"]["ispconfig_password"] = $conf_old["db_password"];
$conf['language'] = $conf_old['language'];
if($conf['language'] == '{language}') $conf['language'] = 'en';
if(isset($conf_old["dbmaster_host"])) $conf["mysql"]["master_host"] = $conf_old["dbmaster_host"];
if(isset($conf_old["dbmaster_database"])) $conf["mysql"]["master_database"] = $conf_old["dbmaster_database"];
if(isset($conf_old["dbmaster_user"])) $conf["mysql"]["master_ispconfig_user"] = $conf_old["dbmaster_user"];
if(isset($conf_old["dbmaster_password"])) $conf["mysql"]["master_ispconfig_password"] = $conf_old["dbmaster_password"];
//* Check if this is a master / slave setup
if($conf["mysql"]["master_host"] != '' && $conf["mysql"]["host"] != $conf["mysql"]["master_host"]) {
    $conf['mysql']['master_slave_setup'] = 'y';
}
// Resolve the IP address of the mysql hostname.
if(!$conf['mysql']['ip'] = gethostbyname($conf['mysql']['host'])) die('Unable to resolve hostname'.$conf['mysql']['host']);
$conf['server_id'] = intval($conf_old["server_id"]);
$conf['ispconfig_log_priority'] = $conf_old["log_priority"];
$inst = new installer();
$inst->is_update = true;
//** Detect the installed applications
$inst->find_installed_apps();
echo "This application will update ISPConfig 3 on your server.\n";
//** Initialize the MySQL server connection
include_once('lib/mysql.lib.php');
//** Database update is a bit brute force and should be rebuild later ;)
/*
 * Try to read the DB-admin settings
 */
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
include_once("/usr/local/ispconfig/server/lib/mysql_clientdb.conf");
$conf["mysql"]["admin_user"] = $clientdb_user;
$conf["mysql"]["admin_password"] = $clientdb_password;
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
//** Ask user for mysql admin_password if empty
if( empty($conf["mysql"]["admin_password"]) ) {
    $conf["mysql"]["admin_password"] = $inst->free_query('MySQL root password', $conf['mysql']['admin_password']);
}
/*
 *  Prepare the dump of the database
 */
prepareDBDump();
//* initialize the database
$inst->db = new db();
//* initialize the master DB, if we have a multiserver setup
if($conf['mysql']['master_slave_setup'] == 'y') {
        //** Get MySQL root credentials
        $finished = false;
        do {
            $tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host']);
            $tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user']);
            $tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password']);
            $tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database']);
            //* Initialize the MySQL server connection
            if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
                $conf['mysql']['master_host'] = $tmp_mysql_server_host;
                $conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
                $conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password;
                $conf['mysql']['master_database'] = $tmp_mysql_server_database;
                $finished = true;
            } else {
                swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error());
            }
        } while ($finished == false);
        unset($finished);
        // initialize the connection to the master database
        $inst->dbmaster = new db();
        if($inst->dbmaster->linkId) $inst->dbmaster->closeConn();
        $inst->dbmaster->dbHost = $conf['mysql']["master_host"];
        $inst->dbmaster->dbName = $conf['mysql']["master_database"];
        $inst->dbmaster->dbUser = $conf['mysql']["master_admin_user"];
        $inst->dbmaster->dbPass = $conf['mysql']["master_admin_password"];
} else {
    $inst->dbmaster = $inst->db;
}
/*
 *  dump the new Database and reconfigure the server.ini
 */
updateDbAndIni();
/*
 * Reconfigure the permisson if needed
 * (if this is done at client side, only this client is updated.
 * If this is done at server side, all clients are updated.
 */
//if($conf_old['dbmaster_user'] != '' or $conf_old['dbmaster_host'] != '') {
    //** Update master database rights
    $reconfigure_master_database_rights_answer = $inst->simple_query('Reconfigure Permissions in master database?', array('yes','no'),'no');
    if($reconfigure_master_database_rights_answer == 'yes') {
        $inst->grant_master_database_rights();
    }
//}
//** Shall the services be reconfigured during update
$reconfigure_services_answer = $inst->simple_query('Reconfigure Services?', array('yes','no'),'yes');
if($reconfigure_services_answer == 'yes') {
    if($conf['services']['mail']) {
        //** Configure postfix
        swriteln('Configuring Postfix');
        $inst->configure_postfix('dont-create-certs');
        //* Configure Jailkit
        swriteln('Configuring Jailkit');
        $inst->configure_jailkit();
        if($conf['dovecot']['installed'] == true) {
            //* Configure dovecot
            swriteln('Configuring Dovecot');
            $inst->configure_dovecot();
        } else {
            //** 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 Getmail
        swriteln('Configuring Getmail');
        $inst->configure_getmail();
    }
    if($conf['services']['web']) {
        //** Configure Pureftpd
        swriteln('Configuring Pureftpd');
        $inst->configure_pureftpd();
    }
    if($conf['services']['dns']) {
        //* Configure DNS
        if($conf['powerdns']['installed'] == true) {
            swriteln('Configuring PowerDNS');
            $inst->configure_powerdns();
        } elseif($conf['bind']['installed'] == true) {
            swriteln('Configuring BIND');
            $inst->configure_bind();
        } else {
            swriteln('Configuring MyDNS');
            $inst->configure_mydns();
        }
    }
    if($conf['services']['web']) {
        //** Configure Apache
        swriteln('Configuring Apache');
        $inst->configure_apache();
        //** Configure vlogger
        swriteln('Configuring vlogger');
        $inst->configure_vlogger();
        //** Configure apps vhost
        swriteln('Configuring Apps vhost');
        $inst->configure_apps_vhost();
    }
    //* Configure DBServer
    swriteln('Configuring Database');
    $inst->configure_dbserver();
    //if(@is_dir('/etc/Bastille')) {
    //* Configure Firewall
    swriteln('Configuring Firewall');
    $inst->configure_firewall();
    //}
}
//** Configure ISPConfig
swriteln('Updating ISPConfig');
//** Customise the port ISPConfig runs on
$ispconfig_port_number = get_ispconfig_port_number();
$conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', $ispconfig_port_number);
// $ispconfig_ssl_default = (is_ispconfig_ssl_enabled() == true)?'y':'n';
if(strtolower($inst->simple_query('Create new ISPConfig SSL certificate',array('yes','no'),'no')) == 'yes') {
    $inst->make_ispconfig_ssl_cert();
}
$inst->install_ispconfig();
//** Configure Crontab
$update_crontab_answer = $inst->simple_query('Reconfigure Crontab?', array('yes','no'),'yes');
if($update_crontab_answer == 'yes') {
    swriteln('Updating Crontab');
    $inst->install_crontab();
}
//** Restart services:
if($reconfigure_services_answer == 'yes') {
    swriteln('Restarting services ...');
    if($conf['mysql']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mysql']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' restart');
    if($conf['services']['mail']) {
        if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
        if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
        if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
        if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
        if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
        if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
        if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
        if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
        if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
        if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
    }
    if($conf['services']['web']) {
        if($conf['apache']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['apache']['init_script']))                 system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
        if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script']))                system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
    }
    if($conf['services']['dns']) {
        if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
        if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
        if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
    }
}
echo "Update finished.\n";
?>
<?php
/*
Copyright (c) 2007-2010, 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 updater.
*/
error_reporting(E_ALL|E_STRICT);
//** The banner on the command line
echo "\n\n".str_repeat('-',80)."\n";
echo " _____ ___________   _____              __ _         ____
|_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
  | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
 _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
 \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
                                              __/ |
                                             |___/ ";
echo "\n".str_repeat('-',80)."\n";
echo "\n\n>> Update  \n\n";
//** Include the library with the basic installer functions
require_once('lib/install.lib.php');
//** Include the library with the basic updater functions
require_once('lib/update.lib.php');
//** Include the base class of the installer class
require_once('lib/installer_base.lib.php');
//** Ensure that current working directory is install directory
$cur_dir = getcwd();
if(realpath(dirname(__FILE__)) != $cur_dir) die("Please run installation/update from _inside_ the install directory!\n");
//** Install logfile
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
//** Check for ISPConfig 2.x versions
if(is_dir('/root/ispconfig') || is_dir('/home/admispconfig')) {
    die('This software cannot be installed on a server wich runs ISPConfig 2.x.');
}
//** Get distribution identifier
$dist = get_distname();
include_once("/usr/local/ispconfig/server/lib/config.inc.php");
$conf_old = $conf;
unset($conf);
if($dist['id'] == '') die('Linux distribution or version not recognized.');
//** Include the distribution-specific installer class library and configuration
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php');
include_once('dist/lib/'.$dist['id'].'.lib.php');
include_once('dist/conf/'.$dist['id'].'.conf.php');
//** Get hostname
exec('hostname -f', $tmp_out);
$conf['hostname'] = $tmp_out[0];
unset($tmp_out);
//** Set the mysql login information
$conf["mysql"]["host"] = $conf_old["db_host"];
$conf["mysql"]["database"] = $conf_old["db_database"];
$conf['mysql']['charset'] = 'utf8';
$conf["mysql"]["ispconfig_user"] = $conf_old["db_user"];
$conf["mysql"]["ispconfig_password"] = $conf_old["db_password"];
$conf['language'] = $conf_old['language'];
if($conf['language'] == '{language}') $conf['language'] = 'en';
if(isset($conf_old["dbmaster_host"])) $conf["mysql"]["master_host"] = $conf_old["dbmaster_host"];
if(isset($conf_old["dbmaster_database"])) $conf["mysql"]["master_database"] = $conf_old["dbmaster_database"];
if(isset($conf_old["dbmaster_user"])) $conf["mysql"]["master_ispconfig_user"] = $conf_old["dbmaster_user"];
if(isset($conf_old["dbmaster_password"])) $conf["mysql"]["master_ispconfig_password"] = $conf_old["dbmaster_password"];
//* Check if this is a master / slave setup
if($conf["mysql"]["master_host"] != '' && $conf["mysql"]["host"] != $conf["mysql"]["master_host"]) {
    $conf['mysql']['master_slave_setup'] = 'y';
}
// Resolve the IP address of the mysql hostname.
if(!$conf['mysql']['ip'] = gethostbyname($conf['mysql']['host'])) die('Unable to resolve hostname'.$conf['mysql']['host']);
$conf['server_id'] = intval($conf_old["server_id"]);
$conf['ispconfig_log_priority'] = $conf_old["log_priority"];
$inst = new installer();
$inst->is_update = true;
//** Detect the installed applications
$inst->find_installed_apps();
echo "This application will update ISPConfig 3 on your server.\n";
//** Initialize the MySQL server connection
include_once('lib/mysql.lib.php');
//** Database update is a bit brute force and should be rebuild later ;)
/*
 * Try to read the DB-admin settings
 */
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
include_once("/usr/local/ispconfig/server/lib/mysql_clientdb.conf");
$conf["mysql"]["admin_user"] = $clientdb_user;
$conf["mysql"]["admin_password"] = $clientdb_password;
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
//** Ask user for mysql admin_password if empty
if( empty($conf["mysql"]["admin_password"]) ) {
    $conf["mysql"]["admin_password"] = $inst->free_query('MySQL root password', $conf['mysql']['admin_password']);
}
/*
 *  Prepare the dump of the database
 */
prepareDBDump();
//* initialize the database
$inst->db = new db();
//* initialize the master DB, if we have a multiserver setup
if($conf['mysql']['master_slave_setup'] == 'y') {
        //** Get MySQL root credentials
        $finished = false;
        do {
            $tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host']);
            $tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user']);
            $tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password']);
            $tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database']);
            //* Initialize the MySQL server connection
            if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
                $conf['mysql']['master_host'] = $tmp_mysql_server_host;
                $conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
                $conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password;
                $conf['mysql']['master_database'] = $tmp_mysql_server_database;
                $finished = true;
            } else {
                swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error());
            }
        } while ($finished == false);
        unset($finished);
        // initialize the connection to the master database
        $inst->dbmaster = new db();
        if($inst->dbmaster->linkId) $inst->dbmaster->closeConn();
        $inst->dbmaster->dbHost = $conf['mysql']["master_host"];
        $inst->dbmaster->dbName = $conf['mysql']["master_database"];
        $inst->dbmaster->dbUser = $conf['mysql']["master_admin_user"];
        $inst->dbmaster->dbPass = $conf['mysql']["master_admin_password"];
} else {
    $inst->dbmaster = $inst->db;
}
/*
 *  dump the new Database and reconfigure the server.ini
 */
updateDbAndIni();
/*
 * Reconfigure the permisson if needed
 * (if this is done at client side, only this client is updated.
 * If this is done at server side, all clients are updated.
 */
//if($conf_old['dbmaster_user'] != '' or $conf_old['dbmaster_host'] != '') {
    //** Update master database rights
    $reconfigure_master_database_rights_answer = $inst->simple_query('Reconfigure Permissions in master database?', array('yes','no'),'no');
    if($reconfigure_master_database_rights_answer == 'yes') {
        $inst->grant_master_database_rights();
    }
//}
//** Shall the services be reconfigured during update
$reconfigure_services_answer = $inst->simple_query('Reconfigure Services?', array('yes','no'),'yes');
if($reconfigure_services_answer == 'yes') {
    if($conf['services']['mail']) {
        //** Configure postfix
        swriteln('Configuring Postfix');
        $inst->configure_postfix('dont-create-certs');
        //** Configure mailman
        swriteln('Configuring Mailman');
        $inst->configure_mailman('update');
        //* Configure Jailkit
        swriteln('Configuring Jailkit');
        $inst->configure_jailkit();
        if($conf['dovecot']['installed'] == true) {
            //* Configure dovecot
            swriteln('Configuring Dovecot');
            $inst->configure_dovecot();
        } else {
            //** 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 Getmail
        swriteln('Configuring Getmail');
        $inst->configure_getmail();
    }
    if($conf['services']['web']) {
        //** Configure Pureftpd
        swriteln('Configuring Pureftpd');
        $inst->configure_pureftpd();
    }
    if($conf['services']['dns']) {
        //* Configure DNS
        if($conf['powerdns']['installed'] == true) {
            swriteln('Configuring PowerDNS');
            $inst->configure_powerdns();
        } elseif($conf['bind']['installed'] == true) {
            swriteln('Configuring BIND');
            $inst->configure_bind();
        } else {
            swriteln('Configuring MyDNS');
            $inst->configure_mydns();
        }
    }
    if($conf['services']['web']) {
        //** Configure Apache
        swriteln('Configuring Apache');
        $inst->configure_apache();
        //** Configure vlogger
        swriteln('Configuring vlogger');
        $inst->configure_vlogger();
        //** Configure apps vhost
        swriteln('Configuring Apps vhost');
        $inst->configure_apps_vhost();
    }
    //* Configure DBServer
    swriteln('Configuring Database');
    $inst->configure_dbserver();
    //if(@is_dir('/etc/Bastille')) {
    //* Configure Firewall
    swriteln('Configuring Firewall');
    $inst->configure_firewall();
    //}
}
//** Configure ISPConfig
swriteln('Updating ISPConfig');
//** Customise the port ISPConfig runs on
$ispconfig_port_number = get_ispconfig_port_number();
$conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', $ispconfig_port_number);
// $ispconfig_ssl_default = (is_ispconfig_ssl_enabled() == true)?'y':'n';
if(strtolower($inst->simple_query('Create new ISPConfig SSL certificate',array('yes','no'),'no')) == 'yes') {
    $inst->make_ispconfig_ssl_cert();
}
$inst->install_ispconfig();
//** Configure Crontab
$update_crontab_answer = $inst->simple_query('Reconfigure Crontab?', array('yes','no'),'yes');
if($update_crontab_answer == 'yes') {
    swriteln('Updating Crontab');
    $inst->install_crontab();
}
//** Restart services:
if($reconfigure_services_answer == 'yes') {
    swriteln('Restarting services ...');
    if($conf['mysql']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mysql']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' restart');
    if($conf['services']['mail']) {
        if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
        if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
        if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
        if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
        if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
        if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
        if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
        if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
        if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
        if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
        if($conf['mailman']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mailman']['init_script']))         system($conf['init_scripts'].'/'.$conf['mailman']['init_script'].' restart');
    }
    if($conf['services']['web']) {
        if($conf['apache']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['apache']['init_script']))                 system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
        if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script']))                system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
    }
    if($conf['services']['dns']) {
        if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
        if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
        if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
    }
}
echo "Update finished.\n";
?>
interface/lib/classes/remoting.inc.php
Diff too large
interface/web/admin/form/remote_user.tform.php
@@ -1,161 +1,162 @@
<?php
/*
    Form Definition
    Tabledefinition
    Datatypes:
    - INTEGER (Forces the input to Int)
    - DOUBLE
    - CURRENCY (Formats the values to currency notation)
    - VARCHAR (no format check, maxlength: 255)
    - TEXT (no format check)
    - DATE (Dateformat, automatic conversion to timestamps)
    Formtype:
    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)
    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hint:
    The ID field of the database table is not part of the datafield definition.
    The ID field must be always auto incement (int or bigint).
*/
$function_list = array();
$function_list['mail_domain_get,mail_domain_add,mail_domain_update,mail_domain_delete,mail_domain_set_status,mail_domain_get_by_domain'] = 'Mail domain functions';
$function_list['mail_user_get,mail_user_add,mail_user_update,mail_user_delete'] = 'Mail user functions';
$function_list['mail_alias_get,mail_alias_add,mail_alias_update,mail_alias_delete'] = 'Mail alias functions';
$function_list['mail_forward_get,mail_forward_add,mail_forward_update,mail_forward_delete'] = 'Mail forward functions';
$function_list['mail_catchall_get,mail_catchall_add,mail_catchall_update,mail_catchall_delete'] = 'Mail catchall functions';
$function_list['mail_transport_get,mail_transport_add,mail_transport_update,mail_transport_delete'] = 'Mail transport functions';
$function_list['mail_whitelist_get,mail_whitelist_add,mail_whitelist_update,mail_whitelist_delete'] = 'Mail whitelist functions';
$function_list['mail_blacklist_get,mail_blacklist_add,mail_blacklist_update,mail_blacklist_delete'] = 'Mail blacklist functions';
$function_list['mail_spamfilter_user_get,mail_spamfilter_user_add,mail_spamfilter_user_update,mail_spamfilter_user_delete'] = 'Mail spamfilter user functions';
$function_list['mail_policy_get,mail_policy_add,mail_policy_update,mail_policy_delete'] = 'Mail spamfilter policy functions';
$function_list['mail_fetchmail_get,mail_fetchmail_add,mail_fetchmail_update,mail_fetchmail_delete'] = 'Mail fetchmail functions';
$function_list['mail_spamfilter_whitelist_get,mail_spamfilter_whitelist_add,mail_spamfilter_whitelist_update,mail_spamfilter_whitelist_delete'] = 'Mail spamfilter whitelist functions';
$function_list['mail_spamfilter_blacklist_get,mail_spamfilter_blacklist_add,mail_spamfilter_blacklist_update,mail_spamfilter_blacklist_delete'] = 'Mail spamfilter blacklist functions';
$function_list['mail_user_filter_get,mail_user_filter_add,mail_user_filter_update,mail_user_filter_delete'] = 'Mail user filter functions';
$function_list['mail_filter_get,mail_filter_add,mail_filter_update,mail_filter_delete'] = 'Mail filter functions';
$function_list['client_get,client_add,client_update,client_delete,client_get_sites_by_user,client_get_by_username,client_change_password,client_get_id'] = 'Client functions';
$function_list['server_get,get_function_list,client_templates_get_all'] = 'Server functions';
$function_list['sites_cron_get,sites_cron_add,sites_cron_update,sites_cron_delete'] = 'Sites cron functions';
$function_list['sites_database_get,sites_database_add,sites_database_update,sites_database_delete, sites_database_get_all_by_user'] = 'Sites database functions';
$function_list['sites_ftp_user_get,sites_ftp_user_add,sites_ftp_user_update,sites_ftp_user_delete'] = 'Sites FTP-User functions';
$function_list['sites_shell_user_get,sites_shell_user_add,sites_shell_user_update,sites_shell_user_delete'] = 'Sites Shell-User functions';
$function_list['sites_web_domain_get,sites_web_domain_add,sites_web_domain_update,sites_web_domain_delete,sites_web_domain_set_status'] = 'Sites Domain functions';
$function_list['sites_web_aliasdomain_get,sites_web_aliasdomain_add,sites_web_aliasdomain_update,sites_web_aliasdomain_delete'] = 'Sites Aliasdomain functions';
$function_list['sites_web_subdomain_get,sites_web_subdomain_add,sites_web_subdomain_update,sites_web_subdomain_delete'] = 'Sites Subdomain functions';
$function_list['dns_zone_get,dns_zone_add,dns_zone_update,dns_zone_delete,dns_zone_set_status'] = 'DNS zone functions';
$function_list['dns_a_get,dns_a_add,dns_a_update,dns_a_delete'] = 'DNS a functions';
$function_list['dns_aaaa_get,dns_aaaa_add,dns_aaaa_update,dns_aaaa_delete'] = 'DNS aaaa functions';
$function_list['dns_alias_get,dns_alias_add,dns_alias_update,dns_alias_delete'] = 'DNS alias functions';
$function_list['dns_cname_get,dns_cname_add,dns_cname_update,dns_cname_delete'] = 'DNS cname functions';
$function_list['dns_hinfo_get,dns_hinfo_add,dns_hinfo_update,dns_hinfo_delete'] = 'DNS hinfo functions';
$function_list['dns_mx_get,dns_mx_add,dns_mx_update,dns_mx_delete'] = 'DNS mx functions';
$function_list['dns_ns_get,dns_ns_add,dns_ns_update,dns_ns_delete'] = 'DNS ns functions';
$function_list['dns_ptr_get,dns_ptr_add,dns_ptr_update,dns_ptr_delete'] = 'DNS ptr functions';
$function_list['dns_rp_get,dns_rp_add,dns_rp_update,dns_rp_delete'] = 'DNS rp functions';
$function_list['dns_srv_get,dns_srv_add,dns_srv_update,dns_srv_delete'] = 'DNS srv functions';
$function_list['dns_txt_get,dns_txt_add,dns_txt_update,dns_txt_delete'] = 'DNS txt functions';
$form["title"]             = "Remote user";
$form["description"]     = "";
$form["name"]             = "remote_user";
$form["action"]            = "remote_user_edit.php";
$form["db_table"]        = "remote_user";
$form["db_table_idx"]    = "remote_userid";
$form["db_history"]        = "yes";
$form["tab_default"]    = "remote_user";
$form["list_default"]    = "remote_user_list.php";
$form["auth"]            = 'yes'; // yes / no
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
$form["tabs"]['remote_user'] = array (
    'title'     => "Remote User",
    'width'     => 100,
    'template'     => "templates/remote_user_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'remote_userid' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT remote_userid,remote_username FROM remote_user WHERE {AUTHSQL} ORDER BY remote_username',
                                        'keyfield'=> 'remote_userid',
                                        'valuefield'=> 'remote_username'
                                     ),
            'value'        => ''
        ),
        'remote_username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'UNIQUE',
                                                        'errmsg'=> 'username_error_unique'),
                                        1 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-]{0,64}$/',
                                                        'errmsg'=> 'username_error_regex'),
2 => array (    'type' => 'NOTEMPTY',
        'errmsg'=> 'username_error_empty'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'remote_password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption' => 'MD5',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'remote_functions' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'CHECKBOXARRAY',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $function_list,
            'separator'    => ';',
            'width'        => '',
            'maxlength'    => '',
            'rows'        => '5',
            'cols'        => '30'
        )
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
?>
<?php
/*
    Form Definition
    Tabledefinition
    Datatypes:
    - INTEGER (Forces the input to Int)
    - DOUBLE
    - CURRENCY (Formats the values to currency notation)
    - VARCHAR (no format check, maxlength: 255)
    - TEXT (no format check)
    - DATE (Dateformat, automatic conversion to timestamps)
    Formtype:
    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)
    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hint:
    The ID field of the database table is not part of the datafield definition.
    The ID field must be always auto incement (int or bigint).
*/
$function_list = array();
$function_list['mail_domain_get,mail_domain_add,mail_domain_update,mail_domain_delete,mail_domain_set_status,mail_domain_get_by_domain'] = 'Mail domain functions';
$function_list['mail_mailinglist_get,mail_mailinglist_add,mail_mailinglist_update,mail_mailinglist_delete'] = 'Mail mailinglist functions';
$function_list['mail_user_get,mail_user_add,mail_user_update,mail_user_delete'] = 'Mail user functions';
$function_list['mail_alias_get,mail_alias_add,mail_alias_update,mail_alias_delete'] = 'Mail alias functions';
$function_list['mail_forward_get,mail_forward_add,mail_forward_update,mail_forward_delete'] = 'Mail forward functions';
$function_list['mail_catchall_get,mail_catchall_add,mail_catchall_update,mail_catchall_delete'] = 'Mail catchall functions';
$function_list['mail_transport_get,mail_transport_add,mail_transport_update,mail_transport_delete'] = 'Mail transport functions';
$function_list['mail_whitelist_get,mail_whitelist_add,mail_whitelist_update,mail_whitelist_delete'] = 'Mail whitelist functions';
$function_list['mail_blacklist_get,mail_blacklist_add,mail_blacklist_update,mail_blacklist_delete'] = 'Mail blacklist functions';
$function_list['mail_spamfilter_user_get,mail_spamfilter_user_add,mail_spamfilter_user_update,mail_spamfilter_user_delete'] = 'Mail spamfilter user functions';
$function_list['mail_policy_get,mail_policy_add,mail_policy_update,mail_policy_delete'] = 'Mail spamfilter policy functions';
$function_list['mail_fetchmail_get,mail_fetchmail_add,mail_fetchmail_update,mail_fetchmail_delete'] = 'Mail fetchmail functions';
$function_list['mail_spamfilter_whitelist_get,mail_spamfilter_whitelist_add,mail_spamfilter_whitelist_update,mail_spamfilter_whitelist_delete'] = 'Mail spamfilter whitelist functions';
$function_list['mail_spamfilter_blacklist_get,mail_spamfilter_blacklist_add,mail_spamfilter_blacklist_update,mail_spamfilter_blacklist_delete'] = 'Mail spamfilter blacklist functions';
$function_list['mail_user_filter_get,mail_user_filter_add,mail_user_filter_update,mail_user_filter_delete'] = 'Mail user filter functions';
$function_list['mail_filter_get,mail_filter_add,mail_filter_update,mail_filter_delete'] = 'Mail filter functions';
$function_list['client_get,client_add,client_update,client_delete,client_get_sites_by_user,client_get_by_username,client_change_password,client_get_id'] = 'Client functions';
$function_list['server_get,get_function_list,client_templates_get_all'] = 'Server functions';
$function_list['sites_cron_get,sites_cron_add,sites_cron_update,sites_cron_delete'] = 'Sites cron functions';
$function_list['sites_database_get,sites_database_add,sites_database_update,sites_database_delete, sites_database_get_all_by_user'] = 'Sites database functions';
$function_list['sites_ftp_user_get,sites_ftp_user_add,sites_ftp_user_update,sites_ftp_user_delete'] = 'Sites FTP-User functions';
$function_list['sites_shell_user_get,sites_shell_user_add,sites_shell_user_update,sites_shell_user_delete'] = 'Sites Shell-User functions';
$function_list['sites_web_domain_get,sites_web_domain_add,sites_web_domain_update,sites_web_domain_delete,sites_web_domain_set_status'] = 'Sites Domain functions';
$function_list['sites_web_aliasdomain_get,sites_web_aliasdomain_add,sites_web_aliasdomain_update,sites_web_aliasdomain_delete'] = 'Sites Aliasdomain functions';
$function_list['sites_web_subdomain_get,sites_web_subdomain_add,sites_web_subdomain_update,sites_web_subdomain_delete'] = 'Sites Subdomain functions';
$function_list['dns_zone_get,dns_zone_add,dns_zone_update,dns_zone_delete,dns_zone_set_status'] = 'DNS zone functions';
$function_list['dns_a_get,dns_a_add,dns_a_update,dns_a_delete'] = 'DNS a functions';
$function_list['dns_aaaa_get,dns_aaaa_add,dns_aaaa_update,dns_aaaa_delete'] = 'DNS aaaa functions';
$function_list['dns_alias_get,dns_alias_add,dns_alias_update,dns_alias_delete'] = 'DNS alias functions';
$function_list['dns_cname_get,dns_cname_add,dns_cname_update,dns_cname_delete'] = 'DNS cname functions';
$function_list['dns_hinfo_get,dns_hinfo_add,dns_hinfo_update,dns_hinfo_delete'] = 'DNS hinfo functions';
$function_list['dns_mx_get,dns_mx_add,dns_mx_update,dns_mx_delete'] = 'DNS mx functions';
$function_list['dns_ns_get,dns_ns_add,dns_ns_update,dns_ns_delete'] = 'DNS ns functions';
$function_list['dns_ptr_get,dns_ptr_add,dns_ptr_update,dns_ptr_delete'] = 'DNS ptr functions';
$function_list['dns_rp_get,dns_rp_add,dns_rp_update,dns_rp_delete'] = 'DNS rp functions';
$function_list['dns_srv_get,dns_srv_add,dns_srv_update,dns_srv_delete'] = 'DNS srv functions';
$function_list['dns_txt_get,dns_txt_add,dns_txt_update,dns_txt_delete'] = 'DNS txt functions';
$form["title"]             = "Remote user";
$form["description"]     = "";
$form["name"]             = "remote_user";
$form["action"]            = "remote_user_edit.php";
$form["db_table"]        = "remote_user";
$form["db_table_idx"]    = "remote_userid";
$form["db_history"]        = "yes";
$form["tab_default"]    = "remote_user";
$form["list_default"]    = "remote_user_list.php";
$form["auth"]            = 'yes'; // yes / no
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
$form["tabs"]['remote_user'] = array (
    'title'     => "Remote User",
    'width'     => 100,
    'template'     => "templates/remote_user_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'remote_userid' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT remote_userid,remote_username FROM remote_user WHERE {AUTHSQL} ORDER BY remote_username',
                                        'keyfield'=> 'remote_userid',
                                        'valuefield'=> 'remote_username'
                                     ),
            'value'        => ''
        ),
        'remote_username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'UNIQUE',
                                                        'errmsg'=> 'username_error_unique'),
                                        1 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-]{0,64}$/',
                                                        'errmsg'=> 'username_error_regex'),
2 => array (    'type' => 'NOTEMPTY',
        'errmsg'=> 'username_error_empty'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'remote_password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption' => 'MD5',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'remote_functions' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'CHECKBOXARRAY',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $function_list,
            'separator'    => ';',
            'width'        => '',
            'maxlength'    => '',
            'rows'        => '5',
            'cols'        => '30'
        )
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
?>
interface/web/admin/form/system_config.tform.php
@@ -1,252 +1,270 @@
<?php
/*
    Form Definition
    Tabledefinition
    Datatypes:
    - INTEGER (Forces the input to Int)
    - DOUBLE
    - CURRENCY (Formats the values to currency notation)
    - VARCHAR (no format check, maxlength: 255)
    - TEXT (no format check)
    - DATE (Dateformat, automatic conversion to timestamps)
    Formtype:
    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)
    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hint:
    The ID field of the database table is not part of the datafield definition.
    The ID field must be always auto incement (int or bigint).
*/
$form["title"]             = "System Config";
$form["description"]     = "";
$form["name"]             = "system_config";
$form["action"]            = "system_config_edit.php";
$form["db_table"]        = "sys_ini";
$form["db_table_idx"]    = "sysini_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "sites";
$form["list_default"]    = "server_list.php";
$form["auth"]            = 'yes'; // yes / no
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
$form["tabs"]['sites'] = array (
    'title'     => "Sites",
    'width'     => 70,
    'template'     => "templates/system_config_sites_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'dbname_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'dbname_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'dbuser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'dbuser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'ftpuser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'ftpuser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'shelluser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'shelluser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'webdavuser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'webdavuser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'dblist_phpmyadmin_link' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'phpmyadmin_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
                                                        'errmsg'=> 'phpmyadmin_url_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'webftp_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
                                                        'errmsg'=> 'webftp_url_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
$form["tabs"]['mail'] = array (
    'title'     => "Mail",
    'width'     => 70,
    'template'     => "templates/system_config_mail_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'mailboxlist_webmail_link' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'webmail_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
                                                        'errmsg'=> 'webmail_url_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'admin_mail' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'admin_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
$form["tabs"]['domains'] = array (
    'title'     => "Domains",
    'width'     => 70,
    'template'     => "templates/system_config_domains_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'use_domain_module' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'new_domain_html' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => ''
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
$form["tabs"]['misc'] = array (
    'title'     => "Misc",
    'width'     => 70,
    'template'     => "templates/system_config_misc_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'dashboard_atom_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => 'http://www.ispconfig.org/atom',
            'value'        => ''
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
?>
<?php
/*
    Form Definition
    Tabledefinition
    Datatypes:
    - INTEGER (Forces the input to Int)
    - DOUBLE
    - CURRENCY (Formats the values to currency notation)
    - VARCHAR (no format check, maxlength: 255)
    - TEXT (no format check)
    - DATE (Dateformat, automatic conversion to timestamps)
    Formtype:
    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)
    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hint:
    The ID field of the database table is not part of the datafield definition.
    The ID field must be always auto incement (int or bigint).
*/
$form["title"]             = "System Config";
$form["description"]     = "";
$form["name"]             = "system_config";
$form["action"]            = "system_config_edit.php";
$form["db_table"]        = "sys_ini";
$form["db_table_idx"]    = "sysini_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "sites";
$form["list_default"]    = "server_list.php";
$form["auth"]            = 'yes'; // yes / no
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
$form["tabs"]['sites'] = array (
    'title'     => "Sites",
    'width'     => 70,
    'template'     => "templates/system_config_sites_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'dbname_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'dbname_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'dbuser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'dbuser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'ftpuser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'ftpuser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'shelluser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'shelluser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'webdavuser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'webdavuser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'dblist_phpmyadmin_link' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'phpmyadmin_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
                                                        'errmsg'=> 'phpmyadmin_url_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'webftp_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
                                                        'errmsg'=> 'webftp_url_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
$form["tabs"]['mail'] = array (
    'title'     => "Mail",
    'width'     => 70,
    'template'     => "templates/system_config_mail_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'mailboxlist_webmail_link' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'webmail_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
                                                        'errmsg'=> 'webmail_url_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'mailmailinglist_link' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'mailmailinglist_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
                                                        'errmsg'=> 'mailinglist_url_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'admin_mail' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'admin_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
$form["tabs"]['domains'] = array (
    'title'     => "Domains",
    'width'     => 70,
    'template'     => "templates/system_config_domains_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'use_domain_module' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'new_domain_html' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => ''
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
$form["tabs"]['misc'] = array (
    'title'     => "Misc",
    'width'     => 70,
    'template'     => "templates/system_config_misc_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'dashboard_atom_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => 'http://www.ispconfig.org/atom',
            'value'        => ''
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
?>
interface/web/admin/lib/lang/en_remote_user.lng
@@ -7,6 +7,7 @@
$wb['password_error_empty'] = 'Password cannot be empty';
$wb['password_strength_txt'] = 'Password Strength:';
$wb['Mail domain functions'] = 'Mail domain functions';
$wb['Mail mailing list functions'] = 'Mail mailinglist functions';
$wb['Mail user functions'] = 'Mail user functions';
$wb['Mail alias functions'] = 'Mail alias functions';
$wb['Mail forward functions'] = 'Mail forward functions';
interface/web/admin/lib/lang/en_system_config.lng
@@ -14,6 +14,8 @@
$wb["dblist_phpmyadmin_link_txt"] = 'Link to phpmyadmin in DB list';
$wb["mailboxlist_webmail_link_txt"] = 'Link to webmail in Mailbox list';
$wb["webmail_url_txt"] = 'Webmail URL';
$wb["mailmailinglist_link_txt"] = 'Link to mailing list in Mailing list list';
$wb["mailmailinglist_url_txt"] = 'Mailing list URL';
$wb["phpmyadmin_url_txt"] = 'PHPMyAdmin URL';
$wb["use_domain_module_txt"] = 'Use the domain-module to add new domains';
$wb["use_domain_module_hint"] = 'If you use this module, your customers can only select one of the domains the admin creates for them. They cannot free edit the domain-field.You have to re-login after changing this value, to make the changes visible.';
interface/web/admin/templates/system_config_mail_edit.htm
@@ -15,6 +15,16 @@
          <label for="webmail_url">{tmpl_var name='webmail_url_txt'}</label>
        <input name="webmail_url" id="webmail_url" value="{tmpl_var name='webmail_url'}" size="30" maxlength="255" type="text" class="textInput" />
      </div>
    <div class="ctrlHolder">
                <p class="label">{tmpl_var name='mailmailinglist_link_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='mailmailinglist_link'}
                    </div>
            </div>
    <div class="ctrlHolder">
          <label for="mailmailinglist_url">{tmpl_var name='mailmailinglist_url_txt'}</label>
        <input name="mailmailinglist_url" id="mailmailinglist_url" value="{tmpl_var name='mailmailinglist_url'}" size="30" maxlength="255" type="text" class="textInput" />
      </div>
    <div class="ctrlHolder">
          <label for="admin_mail">{tmpl_var name='admin_mail_txt'}</label>
        <input name="admin_mail" id="admin_mail" value="{tmpl_var name='admin_mail'}" size="30" maxlength="255" type="text" class="textInput" />
interface/web/client/form/client.tform.php
@@ -1,846 +1,860 @@
<?php
/*
    Form Definition
    Tabledefinition
    Datatypes:
    - INTEGER (Forces the input to Int)
    - DOUBLE
    - CURRENCY (Formats the values to currency notation)
    - VARCHAR (no format check, maxlength: 255)
    - TEXT (no format check)
    - DATE (Dateformat, automatic conversion to timestamps)
    Formtype:
    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)
    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hint:
    The ID field of the database table is not part of the datafield definition.
    The ID field must be always auto incement (int or bigint).
*/
$form["title"]             = "Client";
$form["description"]     = "";
$form["name"]             = "client";
$form["action"]            = "client_edit.php";
$form["db_table"]        = "client";
$form["db_table_idx"]    = "client_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "address";
$form["list_default"]    = "client_list.php";
$form["auth"]            = 'yes';
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
//* Load themes
$themes_list = array();
$handle = @opendir(ISPC_THEMES_PATH);
while ($file = @readdir ($handle)) {
    if (substr($file, 0, 1) != '.') {
        if(@is_dir(ISPC_THEMES_PATH."/$file")) {
            $themes_list[$file] = $file;
        }
    }
}
$form["tabs"]['address'] = array (
    'title'     => "Address",
    'width'     => 100,
    'template'     => "templates/client_edit_address.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'company_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'contact_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'contact_error_empty'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'customer_no' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'username_error_empty'),
                                        1 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_client',
                                                        'function' => 'username_unique',
                                                        'errmsg'=> 'username_error_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,64}$/',
                                                        'errmsg'=> 'username_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption'=> 'CRYPT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'language' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => $conf["language"],
            'value'        => $language_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'usertheme' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'default',
            'value'        => $themes_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'street' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'zip' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'city' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'state' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'country' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'DE',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name',
                                        'keyfield'=> 'iso',
                                        'valuefield'=> 'printable_name'
                                     ),
            'value'        => ''
        ),
        'telephone' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'mobile' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'fax' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'email' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'internet' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => 'http://',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'icq' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'vat_id' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'company_id' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '20',
            'rows'        => '',
            'cols'        => ''
        ),
        'notes' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXTAREA',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '',
            'maxlength'    => '',
            'rows'        => '10',
            'cols'        => '30'
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
$form["tabs"]['limits'] = array (
    'title'     => "Limits",
    'width'     => 80,
    'template'     => "templates/client_edit_limits.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'template_master' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'master_templates'
                                     ),
            'value'        => ''
        ),
        'template_additional' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
        ),
        'default_mailserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_mailserver'
        ),
        'limit_maildomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_maildomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailbox' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailbox_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailalias' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailalias_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailaliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailaliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailforward_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailcatchall' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailcatchall_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailrouting' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailrouting_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailfilter' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfilter_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_fetchmail' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfetchmail_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailquota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailquota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_wblist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_wblist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_policy' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_policy_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_webserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_webserver'
        ),
        'limit_web_domain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_domain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'web_php_options' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'valuelimit' => 'client:web_php_options',
            'value'        => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP')
        ),
        'limit_web_aliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_aliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_subdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_subdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_ftp_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_ftp_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_shell_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_shell_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'ssh_chroot' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'valuelimit' => 'client:ssh_chroot',
            'value'        => array('no' => 'None', 'jailkit' => 'Jailkit')
        ),
        'limit_webdav_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_webdav_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_dnsserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_dnsserver'
        ),
        'limit_dns_zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_zone_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
                'limit_dns_slave_zone' => array (
                        'datatype'      => 'INTEGER',
                        'formtype'      => 'TEXT',
                        'validators'    => array (      0 => array (    'type'  => 'ISINT',
                                                                                                                'errmsg'=> 'limit_dns_slave_zone_error_notint'),
                                                                        ),
                        'default'       => '-1',
                        'value'         => '',
                        'separator'     => '',
                        'width'         => '10',
                        'maxlength'     => '10',
                        'rows'          => '',
                        'cols'          => ''
                ),
        'limit_dns_record' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_record_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_client' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_client_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_dbserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_dbserver'
        ),
        'limit_database' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_database_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_cron' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_notint'),
                                    ),
            'default'   => '0',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_cron_type' => array (
            'datatype'  => 'VARCHAR',
            'formtype'  => 'SELECT',
            'default'   => '',
            'value'     => array('full' => 'Full Cron','chrooted' => 'Chrooted Cron','url' => 'URL Cron')
        ),
        'limit_cron_frequency' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_frequency'),
                                    ),
            'default'   => '-1',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_traffic_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_traffic_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
/*
$form["tabs"]['ipaddress'] = array (
    'title'     => "IP Addresses",
    'width'     => 100,
    'template'     => "templates/client_edit_ipaddress.htm",
    'fields'     => array (
    ##################################
    # Beginn Datatable fields
    ##################################
        'ip_address' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'value'        => array('192.168.0.1' => '192.168.0.1', '192.168.0.2' => '192.168.0.2'),
            'separator'    => ';'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
*/
?>
<?php
/*
    Form Definition
    Tabledefinition
    Datatypes:
    - INTEGER (Forces the input to Int)
    - DOUBLE
    - CURRENCY (Formats the values to currency notation)
    - VARCHAR (no format check, maxlength: 255)
    - TEXT (no format check)
    - DATE (Dateformat, automatic conversion to timestamps)
    Formtype:
    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)
    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hint:
    The ID field of the database table is not part of the datafield definition.
    The ID field must be always auto incement (int or bigint).
*/
$form["title"]             = "Client";
$form["description"]     = "";
$form["name"]             = "client";
$form["action"]            = "client_edit.php";
$form["db_table"]        = "client";
$form["db_table_idx"]    = "client_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "address";
$form["list_default"]    = "client_list.php";
$form["auth"]            = 'yes';
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
//* Load themes
$themes_list = array();
$handle = @opendir(ISPC_THEMES_PATH);
while ($file = @readdir ($handle)) {
    if (substr($file, 0, 1) != '.') {
        if(@is_dir(ISPC_THEMES_PATH."/$file")) {
            $themes_list[$file] = $file;
        }
    }
}
$form["tabs"]['address'] = array (
    'title'     => "Address",
    'width'     => 100,
    'template'     => "templates/client_edit_address.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'company_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'contact_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'contact_error_empty'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'customer_no' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'username_error_empty'),
                                        1 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_client',
                                                        'function' => 'username_unique',
                                                        'errmsg'=> 'username_error_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,64}$/',
                                                        'errmsg'=> 'username_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption'=> 'CRYPT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'language' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => $conf["language"],
            'value'        => $language_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'usertheme' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'default',
            'value'        => $themes_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'street' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'zip' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'city' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'state' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'country' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'DE',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name',
                                        'keyfield'=> 'iso',
                                        'valuefield'=> 'printable_name'
                                     ),
            'value'        => ''
        ),
        'telephone' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'mobile' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'fax' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'email' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'internet' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => 'http://',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'icq' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'vat_id' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'company_id' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '20',
            'rows'        => '',
            'cols'        => ''
        ),
        'notes' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXTAREA',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '',
            'maxlength'    => '',
            'rows'        => '10',
            'cols'        => '30'
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
$form["tabs"]['limits'] = array (
    'title'     => "Limits",
    'width'     => 80,
    'template'     => "templates/client_edit_limits.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'template_master' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'master_templates'
                                     ),
            'value'        => ''
        ),
        'template_additional' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
        ),
        'default_mailserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_mailserver'
        ),
        'limit_maildomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_maildomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailbox' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailbox_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailalias' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailalias_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailaliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailaliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailmailinglist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailmailinglist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailforward_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailcatchall' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailcatchall_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailrouting' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailrouting_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailfilter' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfilter_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_fetchmail' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfetchmail_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailquota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailquota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_wblist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_wblist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_policy' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_policy_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_webserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_webserver'
        ),
        'limit_web_domain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_domain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'web_php_options' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'valuelimit' => 'client:web_php_options',
            'value'        => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP')
        ),
        'limit_web_aliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_aliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_subdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_subdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_ftp_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_ftp_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_shell_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_shell_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'ssh_chroot' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'valuelimit' => 'client:ssh_chroot',
            'value'        => array('no' => 'None', 'jailkit' => 'Jailkit')
        ),
        'limit_webdav_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_webdav_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_dnsserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_dnsserver'
        ),
        'limit_dns_zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_zone_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
                'limit_dns_slave_zone' => array (
                        'datatype'      => 'INTEGER',
                        'formtype'      => 'TEXT',
                        'validators'    => array (      0 => array (    'type'  => 'ISINT',
                                                                                                                'errmsg'=> 'limit_dns_slave_zone_error_notint'),
                                                                        ),
                        'default'       => '-1',
                        'value'         => '',
                        'separator'     => '',
                        'width'         => '10',
                        'maxlength'     => '10',
                        'rows'          => '',
                        'cols'          => ''
                ),
        'limit_dns_record' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_record_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_client' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_client_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_dbserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_dbserver'
        ),
        'limit_database' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_database_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_cron' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_notint'),
                                    ),
            'default'   => '0',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_cron_type' => array (
            'datatype'  => 'VARCHAR',
            'formtype'  => 'SELECT',
            'default'   => '',
            'value'     => array('full' => 'Full Cron','chrooted' => 'Chrooted Cron','url' => 'URL Cron')
        ),
        'limit_cron_frequency' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_frequency'),
                                    ),
            'default'   => '-1',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_traffic_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_traffic_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
/*
$form["tabs"]['ipaddress'] = array (
    'title'     => "IP Addresses",
    'width'     => 100,
    'template'     => "templates/client_edit_ipaddress.htm",
    'fields'     => array (
    ##################################
    # Beginn Datatable fields
    ##################################
        'ip_address' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'value'        => array('192.168.0.1' => '192.168.0.1', '192.168.0.2' => '192.168.0.2'),
            'separator'    => ';'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
*/
?>
interface/web/client/form/client_template.tform.php
@@ -1,510 +1,524 @@
<?php
/*
    Form Definition
    Tabledefinition
    Datatypes:
    - INTEGER (Forces the input to Int)
    - DOUBLE
    - CURRENCY (Formats the values to currency notation)
    - VARCHAR (no format check, maxlength: 255)
    - TEXT (no format check)
    - DATE (Dateformat, automatic conversion to timestamps)
    Formtype:
    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)
    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hint:
    The ID field of the database table is not part of the datafield definition.
    The ID field must be always auto incement (int or bigint).
*/
$form["title"]             = "Client-Templates";
$form["description"]     = "";
$form["name"]             = "client_template";
$form["action"]            = "client_template_edit.php";
$form["db_table"]        = "client_template";
$form["db_table_idx"]    = "template_id";
$form["db_history"]        = "no";
$form["tab_default"]    = "template";
$form["list_default"]    = "client_template_list.php";
$form["auth"]            = 'yes';
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
$form["tabs"]['template'] = array (
    'title'     => "Template",
    'width'     => 80,
    'template'     => "templates/client_template_edit_template.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'template_type' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'm',
            'value'        => array('m' => "Main Template",'a' => "Additional Template"),
        ),
        'template_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'error_template_name_empty'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
$form["tabs"]['limits'] = array (
    'title'     => "Limits",
    'width'     => 80,
    'template'     => "templates/client_template_edit_limits.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'limit_maildomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_maildomain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailbox' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailbox_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailalias' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailalias_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailaliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailaliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailforward_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailcatchall' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailcatchall_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailrouting' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailrouting_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailfilter' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfilter_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_fetchmail' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfetchmail_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailquota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailquota_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_wblist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_wblist_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_policy' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_policy_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_domain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_domain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_aliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_aliasdomain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_subdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_subdomain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_ftp_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_ftp_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_shell_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_shell_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_webdav_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_webdav_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_dns_zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_zone_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
                'limit_dns_slave_zone' => array (
                        'datatype'      => 'INTEGER',
                        'formtype'      => 'TEXT',
                        'validators'    => array (      0 => array (    'type'  => 'ISINT',
                                                                                                                'errmsg'=> 'limit_dns_slave_zone_error_notint'),
                                                                        ),
                        'default'       => '0',
                        'value'         => '',
                        'separator'     => '',
                        'width'         => '10',
                        'maxlength'     => '10',
                        'rows'          => '',
                        'cols'          => ''
                ),
        'limit_dns_record' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_record_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        /*
        'limit_client' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_client_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        */
        'limit_database' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_database_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_cron' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_notint'),
                                    ),
            'default'   => '0',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_cron_type' => array (
            'datatype'  => 'VARCHAR',
            'formtype'  => 'SELECT',
            'default'   => '',
            'value'     => array('full' => 'Full Cron','chrooted' => 'Chrooted Cron','url' => 'URL Cron')
        ),
        'limit_cron_frequency' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_frequency'),
                                    ),
            'default'   => '-1',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_traffic_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_traffic_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
?>
<?php
/*
    Form Definition
    Tabledefinition
    Datatypes:
    - INTEGER (Forces the input to Int)
    - DOUBLE
    - CURRENCY (Formats the values to currency notation)
    - VARCHAR (no format check, maxlength: 255)
    - TEXT (no format check)
    - DATE (Dateformat, automatic conversion to timestamps)
    Formtype:
    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)
    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hint:
    The ID field of the database table is not part of the datafield definition.
    The ID field must be always auto incement (int or bigint).
*/
$form["title"]             = "Client-Templates";
$form["description"]     = "";
$form["name"]             = "client_template";
$form["action"]            = "client_template_edit.php";
$form["db_table"]        = "client_template";
$form["db_table_idx"]    = "template_id";
$form["db_history"]        = "no";
$form["tab_default"]    = "template";
$form["list_default"]    = "client_template_list.php";
$form["auth"]            = 'yes';
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
$form["tabs"]['template'] = array (
    'title'     => "Template",
    'width'     => 80,
    'template'     => "templates/client_template_edit_template.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'template_type' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'm',
            'value'        => array('m' => "Main Template",'a' => "Additional Template"),
        ),
        'template_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'error_template_name_empty'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
$form["tabs"]['limits'] = array (
    'title'     => "Limits",
    'width'     => 80,
    'template'     => "templates/client_template_edit_limits.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'limit_maildomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_maildomain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailbox' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailbox_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailalias' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailalias_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailaliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailaliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailmailinglist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailmailinglist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailforward_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailcatchall' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailcatchall_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailrouting' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailrouting_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailfilter' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfilter_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_fetchmail' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfetchmail_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailquota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailquota_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_wblist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_wblist_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_policy' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_policy_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_domain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_domain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_aliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_aliasdomain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_subdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_subdomain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_ftp_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_ftp_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_shell_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_shell_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_webdav_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_webdav_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_dns_zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_zone_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
                'limit_dns_slave_zone' => array (
                        'datatype'      => 'INTEGER',
                        'formtype'      => 'TEXT',
                        'validators'    => array (      0 => array (    'type'  => 'ISINT',
                                                                                                                'errmsg'=> 'limit_dns_slave_zone_error_notint'),
                                                                        ),
                        'default'       => '0',
                        'value'         => '',
                        'separator'     => '',
                        'width'         => '10',
                        'maxlength'     => '10',
                        'rows'          => '',
                        'cols'          => ''
                ),
        'limit_dns_record' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_record_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        /*
        'limit_client' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_client_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        */
        'limit_database' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_database_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_cron' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_notint'),
                                    ),
            'default'   => '0',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_cron_type' => array (
            'datatype'  => 'VARCHAR',
            'formtype'  => 'SELECT',
            'default'   => '',
            'value'     => array('full' => 'Full Cron','chrooted' => 'Chrooted Cron','url' => 'URL Cron')
        ),
        'limit_cron_frequency' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_frequency'),
                                    ),
            'default'   => '-1',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_traffic_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_traffic_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
?>
interface/web/client/form/reseller.tform.php
@@ -1,797 +1,811 @@
<?php
/*
    Form Definition
    Tabledefinition
    Datatypes:
    - INTEGER (Forces the input to Int)
    - DOUBLE
    - CURRENCY (Formats the values to currency notation)
    - VARCHAR (no format check, maxlength: 255)
    - TEXT (no format check)
    - DATE (Dateformat, automatic conversion to timestamps)
    Formtype:
    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)
    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hint:
    The ID field of the database table is not part of the datafield definition.
    The ID field must be always auto incement (int or bigint).
*/
$form["title"]             = "Reseller";
$form["description"]     = "";
$form["name"]             = "reseller";
$form["action"]            = "reseller_edit.php";
$form["db_table"]        = "client";
$form["db_table_idx"]    = "client_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "address";
$form["list_default"]    = "reseller_list.php";
$form["auth"]            = 'yes';
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
$form["tabs"]['address'] = array (
    'title'     => "Address",
    'width'     => 100,
    'template'     => "templates/reseller_edit_address.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'company_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'contact_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'contact_error_empty'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'customer_no' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'username_error_empty'),
                                        1 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_client',
                                                        'function' => 'username_unique',
                                                        'errmsg'=> 'username_error_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,64}$/',
                                                        'errmsg'=> 'username_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption'=> 'CRYPT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'language' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => $conf["language"],
            'value'        => $language_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'usertheme' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'default',
            'value'        => array('default' => 'default'),
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'street' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'zip' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'city' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'state' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'country' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'DE',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name',
                                        'keyfield'=> 'iso',
                                        'valuefield'=> 'printable_name'
                                     ),
            'value'        => ''
        ),
        'telephone' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'mobile' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'fax' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'email' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'internet' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => 'http://',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'icq' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'vat_id' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'notes' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXTAREA',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '',
            'maxlength'    => '',
            'rows'        => '10',
            'cols'        => '30'
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
$form["tabs"]['limits'] = array (
    'title'     => "Limits",
    'width'     => 80,
    'template'     => "templates/reseller_edit_limits.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'template_master' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'master_templates'
                                     ),
            'value'        => ''
        ),
        'template_additional' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
        ),
        'default_mailserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_maildomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_maildomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailbox' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailbox_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailalias' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailalias_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailforward_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailcatchall' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailcatchall_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailrouting' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailrouting_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailfilter' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfilter_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_fetchmail' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfetchmail_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailquota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailquota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_wblist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_wblist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_policy' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_policy_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_webserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE web_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_web_domain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_domain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'web_php_options' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'value'        => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP')
        ),
        'limit_web_aliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_aliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_subdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_subdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_ftp_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_ftp_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_shell_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_shell_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'ssh_chroot' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'value'        => array('no' => 'None', 'jailkit' => 'Jailkit')
        ),
        'default_dnsserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE dns_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_dns_zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_zone_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
                'limit_dns_slave_zone' => array (
                        'datatype'      => 'INTEGER',
                        'formtype'      => 'TEXT',
                        'validators'    => array (      0 => array (    'type'  => 'ISINT',
                                                                                                                'errmsg'=> 'limit_dns_slave_zone_error_notint'),
                                                                        ),
                        'default'       => '-1',
                        'value'         => '',
                        'separator'     => '',
                        'width'         => '10',
                        'maxlength'     => '10',
                        'rows'          => '',
                        'cols'          => ''
                ),
        'limit_dns_record' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_record_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_client' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_client_error_notint'),
                                        1 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_reseller',
                                                        'function' => 'limit_client'),
                                    ),
            'default'    => '1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_dbserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE db_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_database' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_database_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_cron' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_notint'),
                                    ),
            'default'   => '0',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_cron_type' => array (
            'datatype'  => 'VARCHAR',
            'formtype'  => 'SELECT',
            'default'   => '',
            'value'     => array('full' => 'Full Cron','chrooted' => 'Chrooted Cron','url' => 'URL Cron')
        ),
        'limit_cron_frequency' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_frequency'),
                                    ),
            'default'   => '-1',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_traffic_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_traffic_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
/*
$form["tabs"]['ipaddress'] = array (
    'title'     => "IP Addresses",
    'width'     => 100,
    'template'     => "templates/client_edit_ipaddress.htm",
    'fields'     => array (
    ##################################
    # Beginn Datatable fields
    ##################################
        'ip_address' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'value'        => array('192.168.0.1' => '192.168.0.1', '192.168.0.2' => '192.168.0.2'),
            'separator'    => ';'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
*/
?>
<?php
/*
    Form Definition
    Tabledefinition
    Datatypes:
    - INTEGER (Forces the input to Int)
    - DOUBLE
    - CURRENCY (Formats the values to currency notation)
    - VARCHAR (no format check, maxlength: 255)
    - TEXT (no format check)
    - DATE (Dateformat, automatic conversion to timestamps)
    Formtype:
    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)
    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hint:
    The ID field of the database table is not part of the datafield definition.
    The ID field must be always auto incement (int or bigint).
*/
$form["title"]             = "Reseller";
$form["description"]     = "";
$form["name"]             = "reseller";
$form["action"]            = "reseller_edit.php";
$form["db_table"]        = "client";
$form["db_table_idx"]    = "client_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "address";
$form["list_default"]    = "reseller_list.php";
$form["auth"]            = 'yes';
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
$form["tabs"]['address'] = array (
    'title'     => "Address",
    'width'     => 100,
    'template'     => "templates/reseller_edit_address.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'company_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'contact_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'contact_error_empty'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'customer_no' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'username_error_empty'),
                                        1 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_client',
                                                        'function' => 'username_unique',
                                                        'errmsg'=> 'username_error_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,64}$/',
                                                        'errmsg'=> 'username_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption'=> 'CRYPT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'language' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => $conf["language"],
            'value'        => $language_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'usertheme' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'default',
            'value'        => array('default' => 'default'),
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'street' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'zip' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'city' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'state' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'country' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'DE',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name',
                                        'keyfield'=> 'iso',
                                        'valuefield'=> 'printable_name'
                                     ),
            'value'        => ''
        ),
        'telephone' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'mobile' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'fax' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'email' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'internet' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => 'http://',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'icq' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'vat_id' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'notes' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXTAREA',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '',
            'maxlength'    => '',
            'rows'        => '10',
            'cols'        => '30'
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
$form["tabs"]['limits'] = array (
    'title'     => "Limits",
    'width'     => 80,
    'template'     => "templates/reseller_edit_limits.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'template_master' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'master_templates'
                                     ),
            'value'        => ''
        ),
        'template_additional' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
        ),
        'default_mailserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_maildomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_maildomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailmailinglist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailmailinglist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailbox' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailbox_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailalias' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailalias_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailforward_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailcatchall' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailcatchall_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailrouting' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailrouting_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailfilter' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfilter_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_fetchmail' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfetchmail_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailquota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailquota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_wblist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_wblist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_policy' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_policy_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_webserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE web_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_web_domain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_domain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'web_php_options' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'value'        => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP')
        ),
        'limit_web_aliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_aliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_subdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_subdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_ftp_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_ftp_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_shell_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_shell_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'ssh_chroot' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'value'        => array('no' => 'None', 'jailkit' => 'Jailkit')
        ),
        'default_dnsserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE dns_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_dns_zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_zone_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
                'limit_dns_slave_zone' => array (
                        'datatype'      => 'INTEGER',
                        'formtype'      => 'TEXT',
                        'validators'    => array (      0 => array (    'type'  => 'ISINT',
                                                                                                                'errmsg'=> 'limit_dns_slave_zone_error_notint'),
                                                                        ),
                        'default'       => '-1',
                        'value'         => '',
                        'separator'     => '',
                        'width'         => '10',
                        'maxlength'     => '10',
                        'rows'          => '',
                        'cols'          => ''
                ),
        'limit_dns_record' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_record_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_client' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_client_error_notint'),
                                        1 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_reseller',
                                                        'function' => 'limit_client'),
                                    ),
            'default'    => '1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_dbserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE db_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_database' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_database_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_cron' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_notint'),
                                    ),
            'default'   => '0',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_cron_type' => array (
            'datatype'  => 'VARCHAR',
            'formtype'  => 'SELECT',
            'default'   => '',
            'value'     => array('full' => 'Full Cron','chrooted' => 'Chrooted Cron','url' => 'URL Cron')
        ),
        'limit_cron_frequency' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_frequency'),
                                    ),
            'default'   => '-1',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_traffic_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_traffic_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
/*
$form["tabs"]['ipaddress'] = array (
    'title'     => "IP Addresses",
    'width'     => 100,
    'template'     => "templates/client_edit_ipaddress.htm",
    'fields'     => array (
    ##################################
    # Beginn Datatable fields
    ##################################
        'ip_address' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'value'        => array('192.168.0.1' => '192.168.0.1', '192.168.0.2' => '192.168.0.2'),
            'separator'    => ';'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
*/
?>
interface/web/client/lib/lang/en_client.lng
@@ -1,5 +1,6 @@
<?php
$wb["limit_maildomain_txt"] = 'Max. number of email domains';
$wb["limit_mailmailinglist_txt"] = 'Max. number of mailing lists';
$wb["limit_mailbox_txt"] = 'Max. number of mailboxes';
$wb["limit_mailalias_txt"] = 'Max. number of email aliases';
$wb["limit_mailaliasdomain_txt"] = 'Max. number of domain aliases';
@@ -62,6 +63,7 @@
$wb["username_error_empty"] = 'Username is empty.';
$wb["username_error_unique"] = 'The username must be unique.';
$wb["limit_maildomain_error_notint"] = 'The email domain limit must be a number.';
$wb["limit_mailmailinglist_error_notint"] = 'The mailing list record limit must be a number.';
$wb["limit_mailbox_error_notint"] = 'The mailbox limit must be a number.';
$wb["limit_mailalias_error_notint"] = 'The email alias limit must be a number.';
$wb["limit_mailaliasdomain_error_notint"] = 'The email domain alias limit must be a number.';
interface/web/client/lib/lang/en_client_template.lng
@@ -5,6 +5,7 @@
$wb["limit_mailbox_txt"] = 'Max. number of mailboxes';
$wb["limit_mailalias_txt"] = 'Max. number of email aliases';
$wb["limit_mailaliasdomain_txt"] = 'Max. number of domain aliases';
$wb["limit_mailmailinglist_txt"] = 'Max. number of mailing lists';
$wb["limit_mailforward_txt"] = 'Max. number of email forwarders';
$wb["limit_mailcatchall_txt"] = 'Max. number of email catchall accounts';
$wb["limit_mailrouting_txt"] = 'Max. number of email routes';
@@ -32,6 +33,7 @@
$wb["limit_webdav_user_txt"] = 'Max. number of Webdav users';
$wb["limit_client_txt"] = 'Max. number of Clients';
$wb["limit_maildomain_error_notint"] = 'The email domain limit must be a number.';
$wb["limit_mailmailinglist_error_notint"] = 'The mailing list record limit must be a number.';
$wb["limit_mailbox_error_notint"] = 'The mailbox limit must be a number.';
$wb["limit_mailalias_error_notint"] = 'The email alias limit must be a number.';
$wb["limit_mailaliasdomain_error_notint"] = 'The email domain alias limit must be a number.';
interface/web/client/lib/lang/en_reseller.lng
@@ -1,5 +1,6 @@
<?php
$wb["limit_maildomain_txt"] = 'Max. number of email domains';
$wb["limit_mailmailinglist_txt"] = 'Max. number of mailing lists';
$wb["limit_mailbox_txt"] = 'Max. number of mailboxes';
$wb["limit_mailalias_txt"] = 'Max. number of email aliases';
$wb["limit_mailforward_txt"] = 'Max. number of email forwarders';
@@ -60,6 +61,7 @@
$wb["username_error_empty"] = 'Username is empty.';
$wb["username_error_unique"] = 'The username must be unique.';
$wb["limit_maildomain_error_notint"] = 'The email domain limit must be a number.';
$wb["limit_mailmailinglist_error_notint"] = 'The mailing list record limit must be a number.';
$wb["limit_mailbox_error_notint"] = 'The mailbox limit must be a number.';
$wb["limit_mailalias_error_notint"] = 'The email alias limit must be a number.';
$wb["limit_mailforward_error_notint"] = 'The email forward limit must be a number.';
interface/web/client/templates/client_edit_limits.htm
@@ -1,198 +1,202 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_client">
    <tmpl_if name="is_admin">
        <div class="pnl_toolsarea">
            <fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
                <div class="buttons">
                    <button class="positive iconstxt icoAdd" type="button" value="Add additional template" onClick="addAdditionalTemplate();"><span>Add additional template</span></button>
                    <button class="negative iconstxt icoDelete" type="button" value="Delete additional template" onClick="delAdditionalTemplate();"><span>Delete additional template</span></button>
                </div>
            </fieldset>
        </div>
    </tmpl_if>
    <div class="pnl_formsarea">
        <fieldset class="inlineLabels"><legend>Limits</legend>
            <tmpl_if name="is_admin">
                <div class="ctrlHolder">
                    <label for="template_master">{tmpl_var name='template_master_txt'}</label>
                    <select name="template_master" id="template_master" class="selectInput">
                    {tmpl_var name='template_master'}
                    </select>
                </div>
                <div class="ctrlHolder">
                    <label for="template_additional">{tmpl_var name='template_additional_txt'}</label>
                    <select name="tpl_add_select" id="tpl_add_select" class="selectInput">
                    {tmpl_var name='tpl_add_select'}
                    </select>
                    <div id="template_additional_list"><br /><br />{tmpl_var name='template_additional_list'}</div>
                    <input type="hidden" id="template_additional" name="template_additional" value="{tmpl_var name='template_additional'}">
                </div>
                <div class="ctrlHolder">
                    &nbsp;
                </div>
            </tmpl_if>
            <div class="ctrlHolder">
                <label for="default_mailserver">{tmpl_var name='default_mailserver_txt'}</label>
                <select name="default_mailserver" id="default_mailserver" class="selectInput">
                    {tmpl_var name='default_mailserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_maildomain">{tmpl_var name='limit_maildomain_txt'}</label>
                <input name="limit_maildomain" id="limit_maildomain" value="{tmpl_var name='limit_maildomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailbox">{tmpl_var name='limit_mailbox_txt'}</label>
                <input name="limit_mailbox" id="limit_mailbox" value="{tmpl_var name='limit_mailbox'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailalias">{tmpl_var name='limit_mailalias_txt'}</label>
                <input name="limit_mailalias" id="limit_mailalias" value="{tmpl_var name='limit_mailalias'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailaliasdomain">{tmpl_var name='limit_mailaliasdomain_txt'}</label>
                <input name="limit_mailaliasdomain" id="limit_mailaliasdomain" value="{tmpl_var name='limit_mailaliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailforward">{tmpl_var name='limit_mailforward_txt'}</label>
                <input name="limit_mailforward" id="limit_mailforward" value="{tmpl_var name='limit_mailforward'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailcatchall">{tmpl_var name='limit_mailcatchall_txt'}</label>
                <input name="limit_mailcatchall" id="limit_mailcatchall" value="{tmpl_var name='limit_mailcatchall'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailrouting">{tmpl_var name='limit_mailrouting_txt'}</label>
                <input name="limit_mailrouting" id="limit_mailrouting" value="{tmpl_var name='limit_mailrouting'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailfilter">{tmpl_var name='limit_mailfilter_txt'}</label>
                <input name="limit_mailfilter" id="limit_mailfilter" value="{tmpl_var name='limit_mailfilter'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_fetchmail">{tmpl_var name='limit_fetchmail_txt'}</label>
                <input name="limit_fetchmail" id="limit_fetchmail" value="{tmpl_var name='limit_fetchmail'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailquota">{tmpl_var name='limit_mailquota_txt'}</label>
                <input name="limit_mailquota" id="limit_mailquota" value="{tmpl_var name='limit_mailquota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_wblist">{tmpl_var name='limit_spamfilter_wblist_txt'}</label>
                <input name="limit_spamfilter_wblist" id="limit_spamfilter_wblist" value="{tmpl_var name='limit_spamfilter_wblist'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_user">{tmpl_var name='limit_spamfilter_user_txt'}</label>
                <input name="limit_spamfilter_user" id="limit_spamfilter_user" value="{tmpl_var name='limit_spamfilter_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_policy">{tmpl_var name='limit_spamfilter_policy_txt'}</label>
                <input name="limit_spamfilter_policy" id="limit_spamfilter_policy" value="{tmpl_var name='limit_spamfilter_policy'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="default_webserver">{tmpl_var name='default_webserver_txt'}</label>
                <select name="default_webserver" id="default_webserver" class="selectInput">
                    {tmpl_var name='default_webserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_domain">{tmpl_var name='limit_web_domain_txt'}</label>
                <input name="limit_web_domain" id="limit_web_domain" value="{tmpl_var name='limit_web_domain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_quota">{tmpl_var name='limit_web_quota_txt'}</label>
                <input name="limit_web_quota" id="limit_web_quota" value="{tmpl_var name='limit_web_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
            <div class="ctrlHolder">
                <p class="label">{tmpl_var name='web_php_options_txt'}</p>
                <div class="multiField">
                        {tmpl_var name='web_php_options'}
                </div>
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_aliasdomain">{tmpl_var name='limit_web_aliasdomain_txt'}</label>
                <input name="limit_web_aliasdomain" id="limit_web_aliasdomain" value="{tmpl_var name='limit_web_aliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_subdomain">{tmpl_var name='limit_web_subdomain_txt'}</label>
                <input name="limit_web_subdomain" id="limit_web_subdomain" value="{tmpl_var name='limit_web_subdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_ftp_user">{tmpl_var name='limit_ftp_user_txt'}</label>
                <input name="limit_ftp_user" id="limit_ftp_user" value="{tmpl_var name='limit_ftp_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_shell_user">{tmpl_var name='limit_shell_user_txt'}</label>
                <input name="limit_shell_user" id="limit_shell_user" value="{tmpl_var name='limit_shell_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <p class="label">{tmpl_var name='ssh_chroot_txt'}</p>
                <div class="multiField">
                        {tmpl_var name='ssh_chroot'}
                </div>
            </div>
            <div class="ctrlHolder">
                <label for="limit_webdav_user">{tmpl_var name='limit_webdav_user_txt'}</label>
                <input name="limit_webdav_user" id="limit_webdav_user" value="{tmpl_var name='limit_webdav_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="default_dnsserver">{tmpl_var name='default_dnsserver_txt'}</label>
                <select name="default_dnsserver" id="default_dnsserver" class="selectInput">
                    {tmpl_var name='default_dnsserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_zone">{tmpl_var name='limit_dns_zone_txt'}</label>
                <input name="limit_dns_zone" id="limit_dns_zone" value="{tmpl_var name='limit_dns_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_slave_zone">{tmpl_var name='limit_dns_slave_zone_txt'}</label>
                <input name="limit_dns_slave_zone" id="limit_dns_slave_zone" value="{tmpl_var name='limit_dns_slave_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_record">{tmpl_var name='limit_dns_record_txt'}</label>
                <input name="limit_dns_record" id="limit_dns_record" value="{tmpl_var name='limit_dns_record'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="default_dbserver">{tmpl_var name='default_dbserver_txt'}</label>
                <select name="default_dbserver" id="default_dbserver" class="selectInput">
                    {tmpl_var name='default_dbserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_database">{tmpl_var name='limit_database_txt'}</label>
                <input name="limit_database" id="limit_database" value="{tmpl_var name='limit_database'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron">{tmpl_var name='limit_cron_txt'}</label>
                <input name="limit_cron" id="limit_cron" value="{tmpl_var name='limit_cron'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron_type">{tmpl_var name='limit_cron_type_txt'}</label>
                <select name="limit_cron_type" id="limit_cron_type" class="selectInput formLengthHalf">
                    {tmpl_var name='limit_cron_type'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron_frequency">{tmpl_var name='limit_cron_frequency_txt'}</label>
                <input name="limit_cron_frequency" id="limit_cron_frequency" value="{tmpl_var name='limit_cron_frequency'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_traffic_quota">{tmpl_var name='limit_traffic_quota_txt'}</label>
                <input name="limit_traffic_quota" id="limit_traffic_quota" value="{tmpl_var name='limit_traffic_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
        </fieldset>
        <input type="hidden" name="id" value="{tmpl_var name='id'}">
        <div class="buttonHolder buttons">
            <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','client/client_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
            <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('client/client_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
        </div>
    </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_client">
    <tmpl_if name="is_admin">
        <div class="pnl_toolsarea">
            <fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
                <div class="buttons">
                    <button class="positive iconstxt icoAdd" type="button" value="Add additional template" onClick="addAdditionalTemplate();"><span>Add additional template</span></button>
                    <button class="negative iconstxt icoDelete" type="button" value="Delete additional template" onClick="delAdditionalTemplate();"><span>Delete additional template</span></button>
                </div>
            </fieldset>
        </div>
    </tmpl_if>
    <div class="pnl_formsarea">
        <fieldset class="inlineLabels"><legend>Limits</legend>
            <tmpl_if name="is_admin">
                <div class="ctrlHolder">
                    <label for="template_master">{tmpl_var name='template_master_txt'}</label>
                    <select name="template_master" id="template_master" class="selectInput">
                    {tmpl_var name='template_master'}
                    </select>
                </div>
                <div class="ctrlHolder">
                    <label for="template_additional">{tmpl_var name='template_additional_txt'}</label>
                    <select name="tpl_add_select" id="tpl_add_select" class="selectInput">
                    {tmpl_var name='tpl_add_select'}
                    </select>
                    <div id="template_additional_list"><br /><br />{tmpl_var name='template_additional_list'}</div>
                    <input type="hidden" id="template_additional" name="template_additional" value="{tmpl_var name='template_additional'}">
                </div>
                <div class="ctrlHolder">
                    &nbsp;
                </div>
            </tmpl_if>
            <div class="ctrlHolder">
                <label for="default_mailserver">{tmpl_var name='default_mailserver_txt'}</label>
                <select name="default_mailserver" id="default_mailserver" class="selectInput">
                    {tmpl_var name='default_mailserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_maildomain">{tmpl_var name='limit_maildomain_txt'}</label>
                <input name="limit_maildomain" id="limit_maildomain" value="{tmpl_var name='limit_maildomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailbox">{tmpl_var name='limit_mailbox_txt'}</label>
                <input name="limit_mailbox" id="limit_mailbox" value="{tmpl_var name='limit_mailbox'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailalias">{tmpl_var name='limit_mailalias_txt'}</label>
                <input name="limit_mailalias" id="limit_mailalias" value="{tmpl_var name='limit_mailalias'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailaliasdomain">{tmpl_var name='limit_mailaliasdomain_txt'}</label>
                <input name="limit_mailaliasdomain" id="limit_mailaliasdomain" value="{tmpl_var name='limit_mailaliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailmailinglist">{tmpl_var name='limit_mailmailinglist_txt'}</label>
                <input name="limit_mailmailinglist" id="limit_mailmailinglist" value="{tmpl_var name='limit_mailmailinglist'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailforward">{tmpl_var name='limit_mailforward_txt'}</label>
                <input name="limit_mailforward" id="limit_mailforward" value="{tmpl_var name='limit_mailforward'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailcatchall">{tmpl_var name='limit_mailcatchall_txt'}</label>
                <input name="limit_mailcatchall" id="limit_mailcatchall" value="{tmpl_var name='limit_mailcatchall'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailrouting">{tmpl_var name='limit_mailrouting_txt'}</label>
                <input name="limit_mailrouting" id="limit_mailrouting" value="{tmpl_var name='limit_mailrouting'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailfilter">{tmpl_var name='limit_mailfilter_txt'}</label>
                <input name="limit_mailfilter" id="limit_mailfilter" value="{tmpl_var name='limit_mailfilter'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_fetchmail">{tmpl_var name='limit_fetchmail_txt'}</label>
                <input name="limit_fetchmail" id="limit_fetchmail" value="{tmpl_var name='limit_fetchmail'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailquota">{tmpl_var name='limit_mailquota_txt'}</label>
                <input name="limit_mailquota" id="limit_mailquota" value="{tmpl_var name='limit_mailquota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_wblist">{tmpl_var name='limit_spamfilter_wblist_txt'}</label>
                <input name="limit_spamfilter_wblist" id="limit_spamfilter_wblist" value="{tmpl_var name='limit_spamfilter_wblist'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_user">{tmpl_var name='limit_spamfilter_user_txt'}</label>
                <input name="limit_spamfilter_user" id="limit_spamfilter_user" value="{tmpl_var name='limit_spamfilter_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_policy">{tmpl_var name='limit_spamfilter_policy_txt'}</label>
                <input name="limit_spamfilter_policy" id="limit_spamfilter_policy" value="{tmpl_var name='limit_spamfilter_policy'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="default_webserver">{tmpl_var name='default_webserver_txt'}</label>
                <select name="default_webserver" id="default_webserver" class="selectInput">
                    {tmpl_var name='default_webserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_domain">{tmpl_var name='limit_web_domain_txt'}</label>
                <input name="limit_web_domain" id="limit_web_domain" value="{tmpl_var name='limit_web_domain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_quota">{tmpl_var name='limit_web_quota_txt'}</label>
                <input name="limit_web_quota" id="limit_web_quota" value="{tmpl_var name='limit_web_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
            <div class="ctrlHolder">
                <p class="label">{tmpl_var name='web_php_options_txt'}</p>
                <div class="multiField">
                        {tmpl_var name='web_php_options'}
                </div>
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_aliasdomain">{tmpl_var name='limit_web_aliasdomain_txt'}</label>
                <input name="limit_web_aliasdomain" id="limit_web_aliasdomain" value="{tmpl_var name='limit_web_aliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_subdomain">{tmpl_var name='limit_web_subdomain_txt'}</label>
                <input name="limit_web_subdomain" id="limit_web_subdomain" value="{tmpl_var name='limit_web_subdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_ftp_user">{tmpl_var name='limit_ftp_user_txt'}</label>
                <input name="limit_ftp_user" id="limit_ftp_user" value="{tmpl_var name='limit_ftp_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_shell_user">{tmpl_var name='limit_shell_user_txt'}</label>
                <input name="limit_shell_user" id="limit_shell_user" value="{tmpl_var name='limit_shell_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <p class="label">{tmpl_var name='ssh_chroot_txt'}</p>
                <div class="multiField">
                        {tmpl_var name='ssh_chroot'}
                </div>
            </div>
            <div class="ctrlHolder">
                <label for="limit_webdav_user">{tmpl_var name='limit_webdav_user_txt'}</label>
                <input name="limit_webdav_user" id="limit_webdav_user" value="{tmpl_var name='limit_webdav_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="default_dnsserver">{tmpl_var name='default_dnsserver_txt'}</label>
                <select name="default_dnsserver" id="default_dnsserver" class="selectInput">
                    {tmpl_var name='default_dnsserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_zone">{tmpl_var name='limit_dns_zone_txt'}</label>
                <input name="limit_dns_zone" id="limit_dns_zone" value="{tmpl_var name='limit_dns_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_slave_zone">{tmpl_var name='limit_dns_slave_zone_txt'}</label>
                <input name="limit_dns_slave_zone" id="limit_dns_slave_zone" value="{tmpl_var name='limit_dns_slave_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_record">{tmpl_var name='limit_dns_record_txt'}</label>
                <input name="limit_dns_record" id="limit_dns_record" value="{tmpl_var name='limit_dns_record'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="default_dbserver">{tmpl_var name='default_dbserver_txt'}</label>
                <select name="default_dbserver" id="default_dbserver" class="selectInput">
                    {tmpl_var name='default_dbserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_database">{tmpl_var name='limit_database_txt'}</label>
                <input name="limit_database" id="limit_database" value="{tmpl_var name='limit_database'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron">{tmpl_var name='limit_cron_txt'}</label>
                <input name="limit_cron" id="limit_cron" value="{tmpl_var name='limit_cron'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron_type">{tmpl_var name='limit_cron_type_txt'}</label>
                <select name="limit_cron_type" id="limit_cron_type" class="selectInput formLengthHalf">
                    {tmpl_var name='limit_cron_type'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron_frequency">{tmpl_var name='limit_cron_frequency_txt'}</label>
                <input name="limit_cron_frequency" id="limit_cron_frequency" value="{tmpl_var name='limit_cron_frequency'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_traffic_quota">{tmpl_var name='limit_traffic_quota_txt'}</label>
                <input name="limit_traffic_quota" id="limit_traffic_quota" value="{tmpl_var name='limit_traffic_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
        </fieldset>
        <input type="hidden" name="id" value="{tmpl_var name='id'}">
        <div class="buttonHolder buttons">
            <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','client/client_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
            <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('client/client_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
        </div>
    </div>
</div>
interface/web/client/templates/client_template_edit_limits.htm
@@ -1,132 +1,136 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_client_template">
    <div class="pnl_formsarea">
        <fieldset class="inlineLabels"><legend>Limits</legend>
            <div class="ctrlHolder">
                <label for="limit_maildomain">{tmpl_var name='limit_maildomain_txt'}</label>
                <input name="limit_maildomain" id="limit_maildomain" value="{tmpl_var name='limit_maildomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailbox">{tmpl_var name='limit_mailbox_txt'}</label>
                <input name="limit_mailbox" id="limit_mailbox" value="{tmpl_var name='limit_mailbox'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailalias">{tmpl_var name='limit_mailalias_txt'}</label>
                <input name="limit_mailalias" id="limit_mailalias" value="{tmpl_var name='limit_mailalias'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailaliasdomain">{tmpl_var name='limit_mailaliasdomain_txt'}</label>
                <input name="limit_mailaliasdomain" id="limit_mailaliasdomain" value="{tmpl_var name='limit_mailaliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailforward">{tmpl_var name='limit_mailforward_txt'}</label>
                <input name="limit_mailforward" id="limit_mailforward" value="{tmpl_var name='limit_mailforward'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailcatchall">{tmpl_var name='limit_mailcatchall_txt'}</label>
                <input name="limit_mailcatchall" id="limit_mailcatchall" value="{tmpl_var name='limit_mailcatchall'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailrouting">{tmpl_var name='limit_mailrouting_txt'}</label>
                <input name="limit_mailrouting" id="limit_mailrouting" value="{tmpl_var name='limit_mailrouting'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailfilter">{tmpl_var name='limit_mailfilter_txt'}</label>
                <input name="limit_mailfilter" id="limit_mailfilter" value="{tmpl_var name='limit_mailfilter'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_fetchmail">{tmpl_var name='limit_fetchmail_txt'}</label>
                <input name="limit_fetchmail" id="limit_fetchmail" value="{tmpl_var name='limit_fetchmail'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailquota">{tmpl_var name='limit_mailquota_txt'}</label>
                <input name="limit_mailquota" id="limit_mailquota" value="{tmpl_var name='limit_mailquota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_wblist">{tmpl_var name='limit_spamfilter_wblist_txt'}</label>
                <input name="limit_spamfilter_wblist" id="limit_spamfilter_wblist" value="{tmpl_var name='limit_spamfilter_wblist'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_user">{tmpl_var name='limit_spamfilter_user_txt'}</label>
                <input name="limit_spamfilter_user" id="limit_spamfilter_user" value="{tmpl_var name='limit_spamfilter_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_policy">{tmpl_var name='limit_spamfilter_policy_txt'}</label>
                <input name="limit_spamfilter_policy" id="limit_spamfilter_policy" value="{tmpl_var name='limit_spamfilter_policy'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_domain">{tmpl_var name='limit_web_domain_txt'}</label>
                <input name="limit_web_domain" id="limit_web_domain" value="{tmpl_var name='limit_web_domain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_quota">{tmpl_var name='limit_web_quota_txt'}</label>
                <input name="limit_web_quota" id="limit_web_quota" value="{tmpl_var name='limit_web_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_aliasdomain">{tmpl_var name='limit_web_aliasdomain_txt'}</label>
                <input name="limit_web_aliasdomain" id="limit_web_aliasdomain" value="{tmpl_var name='limit_web_aliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_subdomain">{tmpl_var name='limit_web_subdomain_txt'}</label>
                <input name="limit_web_subdomain" id="limit_web_subdomain" value="{tmpl_var name='limit_web_subdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_ftp_user">{tmpl_var name='limit_ftp_user_txt'}</label>
                <input name="limit_ftp_user" id="limit_ftp_user" value="{tmpl_var name='limit_ftp_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_shell_user">{tmpl_var name='limit_shell_user_txt'}</label>
                <input name="limit_shell_user" id="limit_shell_user" value="{tmpl_var name='limit_shell_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_webdav_user">{tmpl_var name='limit_webdav_user_txt'}</label>
                <input name="limit_webdav_user" id="limit_webdav_user" value="{tmpl_var name='limit_webdav_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_zone">{tmpl_var name='limit_dns_zone_txt'}</label>
                <input name="limit_dns_zone" id="limit_dns_zone" value="{tmpl_var name='limit_dns_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_slave_zone">{tmpl_var name='limit_dns_slave_zone_txt'}</label>
                <input name="limit_dns_slave_zone" id="limit_dns_slave_zone" value="{tmpl_var name='limit_dns_slave_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_record">{tmpl_var name='limit_dns_record_txt'}</label>
                <input name="limit_dns_record" id="limit_dns_record" value="{tmpl_var name='limit_dns_record'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_database">{tmpl_var name='limit_database_txt'}</label>
                <input name="limit_database" id="limit_database" value="{tmpl_var name='limit_database'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron">{tmpl_var name='limit_cron_txt'}</label>
                <input name="limit_cron" id="limit_cron" value="{tmpl_var name='limit_cron'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron_type">{tmpl_var name='limit_cron_type_txt'}</label>
                <select name="limit_cron_type" id="limit_cron_type" class="selectInput formLengthHalf">
                    {tmpl_var name='limit_cron_type'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron_frequency">{tmpl_var name='limit_cron_frequency_txt'}</label>
                <input name="limit_cron_frequency" id="limit_cron_frequency" value="{tmpl_var name='limit_cron_frequency'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_traffic_quota">{tmpl_var name='limit_traffic_quota_txt'}</label>
                <input name="limit_traffic_quota" id="limit_traffic_quota" value="{tmpl_var name='limit_traffic_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
        </fieldset>
        <input type="hidden" name="id" value="{tmpl_var name='id'}">
        <div class="buttonHolder buttons">
            <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','client/client_template_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
            <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('client/client_template_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
        </div>
    </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_client_template">
    <div class="pnl_formsarea">
        <fieldset class="inlineLabels"><legend>Limits</legend>
            <div class="ctrlHolder">
                <label for="limit_maildomain">{tmpl_var name='limit_maildomain_txt'}</label>
                <input name="limit_maildomain" id="limit_maildomain" value="{tmpl_var name='limit_maildomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailbox">{tmpl_var name='limit_mailbox_txt'}</label>
                <input name="limit_mailbox" id="limit_mailbox" value="{tmpl_var name='limit_mailbox'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailalias">{tmpl_var name='limit_mailalias_txt'}</label>
                <input name="limit_mailalias" id="limit_mailalias" value="{tmpl_var name='limit_mailalias'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailaliasdomain">{tmpl_var name='limit_mailaliasdomain_txt'}</label>
                <input name="limit_mailaliasdomain" id="limit_mailaliasdomain" value="{tmpl_var name='limit_mailaliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailmailinglist">{tmpl_var name='limit_mailmailinglist_txt'}</label>
                <input name="limit_mailmailinglist" id="limit_mailmailinglist" value="{tmpl_var name='limit_mailmailinglist'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailforward">{tmpl_var name='limit_mailforward_txt'}</label>
                <input name="limit_mailforward" id="limit_mailforward" value="{tmpl_var name='limit_mailforward'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailcatchall">{tmpl_var name='limit_mailcatchall_txt'}</label>
                <input name="limit_mailcatchall" id="limit_mailcatchall" value="{tmpl_var name='limit_mailcatchall'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailrouting">{tmpl_var name='limit_mailrouting_txt'}</label>
                <input name="limit_mailrouting" id="limit_mailrouting" value="{tmpl_var name='limit_mailrouting'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailfilter">{tmpl_var name='limit_mailfilter_txt'}</label>
                <input name="limit_mailfilter" id="limit_mailfilter" value="{tmpl_var name='limit_mailfilter'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_fetchmail">{tmpl_var name='limit_fetchmail_txt'}</label>
                <input name="limit_fetchmail" id="limit_fetchmail" value="{tmpl_var name='limit_fetchmail'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailquota">{tmpl_var name='limit_mailquota_txt'}</label>
                <input name="limit_mailquota" id="limit_mailquota" value="{tmpl_var name='limit_mailquota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_wblist">{tmpl_var name='limit_spamfilter_wblist_txt'}</label>
                <input name="limit_spamfilter_wblist" id="limit_spamfilter_wblist" value="{tmpl_var name='limit_spamfilter_wblist'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_user">{tmpl_var name='limit_spamfilter_user_txt'}</label>
                <input name="limit_spamfilter_user" id="limit_spamfilter_user" value="{tmpl_var name='limit_spamfilter_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_policy">{tmpl_var name='limit_spamfilter_policy_txt'}</label>
                <input name="limit_spamfilter_policy" id="limit_spamfilter_policy" value="{tmpl_var name='limit_spamfilter_policy'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_domain">{tmpl_var name='limit_web_domain_txt'}</label>
                <input name="limit_web_domain" id="limit_web_domain" value="{tmpl_var name='limit_web_domain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_quota">{tmpl_var name='limit_web_quota_txt'}</label>
                <input name="limit_web_quota" id="limit_web_quota" value="{tmpl_var name='limit_web_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_aliasdomain">{tmpl_var name='limit_web_aliasdomain_txt'}</label>
                <input name="limit_web_aliasdomain" id="limit_web_aliasdomain" value="{tmpl_var name='limit_web_aliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_subdomain">{tmpl_var name='limit_web_subdomain_txt'}</label>
                <input name="limit_web_subdomain" id="limit_web_subdomain" value="{tmpl_var name='limit_web_subdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_ftp_user">{tmpl_var name='limit_ftp_user_txt'}</label>
                <input name="limit_ftp_user" id="limit_ftp_user" value="{tmpl_var name='limit_ftp_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_shell_user">{tmpl_var name='limit_shell_user_txt'}</label>
                <input name="limit_shell_user" id="limit_shell_user" value="{tmpl_var name='limit_shell_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_webdav_user">{tmpl_var name='limit_webdav_user_txt'}</label>
                <input name="limit_webdav_user" id="limit_webdav_user" value="{tmpl_var name='limit_webdav_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_zone">{tmpl_var name='limit_dns_zone_txt'}</label>
                <input name="limit_dns_zone" id="limit_dns_zone" value="{tmpl_var name='limit_dns_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_slave_zone">{tmpl_var name='limit_dns_slave_zone_txt'}</label>
                <input name="limit_dns_slave_zone" id="limit_dns_slave_zone" value="{tmpl_var name='limit_dns_slave_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_record">{tmpl_var name='limit_dns_record_txt'}</label>
                <input name="limit_dns_record" id="limit_dns_record" value="{tmpl_var name='limit_dns_record'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_database">{tmpl_var name='limit_database_txt'}</label>
                <input name="limit_database" id="limit_database" value="{tmpl_var name='limit_database'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron">{tmpl_var name='limit_cron_txt'}</label>
                <input name="limit_cron" id="limit_cron" value="{tmpl_var name='limit_cron'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron_type">{tmpl_var name='limit_cron_type_txt'}</label>
                <select name="limit_cron_type" id="limit_cron_type" class="selectInput formLengthHalf">
                    {tmpl_var name='limit_cron_type'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron_frequency">{tmpl_var name='limit_cron_frequency_txt'}</label>
                <input name="limit_cron_frequency" id="limit_cron_frequency" value="{tmpl_var name='limit_cron_frequency'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_traffic_quota">{tmpl_var name='limit_traffic_quota_txt'}</label>
                <input name="limit_traffic_quota" id="limit_traffic_quota" value="{tmpl_var name='limit_traffic_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
        </fieldset>
        <input type="hidden" name="id" value="{tmpl_var name='id'}">
        <div class="buttonHolder buttons">
            <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','client/client_template_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
            <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('client/client_template_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
        </div>
    </div>
</div>
interface/web/client/templates/reseller_edit_limits.htm
@@ -1,183 +1,187 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_client">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels"><legend>Limits</legend>
<tmpl_if name="is_admin">
      <div class="ctrlHolder">
          <label for="template_master">{tmpl_var name='template_master_txt'}</label>
        <select name="template_master" id="template_master" class="selectInput">
                    {tmpl_var name='template_master'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="template_additional">{tmpl_var name='template_additional_txt'}</label>
        <select name="tpl_add_select" id="tpl_add_select" class="selectInput">
                    {tmpl_var name='tpl_add_select'}
                </select>
          <span id="template_additional_list">{tmpl_var name='template_additional_list'}</span>
            <input type="hidden" id="template_additional" name="template_additional" value="{tmpl_var name='template_additional'}">
      </div>
      <div class="ctrlHolder">
        &nbsp;
      </div>
</tmpl_if>
      <div class="ctrlHolder">
          <label for="default_mailserver">{tmpl_var name='default_mailserver_txt'}</label>
        <select name="default_mailserver" id="default_mailserver" class="selectInput">
                    {tmpl_var name='default_mailserver'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="limit_maildomain">{tmpl_var name='limit_maildomain_txt'}</label>
        <input name="limit_maildomain" id="limit_maildomain" value="{tmpl_var name='limit_maildomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailbox">{tmpl_var name='limit_mailbox_txt'}</label>
        <input name="limit_mailbox" id="limit_mailbox" value="{tmpl_var name='limit_mailbox'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailalias">{tmpl_var name='limit_mailalias_txt'}</label>
        <input name="limit_mailalias" id="limit_mailalias" value="{tmpl_var name='limit_mailalias'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailforward">{tmpl_var name='limit_mailforward_txt'}</label>
        <input name="limit_mailforward" id="limit_mailforward" value="{tmpl_var name='limit_mailforward'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailcatchall">{tmpl_var name='limit_mailcatchall_txt'}</label>
        <input name="limit_mailcatchall" id="limit_mailcatchall" value="{tmpl_var name='limit_mailcatchall'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailrouting">{tmpl_var name='limit_mailrouting_txt'}</label>
        <input name="limit_mailrouting" id="limit_mailrouting" value="{tmpl_var name='limit_mailrouting'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailfilter">{tmpl_var name='limit_mailfilter_txt'}</label>
        <input name="limit_mailfilter" id="limit_mailfilter" value="{tmpl_var name='limit_mailfilter'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_fetchmail">{tmpl_var name='limit_fetchmail_txt'}</label>
        <input name="limit_fetchmail" id="limit_fetchmail" value="{tmpl_var name='limit_fetchmail'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailquota">{tmpl_var name='limit_mailquota_txt'}</label>
        <input name="limit_mailquota" id="limit_mailquota" value="{tmpl_var name='limit_mailquota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
      <div class="ctrlHolder">
          <label for="limit_spamfilter_wblist">{tmpl_var name='limit_spamfilter_wblist_txt'}</label>
        <input name="limit_spamfilter_wblist" id="limit_spamfilter_wblist" value="{tmpl_var name='limit_spamfilter_wblist'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_spamfilter_user">{tmpl_var name='limit_spamfilter_user_txt'}</label>
        <input name="limit_spamfilter_user" id="limit_spamfilter_user" value="{tmpl_var name='limit_spamfilter_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_spamfilter_policy">{tmpl_var name='limit_spamfilter_policy_txt'}</label>
        <input name="limit_spamfilter_policy" id="limit_spamfilter_policy" value="{tmpl_var name='limit_spamfilter_policy'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="default_webserver">{tmpl_var name='default_webserver_txt'}</label>
        <select name="default_webserver" id="default_webserver" class="selectInput">
                    {tmpl_var name='default_webserver'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="limit_web_domain">{tmpl_var name='limit_web_domain_txt'}</label>
        <input name="limit_web_domain" id="limit_web_domain" value="{tmpl_var name='limit_web_domain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_web_quota">{tmpl_var name='limit_web_quota_txt'}</label>
        <input name="limit_web_quota" id="limit_web_quota" value="{tmpl_var name='limit_web_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
      </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='web_php_options_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='web_php_options'}
                    </div>
            </div>
      <div class="ctrlHolder">
          <label for="limit_web_aliasdomain">{tmpl_var name='limit_web_aliasdomain_txt'}</label>
        <input name="limit_web_aliasdomain" id="limit_web_aliasdomain" value="{tmpl_var name='limit_web_aliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_web_subdomain">{tmpl_var name='limit_web_subdomain_txt'}</label>
        <input name="limit_web_subdomain" id="limit_web_subdomain" value="{tmpl_var name='limit_web_subdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_ftp_user">{tmpl_var name='limit_ftp_user_txt'}</label>
        <input name="limit_ftp_user" id="limit_ftp_user" value="{tmpl_var name='limit_ftp_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_shell_user">{tmpl_var name='limit_shell_user_txt'}</label>
        <input name="limit_shell_user" id="limit_shell_user" value="{tmpl_var name='limit_shell_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='ssh_chroot_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='ssh_chroot'}
                    </div>
            </div>
      <div class="ctrlHolder">
          <label for="default_dnsserver">{tmpl_var name='default_dnsserver_txt'}</label>
        <select name="default_dnsserver" id="default_dnsserver" class="selectInput">
                    {tmpl_var name='default_dnsserver'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="limit_dns_zone">{tmpl_var name='limit_dns_zone_txt'}</label>
        <input name="limit_dns_zone" id="limit_dns_zone" value="{tmpl_var name='limit_dns_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_dns_slave_zone">{tmpl_var name='limit_dns_slave_zone_txt'}</label>
        <input name="limit_dns_slave_zone" id="limit_dns_slave_zone" value="{tmpl_var name='limit_dns_slave_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_dns_record">{tmpl_var name='limit_dns_record_txt'}</label>
        <input name="limit_dns_record" id="limit_dns_record" value="{tmpl_var name='limit_dns_record'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_client">{tmpl_var name='limit_client_txt'}</label>
        <input name="limit_client" id="limit_client" value="{tmpl_var name='limit_client'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="default_dbserver">{tmpl_var name='default_dbserver_txt'}</label>
        <select name="default_dbserver" id="default_dbserver" class="selectInput">
                    {tmpl_var name='default_dbserver'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="limit_database">{tmpl_var name='limit_database_txt'}</label>
        <input name="limit_database" id="limit_database" value="{tmpl_var name='limit_database'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
        <label for="limit_cron">{tmpl_var name='limit_cron_txt'}</label>
        <input name="limit_cron" id="limit_cron" value="{tmpl_var name='limit_cron'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
        <label for="limit_cron_type">{tmpl_var name='limit_cron_type_txt'}</label>
        <select name="limit_cron_type" id="limit_cron_type" class="selectInput formLengthHalf">
          {tmpl_var name='limit_cron_type'}
        </select>
            </div>
      <div class="ctrlHolder">
        <label for="limit_cron_frequency">{tmpl_var name='limit_cron_frequency_txt'}</label>
        <input name="limit_cron_frequency" id="limit_cron_frequency" value="{tmpl_var name='limit_cron_frequency'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_traffic_quota">{tmpl_var name='limit_traffic_quota_txt'}</label>
        <input name="limit_traffic_quota" id="limit_traffic_quota" value="{tmpl_var name='limit_traffic_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
      </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','client/reseller_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('client/reseller_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_client">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels"><legend>Limits</legend>
<tmpl_if name="is_admin">
      <div class="ctrlHolder">
          <label for="template_master">{tmpl_var name='template_master_txt'}</label>
        <select name="template_master" id="template_master" class="selectInput">
                    {tmpl_var name='template_master'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="template_additional">{tmpl_var name='template_additional_txt'}</label>
        <select name="tpl_add_select" id="tpl_add_select" class="selectInput">
                    {tmpl_var name='tpl_add_select'}
                </select>
          <span id="template_additional_list">{tmpl_var name='template_additional_list'}</span>
            <input type="hidden" id="template_additional" name="template_additional" value="{tmpl_var name='template_additional'}">
      </div>
      <div class="ctrlHolder">
        &nbsp;
      </div>
</tmpl_if>
      <div class="ctrlHolder">
          <label for="default_mailserver">{tmpl_var name='default_mailserver_txt'}</label>
        <select name="default_mailserver" id="default_mailserver" class="selectInput">
                    {tmpl_var name='default_mailserver'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="limit_maildomain">{tmpl_var name='limit_maildomain_txt'}</label>
        <input name="limit_maildomain" id="limit_maildomain" value="{tmpl_var name='limit_maildomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
                <label for="limit_mailmailinglist">{tmpl_var name='limit_mailmailinglist_txt'}</label>
                <input name="limit_mailmailinglist" id="limit_mailmailinglist" value="{tmpl_var name='limit_mailmailinglist'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailbox">{tmpl_var name='limit_mailbox_txt'}</label>
        <input name="limit_mailbox" id="limit_mailbox" value="{tmpl_var name='limit_mailbox'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailalias">{tmpl_var name='limit_mailalias_txt'}</label>
        <input name="limit_mailalias" id="limit_mailalias" value="{tmpl_var name='limit_mailalias'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailforward">{tmpl_var name='limit_mailforward_txt'}</label>
        <input name="limit_mailforward" id="limit_mailforward" value="{tmpl_var name='limit_mailforward'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailcatchall">{tmpl_var name='limit_mailcatchall_txt'}</label>
        <input name="limit_mailcatchall" id="limit_mailcatchall" value="{tmpl_var name='limit_mailcatchall'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailrouting">{tmpl_var name='limit_mailrouting_txt'}</label>
        <input name="limit_mailrouting" id="limit_mailrouting" value="{tmpl_var name='limit_mailrouting'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailfilter">{tmpl_var name='limit_mailfilter_txt'}</label>
        <input name="limit_mailfilter" id="limit_mailfilter" value="{tmpl_var name='limit_mailfilter'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_fetchmail">{tmpl_var name='limit_fetchmail_txt'}</label>
        <input name="limit_fetchmail" id="limit_fetchmail" value="{tmpl_var name='limit_fetchmail'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_mailquota">{tmpl_var name='limit_mailquota_txt'}</label>
        <input name="limit_mailquota" id="limit_mailquota" value="{tmpl_var name='limit_mailquota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
      <div class="ctrlHolder">
          <label for="limit_spamfilter_wblist">{tmpl_var name='limit_spamfilter_wblist_txt'}</label>
        <input name="limit_spamfilter_wblist" id="limit_spamfilter_wblist" value="{tmpl_var name='limit_spamfilter_wblist'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_spamfilter_user">{tmpl_var name='limit_spamfilter_user_txt'}</label>
        <input name="limit_spamfilter_user" id="limit_spamfilter_user" value="{tmpl_var name='limit_spamfilter_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_spamfilter_policy">{tmpl_var name='limit_spamfilter_policy_txt'}</label>
        <input name="limit_spamfilter_policy" id="limit_spamfilter_policy" value="{tmpl_var name='limit_spamfilter_policy'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="default_webserver">{tmpl_var name='default_webserver_txt'}</label>
        <select name="default_webserver" id="default_webserver" class="selectInput">
                    {tmpl_var name='default_webserver'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="limit_web_domain">{tmpl_var name='limit_web_domain_txt'}</label>
        <input name="limit_web_domain" id="limit_web_domain" value="{tmpl_var name='limit_web_domain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_web_quota">{tmpl_var name='limit_web_quota_txt'}</label>
        <input name="limit_web_quota" id="limit_web_quota" value="{tmpl_var name='limit_web_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
      </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='web_php_options_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='web_php_options'}
                    </div>
            </div>
      <div class="ctrlHolder">
          <label for="limit_web_aliasdomain">{tmpl_var name='limit_web_aliasdomain_txt'}</label>
        <input name="limit_web_aliasdomain" id="limit_web_aliasdomain" value="{tmpl_var name='limit_web_aliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_web_subdomain">{tmpl_var name='limit_web_subdomain_txt'}</label>
        <input name="limit_web_subdomain" id="limit_web_subdomain" value="{tmpl_var name='limit_web_subdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_ftp_user">{tmpl_var name='limit_ftp_user_txt'}</label>
        <input name="limit_ftp_user" id="limit_ftp_user" value="{tmpl_var name='limit_ftp_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_shell_user">{tmpl_var name='limit_shell_user_txt'}</label>
        <input name="limit_shell_user" id="limit_shell_user" value="{tmpl_var name='limit_shell_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='ssh_chroot_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='ssh_chroot'}
                    </div>
            </div>
      <div class="ctrlHolder">
          <label for="default_dnsserver">{tmpl_var name='default_dnsserver_txt'}</label>
        <select name="default_dnsserver" id="default_dnsserver" class="selectInput">
                    {tmpl_var name='default_dnsserver'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="limit_dns_zone">{tmpl_var name='limit_dns_zone_txt'}</label>
        <input name="limit_dns_zone" id="limit_dns_zone" value="{tmpl_var name='limit_dns_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_dns_slave_zone">{tmpl_var name='limit_dns_slave_zone_txt'}</label>
        <input name="limit_dns_slave_zone" id="limit_dns_slave_zone" value="{tmpl_var name='limit_dns_slave_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_dns_record">{tmpl_var name='limit_dns_record_txt'}</label>
        <input name="limit_dns_record" id="limit_dns_record" value="{tmpl_var name='limit_dns_record'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_client">{tmpl_var name='limit_client_txt'}</label>
        <input name="limit_client" id="limit_client" value="{tmpl_var name='limit_client'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="default_dbserver">{tmpl_var name='default_dbserver_txt'}</label>
        <select name="default_dbserver" id="default_dbserver" class="selectInput">
                    {tmpl_var name='default_dbserver'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="limit_database">{tmpl_var name='limit_database_txt'}</label>
        <input name="limit_database" id="limit_database" value="{tmpl_var name='limit_database'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
        <label for="limit_cron">{tmpl_var name='limit_cron_txt'}</label>
        <input name="limit_cron" id="limit_cron" value="{tmpl_var name='limit_cron'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
        <label for="limit_cron_type">{tmpl_var name='limit_cron_type_txt'}</label>
        <select name="limit_cron_type" id="limit_cron_type" class="selectInput formLengthHalf">
          {tmpl_var name='limit_cron_type'}
        </select>
            </div>
      <div class="ctrlHolder">
        <label for="limit_cron_frequency">{tmpl_var name='limit_cron_frequency_txt'}</label>
        <input name="limit_cron_frequency" id="limit_cron_frequency" value="{tmpl_var name='limit_cron_frequency'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="limit_traffic_quota">{tmpl_var name='limit_traffic_quota_txt'}</label>
        <input name="limit_traffic_quota" id="limit_traffic_quota" value="{tmpl_var name='limit_traffic_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
      </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','client/reseller_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('client/reseller_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/dashboard/dashlets/limits.php
@@ -12,6 +12,10 @@
        $limits[] = array('field' => 'limit_maildomain',
                          'db_table' => 'mail_domain',
                          'db_where' => '');
        $limits[] = array('field' => 'limit_mailmailinglist',
                          'db_table' => 'mail_mailinglist',
                          'db_where' => '');
        
        $limits[] = array('field' => 'limit_mailbox',
                          'db_table' => 'mail_user',
interface/web/dashboard/lib/lang/en_dashlet_limits.lng
@@ -3,6 +3,7 @@
$wb['of_txt'] = "of";
$wb['unlimited_txt'] = "Unlimited";
$wb['limit_maildomain_txt'] = "Number of email domains";
$wb['limit_mailmailinglist_txt'] = "Number of mailing lists";
$wb['limit_mailbox_txt'] = "Number of mailboxes";
$wb["limit_mailalias_txt"] = 'Number of email aliases';
$wb["limit_mailaliasdomain_txt"] = 'Number of domain aliases';
interface/web/mail/form/mail_mailinglist.tform.php
New file
@@ -0,0 +1,122 @@
<?php
/*
    Form Definition
    Tabledefinition
    Datatypes:
    - INTEGER (Forces the input to Int)
    - DOUBLE
    - CURRENCY (Formats the values to currency notation)
    - VARCHAR (no format check, maxlength: 255)
    - TEXT (no format check)
    - DATE (Dateformat, automatic conversion to timestamps)
    Formtype:
    - TEXT (Textfield)
    - TEXTAREA (Textarea)
    - PASSWORD (Password textfield, input is not shown when edited)
    - SELECT (Select option field)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hint:
    The ID field of the database table is not part of the datafield definition.
    The ID field must be always auto incement (int or bigint).
*/
$form["title"]             = "Mailing List";
$form["description"]     = "";
$form["name"]             = "mail_mailinglist";
$form["action"]            = "mail_mailinglist_edit.php";
$form["db_table"]        = "mail_mailinglist";
$form["db_table_idx"]    = "mailinglist_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "mailinglist";
$form["list_default"]    = "mail_mailinglist_list.php";
$form["auth"]            = 'yes'; // yes / no
$form["auth_preset"]["userid"]  = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
$form["tabs"]['mailinglist'] = array (
    'title'     => "Mailing List",
    'width'     => 100,
    'template'     => "templates/mail_mailinglist_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'server_id' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'    => ''
        ),
        'domain' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'domain_error_empty'),
                                        1 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z\-]{2,10}$/',
                                                        'errmsg'=> 'domain_error_regex'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'listname' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'listname_error_empty'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'email' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISEMAIL',
                                                        'errmsg'=> 'email_error_isemail'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption'=> 'CLEARTEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
?>
interface/web/mail/lib/lang/en_mail_mailinglist.lng
New file
@@ -0,0 +1,15 @@
<?php
$wb["limit_mailmailinglist_txt"] = 'Limit reached';
$wb["domain_error_empty"] = 'Domain is empty.';
$wb["listname_error_empty"] = 'Listname is empty.';
$wb["domain_error_regex"] = 'Invalid domain name.';
$wb["email_in_use_txt"] = 'Email is in use';
$wb["no_domain_perm"] = 'You have no permission for this domain.';
$wb["password_strength_txt"] = 'Password strength';
$wb["server_id_txt"] = 'Server';
$wb["domain_txt"] = 'Domain';
$wb["listname_txt"] = 'Listname';
$wb["client_txt"] = 'Client';
$wb["email_txt"] = 'Email';
$wb["password_txt"] = 'Password';
?>
interface/web/mail/lib/lang/en_mail_mailinglist_list.lng
New file
@@ -0,0 +1,5 @@
<?php
$wb["list_head_txt"] = 'Mailing List';
$wb["domain_txt"] = 'Domain';
$wb["listname_txt"] = 'Listname';
?>
interface/web/mail/lib/module.conf.php
@@ -1,183 +1,201 @@
<?php
$userid=$app->auth->get_user_id();
$module['name']         = 'mail';
$module['title']         = 'top_menu_email';
$module['template']     = 'module.tpl.htm';
$module['startpage']     = 'mail/mail_domain_list.php';
$module['tab_width']    = '';
//**** Email accounts menu
$items = array();
if($app->auth->get_client_limit($userid,'maildomain') != 0)
{
    $items[] = array( 'title'     => 'Domain',
                      'target'     => 'content',
                      'link'    => 'mail/mail_domain_list.php',
                      'html_id' => 'mail_domain_list');
}
if($app->auth->get_client_limit($userid,'mailaliasdomain') != 0)
{
    $items[] = array( 'title'     => 'Domain Alias',
                      'target'     => 'content',
                      'link'    => 'mail/mail_aliasdomain_list.php',
                      'html_id' => 'mail_aliasdomain_list');
}
if($app->auth->get_client_limit($userid,'mailbox') != 0)
{
    $items[] = array( 'title'     => 'Email Mailbox',
                      'target'     => 'content',
                      'link'    => 'mail/mail_user_list.php',
                      'html_id' => 'mail_user_list');
}
if($app->auth->get_client_limit($userid,'mailalias') != 0)
{
    $items[] = array( 'title'     => 'Email Alias',
                      'target'     => 'content',
                      'link'    => 'mail/mail_alias_list.php',
                      'html_id' => 'mail_alias_list');
}
if($app->auth->get_client_limit($userid,'mailforward') != 0)
{
    $items[] = array( 'title'     => 'Email Forward',
                      'target'     => 'content',
                      'link'    => 'mail/mail_forward_list.php',
                      'html_id' => 'mail_forward_list');
}
if($app->auth->get_client_limit($userid,'mailcatchall') != 0)
{
    $items[] = array( 'title'     => 'Email Catchall',
                      'target'     => 'content',
                      'link'    => 'mail/mail_domain_catchall_list.php',
                      'html_id' => 'mail_domain_catchall_list');
}
if($app->auth->get_client_limit($userid,'mailrouting') != 0)
{
    $items[] = array( 'title'     => 'Email Routing',
                      'target'     => 'content',
                      'link'    => 'mail/mail_transport_list.php',
                      'html_id' => 'mail_transport_list');
}
if(count($items))
{
    $module['nav'][] = array(    'title'    => 'Email Accounts',
                                'open'     => 1,
                                'items'    => $items);
}
//**** Spamfilter menu
$items = array();
if($app->auth->get_client_limit($userid,'spamfilter_wblist') != 0)
{
    $items[] = array( 'title'     => 'Whitelist',
                      'target'     => 'content',
                      'link'    => 'mail/spamfilter_whitelist_list.php',
                      'html_id' => 'spamfilter_whitelist_list');
    $items[] = array( 'title'     => 'Blacklist',
                      'target'     => 'content',
                      'link'    => 'mail/spamfilter_blacklist_list.php',
                      'html_id' => 'spamfilter_blacklist_list');
}
if($app->auth->is_admin()) {
    $items[] = array(     'title'     => 'User / Domain',
                          'target'     => 'content',
                          'link'        => 'mail/spamfilter_users_list.php',
                          'html_id' => 'spamfilter_users_list');
    $items[] = array(     'title'     => 'Policy',
                          'target'     => 'content',
                          'link'        => 'mail/spamfilter_policy_list.php',
                          'html_id' => 'spamfilter_policy_list');
//    $items[] = array(     'title'     => 'Server Settings',
//                          'target'     => 'content',
//                          'link'        => 'mail/spamfilter_config_list.php');
}
if(count($items))
{
    $module['nav'][] = array(    'title'    => 'Spamfilter',
                                'open'     => 1,
                                'items'    => $items);
}
//**** Fetchmail menu
$items = array();
if($app->auth->get_client_limit($userid,'fetchmail') != 0)
{
    $items[] = array( 'title'     => 'Fetchmail',
                      'target'     => 'content',
                      'link'    => 'mail/mail_get_list.php',
                      'html_id' => 'mail_get_list');
    $module['nav'][] = array(    'title'    => 'Fetchmail',
                                'open'     => 1,
                                'items'    => $items);
}
//**** Statistics menu
$items = array();
$items[] = array( 'title'     => 'Mailbox traffic',
                  'target'     => 'content',
                  'link'    => 'mail/mail_user_stats.php',
                  'html_id' => 'mail_user_stats');
$module['nav'][] = array(    'title'    => 'Statistics',
                            'open'     => 1,
                            'items'    => $items);
//**** Global filters menu
$items = array();
if($_SESSION['s']['user']['typ'] == 'admin') {
    $items[] = array(   'title'     => 'Postfix Whitelist',
                            'target'     => 'content',
                          'link'        => 'mail/mail_whitelist_list.php',
                          'html_id' => 'mail_whitelist_list');
    $items[] = array(   'title'     => 'Postfix Blacklist',
                         'target'     => 'content',
                          'link'        => 'mail/mail_blacklist_list.php',
                          'html_id' => 'mail_blacklist_list');
    $items[] = array(   'title'     => 'Content Filter',
                         'target'     => 'content',
                          'link'        => 'mail/mail_content_filter_list.php',
                          'html_id' => 'mail_content_filter_list');
    $items[] = array(   'title'     => 'Relay Recipients',
                         'target'     => 'content',
                          'link'        => 'mail/mail_relay_recipient_list.php',
                          'html_id' => 'mail_relay_recipient_list');
    $module['nav'][] = array(    'title'    => 'Global Filters',
                                'open'     => 1,
                                'items'    => $items);
}
<?php
$userid=$app->auth->get_user_id();
$module['name']         = 'mail';
$module['title']         = 'top_menu_email';
$module['template']     = 'module.tpl.htm';
$module['startpage']     = 'mail/mail_domain_list.php';
$module['tab_width']    = '';
//**** Email accounts menu
$items = array();
if($app->auth->get_client_limit($userid,'maildomain') != 0)
{
    $items[] = array( 'title'     => 'Domain',
                      'target'     => 'content',
                      'link'    => 'mail/mail_domain_list.php',
                      'html_id' => 'mail_domain_list');
}
if($app->auth->get_client_limit($userid,'mailaliasdomain') != 0)
{
    $items[] = array( 'title'     => 'Domain Alias',
                      'target'     => 'content',
                      'link'    => 'mail/mail_aliasdomain_list.php',
                      'html_id' => 'mail_aliasdomain_list');
}
if($app->auth->get_client_limit($userid,'mailbox') != 0)
{
    $items[] = array( 'title'     => 'Email Mailbox',
                      'target'     => 'content',
                      'link'    => 'mail/mail_user_list.php',
                      'html_id' => 'mail_user_list');
}
if($app->auth->get_client_limit($userid,'mailalias') != 0)
{
    $items[] = array( 'title'     => 'Email Alias',
                      'target'     => 'content',
                      'link'    => 'mail/mail_alias_list.php',
                      'html_id' => 'mail_alias_list');
}
if($app->auth->get_client_limit($userid,'mailforward') != 0)
{
    $items[] = array( 'title'     => 'Email Forward',
                      'target'     => 'content',
                      'link'    => 'mail/mail_forward_list.php',
                      'html_id' => 'mail_forward_list');
}
if($app->auth->get_client_limit($userid,'mailcatchall') != 0)
{
    $items[] = array( 'title'     => 'Email Catchall',
                      'target'     => 'content',
                      'link'    => 'mail/mail_domain_catchall_list.php',
                      'html_id' => 'mail_domain_catchall_list');
}
if($app->auth->get_client_limit($userid,'mailrouting') != 0)
{
    $items[] = array( 'title'     => 'Email Routing',
                      'target'     => 'content',
                      'link'    => 'mail/mail_transport_list.php',
                      'html_id' => 'mail_transport_list');
}
if(count($items))
{
    $module['nav'][] = array(    'title'    => 'Email Accounts',
                                'open'     => 1,
                                'items'    => $items);
}
//**** Mailinglist menu
$items = array();
if($app->auth->get_client_limit($userid,'mailmailinglist') != 0)
{
    $items[] = array( 'title'     => 'Mailing List',
                      'target'     => 'content',
                      'link'    => 'mail/mail_mailinglist_list.php',
                      'html_id' => 'mail_mailinglist_list');
}
if(count($items))
{
    $module['nav'][] = array(    'title'    => 'Mailing List',
                                'open'     => 1,
                                'items'    => $items);
}
//**** Spamfilter menu
$items = array();
if($app->auth->get_client_limit($userid,'spamfilter_wblist') != 0)
{
    $items[] = array( 'title'     => 'Whitelist',
                      'target'     => 'content',
                      'link'    => 'mail/spamfilter_whitelist_list.php',
                      'html_id' => 'spamfilter_whitelist_list');
    $items[] = array( 'title'     => 'Blacklist',
                      'target'     => 'content',
                      'link'    => 'mail/spamfilter_blacklist_list.php',
                      'html_id' => 'spamfilter_blacklist_list');
}
if($app->auth->is_admin()) {
    $items[] = array(     'title'     => 'User / Domain',
                          'target'     => 'content',
                          'link'        => 'mail/spamfilter_users_list.php',
                          'html_id' => 'spamfilter_users_list');
    $items[] = array(     'title'     => 'Policy',
                          'target'     => 'content',
                          'link'        => 'mail/spamfilter_policy_list.php',
                          'html_id' => 'spamfilter_policy_list');
//    $items[] = array(     'title'     => 'Server Settings',
//                          'target'     => 'content',
//                          'link'        => 'mail/spamfilter_config_list.php');
}
if(count($items))
{
    $module['nav'][] = array(    'title'    => 'Spamfilter',
                                'open'     => 1,
                                'items'    => $items);
}
//**** Fetchmail menu
$items = array();
if($app->auth->get_client_limit($userid,'fetchmail') != 0)
{
    $items[] = array( 'title'     => 'Fetchmail',
                      'target'     => 'content',
                      'link'    => 'mail/mail_get_list.php',
                      'html_id' => 'mail_get_list');
    $module['nav'][] = array(    'title'    => 'Fetchmail',
                                'open'     => 1,
                                'items'    => $items);
}
//**** Statistics menu
$items = array();
$items[] = array( 'title'     => 'Mailbox traffic',
                  'target'     => 'content',
                  'link'    => 'mail/mail_user_stats.php',
                  'html_id' => 'mail_user_stats');
$module['nav'][] = array(    'title'    => 'Statistics',
                            'open'     => 1,
                            'items'    => $items);
//**** Global filters menu
$items = array();
if($_SESSION['s']['user']['typ'] == 'admin') {
    $items[] = array(   'title'     => 'Postfix Whitelist',
                            'target'     => 'content',
                          'link'        => 'mail/mail_whitelist_list.php',
                          'html_id' => 'mail_whitelist_list');
    $items[] = array(   'title'     => 'Postfix Blacklist',
                         'target'     => 'content',
                          'link'        => 'mail/mail_blacklist_list.php',
                          'html_id' => 'mail_blacklist_list');
    $items[] = array(   'title'     => 'Content Filter',
                         'target'     => 'content',
                          'link'        => 'mail/mail_content_filter_list.php',
                          'html_id' => 'mail_content_filter_list');
    $items[] = array(   'title'     => 'Relay Recipients',
                         'target'     => 'content',
                          'link'        => 'mail/mail_relay_recipient_list.php',
                          'html_id' => 'mail_relay_recipient_list');
    $module['nav'][] = array(    'title'    => 'Global Filters',
                                'open'     => 1,
                                'items'    => $items);
}
?>
interface/web/mail/list/mail_mailinglist.list.php
New file
@@ -0,0 +1,67 @@
<?php
/*
    Datatypes:
    - INTEGER
    - DOUBLE
    - CURRENCY
    - VARCHAR
    - TEXT
    - DATE
*/
// Name of the list
$liste["name"]                 = "mail_mailinglist";
// Database table
$liste["table"]             = "mail_mailinglist";
// Index index field of the database table
$liste["table_idx"]            = "mailinglist_id";
// Search Field Prefix
$liste["search_prefix"]     = "search_";
// Records per page
$liste["records_per_page"]     = 15;
// Script File of the list
$liste["file"]                = "mail_mailinglist_list.php";
// Script file of the edit form
$liste["edit_file"]            = "mail_mailinglist_edit.php";
// Script File of the delete script
$liste["delete_file"]        = "mail_mailinglist_del.php";
// Paging Template
$liste["paging_tpl"]        = "templates/paging.tpl.htm";
// Enable auth
$liste["auth"]                = "yes";
/*****************************************************
* Suchfelder
*****************************************************/
$liste["item"][] = array(    'field'        => "listname",
                            'datatype'    => "VARCHAR",
                            'formtype'    => "TEXT",
                            'op'        => "like",
                            'prefix'    => "%",
                            'suffix'    => "%",
                            'width'        => "",
                            'value'        => "");
$liste["item"][] = array(    'field'        => "domain",
                            'datatype'    => "VARCHAR",
                            'formtype'    => "TEXT",
                            'op'        => "like",
                            'prefix'    => "%",
                            'suffix'    => "%",
                            'width'        => "",
                            'value'        => "");
?>
interface/web/mail/mail_domain_del.php
@@ -1,92 +1,98 @@
<?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.
*/
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/mail_domain.list.php";
$tform_def_file = "form/mail_domain.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('mail');
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
class page_action extends tform_actions {
    function onBeforeDelete() {
        global $app; $conf;
        $domain = $this->dataRecord['domain'];
        // Before we delete the email domain,
        // we will delete all depending records.
        // Delete all forwardings where the osurce or destination belongs to this domain
        $records = $app->db->queryAllRecords("SELECT forwarding_id as id FROM mail_forwarding WHERE source like '%@".$app->db->quote($domain)."' OR destination like '%@".$app->db->quote($domain)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('mail_forwarding','forwarding_id',$rec['id']);
        }
        // Delete all fetchmail accounts where destination belongs to this domain
        $records = $app->db->queryAllRecords("SELECT mailget_id as id FROM mail_get WHERE destination like '%@".$app->db->quote($domain)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('mail_get','mailget_id',$rec['id']);
        }
        // Delete all mailboxes where destination belongs to this domain
        $records = $app->db->queryAllRecords("SELECT mailuser_id as id FROM mail_user WHERE email like '%@".$app->db->quote($domain)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('mail_user','mailuser_id',$rec['id']);
        }
        // Delete all spamfilters that belong to this domain
        $records = $app->db->queryAllRecords("SELECT id FROM spamfilter_users WHERE email = '@".$app->db->quote($domain)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('spamfilter_users','id',$rec['id']);
        }
    }
}
$page = new page_action;
$page->onDelete();
<?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.
*/
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/mail_domain.list.php";
$tform_def_file = "form/mail_domain.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('mail');
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
class page_action extends tform_actions {
    function onBeforeDelete() {
        global $app; $conf;
        $domain = $this->dataRecord['domain'];
        // Before we delete the email domain,
        // we will delete all depending records.
        // Delete all forwardings where the osurce or destination belongs to this domain
        $records = $app->db->queryAllRecords("SELECT forwarding_id as id FROM mail_forwarding WHERE source like '%@".$app->db->quote($domain)."' OR destination like '%@".$app->db->quote($domain)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('mail_forwarding','forwarding_id',$rec['id']);
        }
        // Delete all fetchmail accounts where destination belongs to this domain
        $records = $app->db->queryAllRecords("SELECT mailget_id as id FROM mail_get WHERE destination like '%@".$app->db->quote($domain)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('mail_get','mailget_id',$rec['id']);
        }
        // Delete all mailboxes where destination belongs to this domain
        $records = $app->db->queryAllRecords("SELECT mailuser_id as id FROM mail_user WHERE email like '%@".$app->db->quote($domain)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('mail_user','mailuser_id',$rec['id']);
        }
        // Delete all spamfilters that belong to this domain
        $records = $app->db->queryAllRecords("SELECT id FROM spamfilter_users WHERE email = '@".$app->db->quote($domain)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('spamfilter_users','id',$rec['id']);
        }
        // Delete all mailinglists that belong to this domain
        $records = $app->db->queryAllRecords("SELECT mailinglist_id FROM mail_mailinglist WHERE domain = '".$app->db->quote($domain)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('mail_mailinglist','mailinglist_id',$rec['id']);
        }
    }
}
$page = new page_action;
$page->onDelete();
?>
interface/web/mail/mail_domain_edit.php
@@ -1,367 +1,370 @@
<?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.
*/
/******************************************
* Begin Form configuration
******************************************/
$tform_def_file = "form/mail_domain.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('mail');
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
class page_action extends tform_actions {
    function onShowNew() {
        global $app, $conf;
        // we will check only users, not admins
        if($_SESSION["s"]["user"]["typ"] == 'user') {
            if(!$app->tform->checkClientLimit('limit_maildomain')) {
                $app->error($app->tform->wordbook["limit_maildomain_txt"]);
            }
            if(!$app->tform->checkResellerLimit('limit_maildomain')) {
                $app->error('Reseller: '.$app->tform->wordbook["limit_maildomain_txt"]);
            }
        }
        parent::onShowNew();
    }
    function onShowEnd() {
        global $app, $conf;
        if($_SESSION["s"]["user"]["typ"] == 'admin') {
            // Getting Clients of the user
            if($_SESSION["s"]["user"]["typ"] == 'admin') {
                $sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0 ORDER BY name";
            } else {
                $client_group_id = $_SESSION["s"]["user"]["default_group"];
                $sql = "SELECT client.client_id, limit_web_domain, default_mailserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id";
            }
            $clients = $app->db->queryAllRecords($sql);
            $client_select = '';
            if($_SESSION["s"]["user"]["typ"] == 'admin') $client_select .= "<option value='0'></option>";
            $tmp_data_record = $app->tform->getDataRecord($this->id);
            if(is_array($clients)) {
                foreach( $clients as $client) {
                    $selected = ($client["groupid"] == $tmp_data_record["sys_groupid"])?'SELECTED':'';
                    $client_select .= "<option value='$client[groupid]' $selected>$client[name]</option>\r\n";
                }
            }
            $app->tpl->setVar("client_group_id",$client_select);
        } elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
            // Get the limits of the client
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT client.client_id, contact_name, default_mailserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id order by contact_name");
            // Set the mailserver to the default server of the client
            $tmp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = $client[default_mailserver]");
            $app->tpl->setVar("server_id","<option value='$client[default_mailserver]'>$tmp[server_name]</option>");
            unset($tmp);
            // Fill the client select field
            $sql = "SELECT groupid, name FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id'];
            $clients = $app->db->queryAllRecords($sql);
            $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$client['client_id']);
            $client_select = '<option value="'.$tmp['groupid'].'">'.$client['contact_name'].'</option>';
            $tmp_data_record = $app->tform->getDataRecord($this->id);
            if(is_array($clients)) {
                foreach( $clients as $client) {
                    $selected = @($client["groupid"] == $tmp_data_record["sys_groupid"])?'SELECTED':'';
                    $client_select .= "<option value='$client[groupid]' $selected>$client[name]</option>\r\n";
                }
            }
            $app->tpl->setVar("client_group_id",$client_select);
        }
        /*
         * Now we have to check, if we should use the domain-module to select the domain
         * or not
         */
        $app->uses('ini_parser,getconf');
        $settings = $app->getconf->get_global_config('domains');
        if ($settings['use_domain_module'] == 'y') {
            /*
             * The domain-module is in use.
            */
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            /*
             * The admin can select ALL domains, the user only the domains assigned to him
             */
            $sql = "SELECT domain FROM domain ";
            if ($_SESSION["s"]["user"]["typ"] != 'admin') {
                $sql .= "WHERE sys_groupid =" . $client_group_id;
            }
            $sql .= " ORDER BY domain";
            $domains = $app->db->queryAllRecords($sql);
            $domain_select = '';
            if(is_array($domains) && sizeof($domains) > 0) {
                /* We have domains in the list, so create the drop-down-list */
                foreach( $domains as $domain) {
                    $domain_select .= "<option value=" . $domain['domain'] ;
                    if ($domain['domain'] == $this->dataRecord["domain"]) {
                        $domain_select .= " selected";
                    }
                    $domain_select .= ">" . $domain['domain'] . "</option>\r\n";
                }
            }
            else {
                /*
                 * We have no domains in the domain-list. This means, we can not add ANY new domain.
                 * To avoid, that the variable "domain_option" is empty and so the user can
                 * free enter a domain, we have to create a empty option!
                */
                $domain_select .= "<option value=''></option>\r\n";
            }
            $app->tpl->setVar("domain_option",$domain_select);
        }
        // Get the spamfilter policys for the user
        $tmp_user = $app->db->queryOneRecord("SELECT policy_id FROM spamfilter_users WHERE email = '@".$this->dataRecord["domain"]."'");
        $sql = "SELECT id, policy_name FROM spamfilter_policy WHERE ".$app->tform->getAuthSQL('r');
        $policys = $app->db->queryAllRecords($sql);
        $policy_select = "<option value='0'>".$app->tform->wordbook["no_policy"]."</option>";
        if(is_array($policys)) {
            foreach( $policys as $p) {
                $selected = ($p["id"] == $tmp_user["policy_id"])?'SELECTED':'';
                $policy_select .= "<option value='$p[id]' $selected>$p[policy_name]</option>\r\n";
            }
        }
        $app->tpl->setVar("policy",$policy_select);
        unset($policys);
        unset($policy_select);
        unset($tmp_user);
        if($this->id > 0) {
            //* we are editing a existing record
            $app->tpl->setVar("edit_disabled", 1);
            $app->tpl->setVar("server_id_value", $this->dataRecord["server_id"]);
        } else {
            $app->tpl->setVar("edit_disabled", 0);
        }
        parent::onShowEnd();
    }
    function onSubmit() {
        global $app, $conf;
        if($_SESSION["s"]["user"]["typ"] != 'admin') {
            // Get the limits of the client
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT limit_maildomain, default_mailserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
            // When the record is updated
            if($this->id > 0) {
                // restore the server ID if the user is not admin and record is edited
                $tmp = $app->db->queryOneRecord("SELECT server_id FROM mail_domain WHERE domain_id = ".intval($this->id));
                $this->dataRecord["server_id"] = $tmp["server_id"];
                unset($tmp);
                // When the record is inserted
            } else {
                // set the server ID to the default mailserver of the client
                $this->dataRecord["server_id"] = $client["default_mailserver"];
                // Check if the user may add another mail_domain
                if($client["limit_maildomain"] >= 0) {
                    $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM mail_domain WHERE sys_groupid = $client_group_id");
                    if($tmp["number"] >= $client["limit_maildomain"]) {
                        $app->error($app->tform->wordbook["limit_maildomain_txt"]);
                    }
                }
            }
            // Clients may not set the client_group_id, so we unset them if user is not a admin
            if(!$app->auth->has_clients($_SESSION['s']['user']['userid'])) unset($this->dataRecord["client_group_id"]);
        }
        //* make sure that the email domain is lowercase
        if(isset($this->dataRecord["domain"])) $this->dataRecord["domain"] = strtolower($this->dataRecord["domain"]);
        parent::onSubmit();
    }
    function onAfterInsert() {
        global $app, $conf;
        // make sure that the record belongs to the client group and not the admin group when a dmin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE domain_id = ".$this->id);
        }
        // Spamfilter policy
        $policy_id = intval($this->dataRecord["policy"]);
        if($policy_id > 0) {
            $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".mysql_real_escape_string($this->dataRecord["domain"])."'");
            if($tmp_user["id"] > 0) {
                // There is already a record that we will update
                $app->db->datalogUpdate('spamfilter_users', "policy_id = $ploicy_id", 'id', $tmp_user["id"]);
            } else {
                $tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$this->id);
                // We create a new record
                $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`)
                        VALUES (".$_SESSION["s"]["user"]["userid"].", ".$tmp_domain["sys_groupid"].", 'riud', 'riud', '', ".$this->dataRecord["server_id"].", 5, ".$policy_id.", '@".mysql_real_escape_string($this->dataRecord["domain"])."', '@".mysql_real_escape_string($this->dataRecord["domain"])."', 'Y')";
                $app->db->datalogInsert('spamfilter_users', $insert_data, 'id');
                unset($tmp_domain);
            }
        }  // endif spamfilter policy
    }
    function onBeforeUpdate() {
        global $app, $conf;
        //* Check if the server has been changed
        // We do this only for the admin or reseller users, as normal clients can not change the server ID anyway
        if($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
            $rec = $app->db->queryOneRecord("SELECT server_id, domain from mail_domain WHERE domain_id = ".$this->id);
            if($rec['server_id'] != $this->dataRecord["server_id"]) {
                //* Add a error message and switch back to old server
                $app->tform->errorMessage .= $app->lng('The Server can not be changed.');
                $this->dataRecord["server_id"] = $rec['server_id'];
            }
            unset($rec);
            //* If the user is neither admin nor reseller
        } else {
            //* We do not allow users to change a domain which has been created by the admin
            $rec = $app->db->queryOneRecord("SELECT domain from mail_domain WHERE domain_id = ".$this->id);
            if($rec['domain'] != $this->dataRecord["domain"] && $app->tform->checkPerm($this->id,'u')) {
                //* Add a error message and switch back to old server
                $app->tform->errorMessage .= $app->lng('The Domain can not be changed. Please ask your Administrator if you want to change the domain name.');
                $this->dataRecord["domain"] = $rec['domain'];
            }
            unset($rec);
        }
    }
    function onAfterUpdate() {
        global $app, $conf;
        // make sure that the record belongs to the clinet group and not the admin group when admin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE domain_id = ".$this->id);
        }
        // Spamfilter policy
        $policy_id = intval($this->dataRecord["policy"]);
        $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".mysql_real_escape_string($this->dataRecord["domain"])."'");
        if($policy_id > 0) {
            if($tmp_user["id"] > 0) {
                // There is already a record that we will update
                $app->db->datalogUpdate('spamfilter_users', "policy_id = $policy_id", 'id', $tmp_user["id"]);
            } else {
                $tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$this->id);
                // We create a new record
                $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`)
                        VALUES (".$_SESSION["s"]["user"]["userid"].", ".$tmp_domain["sys_groupid"].", 'riud', 'riud', '', ".$this->dataRecord["server_id"].", 5, ".$policy_id.", '@".mysql_real_escape_string($this->dataRecord["domain"])."', '@".mysql_real_escape_string($this->dataRecord["domain"])."', 'Y')";
                $app->db->datalogInsert('spamfilter_users', $insert_data, 'id');
                unset($tmp_domain);
            }
        } else {
            if($tmp_user["id"] > 0) {
                // There is already a record but the user shall have no policy, so we delete it
                $app->db->datalogDelete('spamfilter_users', 'id', $tmp_user["id"]);
            }
        } // endif spamfilter policy
        //** If the domain name or owner has been changed, change the domain and owner in all mailbox records
        if($this->oldDataRecord['domain'] != $this->dataRecord['domain'] || (isset($this->dataRecord['client_group_id']) && $this->oldDataRecord['sys_groupid'] != $this->dataRecord['client_group_id'])) {
            $app->uses('getconf');
            $mail_config = $app->getconf->get_server_config($this->dataRecord["server_id"],'mail');
            //* Update the mailboxes
            $mailusers = $app->db->queryAllRecords("SELECT * FROM mail_user WHERE email like '%@".mysql_real_escape_string($this->oldDataRecord['domain'])."'");
            $sys_groupid = (isset($this->dataRecord['client_group_id']))?$this->dataRecord['client_group_id']:$this->oldDataRecord['sys_groupid'];
            if(is_array($mailusers)) {
                foreach($mailusers as $rec) {
                    // setting Maildir, Homedir, UID and GID
                    $mail_parts = explode("@",$rec['email']);
                    $maildir = str_replace("[domain]",$this->dataRecord['domain'],$mail_config["maildir_path"]);
                    $maildir = str_replace("[localpart]",$mail_parts[0],$maildir);
                    $maildir = mysql_real_escape_string($maildir);
                    $email = mysql_real_escape_string($mail_parts[0].'@'.$this->dataRecord['domain']);
                    $app->db->datalogUpdate('mail_user', "maildir = '$maildir', email = '$email', sys_groupid = '$sys_groupid'", 'mailuser_id', $rec['mailuser_id']);
                }
            }
            //* Update the aliases
            $forwardings = $app->db->queryAllRecords("SELECT * FROM mail_forwarding WHERE source like '%@".mysql_real_escape_string($this->oldDataRecord['domain'])."' OR destination like '%@".mysql_real_escape_string($this->oldDataRecord['domain'])."'");
            if(is_array($forwardings)) {
                foreach($forwardings as $rec) {
                    $destination = mysql_real_escape_string(str_replace($this->oldDataRecord['domain'],$this->dataRecord['domain'],$rec['destination']));
                    $source = mysql_real_escape_string(str_replace($this->oldDataRecord['domain'],$this->dataRecord['domain'],$rec['source']));
                    $app->db->datalogUpdate('mail_forwarding', "source = '$source', destination = '$destination', sys_groupid = '$sys_groupid'", 'forwarding_id', $rec['forwarding_id']);
                }
            }
            //* Delete the old spamfilter record
            $tmp = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".mysql_real_escape_string($this->oldDataRecord["domain"])."'");
            $app->db->datalogDelete('spamfilter_users', 'id', $tmp["id"]);
            unset($tmp);
        } // end if domain name changed
    }
}
$page = new page_action;
$page->onLoad();
<?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.
*/
/******************************************
* Begin Form configuration
******************************************/
$tform_def_file = "form/mail_domain.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('mail');
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
class page_action extends tform_actions {
    function onShowNew() {
        global $app, $conf;
        // we will check only users, not admins
        if($_SESSION["s"]["user"]["typ"] == 'user') {
            if(!$app->tform->checkClientLimit('limit_maildomain')) {
                $app->error($app->tform->wordbook["limit_maildomain_txt"]);
            }
            if(!$app->tform->checkResellerLimit('limit_maildomain')) {
                $app->error('Reseller: '.$app->tform->wordbook["limit_maildomain_txt"]);
            }
        }
        parent::onShowNew();
    }
    function onShowEnd() {
        global $app, $conf;
        if($_SESSION["s"]["user"]["typ"] == 'admin') {
            // Getting Clients of the user
            if($_SESSION["s"]["user"]["typ"] == 'admin') {
                $sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0 ORDER BY name";
            } else {
                $client_group_id = $_SESSION["s"]["user"]["default_group"];
                $sql = "SELECT client.client_id, limit_web_domain, default_mailserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id";
            }
            $clients = $app->db->queryAllRecords($sql);
            $client_select = '';
            if($_SESSION["s"]["user"]["typ"] == 'admin') $client_select .= "<option value='0'></option>";
            $tmp_data_record = $app->tform->getDataRecord($this->id);
            if(is_array($clients)) {
                foreach( $clients as $client) {
                    $selected = ($client["groupid"] == $tmp_data_record["sys_groupid"])?'SELECTED':'';
                    $client_select .= "<option value='$client[groupid]' $selected>$client[name]</option>\r\n";
                }
            }
            $app->tpl->setVar("client_group_id",$client_select);
        } elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
            // Get the limits of the client
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT client.client_id, contact_name, default_mailserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id order by contact_name");
            // Set the mailserver to the default server of the client
            $tmp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = $client[default_mailserver]");
            $app->tpl->setVar("server_id","<option value='$client[default_mailserver]'>$tmp[server_name]</option>");
            unset($tmp);
            // Fill the client select field
            $sql = "SELECT groupid, name FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id'];
            $clients = $app->db->queryAllRecords($sql);
            $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$client['client_id']);
            $client_select = '<option value="'.$tmp['groupid'].'">'.$client['contact_name'].'</option>';
            $tmp_data_record = $app->tform->getDataRecord($this->id);
            if(is_array($clients)) {
                foreach( $clients as $client) {
                    $selected = @($client["groupid"] == $tmp_data_record["sys_groupid"])?'SELECTED':'';
                    $client_select .= "<option value='$client[groupid]' $selected>$client[name]</option>\r\n";
                }
            }
            $app->tpl->setVar("client_group_id",$client_select);
        }
        /*
         * Now we have to check, if we should use the domain-module to select the domain
         * or not
         */
        $app->uses('ini_parser,getconf');
        $settings = $app->getconf->get_global_config('domains');
        if ($settings['use_domain_module'] == 'y') {
            /*
             * The domain-module is in use.
            */
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            /*
             * The admin can select ALL domains, the user only the domains assigned to him
             */
            $sql = "SELECT domain FROM domain ";
            if ($_SESSION["s"]["user"]["typ"] != 'admin') {
                $sql .= "WHERE sys_groupid =" . $client_group_id;
            }
            $sql .= " ORDER BY domain";
            $domains = $app->db->queryAllRecords($sql);
            $domain_select = '';
            if(is_array($domains) && sizeof($domains) > 0) {
                /* We have domains in the list, so create the drop-down-list */
                foreach( $domains as $domain) {
                    $domain_select .= "<option value=" . $domain['domain'] ;
                    if ($domain['domain'] == $this->dataRecord["domain"]) {
                        $domain_select .= " selected";
                    }
                    $domain_select .= ">" . $domain['domain'] . "</option>\r\n";
                }
            }
            else {
                /*
                 * We have no domains in the domain-list. This means, we can not add ANY new domain.
                 * To avoid, that the variable "domain_option" is empty and so the user can
                 * free enter a domain, we have to create a empty option!
                */
                $domain_select .= "<option value=''></option>\r\n";
            }
            $app->tpl->setVar("domain_option",$domain_select);
        }
        // Get the spamfilter policys for the user
        $tmp_user = $app->db->queryOneRecord("SELECT policy_id FROM spamfilter_users WHERE email = '@".$this->dataRecord["domain"]."'");
        $sql = "SELECT id, policy_name FROM spamfilter_policy WHERE ".$app->tform->getAuthSQL('r');
        $policys = $app->db->queryAllRecords($sql);
        $policy_select = "<option value='0'>".$app->tform->wordbook["no_policy"]."</option>";
        if(is_array($policys)) {
            foreach( $policys as $p) {
                $selected = ($p["id"] == $tmp_user["policy_id"])?'SELECTED':'';
                $policy_select .= "<option value='$p[id]' $selected>$p[policy_name]</option>\r\n";
            }
        }
        $app->tpl->setVar("policy",$policy_select);
        unset($policys);
        unset($policy_select);
        unset($tmp_user);
        if($this->id > 0) {
            //* we are editing a existing record
            $app->tpl->setVar("edit_disabled", 1);
            $app->tpl->setVar("server_id_value", $this->dataRecord["server_id"]);
        } else {
            $app->tpl->setVar("edit_disabled", 0);
        }
        parent::onShowEnd();
    }
    function onSubmit() {
        global $app, $conf;
        if($_SESSION["s"]["user"]["typ"] != 'admin') {
            // Get the limits of the client
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT limit_maildomain, default_mailserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
            // When the record is updated
            if($this->id > 0) {
                // restore the server ID if the user is not admin and record is edited
                $tmp = $app->db->queryOneRecord("SELECT server_id FROM mail_domain WHERE domain_id = ".intval($this->id));
                $this->dataRecord["server_id"] = $tmp["server_id"];
                unset($tmp);
                // When the record is inserted
            } else {
                // set the server ID to the default mailserver of the client
                $this->dataRecord["server_id"] = $client["default_mailserver"];
                // Check if the user may add another mail_domain
                if($client["limit_maildomain"] >= 0) {
                    $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM mail_domain WHERE sys_groupid = $client_group_id");
                    if($tmp["number"] >= $client["limit_maildomain"]) {
                        $app->error($app->tform->wordbook["limit_maildomain_txt"]);
                    }
                }
            }
            // Clients may not set the client_group_id, so we unset them if user is not a admin
            if(!$app->auth->has_clients($_SESSION['s']['user']['userid'])) unset($this->dataRecord["client_group_id"]);
        }
        //* make sure that the email domain is lowercase
        if(isset($this->dataRecord["domain"])) $this->dataRecord["domain"] = strtolower($this->dataRecord["domain"]);
        parent::onSubmit();
    }
    function onAfterInsert() {
        global $app, $conf;
        // make sure that the record belongs to the client group and not the admin group when a dmin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE domain_id = ".$this->id);
        }
        // Spamfilter policy
        $policy_id = intval($this->dataRecord["policy"]);
        if($policy_id > 0) {
            $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".mysql_real_escape_string($this->dataRecord["domain"])."'");
            if($tmp_user["id"] > 0) {
                // There is already a record that we will update
                $app->db->datalogUpdate('spamfilter_users', "policy_id = $ploicy_id", 'id', $tmp_user["id"]);
            } else {
                $tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$this->id);
                // We create a new record
                $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`)
                        VALUES (".$_SESSION["s"]["user"]["userid"].", ".$tmp_domain["sys_groupid"].", 'riud', 'riud', '', ".$this->dataRecord["server_id"].", 5, ".$policy_id.", '@".mysql_real_escape_string($this->dataRecord["domain"])."', '@".mysql_real_escape_string($this->dataRecord["domain"])."', 'Y')";
                $app->db->datalogInsert('spamfilter_users', $insert_data, 'id');
                unset($tmp_domain);
            }
        }  // endif spamfilter policy
    }
    function onBeforeUpdate() {
        global $app, $conf;
        //* Check if the server has been changed
        // We do this only for the admin or reseller users, as normal clients can not change the server ID anyway
        if($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
            $rec = $app->db->queryOneRecord("SELECT server_id, domain from mail_domain WHERE domain_id = ".$this->id);
            if($rec['server_id'] != $this->dataRecord["server_id"]) {
                //* Add a error message and switch back to old server
                $app->tform->errorMessage .= $app->lng('The Server can not be changed.');
                $this->dataRecord["server_id"] = $rec['server_id'];
            }
            unset($rec);
            //* If the user is neither admin nor reseller
        } else {
            //* We do not allow users to change a domain which has been created by the admin
            $rec = $app->db->queryOneRecord("SELECT domain from mail_domain WHERE domain_id = ".$this->id);
            if($rec['domain'] != $this->dataRecord["domain"] && $app->tform->checkPerm($this->id,'u')) {
                //* Add a error message and switch back to old server
                $app->tform->errorMessage .= $app->lng('The Domain can not be changed. Please ask your Administrator if you want to change the domain name.');
                $this->dataRecord["domain"] = $rec['domain'];
            }
            unset($rec);
        }
    }
    function onAfterUpdate() {
        global $app, $conf;
        // make sure that the record belongs to the clinet group and not the admin group when admin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE domain_id = ".$this->id);
        }
        // Spamfilter policy
        $policy_id = intval($this->dataRecord["policy"]);
        $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".mysql_real_escape_string($this->dataRecord["domain"])."'");
        if($policy_id > 0) {
            if($tmp_user["id"] > 0) {
                // There is already a record that we will update
                $app->db->datalogUpdate('spamfilter_users', "policy_id = $policy_id", 'id', $tmp_user["id"]);
            } else {
                $tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$this->id);
                // We create a new record
                $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`)
                        VALUES (".$_SESSION["s"]["user"]["userid"].", ".$tmp_domain["sys_groupid"].", 'riud', 'riud', '', ".$this->dataRecord["server_id"].", 5, ".$policy_id.", '@".mysql_real_escape_string($this->dataRecord["domain"])."', '@".mysql_real_escape_string($this->dataRecord["domain"])."', 'Y')";
                $app->db->datalogInsert('spamfilter_users', $insert_data, 'id');
                unset($tmp_domain);
            }
        } else {
            if($tmp_user["id"] > 0) {
                // There is already a record but the user shall have no policy, so we delete it
                $app->db->datalogDelete('spamfilter_users', 'id', $tmp_user["id"]);
            }
        } // endif spamfilter policy
        //** If the domain name or owner has been changed, change the domain and owner in all mailbox records
        if($this->oldDataRecord['domain'] != $this->dataRecord['domain'] || (isset($this->dataRecord['client_group_id']) && $this->oldDataRecord['sys_groupid'] != $this->dataRecord['client_group_id'])) {
            $app->uses('getconf');
            $mail_config = $app->getconf->get_server_config($this->dataRecord["server_id"],'mail');
            //* Update the mailboxes
            $mailusers = $app->db->queryAllRecords("SELECT * FROM mail_user WHERE email like '%@".mysql_real_escape_string($this->oldDataRecord['domain'])."'");
            $sys_groupid = (isset($this->dataRecord['client_group_id']))?$this->dataRecord['client_group_id']:$this->oldDataRecord['sys_groupid'];
            if(is_array($mailusers)) {
                foreach($mailusers as $rec) {
                    // setting Maildir, Homedir, UID and GID
                    $mail_parts = explode("@",$rec['email']);
                    $maildir = str_replace("[domain]",$this->dataRecord['domain'],$mail_config["maildir_path"]);
                    $maildir = str_replace("[localpart]",$mail_parts[0],$maildir);
                    $maildir = mysql_real_escape_string($maildir);
                    $email = mysql_real_escape_string($mail_parts[0].'@'.$this->dataRecord['domain']);
                    $app->db->datalogUpdate('mail_user', "maildir = '$maildir', email = '$email', sys_groupid = '$sys_groupid'", 'mailuser_id', $rec['mailuser_id']);
                }
            }
            //* Update the aliases
            $forwardings = $app->db->queryAllRecords("SELECT * FROM mail_forwarding WHERE source like '%@".mysql_real_escape_string($this->oldDataRecord['domain'])."' OR destination like '%@".mysql_real_escape_string($this->oldDataRecord['domain'])."'");
            if(is_array($forwardings)) {
                foreach($forwardings as $rec) {
                    $destination = mysql_real_escape_string(str_replace($this->oldDataRecord['domain'],$this->dataRecord['domain'],$rec['destination']));
                    $source = mysql_real_escape_string(str_replace($this->oldDataRecord['domain'],$this->dataRecord['domain'],$rec['source']));
                    $app->db->datalogUpdate('mail_forwarding', "source = '$source', destination = '$destination', sys_groupid = '$sys_groupid'", 'forwarding_id', $rec['forwarding_id']);
                }
            }
            //* Update the mailinglist
            $app->db->query("UPDATE mail_mailinglist SET sys_groupid = $sys_groupid WHERE domain = '".mysql_real_escape_string($this->oldDataRecord['domain'])."'");
            //* Delete the old spamfilter record
            $tmp = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".mysql_real_escape_string($this->oldDataRecord["domain"])."'");
            $app->db->datalogDelete('spamfilter_users', 'id', $tmp["id"]);
            unset($tmp);
        } // end if domain name changed
    }
}
$page = new page_action;
$page->onLoad();
?>
interface/web/mail/mail_mailinglist_del.php
New file
@@ -0,0 +1,58 @@
<?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.
*/
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/mail_mailinglist.list.php";
$tform_def_file = "form/mail_mailinglist.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('mail');
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
class page_action extends tform_actions {
}
$page = new page_action;
$page->onDelete();
?>
interface/web/mail/mail_mailinglist_edit.php
New file
@@ -0,0 +1,256 @@
<?php
/*
Copyright (c) 2005 - 2009, 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.
*/
/******************************************
* Begin Form configuration
******************************************/
$tform_def_file = "form/mail_mailinglist.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('mail');
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
class page_action extends tform_actions {
    function onShowNew() {
        global $app, $conf;
        // we will check only users, not admins
        if($_SESSION["s"]["user"]["typ"] == 'user') {
            if(!$app->tform->checkClientLimit('limit_mailmailinglist')) {
                $app->error($app->tform->wordbook["limit_mailmailinglist_txt"]);
            }
            if(!$app->tform->checkResellerLimit('limit_mailmailinglist')) {
                $app->error('Reseller: '.$app->tform->wordbook["limit_mailmailinglist_txt"]);
            }
        }
        parent::onShowNew();
    }
    function onShowEnd() {
        global $app, $conf;
        if($_SESSION["s"]["user"]["typ"] == 'admin') {
            // Getting Clients of the user
            if($_SESSION["s"]["user"]["typ"] == 'admin') {
                $sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0 ORDER BY name";
            } else {
                $client_group_id = $_SESSION["s"]["user"]["default_group"];
                $sql = "SELECT client.client_id, limit_web_domain, default_mailserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id";
            }
            $clients = $app->db->queryAllRecords($sql);
            $client_select = '';
            if($_SESSION["s"]["user"]["typ"] == 'admin') $client_select .= "<option value='0'></option>";
            $tmp_data_record = $app->tform->getDataRecord($this->id);
            if(is_array($clients)) {
                foreach( $clients as $client) {
                    $selected = ($client["groupid"] == $tmp_data_record["sys_groupid"])?'SELECTED':'';
                    $client_select .= "<option value='$client[groupid]' $selected>$client[name]</option>\r\n";
                }
            }
            $app->tpl->setVar("client_group_id",$client_select);
        } elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
            // Get the limits of the client
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT client.client_id, contact_name, default_mailserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id order by contact_name");
            // Fill the client select field
            $sql = "SELECT groupid, name FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id'];
            $clients = $app->db->queryAllRecords($sql);
            $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$client['client_id']);
            $client_select = '<option value="'.$tmp['groupid'].'">'.$client['contact_name'].'</option>';
            $tmp_data_record = $app->tform->getDataRecord($this->id);
            if(is_array($clients)) {
                foreach( $clients as $client) {
                    $selected = @($client["groupid"] == $tmp_data_record["sys_groupid"])?'SELECTED':'';
                    $client_select .= "<option value='$client[groupid]' $selected>$client[name]</option>\r\n";
                }
            }
            $app->tpl->setVar("client_group_id",$client_select);
        }
        // Getting Domains of the user
        $sql = "SELECT domain FROM mail_domain WHERE ".$app->tform->getAuthSQL('r').' ORDER BY domain';
        $domains = $app->db->queryAllRecords($sql);
        $domain_select = '';
        if(is_array($domains)) {
            foreach( $domains as $domain) {
                $selected = ($domain["domain"] == $this->dataRecord["domain"])?'SELECTED':'';
                $domain_select .= "<option value='$domain[domain]' $selected>$domain[domain]</option>\r\n";
            }
        }
        $app->tpl->setVar("domain_option",$domain_select);
        if($this->id > 0) {
            //* we are editing a existing record
            $app->tpl->setVar("edit_disabled", 1);
            $app->tpl->setVar("listname_value", $this->dataRecord["listname"]);
            $app->tpl->setVar("domain_value", $this->dataRecord["domain"]);
            $app->tpl->setVar("email_value", $this->dataRecord["email"]);
        } else {
            $app->tpl->setVar("edit_disabled", 0);
        }
        parent::onShowEnd();
    }
    function onSubmit() {
        global $app, $conf;
        if($_SESSION["s"]["user"]["typ"] != 'admin') {
            // Get the limits of the client
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT limit_mailmailinglist, default_mailserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
            //* Check if Domain belongs to user
            if(isset($_POST["domain"])) {
                $domain = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = '".$this->dataRecord["domain"]."' AND ".$app->tform->getAuthSQL('r'));
                if($domain["domain"] != $this->dataRecord["domain"]) $app->tform->errorMessage .= $app->tform->lng("no_domain_perm");
            }
            // When the record is updated
            if($this->id == 0) {
                //Check if email is in use
                $check = $app->db->queryOneRecord("SELECT count(source) as number FROM mail_forwarding WHERE source = '".$this->dataRecord["listname"]."@".$this->dataRecord["domain"]."'");
                if($check['number'] != 0) {
                        $app->error($app->tform->wordbook["email_in_use_txt"]);
                }
                $check = $app->db->queryOneRecord("SELECT count(email) as number FROM mail_user WHERE email = '".$this->dataRecord["listname"]."@".$this->dataRecord["domain"]."'");
                if($check['number'] != 0) {
                        $app->error($app->tform->wordbook["email_in_use_txt"]);
                }
                $check = $app->db->queryOneRecord("SELECT count(mailinglist_id) as number FROM mail_mailinglist WHERE listname = '".$this->dataRecord["listname"]."' AND domain = '".$this->dataRecord["domain"]."'");
                if($check['number'] != 0) {
                        $app->error($app->tform->wordbook["email_in_use_txt"]);
                }
                // Check if the user may add another mail_domain
                if($client["limit_mailmailinglist"] >= 0) {
                    $tmp = $app->db->queryOneRecord("SELECT count(mailinglist_id) as number FROM mail_mailinglist WHERE sys_groupid = $client_group_id");
                    if($tmp["number"] >= $client["limit_mailmailinglist"]) {
                        $app->error($app->tform->wordbook["limit_mailmailinglist_txt"]);
                    }
                }
            }
            // Clients may not set the client_group_id, so we unset them if user is not a admin
            if(!$app->auth->has_clients($_SESSION['s']['user']['userid'])) unset($this->dataRecord["client_group_id"]);
        }
        //* make sure that the email domain is lowercase
        if(isset($this->dataRecord["domain"])) $this->dataRecord["domain"] = strtolower($this->dataRecord["domain"]);
        parent::onSubmit();
    }
    function onBeforeInsert() {
        global $app, $conf;
        // Set the server id of the mailinglist = server ID of mail domain.
        $domain = $app->db->queryOneRecord("SELECT server_id FROM mail_domain WHERE domain = '".$this->dataRecord["domain"]."'");
        $this->dataRecord["server_id"] = $domain['server_id'];
    }
    function onAfterInsert() {
        global $app, $conf;
        // make sure that the record belongs to the client group and not the admin group when a dmin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_mailinglist SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE mailinglist_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_mailinglist SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE mailinglist_id = ".$this->id);
        }
    }
    function onBeforeUpdate() {
        global $app, $conf;
        //* Check if the server has been changed
        // We do this only for the admin or reseller users, as normal clients can not change the server ID anyway
        if($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
            $rec = $app->db->queryOneRecord("SELECT server_id, domain from mail_mailinglist WHERE mailinglist_id = ".$this->id);
            $this->dataRecord["server_id"] = $rec['server_id'];
            unset($rec);
            //* If the user is neither admin nor reseller
        } else {
            //* We do not allow users to change a domain which has been created by the admin
            $rec = $app->db->queryOneRecord("SELECT domain from mail_mailinglist WHERE mailinglist_id = ".$this->id);
            if($rec['domain'] != $this->dataRecord["domain"] && $app->tform->checkPerm($this->id,'u')) {
                //* Add a error message and switch back to old server
                $app->tform->errorMessage .= $app->lng('The Domain can not be changed. Please ask your Administrator if you want to change the domain name.');
                $this->dataRecord["domain"] = $rec['domain'];
            }
            unset($rec);
        }
    }
    function onAfterUpdate() {
        global $app, $conf;
        // make sure that the record belongs to the clinet group and not the admin group when admin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_mailinglist SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE mailinglist_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_mailinglist SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE mailinglist_id = ".$this->id);
        }
    }
}
$app->tform_actions = new page_action;
$app->tform_actions->onLoad();
?>
interface/web/mail/mail_mailinglist_list.php
New file
@@ -0,0 +1,44 @@
<?php
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/mail_mailinglist.list.php";
/******************************************
* End Form configuration
******************************************/
//* Check permissions for module
$app->auth->check_module_permissions('mail');
$app->load('listform_actions');
class list_action extends listform_actions {
    function onShow() {
        global $app,$conf;
        $app->uses('getconf');
        $global_config = $app->getconf->get_global_config('mail');
        if($global_config['mailmailinglist_link'] == 'y') {
            $app->tpl->setVar('mailmailinglist_link',1);
        } else {
            $app->tpl->setVar('mailmailinglist_link',0);
        }
        parent::onShow();
    }
}
$list = new list_action;
$list->onLoad();
?>
interface/web/mail/mailinglist.php
New file
@@ -0,0 +1,68 @@
<?php
/*
Copyright (c) 2008, 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.
*/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->auth->check_module_permissions('mail');
/* get the id of the mail (must be int!) */
if (!isset($_GET['id'])){
    die ("No List selected!");
}
$listId = intval($_GET['id']);
/*
 * Get the data to connect to the database
 */
$dbData = $app->db->queryAllRecords("SELECT server_id, listname FROM mail_mailinglist WHERE mailinglist_id = " . $listId);
$serverId = intval($dbData[0]['server_id']);
if ($serverId == 0){
    die ("No List - Server found!");
}
$serverData = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ".$serverId);
$app->uses('getconf');
$global_config = $app->getconf->get_global_config('mail');
if($global_config['mailmailinglist_url'] != '') {
    header('Location:' . $global_config['mailmailinglist_url']);
} else {
/*
 * We only redirect to the login-form, so there is no need, to check any rights
 */
    isset($_SERVER['HTTPS'])? $http = 'https' : $http = 'http';
    header('Location:' . $http . '://' . $serverData['server_name'] . '/cgi-bin/mailman/admin/' . $dbData[0]['listname']);
}
exit;
?>
interface/web/mail/templates/mail_mailinglist_edit.htm
New file
@@ -0,0 +1,80 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_mail_mailinglist">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels"><legend>Mailing List</legend>
        <tmpl_if name="is_admin">
            <div class="ctrlHolder">
                <label for="client_group_id">{tmpl_var name='client_txt'}</label>
                <select name="client_group_id" id="client_group_id" class="selectInput">
                    {tmpl_var name='client_group_id'}
                </select>
            </div>
        </tmpl_if>
        <tmpl_if name="is_reseller">
              <div class="ctrlHolder">
                  <label for="client_group_id">{tmpl_var name='client_txt'}</label>
                <select name="client_group_id" id="client_group_id" class="selectInput">
                    {tmpl_var name='client_group_id'}
                </select>
              </div>
          </tmpl_if>
        <tmpl_if name="edit_disabled">
            <div class="ctrlHolder">
                <label for="domain_disabled">{tmpl_var name='domain_txt'}</label>
                <select name="domain_disabled" id="domain_disabled" class="selectInput" disabled="disabled">
                        {tmpl_var name='domain_option'}
                </select>
                <input type="hidden" name="domain" value="{tmpl_var name='domain_value'}" />
            </div>
            <div class="ctrlHolder">
                <label for="listname_disabled">{tmpl_var name='listname_txt'}</label>
                <input name="listname_disabled" id="listname_disabled" value="{tmpl_var name='listname'}" size="30" maxlength="255" type="text" class="textInput" disabled="disabled" />
                <input type="hidden" name="listname" value="{tmpl_var name='listname_value'}" />
            </div>
            <div class="ctrlHolder">
                <label for="email_disabled">{tmpl_var name='email_txt'}</label>
                <input name="email_disabled" id="email_disabled" value="{tmpl_var name='email'}" size="30" maxlength="255" type="text" class="textInput" disabled="disabled" />
                <input type="hidden" name="email" value="{tmpl_var name='email_value'}" />
            </div>
        <tmpl_else>
            <div class="ctrlHolder">
                <label for="domain">{tmpl_var name='domain_txt'}</label>
                <select name="domain" id="domain" class="selectInput">
                        {tmpl_var name='domain_option'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="listname">{tmpl_var name='listname_txt'}</label>
                <input name="listname" id="listname" value="{tmpl_var name='listname'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
            <div class="ctrlHolder">
                <label for="email">{tmpl_var name='email_txt'}</label>
                <input name="email" id="email" value="{tmpl_var name='email'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
        </tmpl_if>
        <div class="ctrlHolder">
            <label for="password">{tmpl_var name='password_txt'}</label>
            <input name="password" id="password" value="{tmpl_var name='password'}" size="30" maxlength="255" type="password" class="textInput" onkeyup="pass_check(this.value)" />
        </div>
        <div class="ctrlHolder">
                <p class="label">{tmpl_var name='password_strength_txt'}</p>
                <div id="passBar"></div>
                <p class="formHint"><span id="passText">&nbsp;</span></p>
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','mail/mail_mailinglist_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('mail/mail_mailinglist_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/mail/templates/mail_mailinglist_list.htm
New file
@@ -0,0 +1,53 @@
<h2><tmpl_var name="list_head_txt"></h2>
<div class="panel panel_list_mail_mailinglist">
  <div class="pnl_toolsarea">
    <fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
      <div class="buttons">
        <button class="iconstxt icoAdd" type="button" onClick="loadContent('mail/mail_mailinglist_edit.php');">
          <span>{tmpl_var name="add_new_record_txt"}</span>
        </button>
      </div>
    </fieldset>
  </div>
  <div class="pnl_listarea">
    <fieldset><legend><tmpl_var name="list_head_txt"></legend>
      <table class="list">
        <thead>
          <tr>
            <th class="tbl_col_listname" scope="col"><tmpl_var name="listname_txt"></th>
            <th class="tbl_col_domain" scope="col"><tmpl_var name="domain_txt"></th>
            <th class="tbl_col_buttons" scope="col">&nbsp;</th>
          </tr>
          <tr>
            <td class="tbl_col_listname"><input type="text" name="search_listname" value="{tmpl_var name='search_listname'}" /></td>
            <td class="tbl_col_domain"><input type="text" name="search_domain" value="{tmpl_var name='search_domain'}" /></td>
            <td class="tbl_col_buttons"><div class="buttons"><button type="button" class="icons16 icoFilter" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" onClick="submitForm('pageForm','mail/mail_mailinglist_list.php');"><span>{tmpl_var name="filter_txt"}</span></button></div></td>
          </tr>
        </thead>
        <tbody>
          <tmpl_loop name="records">
          <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
            <td class="tbl_col_listname"><a href="#" onClick="loadContent('mail/mail_mailinglist_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="listname"}</a></td>
            <td class="tbl_col_domain"><a href="#" onClick="loadContent('mail/mail_mailinglist_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="domain"}</a></td>
            <td class="tbl_col_buttons">
              <div class="buttons icons16">
                  <tmpl_if name="mailmailinglist_link"><a class="icons16 icoWebmailer" href="mail/mailinglist.php?id={tmpl_var name='id'}" target="mailmailinglist"><span>{tmpl_var name='delete_txt'}</span></a></tmpl_if>
                <a class="icons16 icoDelete" href="javascript: del_record('mail/mail_mailinglist_del.php?id={tmpl_var name='id'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span>{tmpl_var name='delete_txt'}</span></a>
              </div>
            </td>
          </tr>
          </tmpl_loop>
        </tbody>
        <tfoot>
          <tr>
            <td class="tbl_footer tbl_paging" colspan="3"><tmpl_var name="paging"></td>
          </tr>
        </tfoot>
      </table>
    </fieldset>
  </div>
</div>
server/conf/mm_cfg.py.master
New file
@@ -0,0 +1,106 @@
# -*- python -*-
# Copyright (C) 1998,1999,2000 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
"""This is the module which takes your site-specific settings.
From a raw distribution it should be copied to mm_cfg.py.  If you
already have an mm_cfg.py, be careful to add in only the new settings
you want.  The complete set of distributed defaults, with annotation,
are in ./Defaults.  In mm_cfg, override only those you want to
change, after the
  from Defaults import *
line (see below).
Note that these are just default settings - many can be overridden via the
admin and user interfaces on a per-list or per-user basis.
Note also that some of the settings are resolved against the active list
setting by using the value as a format string against the
list-instance-object's dictionary - see the distributed value of
DEFAULT_MSG_FOOTER for an example."""
#######################################################
#    Here's where we get the distributed defaults.    #
from Defaults import *
##############################################################
# Put YOUR site-specific configuration below, in mm_cfg.py . #
# See Defaults.py for explanations of the values.            #
#-------------------------------------------------------------
# The name of the list Mailman uses to send password reminders
# and similar. Don't change if you want mailman-owner to be
# a valid local part.
MAILMAN_SITE_LIST = 'mailman'
#-------------------------------------------------------------
# If you change these, you have to configure your http server
# accordingly (Alias and ScriptAlias directives in most httpds)
DEFAULT_URL_PATTERN = 'http://%s/cgi-bin/mailman/'
PRIVATE_ARCHIVE_URL = '/cgi-bin/mailman/private'
IMAGE_LOGOS         = '/images/mailman/'
#-------------------------------------------------------------
# Default domain for email addresses of newly created MLs
DEFAULT_EMAIL_HOST = '{hostname}'
#-------------------------------------------------------------
# Default host for web interface of newly created MLs
DEFAULT_URL_HOST   = '{hostname}'
#-------------------------------------------------------------
# Required when setting any of its arguments.
add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)
#-------------------------------------------------------------
# The default language for this server.
DEFAULT_SERVER_LANGUAGE = {default_language}
#-------------------------------------------------------------
# Iirc this was used in pre 2.1, leave it for now
USE_ENVELOPE_SENDER    = 0              # Still used?
#-------------------------------------------------------------
# Unset send_reminders on newly created lists
DEFAULT_SEND_REMINDERS = 0
#-------------------------------------------------------------
# Uncomment this if you configured your MTA such that it
# automatically recognizes newly created lists.
# (see /usr/share/doc/mailman/README.Exim4.Debian or
# /usr/share/mailman/postfix-to-mailman.py)
# MTA=None   # Misnomer, suppresses alias output on newlist
#-------------------------------------------------------------
# Uncomment if you use Postfix virtual domains (but not
# postfix-to-mailman.py), but be sure to see
# /usr/share/doc/mailman/README.Debian first.
MTA='Postfix'
POSTFIX_STYLE_VIRTUAL_DOMAINS = [{virtual_domains}]
#-------------------------------------------------------------
# Uncomment if you want to filter mail with SpamAssassin. For
# more information please visit this website:
# http://www.jamesh.id.au/articles/mailman-spamassassin/
# GLOBAL_PIPELINE.insert(1, 'SpamAssassin')
# Note - if you're looking for something that is imported from mm_cfg, but you
# didn't find it above, it's probably in /usr/lib/mailman/Mailman/Defaults.py.
server/mods-available/mail_module.inc.php
@@ -1,153 +1,162 @@
<?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 mail_module {
    var $module_name = 'mail_module';
    var $class_name = 'mail_module';
    var $actions_available = array(    'mail_domain_insert',
                                    'mail_domain_update',
                                    'mail_domain_delete',
                                    'mail_user_insert',
                                    'mail_user_update',
                                    'mail_user_delete',
                                    'mail_access_insert',
                                    'mail_access_update',
                                    'mail_access_delete',
                                    'mail_forwarding_insert',
                                    'mail_forwarding_update',
                                    'mail_forwarding_delete',
                                    'mail_transport_insert',
                                    'mail_transport_update',
                                    'mail_transport_delete',
                                    'mail_get_insert',
                                    'mail_get_update',
                                    'mail_get_delete',
                                    'mail_content_filter_insert',
                                    'mail_content_filter_update',
                                    'mail_content_filter_delete');
    //* This function is called during ispconfig installation to determine
    //  if a symlink shall be created for this plugin.
    function onInstall() {
        global $conf;
        if($conf['services']['mail'] == true) {
            return true;
        } else {
            return false;
        }
    }
    /*
         This function is called when the module is loaded
    */
    function onLoad() {
        global $app;
        /*
        Annonce the actions that where provided by this module, so plugins
        can register on them.
        */
        $app->plugins->announceEvents($this->module_name,$this->actions_available);
        /*
        As we want to get notified of any changes on several database tables,
        we register for them.
        The following function registers the function "functionname"
         to be executed when a record for the table "dbtable" is
         processed in the sys_datalog. "classname" is the name of the
         class that contains the function functionname.
        */
        $app->modules->registerTableHook('mail_access','mail_module','process');
        $app->modules->registerTableHook('mail_domain','mail_module','process');
        $app->modules->registerTableHook('mail_forwarding','mail_module','process');
        $app->modules->registerTableHook('mail_transport','mail_module','process');
        $app->modules->registerTableHook('mail_user','mail_module','process');
        $app->modules->registerTableHook('mail_get','mail_module','process');
        $app->modules->registerTableHook('mail_content_filter','mail_module','process');
    }
    /*
     This function is called when a change in one of the registered tables is detected.
     The function then raises the events for the plugins.
    */
    function process($tablename,$action,$data) {
        global $app;
        switch ($tablename) {
            case 'mail_access':
                if($action == 'i') $app->plugins->raiseEvent('mail_access_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('mail_access_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('mail_access_delete',$data);
            break;
            case 'mail_domain':
                if($action == 'i') $app->plugins->raiseEvent('mail_domain_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('mail_domain_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('mail_domain_delete',$data);
            break;
            case 'mail_forwarding':
                if($action == 'i') $app->plugins->raiseEvent('mail_forwarding_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('mail_forwarding_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('mail_forwarding_delete',$data);
            break;
            case 'mail_transport':
                if($action == 'i') $app->plugins->raiseEvent('mail_transport_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('mail_transport_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('mail_transport_delete',$data);
            break;
            case 'mail_user':
                if($action == 'i') $app->plugins->raiseEvent('mail_user_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('mail_user_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('mail_user_delete',$data);
            break;
            case 'mail_get':
                if($action == 'i') $app->plugins->raiseEvent('mail_get_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('mail_get_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('mail_get_delete',$data);
            break;
            case 'mail_content_filter':
                if($action == 'i') $app->plugins->raiseEvent('mail_content_filter_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('mail_content_filter_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('mail_content_filter_delete',$data);
            break;
        } // end switch
    } // end function
} // end class
<?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 mail_module {
    var $module_name = 'mail_module';
    var $class_name = 'mail_module';
    var $actions_available = array(    'mail_domain_insert',
                                    'mail_domain_update',
                                    'mail_domain_delete',
                                    'mail_user_insert',
                                    'mail_user_update',
                                    'mail_user_delete',
                                    'mail_access_insert',
                                    'mail_access_update',
                                    'mail_access_delete',
                                    'mail_forwarding_insert',
                                    'mail_forwarding_update',
                                    'mail_forwarding_delete',
                                    'mail_transport_insert',
                                    'mail_transport_update',
                                    'mail_transport_delete',
                                    'mail_get_insert',
                                    'mail_get_update',
                                    'mail_get_delete',
                                    'mail_content_filter_insert',
                                    'mail_content_filter_update',
                                    'mail_content_filter_delete',
                                    'mail_mailinglist_insert',
                                    'mail_mailinglist_update',
                                    'mail_mailinglist_delete');
    //* This function is called during ispconfig installation to determine
    //  if a symlink shall be created for this plugin.
    function onInstall() {
        global $conf;
        if($conf['services']['mail'] == true) {
            return true;
        } else {
            return false;
        }
    }
    /*
         This function is called when the module is loaded
    */
    function onLoad() {
        global $app;
        /*
        Annonce the actions that where provided by this module, so plugins
        can register on them.
        */
        $app->plugins->announceEvents($this->module_name,$this->actions_available);
        /*
        As we want to get notified of any changes on several database tables,
        we register for them.
        The following function registers the function "functionname"
         to be executed when a record for the table "dbtable" is
         processed in the sys_datalog. "classname" is the name of the
         class that contains the function functionname.
        */
        $app->modules->registerTableHook('mail_access','mail_module','process');
        $app->modules->registerTableHook('mail_domain','mail_module','process');
        $app->modules->registerTableHook('mail_forwarding','mail_module','process');
        $app->modules->registerTableHook('mail_transport','mail_module','process');
        $app->modules->registerTableHook('mail_user','mail_module','process');
        $app->modules->registerTableHook('mail_get','mail_module','process');
        $app->modules->registerTableHook('mail_content_filter','mail_module','process');
        $app->modules->registerTableHook('mail_mailinglist','mail_module','process');
    }
    /*
     This function is called when a change in one of the registered tables is detected.
     The function then raises the events for the plugins.
    */
    function process($tablename,$action,$data) {
        global $app;
        switch ($tablename) {
            case 'mail_access':
                if($action == 'i') $app->plugins->raiseEvent('mail_access_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('mail_access_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('mail_access_delete',$data);
            break;
            case 'mail_domain':
                if($action == 'i') $app->plugins->raiseEvent('mail_domain_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('mail_domain_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('mail_domain_delete',$data);
            break;
            case 'mail_forwarding':
                if($action == 'i') $app->plugins->raiseEvent('mail_forwarding_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('mail_forwarding_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('mail_forwarding_delete',$data);
            break;
            case 'mail_transport':
                if($action == 'i') $app->plugins->raiseEvent('mail_transport_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('mail_transport_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('mail_transport_delete',$data);
            break;
            case 'mail_user':
                if($action == 'i') $app->plugins->raiseEvent('mail_user_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('mail_user_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('mail_user_delete',$data);
            break;
            case 'mail_get':
                if($action == 'i') $app->plugins->raiseEvent('mail_get_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('mail_get_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('mail_get_delete',$data);
            break;
            case 'mail_content_filter':
                if($action == 'i') $app->plugins->raiseEvent('mail_content_filter_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('mail_content_filter_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('mail_content_filter_delete',$data);
            break;
            case 'mail_mailinglist':
                if($action == 'i') $app->plugins->raiseEvent('mail_mailinglist_insert',$data);
                if($action == 'u') $app->plugins->raiseEvent('mail_mailinglist_update',$data);
                if($action == 'd') $app->plugins->raiseEvent('mail_mailinglist_delete',$data);
            break;
        } // end switch
    } // end function
} // end class
?>
server/plugins-available/mailman_plugin.inc.php
New file
@@ -0,0 +1,155 @@
<?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 mailman_plugin {
    var $plugin_name = 'mailman_plugin';
    var $class_name = 'mailman_plugin';
    var $mailman_config_dir = '/etc/mailman/';
    //* This function is called during ispconfig installation to determine
    //  if a symlink shall be created for this plugin.
    function onInstall() {
        global $conf;
        if($conf['services']['mail'] == true) {
            return true;
        } else {
            return false;
        }
    }
    /*
         This function is called when the plugin is loaded
    */
    function onLoad() {
        global $app;
        /*
        Register for the events
        */
        $app->plugins->registerEvent('mail_mailinglist_insert','mailman_plugin','insert');
        $app->plugins->registerEvent('mail_mailinglist_update','mailman_plugin','update');
        $app->plugins->registerEvent('mail_mailinglist_delete','mailman_plugin','delete');
    }
    function insert($event_name,$data) {
        global $app, $conf;
        $this->update_config();
        exec("/usr/lib/mailman/bin/newlist -u ".$data["new"]["domain"]." -e ".$data["new"]["domain"]." ".$data["new"]["listname"]." ".$data["new"]["email"]." ".$data["new"]["password"]."");
        exec($conf['init_scripts'] . '/' . 'mailman reload &> /dev/null');
        $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ".$data["new"]['mailinglist_id']);
    }
    // The purpose of this plugin is to rewrite the main.cf file
    function update($event_name,$data) {
        global $app, $conf;
        exec("/usr/lib/mailman/bin/change_pw -l ".$data["new"]["listname"]." -p ".$data["new"]["password"]."");
        exec($conf['init_scripts'] . '/' . 'mailman reload &> /dev/null');
        $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ".$data["new"]['mailinglist_id']);
    }
    function delete($event_name,$data) {
        global $app, $conf;
        $this->update_config();
        exec("/usr/lib/mailman/bin/rmlist -a ".$data["old"]["listname"]);
        exec($conf['init_scripts'] . '/' . 'mailman reload &> /dev/null');
    }
    function update_config() {
        global $app, $conf;
        copy($this->mailman_config_dir.'mm_cfg.py',$this->mailman_config_dir.'mm_cfg.py');
        // load the server configuration options
        $app->uses('getconf');
        $server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
        // load files
        $content = file_get_contents($conf["rootpath"]."/conf/mm_cfg.py.master");
        $old_file = file_get_contents($this->mailman_config_dir."/mm_cfg.py");
        $old_options = array();
        $lines = explode("\n", $old_file);
        foreach ($lines as $line)
        {
            if (strlen($line) && substr($line, 0, 1) != '#')
            {
                list($key, $value) = explode("=", $line);
                if (!empty($value))
                {
                    $key = rtrim($key);
                    $old_options[$key] = trim($value);
                }
            }
        }
        // create virtual_domains list
        $domainAll = $app->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain");
        $virtual_domains = '';
        foreach($domainAll as $domain)
        {
            if ($domainAll[0]['domain'] == $domain['domain'])
                $virtual_domains .= "'".$domain['domain']."'";
            else
                $virtual_domains .= ", '".$domain['domain']."'";
        }
        $content = str_replace('{hostname}', $server_config['hostname'], $content);
        $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content);
        $content = str_replace('{virtual_domains}', $virtual_domains, $content);
        file_put_contents($this->mailman_config_dir."/mm_cfg.py", $content);
    }
} // end class
?>