Marius Cramer
2014-01-23 cf646e99be232c783dcbae86e329470674772749
Merge remote-tracking branch 'origin/stable-3.0.5'

Conflicts:
interface/lib/classes/remoting.inc.php
interface/web/sites/web_domain_edit.php
server/lib/classes/monitor_tools.inc.php
server/plugins-available/maildeliver_plugin.inc.php
60 files modified
11 files added
1510 ■■■■■ changed files
install/lib/install.lib.php 17 ●●●●● patch | view | raw | blame | history
install/lib/installer_base.lib.php 9 ●●●●● patch | view | raw | blame | history
install/sql/incremental/upd_0063.sql 20 ●●●●● patch | view | raw | blame | history
install/sql/ispconfig3.sql 31 ●●●●● patch | view | raw | blame | history
interface/lib/classes/client_templates.inc.php 4 ●●● patch | view | raw | blame | history
interface/lib/classes/custom_datasource.inc.php 2 ●●● patch | view | raw | blame | history
interface/lib/classes/ispcmail.inc.php 1 ●●●● patch | view | raw | blame | history
interface/lib/classes/remoting.inc.php 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/remote.conf.php 1 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/server_config_web_edit.htm 4 ●●●● patch | view | raw | blame | history
interface/web/client/client_edit.php 134 ●●●●● patch | view | raw | blame | history
interface/web/client/client_message.php 2 ●●● patch | view | raw | blame | history
interface/web/client/client_template_edit.php 13 ●●●●● patch | view | raw | blame | history
interface/web/client/domain_edit.php 9 ●●●●● patch | view | raw | blame | history
interface/web/client/form/client_template.tform.php 14 ●●●●● patch | view | raw | blame | history
interface/web/client/form/message_template.tform.php 108 ●●●●● patch | view | raw | blame | history
interface/web/client/form/reseller.tform.php 14 ●●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/ar.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/bg.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/br.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/cz.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/de.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/el.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/en.lng 3 ●●●● 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_message_template.lng 11 ●●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/en_client_message_template_list.lng 5 ●●●●● 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_client_template_list.lng 2 ●●● patch | view | raw | blame | history
interface/web/client/lib/lang/en_reseller.lng 4 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/es.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/fi.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/fr.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/hr.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/hu.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/id.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/ja.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/nl.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/pl.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/pt.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/ro.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/ru.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/se.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/sk.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/tr.lng 3 ●●●● patch | view | raw | blame | history
interface/web/client/lib/module.conf.php 25 ●●●● patch | view | raw | blame | history
interface/web/client/list/message_template.list.php 77 ●●●●● patch | view | raw | blame | history
interface/web/client/message_template_del.php 58 ●●●●● patch | view | raw | blame | history
interface/web/client/message_template_edit.php 99 ●●●●● patch | view | raw | blame | history
interface/web/client/message_template_list.php 53 ●●●●● patch | view | raw | blame | history
interface/web/client/reseller_edit.php 104 ●●●●● patch | view | raw | blame | history
interface/web/client/templates/client_edit_address.htm 1 ●●●● patch | view | raw | blame | history
interface/web/client/templates/client_edit_limits.htm 17 ●●●●● patch | view | raw | blame | history
interface/web/client/templates/client_message_template_list.htm 57 ●●●●● patch | view | raw | blame | history
interface/web/client/templates/client_template_edit_limits.htm 15 ●●●●● patch | view | raw | blame | history
interface/web/client/templates/domain_list.htm 6 ●●●●● patch | view | raw | blame | history
interface/web/client/templates/message_template.htm 39 ●●●●● patch | view | raw | blame | history
interface/web/client/templates/message_template_list.htm 52 ●●●●● patch | view | raw | blame | history
interface/web/client/templates/reseller_edit_address.htm 1 ●●●● patch | view | raw | blame | history
interface/web/client/templates/reseller_edit_limits.htm 94 ●●●● patch | view | raw | blame | history
interface/web/sites/database_edit.php 42 ●●●●● patch | view | raw | blame | history
interface/web/sites/templates/web_domain_advanced.htm 12 ●●●● patch | view | raw | blame | history
interface/web/sites/web_domain_edit.php 22 ●●●●● patch | view | raw | blame | history
server/conf/apache_apps.vhost.master 44 ●●●●● patch | view | raw | blame | history
server/conf/apache_ispconfig.conf.master 65 ●●●● patch | view | raw | blame | history
server/conf/vhost.conf.master 54 ●●●● patch | view | raw | blame | history
server/lib/classes/system.inc.php 27 ●●●●● patch | view | raw | blame | history
server/lib/classes/tpl.inc.php 21 ●●●● patch | view | raw | blame | history
server/plugins-available/apache2_plugin.inc.php 7 ●●●● patch | view | raw | blame | history
server/plugins-available/apps_vhost_plugin.inc.php 39 ●●●●● patch | view | raw | blame | history
server/plugins-available/maildeliver_plugin.inc.php 3 ●●●● patch | view | raw | blame | history
install/lib/install.lib.php
@@ -666,6 +666,23 @@
    }
}
function hasLine($filename, $search_pattern, $strict = 0) {
    if($lines = @file($filename)) {
        foreach($lines as $line) {
            if($strict == 0) {
                if(stristr($line, $search_pattern)) {
                    return true;
                }
            } else {
                if(trim($line) == $search_pattern) {
                    return true;
                }
            }
        }
    }
    return false;
}
function is_installed($appname) {
    exec('which '.escapeshellcmd($appname).' 2> /dev/null', $out, $returncode);
    if(isset($out[0]) && stristr($out[0], $appname) && $returncode == 0) {
install/lib/installer_base.lib.php
@@ -1247,6 +1247,15 @@
            replaceLine('/etc/apache2/ports.conf', 'Listen 443', 'Listen 443', 1);
        }
        if(is_file('/etc/apache2/apache.conf')) {
            if(hasLine('/etc/apache2/apache.conf', 'Include sites-enabled/', 1) == false) {
                if(hasLine('/etc/apache2/apache.conf', 'IncludeOptional sites-enabled/*.conf', 1) == false) {
                    replaceLine('/etc/apache2/apache.conf', 'Include sites-enabled/', 'Include sites-enabled/', 1, 1);
                } elseif(hasLine('/etc/apache2/apache.conf', 'IncludeOptional sites-enabled/*.vhost', 1) == false) {
                    replaceLine('/etc/apache2/apache.conf', 'IncludeOptional sites-enabled/*.vhost', 'IncludeOptional sites-enabled/*.vhost', 1, 1);
                }
            }
        }
        //* Copy the ISPConfig configuration include
        $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
install/sql/incremental/upd_0063.sql
New file
@@ -0,0 +1,20 @@
ALTER TABLE `client` ADD `limit_domainmodule` INT NOT NULL DEFAULT '0';
ALTER TABLE `client_template` ADD `limit_domainmodule` INT NOT NULL DEFAULT '0';
CREATE TABLE `client_message_template` (
  `client_message_template_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,
  `template_type` varchar(255) DEFAULT NULL,
  `template_name` varchar(255) DEFAULT NULL,
  `subject` varchar(255) DEFAULT NULL,
  `message` text,
  PRIMARY KEY (`client_message_template_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
ALTER TABLE  `spamfilter_policy` ADD  `policyd_quota_in` int(11) NOT NULL DEFAULT  '-1',
ADD  `policyd_quota_in_period` int(11) NOT NULL DEFAULT  '24',
ADD  `policyd_quota_out` int(11) NOT NULL DEFAULT  '-1',
ADD  `policyd_quota_out_period` int(11) NOT NULL DEFAULT  '24',
ADD  `policyd_greylist` ENUM(  'Y',  'N' ) NOT NULL DEFAULT  'N';
install/sql/ispconfig3.sql
@@ -219,6 +219,7 @@
  `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_domainmodule` int(11) NOT NULL DEFAULT '0',
  `limit_mailmailinglist` int(11) NOT NULL DEFAULT '-1',
  `limit_openvz_vm` int(11) NOT NULL DEFAULT '0',
  `limit_openvz_vm_template_id` int(11) NOT NULL DEFAULT '0',
@@ -321,6 +322,7 @@
  `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_domainmodule` int(11) NOT NULL DEFAULT '0',
  `limit_mailmailinglist` int(11) NOT NULL default '-1',
  `limit_openvz_vm` int(11) NOT NULL DEFAULT '0',
  `limit_openvz_vm_template_id` int(11) NOT NULL DEFAULT '0',
@@ -340,6 +342,30 @@
  PRIMARY KEY (`assigned_template_id`),
  KEY `client_id` (`client_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `invoice_message_template`
--
CREATE TABLE `client_message_template` (
  `client_message_template_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,
  `template_type` varchar(255) DEFAULT NULL,
  `template_name` varchar(255) DEFAULT NULL,
  `subject` varchar(255) DEFAULT NULL,
  `message` text,
  PRIMARY KEY (`client_message_template_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- Dumping data for table `invoice_message_template`
--
-- --------------------------------------------------------
--
@@ -1378,6 +1404,11 @@
  `spam_subject_tag2` varchar(64) default NULL,
  `message_size_limit` int(11) unsigned default NULL,
  `banned_rulenames` varchar(64) default NULL,
  `policyd_quota_in` int(11) NOT NULL DEFAULT  '-1',
  `policyd_quota_in_period` int(11) NOT NULL DEFAULT  '24',
  `policyd_quota_out` int(11) NOT NULL DEFAULT  '-1',
  `policyd_quota_out_period` int(11) NOT NULL DEFAULT  '24',
  `policyd_greylist` ENUM(  'Y',  'N' ) NOT NULL DEFAULT  'N',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
interface/lib/classes/client_templates.inc.php
@@ -106,9 +106,10 @@
        /*
         * Get the master-template for the client
         */
        $sql = "SELECT template_master, template_additional FROM client WHERE client_id = " . $app->functions->intval($clientId);
        $sql = "SELECT template_master, template_additional,limit_client FROM client WHERE client_id = " . $app->functions->intval($clientId);
        $record = $app->db->queryOneRecord($sql);
        $masterTemplateId = $record['template_master'];
        $is_reseller = ($record['limit_client'] > 0)?true:false;
        if($record['template_additional'] != '') {
            // we have to call the update_client_templates function
@@ -222,6 +223,7 @@
         * Write all back to the database
         */
        $update = '';
        if(!$is_reseller) unset($limits['limit_client']); // Only Resellers may have limit_client set in template to ensure that we do not convert a client to reseller accidently.
        foreach($limits as $k => $v){
            if ((strpos($k, 'limit') !== false or $k == 'ssh_chroot' or $k == 'web_php_options' or $k == 'force_suexec') && !is_array($v)){
                if ($update != '') $update .= ', ';
interface/lib/classes/custom_datasource.inc.php
@@ -32,7 +32,7 @@
    function master_templates($field, $record) {
        global $app, $conf;
        $records = $app->db->queryAllRecords("SELECT template_id,template_name FROM client_template WHERE template_type ='m'");
        $records = $app->db->queryAllRecords("SELECT template_id,template_name FROM client_template WHERE template_type ='m' and ".$app->tform->getAuthSQL('r'));
        $records_new[0] = $app->lng('Custom');
        foreach($records as $rec) {
            $key = $rec['template_id'];
interface/lib/classes/ispcmail.inc.php
@@ -223,6 +223,7 @@
        elseif(isset($_SERVER['SERVER_NAME'])) $this->smtp_helo = $_SERVER['SERVER_NAME'];
        else $this->smtp_helo = php_uname('n');
        if($this->smtp_helo == '') $this->smtp_helo = 'localhost';
        return $this->smtp_helo;
    }
interface/lib/classes/remoting.inc.php
@@ -187,7 +187,6 @@
    //** protected functions -----------------------------------------------------------------------------------
    protected function klientadd($formdef_file, $reseller_id, $params)
    {
        global $app;
interface/web/admin/lib/remote.conf.php
@@ -1,5 +1,6 @@
<?php
$function_list['server_get,get_function_list,client_templates_get_all,server_get_serverid_by_ip,server_ip_add,server_ip_update,server_ip_delete'] = 'Server functions';
$function_list['admin_record_permissions'] = 'Record permission changes';
?>
interface/web/admin/templates/server_config_web_edit.htm
@@ -145,11 +145,11 @@
                </div>
                <div class="ctrlHolder">
                    <label for="CA_path">{tmpl_var name='CA_path_txt'}</label>
                    <input name="CA_path" id="CA_path" value="{tmpl_var name='CA_path'}" size="40" maxlength="255" type="text" class="textInput" />
                    <input name="CA_path" id="CA_path" value="{tmpl_var name='CA_path'}" size="40" maxlength="255" type="text" autocomplete="off" class="textInput" />
                </div>
                <div class="ctrlHolder">
                    <label for="CA_pass">{tmpl_var name='CA_pass_txt'}</label>
                    <input name="CA_pass" id="CA_pass" value="{tmpl_var name='CA_pass'}" size="40" maxlength="255" type="password" class="textInput" />
                    <input name="CA_pass" id="CA_pass" value="{tmpl_var name='CA_pass'}" size="40" maxlength="255" type="password" autocomplete="off" class="textInput" />
                </div>
            </div>
            <div class="subsectiontoggle"><span></span>{tmpl_var name='permissions_txt'}<em></em></div>
interface/web/client/client_edit.php
@@ -92,6 +92,11 @@
                }
            }
        }
        //* Resellers shall not be able to create another reseller
        if($_SESSION["s"]["user"]["typ"] == 'user') {
            $this->dataRecord['limit_client'] = 0;
        }
        if($this->id != 0) {
            $this->oldTemplatesAssigned = $app->db->queryAllRecords('SELECT * FROM `client_template_assigned` WHERE `client_id` = ' . $this->id);
@@ -189,9 +194,11 @@
                    $app->tpl->setVar('customer_no',$customer_no_string);
                
                    //* save new counter value
                    /*
                    $system_config['misc']['customer_no_counter']++;
                    $system_config_str = $app->ini_parser->get_ini_string($system_config);
                    $app->db->datalogUpdate('sys_ini', "config = '".$app->db->quote($system_config_str)."'", 'sysini_id', 1);
                    */
                }
            } else {
                //* Logged in user must be a reseller
@@ -206,10 +213,30 @@
                    $app->tpl->setVar('customer_no',$customer_no_string);
                    
                    //* save new counter value
                    /*
                    $customer_no_counter = $app->functions->intval($reseller['customer_no_counter']+1);
                    $app->db->query("UPDATE client SET customer_no_counter = $customer_no_counter WHERE client_id = ".$app->functions->intval($reseller['client_id']));
                    */
                }
            }
        }
        if($app->auth->is_admin()) {
            // Fill the client select field
            $sql = "SELECT client.client_id, sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 AND client.limit_client > 0 ORDER BY sys_group.name";
            $clients = $app->db->queryAllRecords($sql);
            $client_select = "<option value='0'>- ".$app->tform->lng('none_txt')." -</option>";
            //$tmp_data_record = $app->tform->getDataRecord($this->id);
            if(is_array($clients)) {
                $selected_client_id = 0; // needed to get list of PHP versions
                foreach($clients as $client) {
                    if(is_array($this->dataRecord) && ($client["client_id"] == $this->dataRecord['parent_client_id']) && !$selected_client_id) $selected_client_id = $client["client_id"];
                    $selected = @(is_array($this->dataRecord) && ($client["client_id"] == $this->dataRecord['parent_client_id']))?'SELECTED':'';
                    if($selected == 'SELECTED') $selected_client_id = $client["client_id"];
                    $client_select .= "<option value='$client[client_id]' $selected>$client[contactname]</option>\r\n";
                }
            }
            $app->tpl->setVar("parent_client_id", $client_select);
        }
        
        parent::onShowEnd();
@@ -253,6 +280,14 @@
        if($_SESSION['s']['user']['typ'] == 'user') {
            $app->auth->add_group_to_user($_SESSION['s']['user']['userid'], $groupid);
            $app->db->query("UPDATE client SET parent_client_id = ".$app->functions->intval($_SESSION['s']['user']['client_id'])." WHERE client_id = ".$this->id);
        } else {
            if($this->dataRecord['parent_client_id'] > 0) {
                //* get userid of the reseller and add it to the group of the client
                $tmp = $app->db->queryOneRecord("SELECT sys_user.userid FROM sys_user,sys_group WHERE sys_user.default_group = sys_group.groupid AND sys_group.client_id = ".$app->functions->intval($this->dataRecord['parent_client_id']));
                $app->auth->add_group_to_user($tmp['userid'], $groupid);
                $app->db->query("UPDATE client SET parent_client_id = ".$app->functions->intval($this->dataRecord['parent_client_id'])." WHERE client_id = ".$this->id);
                unset($tmp);
            }
        }
        //* Set the default servers
@@ -272,6 +307,75 @@
            $app->uses('client_templates');
            $app->client_templates->update_client_templates($this->id, $this->_template_additional);
        }
        if($this->dataRecord['customer_no'] == $this->dataRecord['customer_no_org']) {
            if($app->auth->is_admin()) {
                //* Logged in User is admin
                //* get the system config
                $app->uses('getconf');
                $system_config = $app->getconf->get_global_config();
                if($system_config['misc']['customer_no_template'] != '') {
                    //* save new counter value
                    $system_config['misc']['customer_no_counter']++;
                    $system_config_str = $app->ini_parser->get_ini_string($system_config);
                    $app->db->datalogUpdate('sys_ini', "config = '".$app->db->quote($system_config_str)."'", 'sysini_id', 1);
                }
            } else {
                //* Logged in user must be a reseller
                //* get the record of the reseller
                $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
                $reseller = $app->db->queryOneRecord("SELECT client.client_id, client.customer_no_template, client.customer_no_counter, client.customer_no_start FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ".$client_group_id);
                if($reseller['customer_no_template'] != '') {
                    //* save new counter value
                    $customer_no_counter = $app->functions->intval($reseller['customer_no_counter']+1);
                    $app->db->query("UPDATE client SET customer_no_counter = $customer_no_counter WHERE client_id = ".$app->functions->intval($reseller['client_id']));
                }
            }
        }
        //* Send welcome email
        $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
        $sql = "SELECT * FROM client_message_template WHERE template_type = 'welcome' AND sys_groupid = ".$client_group_id;
        $email_template = $app->db->queryOneRecord($sql);
        $client = $app->tform->getDataRecord($this->id);
        if(is_array($email_template) && $client['email'] != '') {
            //* Parse client details into message
            $message = $email_template['message'];
            $subject = $email_template['subject'];
            foreach($client as $key => $val) {
                switch ($key) {
                case 'password':
                    $message = str_replace('{password}', $this->dataRecord['password'], $message);
                    $subject = str_replace('{password}', $this->dataRecord['password'], $subject);
                    break;
                case 'gender':
                    $message = str_replace('{salutation}', $wb['gender_'.$val.'_txt'], $message);
                    $subject = str_replace('{salutation}', $wb['gender_'.$val.'_txt'], $subject);
                    break;
                default:
                    $message = str_replace('{'.$key.'}', $val, $message);
                    $subject = str_replace('{'.$key.'}', $val, $subject);
                }
            }
            //* Get sender address
            if($app->auth->is_admin()) {
                $app->uses('getconf');
                $system_config = $app->getconf->get_global_config();
                $from = $system_config['admin_mail'];
            } else {
                $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
                $reseller = $app->db->queryOneRecord("SELECT client.email FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ".$client_group_id);
                $from = $reseller["email"];
            }
            //* Send the email
            $app->functions->mail($client['email'], $subject, $message, $from);
        }
        parent::onAfterInsert();
    }
@@ -412,7 +516,7 @@
            $app->db->query($sql);
        }
        // reseller status changed
        //* reseller status changed
        if(isset($this->dataRecord["limit_client"]) && $this->dataRecord["limit_client"] != $this->oldDataRecord["limit_client"]) {
            $modules = $conf['interface_modules_enabled'];
            if($this->dataRecord["limit_client"] > 0) $modules .= ',client';
@@ -421,6 +525,34 @@
            $sql = "UPDATE sys_user SET modules = '$modules' WHERE client_id = $client_id";
            $app->db->query($sql);
        }
        //* Client has been moved to another reseller
        if($_SESSION['s']['user']['typ'] == 'admin' && isset($this->dataRecord['parent_client_id']) && $this->dataRecord['parent_client_id'] != $this->oldDataRecord['parent_client_id']) {
            //* Get groupid of the client
            $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".intval($this->id));
            $groupid = $tmp['groupid'];
            unset($tmp);
            //* Remove sys_user of old reseller from client group
            if($this->oldDataRecord['parent_client_id'] > 0) {
                //* get userid of the old reseller remove it from the group of the client
                $tmp = $app->db->queryOneRecord("SELECT sys_user.userid FROM sys_user,sys_group WHERE sys_user.default_group = sys_group.groupid AND sys_group.client_id = ".$app->functions->intval($this->oldDataRecord['parent_client_id']));
                $app->auth->remove_group_from_user($tmp['userid'], $groupid);
                unset($tmp);
            }
            //* Add sys_user of new reseller to client group
            if($this->dataRecord['parent_client_id'] > 0) {
                //* get userid of the reseller and add it to the group of the client
                $tmp = $app->db->queryOneRecord("SELECT sys_user.userid, sys_user.default_group FROM sys_user,sys_group WHERE sys_user.default_group = sys_group.groupid AND sys_group.client_id = ".$app->functions->intval($this->dataRecord['parent_client_id']));
                $app->auth->add_group_to_user($tmp['userid'], $groupid);
                $app->db->query("UPDATE client SET sys_userid = ".$app->functions->intval($tmp['userid']).", sys_groupid = ".$app->functions->intval($tmp['default_group']).", parent_client_id = ".$app->functions->intval($this->dataRecord['parent_client_id'])." WHERE client_id = ".$this->id);
                unset($tmp);
            } else {
                //* Client is not assigned to a reseller anymore, so we assign it to the admin
                $app->db->query("UPDATE client SET sys_userid = 1, sys_groupid = 1, parent_client_id = 0 WHERE client_id = ".$this->id);
            }
        }
        if(isset($this->dataRecord['template_master'])) {
            $app->uses('client_templates');
interface/web/client/client_message.php
@@ -146,7 +146,7 @@
//message variables
$message_variables = '';
$sql = "SHOW COLUMNS FROM client WHERE Field NOT IN ('client_id', 'sys_userid', 'sys_groupid', 'sys_perm_user', 'sys_perm_group', 'sys_perm_other', 'password', 'parent_client_id', 'id_rsa', 'ssh_rsa', 'created_at', 'default_mailserver', 'default_webserver', 'web_php_options', 'ssh_chroot', 'default_dnsserver', 'default_dbserver', 'template_master', 'template_additional') AND Field NOT LIKE 'limit_%'";
$sql = "SHOW COLUMNS FROM client WHERE Field NOT IN ('client_id', 'sys_userid', 'sys_groupid', 'sys_perm_user', 'sys_perm_group', 'sys_perm_other', 'password', 'parent_client_id', 'id_rsa', 'ssh_rsa', 'created_at', 'default_mailserver', 'default_webserver', 'web_php_options', 'ssh_chroot', 'default_dnsserver', 'default_dbserver', 'template_master', 'template_additional', 'force_suexec', 'default_slave_dnsserver', 'usertheme', 'locked', 'canceled', 'can_use_api', 'tmp_data', 'customer_no_template', 'customer_no_start', 'customer_no_counter', 'added_date', 'added_by') AND Field NOT LIKE 'limit_%'";
$field_names = $app->db->queryAllRecords($sql);
if(!empty($field_names) && is_array($field_names)){
    foreach($field_names as $field_name){
interface/web/client/client_template_edit.php
@@ -51,6 +51,19 @@
class page_action extends tform_actions {
    function onSubmit() {
        global $app;
        //* Resellers shall not be able to create another reseller or set reseller specific settings
        if($_SESSION["s"]["user"]["typ"] == 'user') {
            $this->dataRecord['limit_client'] = 0;
            $this->dataRecord['limit_domainmodule'] = 0;
        }
        parent::onSubmit();
    }
    function onBeforeUpdate() {
        global $app;
interface/web/client/domain_edit.php
@@ -52,6 +52,15 @@
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'.lng';
include $lng_file;
if(!$app->tform->checkClientLimit('limit_domainmodule')) {
    $app->uses('ini_parser,getconf');
    $settings = $app->getconf->get_global_config('domains');
    if ($settings['use_domain_module'] == 'y') {
        $app->error($settings['new_domain_html']);
    }
}
class page_action extends tform_actions {
    function onShowNew() {
interface/web/client/form/client_template.tform.php
@@ -101,6 +101,20 @@
        //#################################
        // Begin Datatable fields
        //#################################
        'limit_client' => array (
            'datatype' => 'INTEGER',
            'formtype' => 'TEXT',
            'validators' => array (  0 => array ( 'type' => 'ISINT',
                    'errmsg'=> 'limit_client_error_notint'),
            ),
            'default' => '1',
            'value'  => '',
            'separator' => '',
            'width'  => '10',
            'maxlength' => '10',
            'rows'  => '',
            'cols'  => ''
        ),
        'limit_maildomain' => array (
            'datatype' => 'INTEGER',
            'formtype' => 'TEXT',
interface/web/client/form/message_template.tform.php
New file
@@ -0,0 +1,108 @@
<?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"]    = "Email template";
$form["description"]  = "";
$form["name"]    = "client_message_template";
$form["action"]   = "message_template_edit.php";
$form["db_table"]  = "client_message_template";
$form["db_table_idx"] = "client_message_template_id";
$form["db_history"]  = "no";
$form["tab_default"] = "template";
$form["list_default"] = "message_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
$form["tabs"]['template'] = array (
    'title'  => "Settings",
    'width'  => 100,
    'template'  => "templates/message_template.htm",
    'fields'  => array (
        //#################################
        // Begin Datatable fields
        //#################################
        'template_type' => array (
            'datatype' => 'VARCHAR',
            'formtype' => 'SELECT',
            'default' => '',
            'value'  => array('welcome' => 'Default welcome email', 'other' => 'Other')
        ),
        'template_name' => array (
            'datatype' => 'VARCHAR',
            'formtype' => 'TEXT',
            'default' => '',
            'value'  => '',
            'separator' => '',
            'width'  => '30',
            'maxlength' => '255',
            'rows'  => '',
            'cols'  => ''
        ),
        'subject' => array (
            'datatype' => 'VARCHAR',
            'formtype' => 'TEXT',
            'default' => '',
            'value'  => '',
            'separator' => '',
            'width'  => '30',
            'maxlength' => '255',
            'rows'  => '',
            'cols'  => ''
        ),
        'message' => array (
            'datatype' => 'TEXT',
            'formtype' => 'TEXTAREA',
            'default' => '',
            'value'  => '',
            'separator' => '',
            'width'  => '30',
            'maxlength' => '255',
            'rows'  => '',
            'cols'  => ''
        ),
        //#################################
        // END Datatable fields
        //#################################
    )
);
?>
interface/web/client/form/reseller.tform.php
@@ -1203,6 +1203,20 @@
            'width'  => '30',
            'maxlength' => '255'
        ),
        'limit_domainmodule' => array (
            'datatype' => 'INTEGER',
            'formtype' => 'TEXT',
            'validators' => array (  0 => array ( 'type' => 'ISINT',
                    'errmsg'=> 'limit_domainmodule_error_notint'),
            ),
            'default' => '0',
            'value'  => '',
            'separator' => '',
            'width'  => '10',
            'maxlength' => '10',
            'rows'  => '',
            'cols'  => ''
        ),
        //#################################
        // END Datatable fields
        //#################################
interface/web/client/lib/lang/ar.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Add Client';
$wb['Edit Client'] = 'Edit Client';
$wb['Clients'] = 'Clients';
$wb['Edit Client-Templates'] = 'Edit Client-Templates';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Add Reseller';
$wb['Edit Reseller'] = 'Edit Reseller';
$wb['Resellers'] = 'Resellers';
interface/web/client/lib/lang/bg.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Добавяне на клиент';
$wb['Edit Client'] = 'Редактиране на клиент';
$wb['Clients'] = 'Клиенти';
$wb['Edit Client-Templates'] = 'Редактирай Клиентски-Шаблон';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Добави дистрибутор';
$wb['Edit Reseller'] = 'Редактирай дистрибутор';
$wb['Resellers'] = 'Дистрибутори';
interface/web/client/lib/lang/br.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Adcionar Cliente';
$wb['Edit Client'] = 'Editar Cliente';
$wb['Clients'] = 'Clientes';
$wb['Edit Client-Templates'] = 'Editar Gabaritos de Clientes';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Adcionar Revendedor';
$wb['Edit Reseller'] = 'Editar Revendedor';
$wb['Resellers'] = 'Revendedores';
interface/web/client/lib/lang/cz.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Přidat klienta';
$wb['Edit Client'] = 'Upravit klienta';
$wb['Clients'] = 'Klienti';
$wb['Edit Client-Templates'] = 'Upravit klientské šablony';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Přidat distributora';
$wb['Edit Reseller'] = 'Upravit distributora';
$wb['Resellers'] = 'Distributoři (prodejci)';
interface/web/client/lib/lang/de.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Kunde hinzufügen';
$wb['Edit Client'] = 'Kunde bearbeiten';
$wb['Clients'] = 'Kunden';
$wb['Edit Client-Templates'] = 'Kundenvorlagen';
$wb['Templates'] = 'Vorlagen';
$wb['Limit-Templates'] = 'Kundenvorlagen';
$wb['Add Reseller'] = 'Reseller hinzufügen';
$wb['Edit Reseller'] = 'Reseller bearbeiten';
$wb['Resellers'] = 'Reseller';
interface/web/client/lib/lang/el.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Νέος Πελάτης';
$wb['Edit Client'] = 'Επεξεργασία Πελάτη';
$wb['Clients'] = 'Πελάτες';
$wb['Edit Client-Templates'] = 'Επεξεργασία προτύπων πελατών';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Νέος Μεταπωλητής';
$wb['Edit Reseller'] = 'Επεξεργασία Μεταπωλητή';
$wb['Resellers'] = 'Μεταπωλητές';
interface/web/client/lib/lang/en.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Add Client';
$wb['Edit Client'] = 'Edit Client';
$wb['Clients'] = 'Clients';
$wb['Edit Client-Templates'] = 'Edit Client-Templates';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Add Reseller';
$wb['Edit Reseller'] = 'Edit Reseller';
$wb['Resellers'] = 'Resellers';
interface/web/client/lib/lang/en_client.lng
@@ -170,4 +170,6 @@
$wb['mail_servers_used'] = 'The server you are trying to remove from this client is used as a Mailserver. Be sure that this server is not used by this client before to remove it.';
$wb['added_by_txt'] = 'Added by';
$wb['added_date_txt'] = 'Added date';
$wb['parent_client_id_txt'] = 'Client of reseller';
$wb['none_txt'] = 'none';
?>
interface/web/client/lib/lang/en_client_message_template.lng
New file
@@ -0,0 +1,11 @@
<?php
$wb["template_type_txt"] = 'Email type';
$wb["template_name_txt"] = 'Template name';
$wb["subject_txt"] = 'Subject';
$wb["message_txt"] = 'Message';
$wb['Email template'] = 'Email template';
$wb['Settings'] = 'Setting';
$wb['variables_txt'] = 'Variables';
$wb['variables_description_txt'] = '(The username and password variables are only available in welcome emails.)';
$wb['duplicate_welcome_error'] = 'There can be only one default welcome email template. Please edit the existing template instead of adding a new one.';
?>
interface/web/client/lib/lang/en_client_message_template_list.lng
New file
@@ -0,0 +1,5 @@
<?php
$wb["list_head_txt"] = 'Email templates';
$wb["template_type_txt"] = 'Message for';
$wb["template_name_txt"] = 'Template name';
?>
interface/web/client/lib/lang/en_client_template.lng
@@ -88,4 +88,6 @@
$wb['aps_limits_txt'] = 'APS Installer Limits';
$wb['limit_aps_txt'] = 'Max. number of APS instances';
$wb['limit_aps_error_notint'] = 'The APS instances limit must be a number.';
$wb['limit_domainmodule_txt'] = 'Domainmodule Limit';
$wb['client_limits_txt'] = 'Client Limits'
?>
interface/web/client/lib/lang/en_client_template_list.lng
@@ -1,5 +1,5 @@
<?php
$wb["list_head_txt"] = 'Client-Templates';
$wb["list_head_txt"] = 'Client and Reseller Templates';
$wb["template_type_txt"] = 'Type';
$wb["template_name_txt"] = 'Template name';
$wb['template_id_txt'] = 'Template ID';
interface/web/client/lib/lang/en_reseller.lng
@@ -172,4 +172,8 @@
$wb['customer_no_counter_txt'] = 'Customer No. counter';
$wb['added_by_txt'] = 'Added by';
$wb['added_date_txt'] = 'Added date';
$wb['limit_domainmodule_error_notint'] = 'Domainmodule limit must be a number.';
$wb['limit_domainmodule_txt'] = 'Domainmodule Limit';
$wb['client_limits_txt'] = 'Client Limits';
$wb['err_msg_master_tpl_set'] = 'All custom limit settings are ignored if any master template other than "custom" is selected.';
?>
interface/web/client/lib/lang/es.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Añadir cliente';
$wb['Edit Client'] = 'Editar cliente';
$wb['Clients'] = 'Clientes';
$wb['Edit Client-Templates'] = 'Editar plantillas de clientes';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Añadir revendedor';
$wb['Edit Reseller'] = 'Editar revendedor';
$wb['Resellers'] = 'Revendedores';
interface/web/client/lib/lang/fi.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Lisää asiakas';
$wb['Edit Client'] = 'Muokkaa asiakkaan tietoja';
$wb['Clients'] = 'Asiakkaat';
$wb['Edit Client-Templates'] = 'Muokkaa asiakasmalleja';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Lisää uusi jälleenmyyjä';
$wb['Edit Reseller'] = 'Muokkaa jälleenmyyjää';
$wb['Resellers'] = 'Jälleenmyyjät';
interface/web/client/lib/lang/fr.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Ajouter un Client';
$wb['Edit Client'] = 'Editer un Client';
$wb['Clients'] = 'Clients';
$wb['Edit Client-Templates'] = 'Editer les modèles de Clients';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Ajouter un Revendeur';
$wb['Edit Reseller'] = 'Editer un Revendeur';
$wb['Resellers'] = 'Revendeurs';
interface/web/client/lib/lang/hr.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Dodaj klijenta';
$wb['Edit Client'] = 'Editiraj klijenta';
$wb['Clients'] = 'Klijenti';
$wb['Edit Client-Templates'] = 'Editiraj predložak za klijente';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Dodaj preprodavača';
$wb['Edit Reseller'] = 'Editiraj preprodavača';
$wb['Resellers'] = 'Preprodavači';
interface/web/client/lib/lang/hu.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Ügyfél hozzáadása';
$wb['Edit Client'] = 'Ügyfél adatok szerkesztése';
$wb['Clients'] = 'Ügyfelek';
$wb['Edit Client-Templates'] = 'Ügyfél-Sablonok szerkesztése';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Új Viszonteladó';
$wb['Edit Reseller'] = 'Viszonteladók szerkesztése';
$wb['Resellers'] = 'Viszonteladók';
interface/web/client/lib/lang/id.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Tambah Klien';
$wb['Edit Client'] = 'Sunting Klien';
$wb['Clients'] = 'Klien';
$wb['Edit Client-Templates'] = 'Sunting Template Klien';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Tambah Reseller';
$wb['Edit Reseller'] = 'Sunting Reseller';
$wb['Resellers'] = 'Reseller';
interface/web/client/lib/lang/ja.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'クライアントを追加する';
$wb['Edit Client'] = 'クライアントを編集する';
$wb['Clients'] = 'クライアント';
$wb['Edit Client-Templates'] = 'クライアントテンプレートを編集する';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'リセラーを追加する';
$wb['Edit Reseller'] = 'リセラーを編集する';
$wb['Resellers'] = 'リセラー';
interface/web/client/lib/lang/nl.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Toevoegen klant';
$wb['Edit Client'] = 'Wijzigen klant';
$wb['Clients'] = 'klanten';
$wb['Edit Client-Templates'] = 'Wijzig klant-template';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Toevoegen Reseller';
$wb['Edit Reseller'] = 'Wijzigen Reseller';
$wb['Resellers'] = 'Resellers';
interface/web/client/lib/lang/pl.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Dodaj klienta';
$wb['Edit Client'] = 'Edytuj klienta';
$wb['Clients'] = 'Klienci';
$wb['Edit Client-Templates'] = 'Edytuj szablony klientów';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Dodaj Resellera';
$wb['Edit Reseller'] = 'Edytuj Resellera';
$wb['Resellers'] = 'Resellerzy';
interface/web/client/lib/lang/pt.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Adicionar Cliente';
$wb['Edit Client'] = 'Editar Cliente';
$wb['Clients'] = 'Clientes';
$wb['Edit Client-Templates'] = 'Editar Templates de Clientes';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Adicionar Revendedor';
$wb['Edit Reseller'] = 'Editar Revendedor';
$wb['Resellers'] = 'Revendedores';
interface/web/client/lib/lang/ro.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Add Client';
$wb['Edit Client'] = 'Edit Client';
$wb['Clients'] = 'Clients';
$wb['Edit Client-Templates'] = 'Edit Client-Templates';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Add Reseller';
$wb['Edit Reseller'] = 'Edit Reseller';
$wb['Resellers'] = 'Resellers';
interface/web/client/lib/lang/ru.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Добавить клиента';
$wb['Edit Client'] = 'Изменить клиента';
$wb['Clients'] = 'Клиенты';
$wb['Edit Client-Templates'] = 'Изменить шаблон клиента';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Добавить реселлера';
$wb['Edit Reseller'] = 'Изменить реселлера';
$wb['Resellers'] = 'Реселлеры';
interface/web/client/lib/lang/se.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Add Client';
$wb['Edit Client'] = 'Edit Client';
$wb['Clients'] = 'Clients';
$wb['Edit Client-Templates'] = 'Edit Client-Templates';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Add Reseller';
$wb['Edit Reseller'] = 'Edit Reseller';
$wb['Resellers'] = 'Resellers';
interface/web/client/lib/lang/sk.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Pridať klienta';
$wb['Edit Client'] = 'Upraviť klienta';
$wb['Clients'] = 'Klienti';
$wb['Edit Client-Templates'] = 'Upraviť klient-Šablónu';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Pridať nového predajcu';
$wb['Edit Reseller'] = 'Upraviť predajcu';
$wb['Resellers'] = 'Predajcovia';
interface/web/client/lib/lang/tr.lng
@@ -5,7 +5,8 @@
$wb['Add Client'] = 'Müşteri Ekle';
$wb['Edit Client'] = 'Müşteri Düzenle';
$wb['Clients'] = 'Müşteriler';
$wb['Edit Client-Templates'] = 'Müşteri-Şablon Düzenle';
$wb['Templates'] = 'Templates';
$wb['Limit-Templates'] = 'Limit-Templates';
$wb['Add Reseller'] = 'Reseller Ekle';
$wb['Edit Reseller'] = 'Reseller Düzenle';
$wb['Resellers'] = 'Resellerlar';
interface/web/client/lib/module.conf.php
@@ -17,13 +17,6 @@
    'link' => 'client/client_edit.php',
    'html_id'   => 'client_add');
if($_SESSION["s"]["user"]["typ"] == 'admin'){
    $items[] = array(   'title'  => "Edit Client-Templates",
        'target'  => 'content',
        'link' => 'client/client_template_list.php',
        'html_id'   => 'client_template_list');
}
$module["nav"][] = array(   'title' => 'Clients',
    'open'  => 1,
    'items' => $items);
@@ -66,6 +59,24 @@
unset($items);
$items[] = array(   'title'  => "Limit-Templates",
    'target'  => 'content',
    'link' => 'client/client_template_list.php',
    'html_id'   => 'client_template_list');
$items[] = array(   'title'  => "Email-Templates",
    'target'  => 'content',
    'link' => 'client/message_template_list.php',
    'html_id'   => 'message_template_list');
$module["nav"][] = array(   'title' => 'Templates',
    'open'  => 1,
    'items' => $items);
unset($items);
$app->uses('ini_parser,getconf');
$settings = $app->getconf->get_global_config('domains');
interface/web/client/list/message_template.list.php
New file
@@ -0,0 +1,77 @@
<?php
/*
Copyright (c) 2010, Till Brehm, projektfarm Gmbh
All rights reserved.
*/
/*
    Datatypes:
    - INTEGER
    - DOUBLE
    - CURRENCY
    - VARCHAR
    - TEXT
    - DATE
*/
// Name of the list
$liste["name"]     = "client_message_template";
// Database table
$liste["table"]    = "client_message_template";
// Index index field of the database table
$liste["table_idx"]   = "client_message_template_id";
// Search Field Prefix
$liste["search_prefix"]  = "search_";
// Records per page
$liste["records_per_page"]  = 15;
// Script File of the list
$liste["file"]    = "message_template_list.php";
// Script file of the edit form
$liste["edit_file"]   = "message_template_edit.php";
// Script File of the delete script
$liste["delete_file"]  = "message_template_del.php";
// Paging Template
$liste["paging_tpl"]  = "templates/paging.tpl.htm";
// Enable authe
$liste["auth"]    = "yes";
/*****************************************************
* Suchfelder
*****************************************************/
$liste["item"][] = array( 'field'  => "template_type",
    'datatype' => "VARCHAR",
    'formtype' => "SELECT",
    'op'  => "=",
    'prefix' => "",
    'suffix' => "",
    'width'  => "",
    'value'  => array('welcome' => 'Default welcome email', 'other' => 'Other'));
$liste["item"][] = array( 'field'  => "template_name",
    'datatype' => "VARCHAR",
    'formtype' => "TEXT",
    'op'  => "like",
    'prefix' => "%",
    'suffix' => "%",
    'width'  => "",
    'value'  => "");
?>
interface/web/client/message_template_del.php
New file
@@ -0,0 +1,58 @@
<?php
/*
Copyright (c) 2014 Till Brehm, ISPConfig UG
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/message_template.list.php";
$tform_def_file = "form/message_template.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('client');
$app->uses('tpl,tform');
$app->load('tform_actions');
class page_action extends tform_actions {
}
$page = new page_action;
$page->onDelete()
?>
interface/web/client/message_template_edit.php
New file
@@ -0,0 +1,99 @@
<?php
/*
Copyright (c) 2014 Till Brehm, ISPConfig UG
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/message_template.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('client');
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
class page_action extends tform_actions {
    function onSubmit() {
        global $app, $conf;
        // Check for duplicates
        if($this->dataRecord['template_type'] == 'welcome') {
            $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
            $sql = "SELECT count(client_message_template_id) as number FROM client_message_template WHERE template_type = 'welcome' AND sys_groupid = ".$client_group_id;
            if($this->id > 0) {
                $sql .= " AND client_message_template_id != ".$this->id;
            }
            $tmp = $app->db->queryOneRecord($sql);
            if($tmp['number'] > 0) $app->tform->errorMessage .= $app->tform->lng('duplicate_welcome_error');
        }
        parent::onSubmit();
    }
    function onShowEnd() {
        global $app, $conf;
        //message variables
        $message_variables = '';
        $sql = "SHOW COLUMNS FROM client WHERE Field NOT IN ('client_id', 'sys_userid', 'sys_groupid', 'sys_perm_user', 'sys_perm_group', 'sys_perm_other', 'parent_client_id', 'id_rsa', 'ssh_rsa', 'created_at', 'default_mailserver', 'default_webserver', 'web_php_options', 'ssh_chroot', 'default_dnsserver', 'default_dbserver', 'template_master', 'template_additional', 'force_suexec', 'default_slave_dnsserver', 'usertheme', 'locked', 'canceled', 'can_use_api', 'tmp_data', 'customer_no_template', 'customer_no_start', 'customer_no_counter', 'added_date', 'added_by') AND Field NOT LIKE 'limit_%'";
        $field_names = $app->db->queryAllRecords($sql);
        if(!empty($field_names) && is_array($field_names)){
            foreach($field_names as $field_name){
                if($field_name['Field'] != ''){
                    if($field_name['Field'] == 'gender'){
                        $message_variables .= '<a href="javascript:void(0);" class="addPlaceholder">{salutation}</a> ';
                    } else {
                        $message_variables .= '<a href="javascript:void(0);" class="addPlaceholder">{'.$field_name['Field'].'}</a> ';
                    }
                }
            }
        }
        $app->tpl->setVar('message_variables', trim($message_variables));
        parent::onShowEnd();
    }
}
$page = new page_action;
$page->onLoad();
?>
interface/web/client/message_template_list.php
New file
@@ -0,0 +1,53 @@
<?php
/*
Copyright (c) 2014 Till Brehm, ISPConfig UG
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';
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/message_template.list.php";
/******************************************
* End Form configuration
******************************************/
//* Check permissions for module
$app->auth->check_module_permissions('client');
$app->uses('listform_actions');
//$app->listform_actions->SQLOrderBy = 'ORDER BY company_name, contact_name, client_id';
//$app->listform_actions->SQLExtWhere = "limit_client = 0";
$app->listform_actions->onLoad();
?>
interface/web/client/reseller_edit.php
@@ -94,6 +94,26 @@
                }
            }
        }
        if($this->id != 0) {
            $this->oldTemplatesAssigned = $app->db->queryAllRecords('SELECT * FROM `client_template_assigned` WHERE `client_id` = ' . $this->id);
            if(!is_array($this->oldTemplatesAssigned) || count($this->oldTemplatesAssigned) < 1) {
                // check previous type of storing templates
                $tpls = explode('/', $this->oldDataRecord['template_additional']);
                $this->oldTemplatesAssigned = array();
                foreach($tpls as $item) {
                    $item = trim($item);
                    if(!$item) continue;
                    $this->oldTemplatesAssigned[] = array('assigned_template_id' => 0, 'client_template_id' => $item, 'client_id' => $this->id);
                }
                unset($tpls);
            }
        } else {
            $this->oldTemplatesAssigned = array();
        }
        $this->_template_additional = explode('/', $this->dataRecord['template_additional']);
        $this->dataRecord['template_additional'] = '';
        parent::onSubmit();
    }
@@ -117,13 +137,27 @@
        $result = $app->db->queryAllRecords('SELECT assigned_template_id, client_template_id FROM client_template_assigned WHERE client_id = ' . $this->id);
        if($result && count($result) > 0) {
            // new style
            $items = array();
            $text = '';
            foreach($result as $item){
                if (trim($item['client_template_id']) != ''){
                    if ($text != '') $text .= '';
                    $text .= '<li rel="' . $item['assigned_template_id'] . '">' . $tpl[$item['client_template_id']]. '<a href="#" class="button icons16 icoDelete"></a></li>';
                    $text .= '<li rel="' . $item['assigned_template_id'] . '">' . $tpl[$item['client_template_id']];
                    $text .= '<a href="#" class="button icons16 icoDelete"></a>';
                    $tmp = new stdClass();
                    $tmp->id = $item['assigned_template_id'];
                    $tmp->data = '';
                    $app->plugin->raiseEvent('get_client_template_details', $tmp);
                    if($tmp->data != '') $text .= '<br /><em>' . $tmp->data . '</em>';
                    $text .= '</li>';
                    $items[] = $item['assigned_template_id'] . ':' . $item['client_template_id'];
                }
            }
            $tmprec = $app->tform->getHTML(array('template_additional' => implode('/', $items)), $this->active_tab, 'EDIT');
            $app->tpl->setVar('template_additional', $tmprec['template_additional']);
            unset($tmprec);
        } else {
            // old style
            $sql = "SELECT template_additional FROM client WHERE client_id = " . $this->id;
@@ -139,6 +173,7 @@
        }
        $app->tpl->setVar('template_additional_list', $text);
        $app->tpl->setVar('app_module', 'client');
        
        //* Set the 'customer no' default value
        if($this->id == 0) {
@@ -153,9 +188,11 @@
                $app->tpl->setVar('customer_no',$customer_no_string);
                
                //* save new counter value
                /*
                $system_config['misc']['customer_no_counter']++;
                $system_config_str = $app->ini_parser->get_ini_string($system_config);
                $app->db->datalogUpdate('sys_ini', "config = '".$app->db->quote($system_config_str)."'", 'sysini_id', 1);
                */
            }
        }
        
@@ -210,6 +247,66 @@
        $sql = "UPDATE client SET default_mailserver = $default_mailserver, default_webserver = $default_webserver, default_dnsserver = $default_dnsserver, default_slave_dnsserver = $default_dnsserver, default_dbserver = $default_dbserver WHERE client_id = ".$this->id;
        $app->db->query($sql);
        if(isset($this->dataRecord['template_master'])) {
            $app->uses('client_templates');
            $app->client_templates->update_client_templates($this->id, $this->_template_additional);
        }
        if($this->dataRecord['customer_no'] == $this->dataRecord['customer_no_org']) {
            //* get the system config
            $app->uses('getconf');
            $system_config = $app->getconf->get_global_config();
            if($system_config['misc']['customer_no_template'] != '') {
                //* save new counter value
                $system_config['misc']['customer_no_counter']++;
                $system_config_str = $app->ini_parser->get_ini_string($system_config);
                $app->db->datalogUpdate('sys_ini', "config = '".$app->db->quote($system_config_str)."'", 'sysini_id', 1);
            }
        }
        //* Send welcome email
        $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
        $sql = "SELECT * FROM client_message_template WHERE template_type = 'welcome' AND sys_groupid = ".$client_group_id;
        $email_template = $app->db->queryOneRecord($sql);
        $client = $app->tform->getDataRecord($this->id);
        if(is_array($email_template) && $client['email'] != '') {
            //* Parse client details into message
            $message = $email_template['message'];
            $subject = $email_template['subject'];
            foreach($client as $key => $val) {
                switch ($key) {
                case 'password':
                    $message = str_replace('{password}', $this->dataRecord['password'], $message);
                    $subject = str_replace('{password}', $this->dataRecord['password'], $subject);
                    break;
                case 'gender':
                    $message = str_replace('{salutation}', $wb['gender_'.$val.'_txt'], $message);
                    $subject = str_replace('{salutation}', $wb['gender_'.$val.'_txt'], $subject);
                    break;
                default:
                    $message = str_replace('{'.$key.'}', $val, $message);
                    $subject = str_replace('{'.$key.'}', $val, $subject);
                }
            }
            //* Get sender address
            if($app->auth->is_admin()) {
                $app->uses('getconf');
                $system_config = $app->getconf->get_global_config();
                $from = $system_config['admin_mail'];
            } else {
                $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
                $reseller = $app->db->queryOneRecord("SELECT client.email FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ".$client_group_id);
                $from = $reseller["email"];
            }
            //* Send the email
            $app->functions->mail($client['email'], $subject, $message, $from);
        }
        parent::onAfterInsert();
    }
@@ -272,6 +369,11 @@
            $sql = "UPDATE sys_user SET modules = '$modules' WHERE client_id = $client_id";
            $app->db->query($sql);
        }
        if(isset($this->dataRecord['template_master'])) {
            $app->uses('client_templates');
            $app->client_templates->update_client_templates($this->id, $this->_template_additional);
        }
        parent::onAfterUpdate();
    }
interface/web/client/templates/client_edit_address.htm
@@ -22,6 +22,7 @@
            <div class="ctrlHolder">
                <label for="customer_no">{tmpl_var name='customer_no_txt'}</label>
                <input name="customer_no" id="customer_no" value="{tmpl_var name='customer_no'}" size="30" maxlength="255" type="text" class="textInput" />
                <input name="customer_no_org" id="customer_no_org" value="{tmpl_var name='customer_no'}" type="hidden" />
            </div>
            <div class="ctrlHolder">
                <label for="username">{tmpl_var name='username_txt'}*</label>
interface/web/client/templates/client_edit_limits.htm
@@ -3,7 +3,6 @@
<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 topbuttons">
@@ -11,11 +10,9 @@
                </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">
@@ -40,7 +37,14 @@
                <div class="ctrlHolder">
                    &nbsp;
                </div>
            </tmpl_if>
                <tmpl_if name="is_admin">
                <div class="ctrlHolder">
                    <label for="parent_client_id_id">{tmpl_var name='parent_client_id_txt'}</label>
                    <select name="parent_client_id" id="parent_client_id" class="selectInput">
                        {tmpl_var name='parent_client_id'}
                    </select>
                </div>
                </tmpl_if>
            <div class="subsectiontoggle"><span class="showing"></span>{tmpl_var name='web_limits_txt'}<em class="showing"></em></div>
            <div>
                <div class="ctrlHolder">
@@ -301,7 +305,7 @@
    </div>
</div>
<tmpl_if name="is_admin">
<script type="text/javascript">
<!--
function custom_template_selected() {
@@ -317,7 +321,7 @@
        .find('div.pnl_formsarea')
        .find('fieldset')
        .find('input,select,button')
        .not('#template_master,#template_additional,#default_mailserver,#default_webserver,#default_dbserver,#default_dnsserver,#default_slave_dnsserver')
        .not('#template_master,#template_additional,#default_mailserver,#default_webserver,#default_dbserver,#default_dnsserver,#default_slave_dnsserver,#customer_no_template,#customer_no_start,#customer_no_counter,#parent_client_id')
        .click(function(e) {
            if(custom_template_selected()) return true;
            e.preventDefault();
@@ -330,4 +334,3 @@
//-->
</script>
</tmpl_if>
interface/web/client/templates/client_message_template_list.htm
New file
@@ -0,0 +1,57 @@
<h2><tmpl_var name="list_head_txt"></h2>
<div class="panel panel_list_client_message_template">
  <div class="pnl_toolsarea">
    <fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
      <div class="buttons">
        <button class="iconstxt icoAdd" type="button" onclick="loadContent('client/message_template_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_template_type" scope="col"><tmpl_var name="template_type_txt"></th>
            <th class="tbl_col_template_name" scope="col"><tmpl_var name="template_name_txt"></th>
            <th class="tbl_col_buttons" scope="col">&nbsp;</th>
          </tr>
          <tr>
            <td class="tbl_col_template_type"><select name="search_template_type" onChange="submitForm('pageForm','client/message_template_list.php');">{tmpl_var name='search_template_type'}</select></td>
            <td class="tbl_col_template_name"><input type="text" name="search_template_name" value="{tmpl_var name='search_template_name'}" /></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','client/message_template_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_template_type"><a href="#" onclick="loadContent('client/message_template_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="template_type"}</a></td>
            <td class="tbl_col_template_name"><a href="#" onclick="loadContent('client/message_template_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="template_name"}</a></td>
            <td class="tbl_col_buttons">
              <div class="buttons icons16">
                <a class="button icons16 icoDelete" href="javascript: del_record('client/message_template_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>
          <tmpl_unless name="records">
              <tr class="tbl_row_noresults tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
                  <td colspan="2">{tmpl_var name='globalsearch_noresults_text_txt'}</td>
              </tr>
          </tmpl_unless>
        </tbody>
        <tfoot>
          <tr>
            <td class="tbl_footer tbl_paging" colspan="3"><tmpl_var name="paging"></td>
          </tr>
        </tfoot>
      </table>
    </fieldset>
  </div>
</div>
interface/web/client/templates/client_template_edit_limits.htm
@@ -5,7 +5,7 @@
    <div class="pnl_formsarea">
        <fieldset class="inlineLabels"><legend>Limits</legend>
            <div class="subsectiontoggle"><span class="showing"></span>{tmpl_var name='web_limits_txt'}<em class="showing"></em></div>
            <div class="subsectiontoggle"><span class="showing"></span>{tmpl_var name='web_limits_txt'}<em class="showing"></em></div>
            <div>
                <div class="ctrlHolder">
                    <label for="limit_web_domain">{tmpl_var name='limit_web_domain_txt'}</label>
@@ -224,6 +224,19 @@
                    <input name="limit_aps" id="limit_aps" value="{tmpl_var name='limit_aps'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
                </div>
            </div>
            <tmpl_if name="is_admin">
            <div class="subsectiontoggle"><span></span>{tmpl_var name='client_limits_txt'}<em></em></div>
            <div style="display:none;">
                <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="limit_domainmodule">{tmpl_var name='limit_domainmodule_txt'}</label>
                    <input name="limit_domainmodule" id="limit_domainmodule" value="{tmpl_var name='limit_domainmodule'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
                </div>
            </div>
            </tmpl_if>
        </fieldset>
        <input type="hidden" name="id" value="{tmpl_var name='id'}">
interface/web/client/templates/domain_list.htm
@@ -6,15 +6,9 @@
    <div class="pnl_toolsarea">
        <fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
            <div class="buttons">
                <tmpl_if name="is_admin">
                <button class="button iconstxt icoAdd" type="button" onclick="loadContent('client/domain_edit.php');">
                    <span>{tmpl_var name="add_new_record_txt"}</span>
                </button>
                <tmpl_else>
                <button class="button iconstxt icoAdd" type="button" onclick="loadContent('client/domain_new_client.php');">
                    <span>{tmpl_var name="add_new_record_txt"}</span>
                </button>
                </tmpl_if>
            </div>
        </fieldset>
    </div>
interface/web/client/templates/message_template.htm
New file
@@ -0,0 +1,39 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_invoice_message_template">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels"><legend>Settings</legend>
      <div class="ctrlHolder">
          <label for="template_type">{tmpl_var name='template_type_txt'}</label>
        <select name="template_type" id="template_type" class="selectInput">
                    {tmpl_var name='template_type'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="template_name">{tmpl_var name='template_name_txt'}</label>
        <input name="template_name" id="template_name" value="{tmpl_var name='template_name'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="subject">{tmpl_var name='subject_txt'}</label>
        <input name="subject" id="subject" value="{tmpl_var name='subject'}" style="width:500px" size="30" maxlength="255" type="text" class="textInput" />
        <br clear="all">{tmpl_var name='variables_txt'}: {tmpl_var name="message_variables"} <br />{tmpl_var name='variables_description_txt'}
            </div>
      <div class="ctrlHolder">
          <label for="message">{tmpl_var name='message_txt'}</label>
        <textarea name="message" id="message" rows='' cols='' style="width:500px">{tmpl_var name='message'}</textarea>
        <br clear="all">{tmpl_var name='variables_txt'}: {tmpl_var name="message_variables"} <br />{tmpl_var name='variables_description_txt'}
      </div>
      <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','client/message_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/message_template_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
  </div>
</div>
interface/web/client/templates/message_template_list.htm
New file
@@ -0,0 +1,52 @@
<h2><tmpl_var name="list_head_txt"></h2>
<div class="panel panel_list_invoice_message_template">
  <div class="pnl_toolsarea">
    <fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
      <div class="buttons">
        <button class="iconstxt icoAdd" type="button" onClick="loadContent('billing/invoice_message_template_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_template_type" scope="col"><tmpl_var name="template_type_txt"></th>
            <th class="tbl_col_template_name" scope="col"><tmpl_var name="template_name_txt"></th>
            <th class="tbl_col_buttons" scope="col">&nbsp;</th>
          </tr>
          <tr>
            <td class="tbl_col_template_type"><select name="search_template_type" onChange="submitForm('pageForm','billing/invoice_message_template_list.php');">{tmpl_var name='search_template_type'}</select></td>
            <td class="tbl_col_template_name"><input type="text" name="search_template_name" value="{tmpl_var name='search_template_name'}" /></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','billing/invoice_message_template_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_template_type"><a href="#" onClick="loadContent('billing/invoice_message_template_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="template_type"}</a></td>
            <td class="tbl_col_template_name"><a href="#" onClick="loadContent('billing/invoice_message_template_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="template_name"}</a></td>
            <td class="tbl_col_buttons">
              <div class="buttons icons16">
                <a class="button icons16 icoDelete" href="javascript: del_record('billing/invoice_message_template_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>
interface/web/client/templates/reseller_edit_address.htm
@@ -22,6 +22,7 @@
            <div class="ctrlHolder">
                <label for="customer_no">{tmpl_var name='customer_no_txt'}</label>
                <input name="customer_no" id="customer_no" value="{tmpl_var name='customer_no'}" size="30" maxlength="255" type="text" class="textInput" />
                <input name="customer_no_org" id="customer_no_org" value="{tmpl_var name='customer_no'}" type="hidden" />
            </div>
            <div class="ctrlHolder">
                <label for="username">{tmpl_var name='username_txt'}*</label>
interface/web/client/templates/reseller_edit_limits.htm
@@ -3,33 +3,44 @@
<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 topbuttons">
                <button class="positive iconstxt icoAdd" type="button" value="{tmpl_var name='add_additional_template_txt'}" onclick="addAdditionalTemplate();"><span>{tmpl_var name='add_additional_template_txt'}</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">
            <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">
                        {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_var name='tpl_add_select'}
                    </select>
                </div>
                <div class="ctrlHolder">
                    <p class="label">{tmpl_var name='active_template_additional_txt'}</p>
                    <div id="template_additional_list" class="multiField">
                        <ul>
                        {tmpl_var name='template_additional_list'}
                        </ul>
                    </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="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="customer_no_template">{tmpl_var name='customer_no_template_txt'}</label>
                <input name="customer_no_template" id="customer_no_template" value="{tmpl_var name='customer_no_template'}" size="30" maxlength="255" type="text" class="textInput formLengthHalf" />
@@ -291,6 +302,17 @@
                    <input name="limit_aps" id="limit_aps" value="{tmpl_var name='limit_aps'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
                </div>
            </div>
            <div class="subsectiontoggle"><span></span>{tmpl_var name='client_limits_txt'}<em></em></div>
            <div style="display:none;">
                <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="limit_domainmodule">{tmpl_var name='limit_domainmodule_txt'}</label>
                    <input name="limit_domainmodule" id="limit_domainmodule" value="{tmpl_var name='limit_domainmodule'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
                </div>
            </div>
        </fieldset>
        <input type="hidden" name="id" value="{tmpl_var name='id'}">
@@ -301,4 +323,34 @@
        </div>
    </div>
</div>
</div>
<tmpl_if name="is_admin">
<script type="text/javascript">
<!--
function custom_template_selected() {
    return ($('#template_master').val() == '0' ? true : false);
}
jQuery('#template_additional_list').find('li > a').click(function(e) {
    e.preventDefault();
    delAdditionalTemplate($(this).parent().attr('rel'));
});
jQuery('div.panel_client')
        .find('div.pnl_formsarea')
        .find('fieldset')
        .find('input,select,button')
        .not('#template_master,#template_additional,#default_mailserver,#default_webserver,#default_dbserver,#default_dnsserver,#default_slave_dnsserver,#customer_no_template,#customer_no_start,#customer_no_counter')
        .click(function(e) {
            if(custom_template_selected()) return true;
            e.preventDefault();
            alert('{tmpl_var name="err_msg_master_tpl_set"}');
        })
        .focus(function() {
            if(custom_template_selected()) return true;
            $(this).blur();
        });
//-->
</script>
</tmpl_if>
interface/web/sites/database_edit.php
@@ -302,7 +302,26 @@
                }
            }
        }
        if ($app->tform->errorMessage == '') {
            // force update of the used database user
            if($this->dataRecord['database_user_id']) {
                $user_old_rec = $app->db->queryOneRecord('SELECT * FROM `web_database_user` WHERE `database_user_id` = ' . $app->functions->intval($this->dataRecord['database_user_id']));
                if($user_old_rec) {
                    $user_new_rec = $user_old_rec;
                    $user_new_rec['server_id'] = $this->dataRecord['server_id'];
                    $app->db->datalogSave('web_database_user', 'UPDATE', 'database_user_id', $this->dataRecord['database_user_id'], $user_old_rec, $user_new_rec);
                }
            }
            if($this->dataRecord['database_ro_user_id']) {
                $user_old_rec = $app->db->queryOneRecord('SELECT * FROM `web_database_user` WHERE `database_user_id` = ' . $app->functions->intval($this->dataRecord['database_ro_user_id']));
                if($user_old_rec) {
                    $user_new_rec = $user_old_rec;
                    $user_new_rec['server_id'] = $this->dataRecord['server_id'];
                    $app->db->datalogSave('web_database_user', 'UPDATE', 'database_user_id', $this->dataRecord['database_ro_user_id'], $user_old_rec, $user_new_rec);
                }
            }
        }
        parent::onBeforeUpdate();
    }
@@ -371,6 +390,27 @@
            }
        }
        if ($app->tform->errorMessage == '') {
            // force update of the used database user
            if($this->dataRecord['database_user_id']) {
                $user_old_rec = $app->db->queryOneRecord('SELECT * FROM `web_database_user` WHERE `database_user_id` = ' . $app->functions->intval($this->dataRecord['database_user_id']));
                if($user_old_rec) {
                    $user_new_rec = $user_old_rec;
                    $user_new_rec['server_id'] = $this->dataRecord['server_id'];
                    $app->db->datalogSave('web_database_user', 'UPDATE', 'database_user_id', $this->dataRecord['database_user_id'], $user_old_rec, $user_new_rec);
                }
            }
            if($this->dataRecord['database_ro_user_id']) {
                $user_old_rec = $app->db->queryOneRecord('SELECT * FROM `web_database_user` WHERE `database_user_id` = ' . $app->functions->intval($this->dataRecord['database_ro_user_id']));
                if($user_old_rec) {
                    $user_new_rec = $user_old_rec;
                    $user_new_rec['server_id'] = $this->dataRecord['server_id'];
                    $app->db->datalogSave('web_database_user', 'UPDATE', 'database_user_id', $this->dataRecord['database_ro_user_id'], $user_old_rec, $user_new_rec);
                }
            }
        }
        parent::onBeforeInsert();
    }
interface/web/sites/templates/web_domain_advanced.htm
@@ -55,27 +55,27 @@
                </div>
                <div class="ctrlHolder">
                    <label for="pm_max_children">{tmpl_var name='pm_max_children_txt'}</label>
                    <input name="pm_max_children" id="pm_max_children" value="{tmpl_var name='pm_max_children'}" size="3" maxlength="3" type="text" class="textInput formLengthLimit" />
                    <input name="pm_max_children" id="pm_max_children" value="{tmpl_var name='pm_max_children'}" size="6" maxlength="6" type="text" class="textInput formLengthLimit" />
                </div>
                <div class="ctrlHolder pm_dynamic">
                    <label for="pm_start_servers">{tmpl_var name='pm_start_servers_txt'}</label>
                    <input name="pm_start_servers" id="pm_start_servers" value="{tmpl_var name='pm_start_servers'}" size="3" maxlength="3" type="text" class="textInput formLengthLimit" />
                    <input name="pm_start_servers" id="pm_start_servers" value="{tmpl_var name='pm_start_servers'}" size="6" maxlength="6" type="text" class="textInput formLengthLimit" />
                </div>
                <div class="ctrlHolder pm_dynamic">
                    <label for="pm_min_spare_servers">{tmpl_var name='pm_min_spare_servers_txt'}</label>
                    <input name="pm_min_spare_servers" id="pm_min_spare_servers" value="{tmpl_var name='pm_min_spare_servers'}" size="3" maxlength="3" type="text" class="textInput formLengthLimit" />
                    <input name="pm_min_spare_servers" id="pm_min_spare_servers" value="{tmpl_var name='pm_min_spare_servers'}" size="6" maxlength="6" type="text" class="textInput formLengthLimit" />
                </div>
                <div class="ctrlHolder pm_dynamic">
                    <label for="pm_max_spare_servers">{tmpl_var name='pm_max_spare_servers_txt'}</label>
                    <input name="pm_max_spare_servers" id="pm_max_spare_servers" value="{tmpl_var name='pm_max_spare_servers'}" size="3" maxlength="3" type="text" class="textInput formLengthLimit" />
                    <input name="pm_max_spare_servers" id="pm_max_spare_servers" value="{tmpl_var name='pm_max_spare_servers'}" size="6" maxlength="6" type="text" class="textInput formLengthLimit" />
                </div>
                <div class="ctrlHolder pm_ondemand">
                    <label for="pm_process_idle_timeout">{tmpl_var name='pm_process_idle_timeout_txt'}</label>
                    <input name="pm_process_idle_timeout" id="pm_process_idle_timeout" value="{tmpl_var name='pm_process_idle_timeout'}" size="3" maxlength="6" type="text" class="textInput formLengthLimit" />&nbsp;s
                    <input name="pm_process_idle_timeout" id="pm_process_idle_timeout" value="{tmpl_var name='pm_process_idle_timeout'}" size="6" maxlength="6" type="text" class="textInput formLengthLimit" />&nbsp;s
                </div>
                <div class="ctrlHolder">
                    <label for="pm_max_requests">{tmpl_var name='pm_max_requests_txt'}</label>
                    <input name="pm_max_requests" id="pm_max_requests" value="{tmpl_var name='pm_max_requests'}" size="3" maxlength="6" type="text" class="textInput formLengthLimit" />
                    <input name="pm_max_requests" id="pm_max_requests" value="{tmpl_var name='pm_max_requests'}" size="6" maxlength="6" type="text" class="textInput formLengthLimit" />
                </div>
            </div>
            <div class="ctrlHolder php">
interface/web/sites/web_domain_edit.php
@@ -133,11 +133,21 @@
            } else {
                $server_id = (isset($web_servers[0])) ? intval($web_servers[0]) : 0;
            }
            if($app->functions->intval($this->dataRecord["server_id"]) > 0) {
                // check if server is in client's servers or add it.
                $chk_sid = explode(',', $client['web_servers']);
                if(in_array($this->dataRecord["server_id"], $client['web_servers']) == false) {
                    if($client['web_servers'] != '') $client['web_servers'] .= ',';
                    $client['web_servers'] .= $app->functions->intval($this->dataRecord["server_id"]);
                }
            }
            //* Fill the IPv4 select field with the IP addresses that are allowed for this client
            $sql = "SELECT ip_address FROM server_ip WHERE server_id IN (" . $client['web_servers'] . ") AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
            $ips = $app->db->queryAllRecords($sql);
            $ip_select = ($web_config['enable_ip_wildcard'] == 'y')?"<option value='*'>*</option>":"";
            //if(!in_array($this->dataRecord["ip_address"], $ips)) $ip_select .= "<option value='".$this->dataRecord["ip_address"]."' SELECTED>".$this->dataRecord["ip_address"]."</option>\r\n";
            //$ip_select = "";
            if(is_array($ips)) {
                foreach( $ips as $ip) {
@@ -234,10 +244,20 @@
            }
            $app->tpl->setVar("client_group_id", $client_select);
            if($app->functions->intval($this->dataRecord["server_id"]) > 0) {
                // check if server is in client's servers or add it.
                $chk_sid = explode(',', $client['web_servers']);
                if(in_array($this->dataRecord["server_id"], $client['web_servers']) == false) {
                    if($client['web_servers'] != '') $client['web_servers'] .= ',';
                    $client['web_servers'] .= $app->functions->intval($this->dataRecord["server_id"]);
                }
            }
            //* Fill the IPv4 select field with the IP addresses that are allowed for this client
            $sql = "SELECT ip_address FROM server_ip WHERE server_id IN (" . $client['web_servers'] . ") AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
            $ips = $app->db->queryAllRecords($sql);
            $ip_select = ($web_config['enable_ip_wildcard'] == 'y')?"<option value='*'>*</option>":"";
            //if(!in_array($this->dataRecord["ip_address"], $ips)) $ip_select .= "<option value='".$this->dataRecord["ip_address"]."' SELECTED>".$this->dataRecord["ip_address"]."</option>\r\n";
            //$ip_select = "";
            if(is_array($ips)) {
                foreach( $ips as $ip) {
server/conf/apache_apps.vhost.master
@@ -4,38 +4,46 @@
# for the ISPConfig apps vhost
######################################################
{vhost_port_listen} Listen {apps_vhost_port}
# NameVirtualHost *:{apps_vhost_port}
{tmpl_var name='vhost_port_listen'} Listen {tmpl_var name='apps_vhost_port'}
# NameVirtualHost *:{tmpl_var name='apps_vhost_port'}
<VirtualHost {apps_vhost_ip}:{apps_vhost_port}>
<VirtualHost {tmpl_var name='apps_vhost_ip'}:{tmpl_var name='apps_vhost_port'}>
  ServerAdmin webmaster@localhost
  {apps_vhost_servername}
  {tmpl_var name='apps_vhost_servername'}
  
  <FilesMatch "\.ph(p3?|tml)$">
    SetHandler None
  </FilesMatch>
  
  <IfModule mod_php5.c>
    DocumentRoot {apps_vhost_dir}
    DocumentRoot {tmpl_var name='apps_vhost_dir'}
    AddType application/x-httpd-php .php
    <Directory {apps_vhost_dir}>
      Options FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
    <Directory {tmpl_var name='apps_vhost_dir'}>
        Options FollowSymLinks
        AllowOverride None
        {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
        Require all granted
        {tmpl_else}
        Order allow,deny
        Allow from all
        {/tmpl_if}
    </Directory>
  </IfModule>
  
  <IfModule mod_fcgid.c>
    DocumentRoot {apps_vhost_dir}
    DocumentRoot {tmpl_var name='apps_vhost_dir'}
    SuexecUserGroup ispapps ispapps
    <Directory {apps_vhost_dir}>
      Options Indexes FollowSymLinks MultiViews +ExecCGI
      AllowOverride AuthConfig Indexes Limit Options FileInfo
      AddHandler fcgid-script .php
      FCGIWrapper {apps_vhost_basedir}/php-fcgi-scripts/apps/.php-fcgi-starter .php
      Order allow,deny
      Allow from all
    <Directory {tmpl_var name='apps_vhost_dir'}>
        Options Indexes FollowSymLinks MultiViews +ExecCGI
        AllowOverride AuthConfig Indexes Limit Options FileInfo
        AddHandler fcgid-script .php
        FCGIWrapper {tmpl_var name='apps_vhost_basedir'}/php-fcgi-scripts/apps/.php-fcgi-starter .php
        {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
        Require all granted
        {tmpl_else}
        Order allow,deny
        Allow from all
        {/tmpl_if}
    </Directory>
  </IfModule>
server/conf/apache_ispconfig.conf.master
@@ -8,61 +8,100 @@
<Directory /var/www/clients>
    AllowOverride None
    Order Deny,Allow
    Deny from all
    {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
    Require all deny
    {tmpl_else}
    Order Deny,Allow
    Deny from all
    {/tmpl_if}
</Directory>
# Do not allow access to the root file system of the server for security reasons
<Directory />
    AllowOverride None
    Order Deny,Allow
    Deny from all
    {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
    Require all deny
    {tmpl_else}
    Order Deny,Allow
    Deny from all
    {/tmpl_if}
</Directory>
<Directory /var/www/conf>
    AllowOverride None
    Order Deny,Allow
    Deny from all
    {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
    Require all deny
    {tmpl_else}
    Order Deny,Allow
    Deny from all
    {/tmpl_if}
</Directory>
# Except of the following directories that contain website scripts
<Directory /usr/share/phpmyadmin>
        {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
        Require all granted
        {tmpl_else}
        Order allow,deny
        Allow from all
        {/tmpl_if}
</Directory>
<Directory /usr/share/phpMyAdmin>
        {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
        Require all granted
        {tmpl_else}
        Order allow,deny
        Allow from all
        {/tmpl_if}
</Directory>
<Directory /usr/share/squirrelmail>
        {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
        Require all granted
        {tmpl_else}
        Order allow,deny
        Allow from all
        {/tmpl_if}
</Directory>
# Allow access to mailman on OpenSuSE
<Directory /usr/lib/mailman/cgi-bin>
        AllowOverride All
        order allow,deny
        allow from all
        {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
        Require all granted
        {tmpl_else}
        Order allow,deny
        Allow from all
        {/tmpl_if}
</Directory>
<Directory /usr/lib/mailman/icons>
        order allow,deny
        allow from all
        {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
        Require all granted
        {tmpl_else}
        Order allow,deny
        Allow from all
        {/tmpl_if}
</Directory>
<Directory /var/lib/mailman/archives/>
        Options +FollowSymLinks
        order allow,deny
        allow from all
        {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
        Require all granted
        {tmpl_else}
        Order allow,deny
        Allow from all
        {/tmpl_if}
</Directory>
# allow path to awstats and alias for awstats icons
<Directory /usr/share/awstats>
        {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
        Require all granted
        {tmpl_else}
        Order allow,deny
        Allow from all
        {/tmpl_if}
</Directory>
Alias /awstats-icon "/usr/share/awstats/icon"
server/conf/vhost.conf.master
@@ -1,8 +1,12 @@
<Directory {tmpl_var name='web_basedir'}/{tmpl_var name='domain'}>
        AllowOverride None
        {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
        Require all deny
        {tmpl_else}
        Order Deny,Allow
        Deny from all
        {/tmpl_if}
</Directory>
<tmpl_loop name="vhosts">
@@ -55,8 +59,12 @@
        <Directory {tmpl_var name='web_document_root_www'}>
                Options FollowSymLinks
                AllowOverride <tmpl_var name='allow_override'>
                {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
                Require all granted
                {tmpl_else}
                Order allow,deny
                Allow from all
                {/tmpl_if}
<tmpl_if name='ssi' op='==' value='y'>
                # ssi enabled
@@ -66,17 +74,25 @@
</tmpl_if>
<tmpl_if name='php' op='==' value='no'>
                <Files ~ '.php[s3-6]{0,1}$'>
                        {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
                        Require all denied
                        {tmpl_else}
                        Order allow,deny
                        Deny from all
                        Allow from none
                        {/tmpl_if}
                </Files>
</tmpl_if>
        </Directory>
        <Directory {tmpl_var name='web_document_root'}>
                Options FollowSymLinks
                AllowOverride <tmpl_var name='allow_override'>
                {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
                Require all granted
                {tmpl_else}
                Order allow,deny
                Allow from all
                {/tmpl_if}
<tmpl_if name='ssi' op='==' value='y'>
                # ssi enabled
@@ -86,9 +102,13 @@
</tmpl_if>
<tmpl_if name='php' op='==' value='no'>
                <Files ~ '.php[s3-6]{0,1}$'>
                        Order allow,deny
                        Deny from all
                        Allow from none
                    {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
                    Require all denied
                    {tmpl_else}
                    Order allow,deny
                    Deny from all
                    Allow from none
                    {/tmpl_if}
                </Files>
</tmpl_if>
        </Directory>
@@ -141,8 +161,12 @@
<tmpl_if name='cgi' op='==' value='y'>
        # cgi enabled
    <Directory {tmpl_var name='document_root'}/cgi-bin>
            {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
            Require all granted
            {tmpl_else}
            Order allow,deny
            Allow from all
            {/tmpl_if}
        </Directory>
        ScriptAlias  /cgi-bin/ <tmpl_var name='document_root'>/cgi-bin/
        AddHandler cgi-script .cgi
@@ -189,8 +213,12 @@
        Action php5-cgi /php5-cgi
        AddHandler php5-cgi .php .php3 .php4 .php5
        <Directory {tmpl_var name='cgi_starter_path'}>
                Order allow,deny
                Allow from all
            {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
            Require all granted
            {tmpl_else}
            Order allow,deny
            Allow from all
            {/tmpl_if}
        </Directory>
</tmpl_if>
<tmpl_if name='php' op='==' value='fast-cgi'>
@@ -224,23 +252,35 @@
                FCGIWrapper <tmpl_var name='fastcgi_starter_path'><tmpl_var name='fastcgi_starter_script'> .php
                Options +ExecCGI
                AllowOverride <tmpl_var name='allow_override'>
                {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
                Require all granted
                {tmpl_else}
                Order allow,deny
                Allow from all
                {/tmpl_if}
        </Directory>
        <Directory {tmpl_var name='web_document_root'}>
                AddHandler fcgid-script .php .php3 .php4 .php5
                FCGIWrapper <tmpl_var name='fastcgi_starter_path'><tmpl_var name='fastcgi_starter_script'> .php
                Options +ExecCGI
                AllowOverride <tmpl_var name='allow_override'>
                {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
                Require all granted
                {tmpl_else}
                Order allow,deny
                Allow from all
                {/tmpl_if}
        </Directory>
</tmpl_if>
<tmpl_if name='php' op='==' value='php-fpm'>
        <IfModule mod_fastcgi.c>
                <Directory {tmpl_var name='document_root'}/cgi-bin>
                        Order allow,deny
                        Allow from all
                    {tmpl_if name='apache_version' op='>' value='2.2' format='version'}
                    Require all granted
                    {tmpl_else}
                    Order allow,deny
                    Allow from all
                    {/tmpl_if}
                </Directory>
                AddHandler php5-fcgi .php
                Action php5-fcgi /php5-fcgi
server/lib/classes/system.inc.php
@@ -851,7 +851,7 @@
        //* We allow only some characters in the path
        // * is allowed, for example it is part of wildcard certificates/keys: *.example.com.crt
        if(!preg_match('@^/[-a-zA-Z0-9_/.*~]{1,}$@', $path)) return false;
        if(!preg_match('@^/[-a-zA-Z0-9_/.*]{1,}[~]?$@', $path)) return false;
        //* Check path for symlinks
        $path_parts = explode('/', $path);
@@ -1724,6 +1724,31 @@
        if(substr($init_script_directory, -1) === '/') $init_script_directory = substr($init_script_directory, 0, -1);
        return $init_script_directory.'/'.$servicename.' '.$action;
    }
    function getapacheversion($get_minor = false) {
        global $app;
        $cmd = '';
        if($this->is_installed('apache2ctl')) $cmd = 'apache2ctl -v';
        elseif($this->is_installed('apachectl')) $cmd = 'apachectl -v';
        else {
            $app->log("Could not check apache version, apachectl not found.", LOGLEVEL_WARN);
            return '2.2';
        }
        exec($cmd, $output, $return_var);
        if($return_var != 0 || !$output[0]) {
            $app->log("Could not check apache version, apachectl did not return any data.", LOGLEVEL_WARN);
            return '2.2';
        }
        if(preg_match('/version:\s*Apache\/(\d+)(\.(\d+)(\.(\d+))*)?(\D|$)/i', $output[0], $matches)) {
            return $matches[1] . (isset($matches[3]) ? '.' . $matches[3] : '') . (isset($matches[5]) && $get_minor == true ? '.' . $matches[5] : '');
        } else {
            $app->log("Could not check apache version, did not find version string in apachectl output.", LOGLEVEL_WARN);
            return '2.2';
        }
    }
}
server/lib/classes/tpl.inc.php
@@ -1109,7 +1109,7 @@
         * @access private
         * @return string used for eval'ing
         */
        function _parseIf ($varname, $value=null, $op=null, $namespace=null) {
        function _parseIf ($varname, $value=null, $op=null, $namespace=null, $format=null) {
            if (isset($namespace)) $namespace = substr($namespace, 0, -1);
            $comp_str = ''; // used for extended if statements
@@ -1151,10 +1151,19 @@
                }
            }
            if ($this->OPTIONS['GLOBAL_VARS'] && empty($namespace)) {
                return '(('.$retstr.'[\''.$varname.'\'] !== null) ? '.$retstr.'[\''.$varname.'\'] : $this->_vars[\''.$varname.'\'])'.$comp_str;
                $retstr = '(('.$retstr.'[\''.$varname.'\'] !== null) ? '.$retstr.'[\''.$varname.'\'] : $this->_vars[\''.$varname.'\'])';
                if(isset($format) && isset($value) && $format == 'version') {
                    return 'version_compare(' . $retstr . ', \'' . $value . '\', ' . (!empty($op) ? $op : '==') . ')';
                } else {
                    return $retstr.$comp_str;
                }
            }
            else {
                return $retstr."['".$varname."']".$comp_str;
                if(isset($format) && isset($value) && $format == 'version') {
                    return 'version_compare(' . $retstr."['".$varname."']" . ', \'' . $value . '\', ' . (!empty($op) ? $op : '==') . ')';
                } else {
                    return $retstr."['".$varname."']".$comp_str;
                }
            }
        }
@@ -1330,15 +1339,15 @@
                break;
            case 'if':
                return '<?php if ('. $this->_parseIf($var, @$value, @$op, @$namespace) .') { ?>'.$newline;
                return '<?php if ('. $this->_parseIf($var, @$value, @$op, @$namespace, @$format) .') { ?>'.$newline;
                break;
            case 'unless':
                return '<?php if (!'. $this->_parseIf($var, @$value, @$op, @$namespace) .') { ?>'.$newline;
                return '<?php if (!'. $this->_parseIf($var, @$value, @$op, @$namespace, @$format) .') { ?>'.$newline;
                break;
            case 'elseif':
                return '<?php } elseif ('. $this->_parseIf($var, @$value, @$op, @$namespace) .') { ?>'.$newline;
                return '<?php } elseif ('. $this->_parseIf($var, @$value, @$op, @$namespace, @$format) .') { ?>'.$newline;
                break;
            case 'loop':
server/plugins-available/apache2_plugin.inc.php
@@ -1019,6 +1019,7 @@
        }
        $tpl->setVar($vhost_data);
        $tpl->setVar('apache_version', $app->system->getapacheversion());
        // Rewrite rules
        $rewrite_rules = array();
@@ -1225,6 +1226,7 @@
            $fcgi_tpl = new tpl();
            $fcgi_tpl->newTemplate('php-fcgi-starter.master');
            $fcgi_tpl->setVar('apache_version', $app->system->getapacheversion());
            // Support for multiple PHP versions (FastCGI)
            if(trim($data['new']['fastcgi_php_version']) != ''){
@@ -1364,6 +1366,7 @@
            $cgi_tpl = new tpl();
            $cgi_tpl->newTemplate('php-cgi-starter.master');
            $cgi_tpl->setVar('apache_version', $app->system->getapacheversion());
            // This works because PHP "rewrites" a symlink to the physical path
            $php_open_basedir = ($data['new']['php_open_basedir'] == '')?$data['new']['document_root']:$data['new']['php_open_basedir'];
@@ -2028,6 +2031,7 @@
        $tpl = new tpl();
        $tpl->newTemplate('apache_ispconfig.conf.master');
        $tpl->setVar('apache_version', $app->system->getapacheversion());
        $records = $app->db->queryAllRecords('SELECT * FROM server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'");
        $records_out= array();
@@ -2737,7 +2741,8 @@
        $app->load('tpl');
        $tpl = new tpl();
        $tpl->newTemplate('php_fpm_pool.conf.master');
        $tpl->setVar('apache_version', $app->system->getapacheversion());
        if($data['new']['php_fpm_use_socket'] == 'y'){
            $use_tcp = 0;
            $use_socket = 1;
server/plugins-available/apps_vhost_plugin.inc.php
@@ -80,13 +80,12 @@
        $web_config = $app->getconf->get_server_config($conf["server_id"], 'web');
        if($web_config['server_type'] == 'apache'){
            // Dont just copy over the virtualhost template but add some custom settings
            if(file_exists($conf["rootpath"]."/conf-custom/apache_apps.vhost.master")) {
                $content = file_get_contents($conf["rootpath"]."/conf-custom/apache_apps.vhost.master");
            } else {
                $content = file_get_contents($conf["rootpath"]."/conf/apache_apps.vhost.master");
            }
            $app->load('tpl');
            $tpl = new tpl();
            $tpl->newTemplate('apache_apps.vhost.master');
            $tpl->setVar('apache_version', $app->system->getapacheversion());
            $vhost_conf_dir = $web_config['vhost_conf_dir'];
            $vhost_conf_enabled_dir = $web_config['vhost_conf_enabled_dir'];
@@ -95,21 +94,31 @@
            $web_config['apps_vhost_port'] = (empty($web_config['apps_vhost_port']))?8081:$web_config['apps_vhost_port'];
            $web_config['apps_vhost_ip'] = (empty($web_config['apps_vhost_ip']))?'_default_':$web_config['apps_vhost_ip'];
            $tpl->setVar('apps_vhost_ip', $web_config['apps_vhost_ip']);
            $tpl->setVar('apps_vhost_port', $web_config['apps_vhost_port']);
            $tpl->setVar('apps_vhost_dir', $web_config['website_basedir'].'/apps');
            $tpl->setVar('apps_vhost_servername', $apps_vhost_servername);
            $tpl->setVar('apps_vhost_basedir', $web_config['website_basedir']);
            $vhost_port_listen = '';
            // comment out the listen directive if port is 80 or 443
            if($web_config['apps_vhost_port'] == 80 or $web_config['apps_vhost_port'] == 443) {
                $vhost_port_listen = '#';
            }
            $tpl->setVar('vhost_port_listen', $vhost_port_listen);
            $content = $tpl->grab();
            /* for backwards compatibility we replace the old syntax by hand now */
            $content = str_replace('{apps_vhost_ip}', $web_config['apps_vhost_ip'], $content);
            $content = str_replace('{apps_vhost_port}', $web_config['apps_vhost_port'], $content);
            $content = str_replace('{apps_vhost_dir}', $web_config['website_basedir'].'/apps', $content);
            $content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
            $content = str_replace('{apps_vhost_basedir}', $web_config['website_basedir'], $content);
            $content = str_replace('{vhost_port_listen}', $vhost_port_listen, $content);
            /* end of backwards compatibility section */
            // comment out the listen directive if port is 80 or 443
            if($web_config['apps_vhost_port'] == 80 or $web_config['apps_vhost_port'] == 443) {
                $content = str_replace('{vhost_port_listen}', '#', $content);
            } else {
                $content = str_replace('{vhost_port_listen}', '', $content);
            }
            file_put_contents("$vhost_conf_dir/apps.vhost", $content);
            $app->system->file_put_contents("$vhost_conf_dir/apps.vhost", $content);
            $app->services->restartServiceDelayed('httpd', 'restart');
        }
server/plugins-available/maildeliver_plugin.inc.php
@@ -208,8 +208,9 @@
            if ( ! is_dir($data["new"]["maildir"].'/sieve/') ) {
                $app->system->mkdirpath($data["new"]["maildir"].'/sieve/', 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']);
            }
            file_put_contents($sieve_file, $tpl->grab());
            exec('chown '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($sieve_file));
            file_put_contents($sieve_file_isp, $tpl->grab());
            chown($sieve_file_isp,$mail_config['mailuser_name']);
            chgrp($sieve_file_isp,$mail_config['mailuser_group']);
            chdir($data["new"]["maildir"]);