tbrehm
2007-07-03 4fae7e24eb4a3d3dd5cd3eeaa97d6fef97426547
Added limits for websites and FTP users.
10 files modified
256 ■■■■ changed files
interface/web/client/form/client.tform.php 67 ●●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/en_client.lng 6 ●●●●● patch | view | raw | blame | history
interface/web/client/templates/client_edit_limits.htm 27 ●●●●● patch | view | raw | blame | history
interface/web/sites/ftp_user_edit.php 21 ●●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/en_ftp_user.lng 1 ●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/en_web_domain.lng 47 ●●●● patch | view | raw | blame | history
interface/web/sites/web_aliasdomain_edit.php 22 ●●●●● patch | view | raw | blame | history
interface/web/sites/web_domain_edit.php 38 ●●●● patch | view | raw | blame | history
interface/web/sites/web_subdomain_edit.php 23 ●●●●● patch | view | raw | blame | history
server/plugins-enabled/apache2_plugin.inc.php 4 ●●●● patch | view | raw | blame | history
interface/web/client/form/client.tform.php
@@ -459,6 +459,73 @@
            'rows'        => '',
            'cols'        => ''
        ),
        'default_webserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_web_domain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_domain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_aliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_aliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_subdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_subdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_ftp_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_ftp_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # END Datatable fields
    ##################################
interface/web/client/lib/lang/en_client.lng
@@ -45,4 +45,10 @@
$wb["limit_client_error_notint"] = 'Client Limit is not a number.';
$wb["firstname_error_empty"] = 'Firstname is empty.';
$wb["contact_error_empty"] = 'Contact name is empty.';
$wb["default_webserver_txt"] = 'Default Webserver';
$wb["limit_web_domain_txt"] = 'Max. number of web domains';
$wb["limit_web_aliasdomain_txt"] = 'Max. number of web aliasdomains';
$wb["limit_web_subdomain_txt"] = 'Max. number of web subdomains';
$wb["limit_ftp_user_txt"] = 'Max. number of FTP users';
?>
interface/web/client/templates/client_edit_limits.htm
@@ -64,6 +64,33 @@
    <td class="frmText11"><input name="limit_spamfilter_policy" type="text" class="text" value="{tmpl_var name='limit_spamfilter_policy'}" size="10" maxlength="10"></td>
  </tr>
  <tr>
    <td><h2>Websites</h2></td>
  </tr>
  <tr>
    <td class="frmText11">{tmpl_var name='default_webserver_txt'}:</td>
    <td class="frmText11">
        <select name="default_webserver" class="text">
            {tmpl_var name='default_webserver'}
        </select>
    </td>
  </tr>
  <tr>
    <td class="frmText11" width="280">{tmpl_var name='limit_web_domain_txt'}:</td>
    <td class="frmText11" width="220"><input name="limit_web_domain" type="text" class="text" value="{tmpl_var name='limit_web_domain'}" size="10" maxlength="10"></td>
  </tr>
  <tr>
    <td class="frmText11" width="280">{tmpl_var name='limit_web_subdomain_txt'}:</td>
    <td class="frmText11" width="220"><input name="limit_web_subdomain" type="text" class="text" value="{tmpl_var name='limit_web_subdomain'}" size="10" maxlength="10"></td>
  </tr>
  <tr>
    <td class="frmText11" width="280">{tmpl_var name='limit_web_aliasdomain_txt'}:</td>
    <td class="frmText11" width="220"><input name="limit_web_aliasdomain" type="text" class="text" value="{tmpl_var name='limit_web_aliasdomain'}" size="10" maxlength="10"></td>
  </tr>
  <tr>
    <td class="frmText11" width="280">{tmpl_var name='limit_ftp_user_txt'}:</td>
    <td class="frmText11" width="220"><input name="limit_ftp_user" type="text" class="text" value="{tmpl_var name='limit_ftp_user'}" size="10" maxlength="10"></td>
  </tr>
  <tr>
    <td class="frmText11">&nbsp;</td>
    <td class="frmText11">&nbsp;</td>
  </tr>
interface/web/sites/ftp_user_edit.php
@@ -53,6 +53,27 @@
class page_action extends tform_actions {
    
    function onShowNew() {
        global $app, $conf;
        // we will check only users, not admins
        if($_SESSION["s"]["user"]["typ"] == 'user') {
            // Get the limits of the client
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT limit_ftp_user FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
            // Check if the user may add another maildomain.
            if($client["limit_ftp_user"] >= 0) {
                $tmp = $app->db->queryOneRecord("SELECT count(ftp_user_id) as number FROM ftp_user WHERE sys_groupid = $client_group_id");
                if($tmp["number"] >= $client["limit_ftp_user"]) {
                    $app->error($app->tform->wordbook["limit_ftp_user_txt"]);
                }
            }
        }
        parent::onShowNew();
    }
    
    function onAfterInsert() {
        global $app, $conf;
interface/web/sites/lib/lang/en_ftp_user.lng
@@ -15,4 +15,5 @@
$wb["password_txt"] = 'Password';
$wb["quota_size_txt"] = 'Harddisk-Quota';
$wb["active_txt"] = 'Active';
$wb["limit_ftp_user_txt"] = 'The max. number of FTP users for your account is reached.';
?>
interface/web/sites/lib/lang/en_web_domain.lng
@@ -1,23 +1,26 @@
<?php
$wb["server_id_txt"] = 'Server';
$wb["domain_txt"] = 'Domain';
$wb["type_txt"] = 'Type';
$wb["parent_domain_id_txt"] = 'Parent Website';
$wb["redirect_type_txt"] = 'Redirect Type';
$wb["redirect_path_txt"] = 'Redirect Path';
$wb["active_txt"] = 'Active';
$wb["btn_save_txt"] = 'Save';
$wb["btn_cancel_txt"] = 'Cancel';
$wb["document_root_txt"] = 'Documentroot';
$wb["system_user_txt"] = 'Linux User';
$wb["system_group_txt"] = 'Linux Group';
$wb["ip_address_txt"] = 'IP-Address';
$wb["vhost_type_txt"] = 'VHost Type';
$wb["hd_quota_txt"] = 'Harddisk Quota';
$wb["traffic_quota_txt"] = 'Traffic Quaota';
$wb["cgi_txt"] = 'CGI';
$wb["ssi_txt"] = 'SSI';
$wb["suexec_txt"] = 'SuEXEC';
$wb["php_txt"] = 'PHP';
$wb["client_txt"] = 'Client';
<?php
$wb["server_id_txt"] = 'Server';
$wb["domain_txt"] = 'Domain';
$wb["type_txt"] = 'Type';
$wb["parent_domain_id_txt"] = 'Parent Website';
$wb["redirect_type_txt"] = 'Redirect Type';
$wb["redirect_path_txt"] = 'Redirect Path';
$wb["active_txt"] = 'Active';
$wb["btn_save_txt"] = 'Save';
$wb["btn_cancel_txt"] = 'Cancel';
$wb["document_root_txt"] = 'Documentroot';
$wb["system_user_txt"] = 'Linux User';
$wb["system_group_txt"] = 'Linux Group';
$wb["ip_address_txt"] = 'IP-Address';
$wb["vhost_type_txt"] = 'VHost Type';
$wb["hd_quota_txt"] = 'Harddisk Quota';
$wb["traffic_quota_txt"] = 'Traffic Quaota';
$wb["cgi_txt"] = 'CGI';
$wb["ssi_txt"] = 'SSI';
$wb["suexec_txt"] = 'SuEXEC';
$wb["php_txt"] = 'PHP';
$wb["client_txt"] = 'Client';
$wb["limit_web_domain_txt"] = 'The max. number of web domains for your account is reached.';
$wb["limit_web_aliasdomain_txt"] = 'The max. number of aliasdomains for your account is reached.';
$wb["limit_web_subdomain_txt"] = 'The max. number of web subdomains for your account is reached.';
?>
interface/web/sites/web_aliasdomain_edit.php
@@ -53,6 +53,28 @@
class page_action extends tform_actions {
    
    function onShowNew() {
        global $app, $conf;
        // we will check only users, not admins
        if($_SESSION["s"]["user"]["typ"] == 'user') {
            // Get the limits of the client
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT limit_web_aliasdomain FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
            // Check if the user may add another maildomain.
            if($client["limit_web_aliasdomain"] >= 0) {
                $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = $client_group_id and type = 'alias'");
                if($tmp["number"] >= $client["limit_web_aliasdomain"]) {
                    $app->error($app->tform->wordbook["limit_web_aliasdomain_txt"]);
                }
            }
        }
        parent::onShowNew();
    }
    /*
    function onShowEnd() {
        global $app, $conf;
interface/web/sites/web_domain_edit.php
@@ -53,6 +53,28 @@
class page_action extends tform_actions {
    function onShowNew() {
        global $app, $conf;
        // we will check only users, not admins
        if($_SESSION["s"]["user"]["typ"] == 'user') {
            // Get the limits of the client
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT limit_web_domain FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
            // Check if the user may add another maildomain.
            if($client["limit_web_domain"] >= 0) {
                $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = $client_group_id and type = 'vhost'");
                if($tmp["number"] >= $client["limit_web_domain"]) {
                    $app->error($app->tform->wordbook["limit_web_domain_txt"]);
                }
            }
        }
        parent::onShowNew();
    }
    function onShowEnd() {
        global $app, $conf;
        
@@ -123,7 +145,7 @@
        if($_SESSION["s"]["user"]["typ"] != 'admin') {
            // Get the limits of the client
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT limit_maildomain, default_mailserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
            $client = $app->db->queryOneRecord("SELECT limit_web_domain, default_webserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
            
            // When the record is updated
            if($this->id > 0) {
@@ -136,15 +158,15 @@
                // set the server ID to the default mailserver of the client
                $this->dataRecord["server_id"] = $client["default_webserver"];
                
                /*
                // Check if the user may add another mail_domain
                if($client["limit_maildomain"] >= 0) {
                    $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM mail_domain WHERE sys_groupid = $client_group_id");
                    if($tmp["number"] >= $client["limit_maildomain"]) {
                        $app->error($app->tform->wordbook["limit_webdomain_txt"]);
                // Check if the user may add another web_domain
                if($client["limit_web_domain"] >= 0) {
                    $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = $client_group_id and type = 'vhost'");
                    if($tmp["number"] >= $client["limit_web_domain"]) {
                        $app->error($app->tform->wordbook["limit_web_domain_txt"]);
                    }
                }
                */
            }
            
            // Clients may not set the client_group_id, so we unset them if user is not a admin
interface/web/sites/web_subdomain_edit.php
@@ -53,12 +53,35 @@
class page_action extends tform_actions {
    
    function onShowNew() {
        global $app, $conf;
        // we will check only users, not admins
        if($_SESSION["s"]["user"]["typ"] == 'user') {
            // Get the limits of the client
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT limit_web_subdomain FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
            // Check if the user may add another maildomain.
            if($client["limit_web_subdomain"] >= 0) {
                $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = $client_group_id and type = 'subdomain'");
                if($tmp["number"] >= $client["limit_web_subdomain"]) {
                    $app->error($app->tform->wordbook["limit_web_subdomain_txt"]);
                }
            }
        }
        parent::onShowNew();
    }
    function onShowEnd() {
        global $app, $conf;
        
        // Get the record of the parent domain
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".intval($this->dataRecord["parent_domain_id"]));
        
        // remove the parent domain part of the domain name before we show it in the text field.
        $this->dataRecord["domain"] = str_replace('.'.$parent_domain["domain"],'',$this->dataRecord["domain"]);
        $app->tpl->setVar("domain",$this->dataRecord["domain"]);
        
server/plugins-enabled/apache2_plugin.inc.php
@@ -68,7 +68,7 @@
        if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) {
            // This is not a vhost, so we need to update the parent record instead.
            $parent_domain_id = intval($data["new"]["parent_domain_id"]);
            $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$parent_domain_id);
            $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$parent_domain_id." AND active = 'y'");
            $data["new"] = $tmp;
            $data["old"] = $tmp;
        }
@@ -150,7 +150,7 @@
        }
        
        // get alias domains (co-domains and subdomains)
        $aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$data["new"]["domain_id"]);
        $aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$data["new"]["domain_id"]." AND active = 'y'");
        $server_alias = '';
        if(is_array($aliases)) {
            foreach($aliases as $alias) {