Exemple #1
0
 function onShowEnd()
 {
     global $app, $conf, $wb;
     if ($_SESSION["s"]["user"]["typ"] == 'admin') {
         // Getting Clients of the user
         $sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0 ORDER BY name";
         $clients = $app->db->queryAllRecords($sql);
         $client_select = '';
         if ($_SESSION["s"]["user"]["typ"] == 'admin') {
             $client_select .= "<option value='0'></option>";
         }
         $tmp_data_record = $app->tform->getDataRecord($this->id);
         if (is_array($clients)) {
             foreach ($clients as $client) {
                 $selected = $client["groupid"] == $tmp_data_record["sys_groupid"] ? 'SELECTED' : '';
                 $client_select .= "<option value='{$client['groupid']}' {$selected}>{$client['name']}</option>\r\n";
             }
         }
         $app->tpl->setVar("client_group_id", $client_select);
     }
     if ($this->id > 0) {
         //* we are editing a existing record
         $app->tpl->setVar("edit_disabled", 1);
     } else {
         $app->tpl->setVar("edit_disabled", 0);
     }
     $app->tpl->setVar($wb);
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf;
     $rec = $app->tform->getDataRecord($_SESSION['s']['user']['mailuser_id']);
     $app->tpl->setVar("email", $rec['email']);
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf;
     $rec = $app->tform->getDataRecord($this->id);
     $app->tpl->setVar("email", $rec['email']);
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf;
     // Getting email from data record
     $email = $this->dataRecord["email"];
     $email_parts = explode("@", $email);
     $app->tpl->setVar("email_local_part", $email_parts[0]);
     // Getting Domains of the user
     $sql = "SELECT domain FROM mail_domain WHERE type = 'local' AND " . $app->tform->getAuthSQL('r');
     $domains = $app->db->queryAllRecords($sql);
     $domain_select = '';
     foreach ($domains as $domain) {
         $selected = $domain["domain"] == $email_parts[1] ? 'SELECTED' : '';
         $domain_select .= "<option value='{$domain['domain']}' {$selected}>{$domain['domain']}</option>\r\n";
     }
     $app->tpl->setVar("email_domain", $domain_select);
     // calculate scores
     if (count($this->dataRecord) > 0) {
         $app->tpl->setVar("spam_rewrite_score_int", number_format($this->dataRecord["spam_rewrite_score_int"] / 100, 2, '.', ''));
         $app->tpl->setVar("spam_redirect_score_int", number_format($this->dataRecord["spam_redirect_score_int"] / 100, 2, '.', ''));
         $app->tpl->setVar("spam_delete_score_int", number_format($this->dataRecord["spam_delete_score_int"] / 100, 2, '.', ''));
     }
     // Changing maildir to mailbox_id
     $sql = "SELECT mailbox_id FROM mail_box WHERE maildir = '" . $this->dataRecord["spam_redirect_maildir"] . "' AND " . $app->tform->getAuthSQL('r');
     $mailbox = $app->db->queryOneRecord($sql);
     $this->dataRecord["spam_redirect_maildir"] = $mailbox["mailbox_id"];
     parent::onShowEnd();
 }
 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"]);
     parent::onShowEnd();
 }
Exemple #6
0
 function onShowEnd()
 {
     global $app, $conf;
     // Split the 3 parts of the SRV Record apart
     $split = explode(' ', $this->dataRecord['data']);
     $app->tpl->setVar('weight', $split[0]);
     $app->tpl->setVar('port', $split[1]);
     $app->tpl->setVar('target', $split[2]);
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app;
     // Is autoresponder set?
     if ($this->dataRecord['autoresponder'] == 'y') {
         $app->tpl->setVar("ar_active", 'checked="checked"');
     } else {
         $app->tpl->setVar("ar_active", '');
     }
     parent::onShowEnd();
 }
Exemple #8
0
 function onShowEnd()
 {
     global $app, $conf;
     if ($this->id > 0) {
         //* we are editing a existing record
         $app->tpl->setVar("edit_disabled", 1);
         $app->tpl->setVar("parent_domain_id_value", $this->dataRecord["parent_domain_id"]);
     } else {
         $app->tpl->setVar("edit_disabled", 0);
     }
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf;
     // Split the 3 parts of the SRV Record apart
     $split = explode(' ', $this->dataRecord['data']);
     // Weight
     $this->dataRecord['weight'] = $split[0];
     // Port
     $this->dataRecord['port'] = $split[1];
     // Target
     $this->dataRecord['target'] = $split[2];
     // Bind the new datarecord to the template
     $app->tpl->setVar($this->dataRecord);
     parent::onShowEnd();
 }
Exemple #10
0
 function onShowEnd()
 {
     global $app, $conf;
     // Getting Servers
     $sql = "SELECT server_id,server_name FROM server WHERE server_id != " . $app->functions->intval($this->id) . " ORDER BY server_name";
     $mirror_servers = $app->db->queryAllRecords($sql);
     $mirror_server_select = '<option value="0">' . $app->tform->lng('- None -') . '</option>';
     if (is_array($mirror_servers)) {
         foreach ($mirror_servers as $mirror_server) {
             $selected = $mirror_server["server_id"] == $this->dataRecord['mirror_server_id'] ? 'SELECTED' : '';
             $mirror_server_select .= "<option value='{$mirror_server['server_id']}' {$selected}>{$mirror_server['server_name']}</option>\r\n";
         }
     }
     $app->tpl->setVar("mirror_server_id", $mirror_server_select);
     parent::onShowEnd();
 }
Exemple #11
0
 function onShowEnd()
 {
     global $app, $conf, $interfaceConf;
     /*
      * If the names are restricted -> remove the restriction, so that the
      * data can be edited
      */
     $app->uses('getconf,tools_sites');
     $global_config = $app->getconf->get_global_config('sites');
     $ftpuser_prefix = $app->tools_sites->replacePrefix($global_config['ftpuser_prefix'], $this->dataRecord);
     if ($this->dataRecord['username'] != "") {
         /* REMOVE the restriction */
         $app->tpl->setVar("username", $app->tools_sites->removePrefix($this->dataRecord['username'], $this->dataRecord['username_prefix'], $ftpuser_prefix));
     }
     $app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $ftpuser_prefix, $global_config['ftpuser_prefix']));
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf;
     // available dashlets
     $available_dashlets_txt = '';
     $handle = @opendir(ISPC_WEB_PATH . '/dashboard/dashlets');
     while ($file = @readdir($handle)) {
         if ($file != '.' && $file != '..' && !is_dir($file)) {
             $available_dashlets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">[' . substr($file, 0, -4) . ']<pre class="addPlaceholderContent" style="display:none;">[' . substr($file, 0, -4) . '],</pre></a> ';
         }
     }
     if ($available_dashlets_txt == '') {
         $available_dashlets_txt = '------';
     }
     $app->tpl->setVar("available_dashlets_txt", $available_dashlets_txt);
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf;
     $email = $this->dataRecord["source"];
     $email_parts = explode("@", $email);
     $app->tpl->setVar("email_local_part", $email_parts[0]);
     // Getting Domains of the user
     $sql = "SELECT domain FROM mail_domain WHERE " . $app->tform->getAuthSQL('r') . ' ORDER BY domain';
     $domains = $app->db->queryAllRecords($sql);
     $domain_select = '';
     foreach ($domains as $domain) {
         $selected = isset($email_parts[1]) && $domain["domain"] == $email_parts[1] ? 'SELECTED' : '';
         $domain_select .= "<option value='{$domain['domain']}' {$selected}>{$domain['domain']}</option>\r\n";
     }
     $app->tpl->setVar("email_domain", $domain_select);
     parent::onShowEnd();
 }
 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();
 }
Exemple #15
0
 function onShowEnd()
 {
     global $app, $conf, $interfaceConf;
     /*
      * If the names are restricted -> remove the restriction, so that the
      * data can be edited
      */
     $app->uses('getconf');
     $global_config = $app->getconf->get_global_config('sites');
     // $ftpuser_prefix = ($global_config['ftpuser_prefix'] == '')?'':str_replace('[CLIENTNAME]', $this->getClientName(), $global_config['ftpuser_prefix']);
     $ftpuser_prefix = replacePrefix($global_config['ftpuser_prefix'], $this->dataRecord);
     if ($this->dataRecord['username'] != "") {
         /* REMOVE the restriction */
         $app->tpl->setVar("username", preg_replace('/' . $ftpuser_prefix . '/', '', $this->dataRecord['username'], 1));
     }
     if ($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
         $app->tpl->setVar("username_prefix", $global_config['ftpuser_prefix']);
     } else {
         $app->tpl->setVar("username_prefix", $ftpuser_prefix);
     }
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf;
     $email = $this->dataRecord["source"];
     $email_parts = explode("@", $email);
     $app->tpl->setVar("email_local_part", $email_parts[0]);
     $email_parts[1] = $app->functions->idn_decode($email_parts[1]);
     // Getting Domains of the user
     // $sql = "SELECT domain FROM mail_domain WHERE ".$app->tform->getAuthSQL('r').' ORDER BY domain';
     $sql = "SELECT domain FROM mail_domain WHERE domain NOT IN (SELECT SUBSTR(source,2) FROM mail_forwarding WHERE type = 'aliasdomain') AND " . $app->tform->getAuthSQL('r') . " ORDER BY domain";
     $domains = $app->db->queryAllRecords($sql);
     $domain_select = '';
     if (is_array($domains)) {
         foreach ($domains as $domain) {
             $domain['domain'] = $app->functions->idn_decode($domain['domain']);
             $selected = $domain["domain"] == @$email_parts[1] ? 'SELECTED' : '';
             $domain_select .= "<option value='{$domain['domain']}' {$selected}>{$domain['domain']}</option>\r\n";
         }
     }
     $app->tpl->setVar("email_domain", $domain_select);
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf;
     $source_domain = substr($this->dataRecord["source"], 1);
     $destination_domain = substr($this->dataRecord["destination"], 1);
     // Getting Domains of the user
     $sql = "SELECT domain FROM mail_domain WHERE " . $app->tform->getAuthSQL('r') . ' ORDER BY domain';
     $domains = $app->db->queryAllRecords($sql);
     $source_select = '';
     $destination_select = '';
     if (is_array($domains)) {
         foreach ($domains as $domain) {
             $selected = $domain["domain"] == @$source_domain ? 'SELECTED' : '';
             $source_select .= "<option value='{$domain['domain']}' {$selected}>{$domain['domain']}</option>\r\n";
             $selected = $domain["domain"] == @$destination_domain ? 'SELECTED' : '';
             $destination_select .= "<option value='{$domain['domain']}' {$selected}>{$domain['domain']}</option>\r\n";
         }
     }
     $app->tpl->setVar("source_domain", $source_select);
     $app->tpl->setVar("destination_domain", $destination_select);
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf, $interfaceConf;
     /*
      * If the names are restricted -> remove the restriction, so that the
      * data can be edited
      */
     $app->uses('getconf,tools_sites');
     $global_config = $app->getconf->get_global_config('sites');
     $shelluser_prefix = $app->tools_sites->replacePrefix($global_config['shelluser_prefix'], $this->dataRecord);
     if ($this->dataRecord['username'] != "") {
         /* REMOVE the restriction */
         $app->tpl->setVar("username", $app->tools_sites->removePrefix($this->dataRecord['username'], $this->dataRecord['username_prefix'], $shelluser_prefix));
     }
     $app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $shelluser_prefix, $global_config['shelluser_prefix']));
     if ($this->id > 0) {
         //* we are editing a existing record
         $app->tpl->setVar("edit_disabled", 1);
         $app->tpl->setVar("parent_domain_id_value", $this->dataRecord["parent_domain_id"]);
     } else {
         $app->tpl->setVar("edit_disabled", 0);
     }
     parent::onShowEnd();
 }
Exemple #19
0
 function onShowEnd()
 {
     global $app;
     $sql = "SELECT template_id,template_name FROM client_template WHERE template_type = 'a' ORDER BY template_name ASC";
     $tpls = $app->db->queryAllRecords($sql);
     $option = '';
     $tpl = array();
     foreach ($tpls as $item) {
         $option .= '<option value="' . $item['template_id'] . '|' . $item['template_name'] . '">' . $item['template_name'] . '</option>';
         $tpl[$item['template_id']] = $item['template_name'];
     }
     $app->tpl->setVar('tpl_add_select', $option);
     // check for new-style records
     $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']];
                 $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;
         $result = $app->db->queryOneRecord($sql);
         $tplAdd = explode("/", $result['template_additional']);
         $text = '';
         foreach ($tplAdd as $item) {
             if (trim($item) != '') {
                 if ($text != '') {
                     $text .= '';
                 }
                 $text .= '<li>' . $tpl[$item] . '<a href="#" class="button icons16 icoDelete"></a></li>';
             }
         }
     }
     $app->tpl->setVar('template_additional_list', $text);
     $app->tpl->setVar('app_module', 'client');
     //* Set the 'customer no' default value
     if ($this->id == 0) {
         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'] != '') {
                 //* Set customer no default
                 $customer_no = $app->functions->intval($system_config['misc']['customer_no_start'] + $system_config['misc']['customer_no_counter']);
                 $customer_no_string = str_replace('[CUSTOMER_NO]', $customer_no, $system_config['misc']['customer_no_template']);
                 $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
             //* 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'] != '') {
                 //* Set customer no default
                 $customer_no = $app->functions->intval($reseller['customer_no_start'] + $reseller['customer_no_counter']);
                 $customer_no_string = str_replace('[CUSTOMER_NO]', $customer_no, $reseller['customer_no_template']);
                 $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 client.company_name, client.contact_name, 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();
 }
Exemple #20
0
 function onShowEnd()
 {
     global $app;
     $sql = "SELECT template_id,template_name FROM client_template WHERE template_type = 'a'";
     $tpls = $app->db->queryAllRecords($sql);
     $option = '';
     $tpl = array();
     foreach ($tpls as $item) {
         $option .= '<option value="' . $item['template_id'] . '|' . $item['template_name'] . '">' . $item['template_name'] . '</option>';
         $tpl[$item['template_id']] = $item['template_name'];
     }
     $app->tpl->setVar('tpl_add_select', $option);
     $sql = "SELECT template_additional FROM client WHERE client_id = " . $this->id;
     $result = $app->db->queryOneRecord($sql);
     $tplAdd = explode("/", $result['template_additional']);
     $text = '';
     foreach ($tplAdd as $item) {
         if (trim($item) != '') {
             if ($text != '') {
                 $text .= '<br />';
             }
             $text .= $tpl[$item];
         }
     }
     $app->tpl->setVar('template_additional_list', $text);
     $app->tpl->setVar('app_module', 'client');
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf;
     /*
      * Now we have to check, if we should use the domain-module to select the domain
      * or not
      */
     $app->uses('ini_parser,getconf');
     $settings = $app->getconf->get_global_config('domains');
     if ($settings['use_domain_module'] == 'y') {
         /*
          * The domain-module is in use.
          */
         $domains = $app->tools_sites->getDomainModuleDomains();
         $domain_select = '';
         if (is_array($domains) && sizeof($domains) > 0) {
             /* We have domains in the list, so create the drop-down-list */
             foreach ($domains as $domain) {
                 $domain_select .= "<option value=" . $domain['domain_id'];
                 if ($domain['domain'] == $this->dataRecord["domain"]) {
                     $domain_select .= " selected";
                 }
                 $domain_select .= ">" . $app->functions->idn_decode($domain['domain']) . "</option>\r\n";
             }
         } else {
             /*
              * We have no domains in the domain-list. This means, we can not add ANY new domain.
              * To avoid, that the variable "domain_option" is empty and so the user can
              * free enter a domain, we have to create a empty option!
              */
             $domain_select .= "<option value=''></option>\r\n";
         }
         $app->tpl->setVar("domain_option", $domain_select);
     }
     if ($_SESSION["s"]["user"]["typ"] == 'admin') {
         // Directive Snippets
         $proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y'");
         $proxy_directive_snippets_txt = '';
         if (is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)) {
             foreach ($proxy_directive_snippets as $proxy_directive_snippet) {
                 $proxy_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">[' . $proxy_directive_snippet['name'] . ']<pre class="addPlaceholderContent" style="display:none;">' . $proxy_directive_snippet['snippet'] . '</pre></a> ';
             }
         }
         if ($proxy_directive_snippets_txt == '') {
             $proxy_directive_snippets_txt = '------';
         }
         $app->tpl->setVar("proxy_directive_snippets_txt", $proxy_directive_snippets_txt);
     }
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf;
     $app->uses('ini_parser,getconf');
     $read_limits = array('limit_cgi', 'limit_ssi', 'limit_perl', 'limit_ruby', 'limit_python', 'force_suexec', 'limit_hterror', 'limit_wildcard', 'limit_ssl');
     //* Client: If the logged in user is not admin and has no sub clients (no reseller)
     if ($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
         // Get the limits of the client
         $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
         $client = $app->db->queryOneRecord("SELECT client.limit_web_domain, client.default_webserver, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = {$client_group_id}");
         //* Get global web config
         $web_config = $app->getconf->get_server_config($client['default_webserver'], 'web');
         // Set the webserver to the default server of the client
         $tmp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = " . intval($client['default_webserver']));
         $app->tpl->setVar("server_id", "<option value='{$client['default_webserver']}'>{$tmp['server_name']}</option>");
         unset($tmp);
         //* Fill the IPv4 select field with the IP addresses that are allowed for this client; if website was created on a different server (e.g. by admin), display IP addresses from that server - otherwise IP will be changed to * if user changes the tab
         $sql = "SELECT ip_address FROM server_ip WHERE server_id = " . ($app->functions->intval($this->dataRecord["server_id"]) > 0 && $app->functions->intval($this->dataRecord["server_id"]) != $app->functions->intval($client['default_webserver']) ? $app->functions->intval($this->dataRecord["server_id"]) : $app->functions->intval($client['default_webserver'])) . " AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=" . $app->functions->intval($_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) {
                 $selected = $ip["ip_address"] == $this->dataRecord["ip_address"] ? 'SELECTED' : '';
                 $ip_select .= "<option value='{$ip['ip_address']}' {$selected}>{$ip['ip_address']}</option>\r\n";
             }
         }
         $app->tpl->setVar("ip_address", $ip_select);
         unset($tmp);
         unset($ips);
         //* Fill the IPv6 select field with the IP addresses that are allowed for this client; if website was created on a different server (e.g. by admin), display IP addresses from that server
         $sql = "SELECT ip_address FROM server_ip WHERE server_id = " . ($app->functions->intval($this->dataRecord["server_id"]) > 0 && $app->functions->intval($this->dataRecord["server_id"]) != $app->functions->intval($client['default_webserver']) ? $app->functions->intval($this->dataRecord["server_id"]) : $app->functions->intval($client['default_webserver'])) . " AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=" . $app->functions->intval($_SESSION['s']['user']['client_id']) . ")";
         $ips = $app->db->queryAllRecords($sql);
         $ip_select = "<option value=''></option>";
         //$ip_select = "";
         if (is_array($ips)) {
             foreach ($ips as $ip) {
                 $selected = $ip["ip_address"] == $this->dataRecord["ipv6_address"] ? 'SELECTED' : '';
                 $ip_select .= "<option value='{$ip['ip_address']}' {$selected}>{$ip['ip_address']}</option>\r\n";
             }
         }
         $app->tpl->setVar("ipv6_address", $ip_select);
         unset($tmp);
         unset($ips);
         //PHP Version Selection (FastCGI)
         $server_type = 'apache';
         if (!empty($web_config['server_type'])) {
             $server_type = $web_config['server_type'];
         }
         if ($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') {
             $this->dataRecord['php'] = 'php-fpm';
         }
         if ($this->dataRecord['php'] == 'php-fpm') {
             $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = " . ($this->id > 0 ? $app->functions->intval($this->dataRecord['server_id']) : $app->functions->intval($client['default_webserver'])) . " AND (client_id = 0 OR client_id=" . $app->functions->intval($_SESSION['s']['user']['client_id']) . ")");
         }
         if ($this->dataRecord['php'] == 'fast-cgi') {
             $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = " . ($this->id > 0 ? $app->functions->intval($this->dataRecord['server_id']) : $app->functions->intval($client['default_webserver'])) . " AND (client_id = 0 OR client_id=" . $app->functions->intval($_SESSION['s']['user']['client_id']) . ")");
         }
         $php_select = "<option value=''>Default</option>";
         if (is_array($php_records) && !empty($php_records)) {
             foreach ($php_records as $php_record) {
                 if ($this->dataRecord['php'] == 'php-fpm') {
                     $php_version = $php_record['name'] . ':' . $php_record['php_fpm_init_script'] . ':' . $php_record['php_fpm_ini_dir'] . ':' . $php_record['php_fpm_pool_dir'];
                 } else {
                     $php_version = $php_record['name'] . ':' . $php_record['php_fastcgi_binary'] . ':' . $php_record['php_fastcgi_ini_dir'];
                 }
                 $selected = $php_version == $this->dataRecord["fastcgi_php_version"] ? 'SELECTED' : '';
                 $php_select .= "<option value='{$php_version}' {$selected}>" . $php_record['name'] . "</option>\r\n";
             }
         }
         $app->tpl->setVar("fastcgi_php_version", $php_select);
         unset($php_records);
         // add limits to template to be able to hide settings
         foreach ($read_limits as $limit) {
             $app->tpl->setVar($limit, $client[$limit]);
         }
         //* Reseller: If the logged in user is not admin and has sub clients (is a reseller)
     } elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
         // Get the limits of the client
         $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
         $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_domain, client.default_webserver, client.contact_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, sys_group.name, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = {$client_group_id}");
         //* Get global web config
         $web_config = $app->getconf->get_server_config($client['default_webserver'], 'web');
         // Set the webserver to the default server of the client
         $tmp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = " . $app->functions->intval($client['default_webserver']));
         $app->tpl->setVar("server_id", "<option value='{$client['default_webserver']}'>{$tmp['server_name']}</option>");
         unset($tmp);
         // Fill the client select field
         $sql = "SELECT 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 client.parent_client_id = " . $client['client_id'] . " ORDER BY client.company_name, client.contact_name, sys_group.name";
         $records = $app->db->queryAllRecords($sql);
         $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = " . $app->functions->intval($client['client_id']));
         $client_select = '<option value="' . $tmp['groupid'] . '">' . $client['contactname'] . '</option>';
         //$tmp_data_record = $app->tform->getDataRecord($this->id);
         if (is_array($records)) {
             $selected_client_group_id = 0;
             // needed to get list of PHP versions
             foreach ($records as $rec) {
                 if (is_array($this->dataRecord) && ($rec["groupid"] == $this->dataRecord['client_group_id'] || $rec["groupid"] == $this->dataRecord['sys_groupid']) && !$selected_client_group_id) {
                     $selected_client_group_id = $rec["groupid"];
                 }
                 $selected = @(is_array($this->dataRecord) && ($rec["groupid"] == $this->dataRecord['client_group_id'] || $rec["groupid"] == $this->dataRecord['sys_groupid'])) ? 'SELECTED' : '';
                 if ($selected == 'SELECTED') {
                     $selected_client_group_id = $rec["groupid"];
                 }
                 $client_select .= "<option value='{$rec['groupid']}' {$selected}>{$rec['contactname']}</option>\r\n";
             }
         }
         $app->tpl->setVar("client_group_id", $client_select);
         //* Fill the IPv4 select field with the IP addresses that are allowed for this client; if website was created on a different server (e.g. by admin), display IP addresses from that server - otherwise IP will be changed to * if user changes the tab
         $sql = "SELECT ip_address FROM server_ip WHERE server_id = " . ($app->functions->intval($this->dataRecord["server_id"]) > 0 && $app->functions->intval($this->dataRecord["server_id"]) != $app->functions->intval($client['default_webserver']) ? $app->functions->intval($this->dataRecord["server_id"]) : $app->functions->intval($client['default_webserver'])) . " AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=" . $app->functions->intval($_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) {
                 $selected = $ip["ip_address"] == $this->dataRecord["ip_address"] ? 'SELECTED' : '';
                 $ip_select .= "<option value='{$ip['ip_address']}' {$selected}>{$ip['ip_address']}</option>\r\n";
             }
         }
         $app->tpl->setVar("ip_address", $ip_select);
         unset($tmp);
         unset($ips);
         //* Fill the IPv6 select field with the IP addresses that are allowed for this client; if website was created on a different server (e.g. by admin), display IP addresses from that server
         $sql = "SELECT ip_address FROM server_ip WHERE server_id = " . ($app->functions->intval($this->dataRecord["server_id"]) > 0 && $app->functions->intval($this->dataRecord["server_id"]) != $app->functions->intval($client['default_webserver']) ? $app->functions->intval($this->dataRecord["server_id"]) : $app->functions->intval($client['default_webserver'])) . " AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=" . $app->functions->intval($_SESSION['s']['user']['client_id']) . ")";
         $ips = $app->db->queryAllRecords($sql);
         $ip_select = "<option value=''></option>";
         //$ip_select = "";
         if (is_array($ips)) {
             foreach ($ips as $ip) {
                 $selected = $ip["ip_address"] == $this->dataRecord["ipv6_address"] ? 'SELECTED' : '';
                 $ip_select .= "<option value='{$ip['ip_address']}' {$selected}>{$ip['ip_address']}</option>\r\n";
             }
         }
         $app->tpl->setVar("ipv6_address", $ip_select);
         unset($tmp);
         unset($ips);
         //PHP Version Selection (FastCGI)
         $server_type = 'apache';
         if (!empty($web_config['server_type'])) {
             $server_type = $web_config['server_type'];
         }
         if ($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') {
             $this->dataRecord['php'] = 'php-fpm';
         }
         $selected_client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = " . $app->functions->intval($selected_client_group_id));
         //$sql_where = " AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id']." OR client_id = ".intval($selected_client['client_id']).")";
         $sql_where = " AND (client_id = 0 OR client_id = " . intval($selected_client['client_id']) . ")";
         if ($this->dataRecord['php'] == 'php-fpm') {
             $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = " . ($this->id > 0 ? $app->functions->intval($this->dataRecord['server_id']) : $app->functions->intval($client['default_webserver'])) . $sql_where);
         }
         if ($this->dataRecord['php'] == 'fast-cgi') {
             $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = " . ($this->id > 0 ? $app->functions->intval($this->dataRecord['server_id']) : $app->functions->intval($client['default_webserver'])) . $sql_where);
         }
         $php_select = "<option value=''>Default</option>";
         if (is_array($php_records) && !empty($php_records)) {
             foreach ($php_records as $php_record) {
                 if ($this->dataRecord['php'] == 'php-fpm') {
                     $php_version = $php_record['name'] . ':' . $php_record['php_fpm_init_script'] . ':' . $php_record['php_fpm_ini_dir'] . ':' . $php_record['php_fpm_pool_dir'];
                 } else {
                     $php_version = $php_record['name'] . ':' . $php_record['php_fastcgi_binary'] . ':' . $php_record['php_fastcgi_ini_dir'];
                 }
                 $selected = $php_version == $this->dataRecord["fastcgi_php_version"] ? 'SELECTED' : '';
                 $php_select .= "<option value='{$php_version}' {$selected}>" . $php_record['name'] . "</option>\r\n";
             }
         }
         $app->tpl->setVar("fastcgi_php_version", $php_select);
         unset($php_records);
         // add limits to template to be able to hide settings
         foreach ($read_limits as $limit) {
             $app->tpl->setVar($limit, $client[$limit]);
         }
         //* Admin: If the logged in user is admin
     } else {
         // The user is admin, so we fill in all IP addresses of the server
         if ($this->id > 0) {
             if (!isset($this->dataRecord["server_id"])) {
                 $tmp = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = " . $app->functions->intval($this->id));
                 $this->dataRecord["server_id"] = $tmp["server_id"];
                 unset($tmp);
             }
             $server_id = intval(@$this->dataRecord["server_id"]);
         } else {
             // Get the first server ID
             $tmp = $app->db->queryOneRecord("SELECT server_id FROM server WHERE web_server = 1 ORDER BY server_name LIMIT 0,1");
             $server_id = intval($tmp['server_id']);
         }
         //* get global web config
         $web_config = $app->getconf->get_server_config($server_id, 'web');
         //* Fill the IPv4 select field
         $sql = "SELECT ip_address FROM server_ip WHERE ip_type = 'IPv4' AND server_id = " . $app->functions->intval($server_id);
         $ips = $app->db->queryAllRecords($sql);
         $ip_select = $web_config['enable_ip_wildcard'] == 'y' ? "<option value='*'>*</option>" : "";
         //$ip_select = "";
         if (is_array($ips)) {
             foreach ($ips as $ip) {
                 $selected = $ip["ip_address"] == $this->dataRecord["ip_address"] ? 'SELECTED' : '';
                 $ip_select .= "<option value='{$ip['ip_address']}' {$selected}>{$ip['ip_address']}</option>\r\n";
             }
         }
         $app->tpl->setVar("ip_address", $ip_select);
         unset($tmp);
         unset($ips);
         //* Fill the IPv6 select field
         $sql = "SELECT ip_address FROM server_ip WHERE ip_type = 'IPv6' AND server_id = " . $app->functions->intval($server_id);
         $ips = $app->db->queryAllRecords($sql);
         $ip_select = "<option value=''></option>";
         //$ip_select = "";
         if (is_array($ips)) {
             foreach ($ips as $ip) {
                 $selected = $ip["ip_address"] == $this->dataRecord["ipv6_address"] ? 'SELECTED' : '';
                 $ip_select .= "<option value='{$ip['ip_address']}' {$selected}>{$ip['ip_address']}</option>\r\n";
             }
         }
         $app->tpl->setVar("ipv6_address", $ip_select);
         unset($tmp);
         unset($ips);
         // Fill the client select field
         $sql = "SELECT 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 ORDER BY client.company_name, client.contact_name, sys_group.name";
         $clients = $app->db->queryAllRecords($sql);
         $client_select = "<option value='0'></option>";
         //$tmp_data_record = $app->tform->getDataRecord($this->id);
         if (is_array($clients)) {
             $selected_client_group_id = 0;
             // needed to get list of PHP versions
             foreach ($clients as $client) {
                 if (is_array($this->dataRecord) && ($client["groupid"] == $this->dataRecord['client_group_id'] || $client["groupid"] == $this->dataRecord['sys_groupid']) && !$selected_client_group_id) {
                     $selected_client_group_id = $client["groupid"];
                 }
                 //$selected = @($client["groupid"] == $tmp_data_record["sys_groupid"])?'SELECTED':'';
                 $selected = @(is_array($this->dataRecord) && ($client["groupid"] == $this->dataRecord['client_group_id'] || $client["groupid"] == $this->dataRecord['sys_groupid'])) ? 'SELECTED' : '';
                 if ($selected == 'SELECTED') {
                     $selected_client_group_id = $client["groupid"];
                 }
                 $client_select .= "<option value='{$client['groupid']}' {$selected}>{$client['contactname']}</option>\r\n";
             }
         }
         $app->tpl->setVar("client_group_id", $client_select);
         //PHP Version Selection (FastCGI)
         $server_type = 'apache';
         if (!empty($web_config['server_type'])) {
             $server_type = $web_config['server_type'];
         }
         if ($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') {
             $this->dataRecord['php'] = 'php-fpm';
         }
         $selected_client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = " . $app->functions->intval($selected_client_group_id));
         //$sql_where = " AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id']." OR client_id = ".intval($selected_client['client_id']).")";
         $sql_where = " AND (client_id = 0 OR client_id = " . $app->functions->intval($selected_client['client_id']) . ")";
         if ($this->dataRecord['php'] == 'php-fpm') {
             $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = {$server_id}" . $sql_where);
         }
         if ($this->dataRecord['php'] == 'fast-cgi') {
             $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = " . $app->functions->intval($server_id) . $sql_where);
         }
         $php_select = "<option value=''>Default</option>";
         if (is_array($php_records) && !empty($php_records)) {
             foreach ($php_records as $php_record) {
                 if ($this->dataRecord['php'] == 'php-fpm') {
                     $php_version = $php_record['name'] . ':' . $php_record['php_fpm_init_script'] . ':' . $php_record['php_fpm_ini_dir'] . ':' . $php_record['php_fpm_pool_dir'];
                 } else {
                     $php_version = $php_record['name'] . ':' . $php_record['php_fastcgi_binary'] . ':' . $php_record['php_fastcgi_ini_dir'];
                 }
                 $selected = $php_version == $this->dataRecord["fastcgi_php_version"] ? 'SELECTED' : '';
                 $php_select .= "<option value='{$php_version}' {$selected}>" . $php_record['name'] . "</option>\r\n";
             }
         }
         $app->tpl->setVar("fastcgi_php_version", $php_select);
         unset($php_records);
         foreach ($read_limits as $limit) {
             $app->tpl->setVar($limit, $limit == 'force_suexec' ? 'n' : 'y');
         }
         // Directive Snippets
         $php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y'");
         $php_directive_snippets_txt = '';
         if (is_array($php_directive_snippets) && !empty($php_directive_snippets)) {
             foreach ($php_directive_snippets as $php_directive_snippet) {
                 $php_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">[' . $php_directive_snippet['name'] . ']<pre class="addPlaceholderContent" style="display:none;">' . htmlentities($php_directive_snippet['snippet']) . '</pre></a> ';
             }
         }
         if ($php_directive_snippets_txt == '') {
             $php_directive_snippets_txt = '------';
         }
         $app->tpl->setVar("php_directive_snippets_txt", $php_directive_snippets_txt);
         if ($server_type == 'apache') {
             $apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y'");
             $apache_directive_snippets_txt = '';
             if (is_array($apache_directive_snippets) && !empty($apache_directive_snippets)) {
                 foreach ($apache_directive_snippets as $apache_directive_snippet) {
                     $apache_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">[' . $apache_directive_snippet['name'] . ']<pre class="addPlaceholderContent" style="display:none;">' . htmlentities($apache_directive_snippet['snippet']) . '</pre></a> ';
                 }
             }
             if ($apache_directive_snippets_txt == '') {
                 $apache_directive_snippets_txt = '------';
             }
             $app->tpl->setVar("apache_directive_snippets_txt", $apache_directive_snippets_txt);
         }
         if ($server_type == 'nginx') {
             $nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y'");
             $nginx_directive_snippets_txt = '';
             if (is_array($nginx_directive_snippets) && !empty($nginx_directive_snippets)) {
                 foreach ($nginx_directive_snippets as $nginx_directive_snippet) {
                     $nginx_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">[' . $nginx_directive_snippet['name'] . ']<pre class="addPlaceholderContent" style="display:none;">' . htmlentities($nginx_directive_snippet['snippet']) . '</pre></a> ';
                 }
             }
             if ($nginx_directive_snippets_txt == '') {
                 $nginx_directive_snippets_txt = '------';
             }
             $app->tpl->setVar("nginx_directive_snippets_txt", $nginx_directive_snippets_txt);
         }
         $proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y'");
         $proxy_directive_snippets_txt = '';
         if (is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)) {
             foreach ($proxy_directive_snippets as $proxy_directive_snippet) {
                 $proxy_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">[' . $proxy_directive_snippet['name'] . ']<pre class="addPlaceholderContent" style="display:none;">' . htmlentities($proxy_directive_snippet['snippet']) . '</pre></a> ';
             }
         }
         if ($proxy_directive_snippets_txt == '') {
             $proxy_directive_snippets_txt = '------';
         }
         $app->tpl->setVar("proxy_directive_snippets_txt", $proxy_directive_snippets_txt);
     }
     $ssl_domain_select = '';
     $ssl_domains = array();
     $tmpd = $app->db->queryAllRecords("SELECT domain, type FROM web_domain WHERE domain_id = " . $this->id . " OR parent_domain_id = " . $this->id);
     foreach ($tmpd as $tmp) {
         if ($tmp['type'] == 'subdomain' || $tmp['type'] == 'vhostsubdomain') {
             $ssl_domains[] = $tmp["domain"];
         } else {
             $ssl_domains = array_merge($ssl_domains, array($tmp["domain"], 'www.' . $tmp["domain"], '*.' . $tmp["domain"]));
         }
     }
     if (is_array($ssl_domains)) {
         foreach ($ssl_domains as $ssl_domain) {
             $selected = $ssl_domain == $this->dataRecord['ssl_domain'] ? 'SELECTED' : '';
             $ssl_domain_select .= "<option value='{$ssl_domain}' {$selected}>{$ssl_domain}</option>\r\n";
         }
     }
     $app->tpl->setVar("ssl_domain", $ssl_domain_select);
     unset($ssl_domain_select);
     unset($ssl_domains);
     unset($ssl_domain);
     if ($this->id > 0) {
         //* we are editing a existing record
         $app->tpl->setVar("edit_disabled", 1);
         $app->tpl->setVar("server_id_value", $this->dataRecord["server_id"]);
     } else {
         $app->tpl->setVar("edit_disabled", 0);
     }
     $tmp_txt = $this->dataRecord['traffic_quota_lock'] == 'y' ? '<b>(' . $app->tform->lng('traffic_quota_exceeded_txt') . ')</b>' : '';
     $app->tpl->setVar("traffic_quota_exceeded_txt", $tmp_txt);
     /*
      * Now we have to check, if we should use the domain-module to select the domain
      * or not
      */
     $settings = $app->getconf->get_global_config('domains');
     if ($settings['use_domain_module'] == 'y') {
         /*
          * The domain-module is in use.
          */
         $domains = $app->tools_sites->getDomainModuleDomains();
         $domain_select = '';
         if (is_array($domains) && sizeof($domains) > 0) {
             /* We have domains in the list, so create the drop-down-list */
             foreach ($domains as $domain) {
                 $domain_select .= "<option value=" . $domain['domain_id'];
                 if ($domain['domain'] == $this->dataRecord["domain"]) {
                     $domain_select .= " selected";
                 }
                 $domain_select .= ">" . $app->functions->idn_decode($domain['domain']) . "</option>\r\n";
             }
         } else {
             /*
              * We have no domains in the domain-list. This means, we can not add ANY new domain.
              * To avoid, that the variable "domain_option" is empty and so the user can
              * free enter a domain, we have to create a empty option!
              */
             $domain_select .= "<option value=''></option>\r\n";
         }
         $app->tpl->setVar("domain_option", $domain_select);
     }
     // check for configuration errors in sys_datalog
     if ($this->id > 0) {
         $datalog = $app->db->queryOneRecord("SELECT sys_datalog.error, sys_log.tstamp FROM sys_datalog, sys_log WHERE sys_datalog.dbtable = 'web_domain' AND sys_datalog.dbidx = 'domain_id:" . $app->functions->intval($this->id) . "' AND sys_datalog.datalog_id = sys_log.datalog_id AND sys_log.message = CONCAT('Processed datalog_id ',sys_log.datalog_id) ORDER BY sys_datalog.tstamp DESC");
         if (is_array($datalog) && !empty($datalog)) {
             if (trim($datalog['error']) != '') {
                 $app->tpl->setVar("config_error_msg", nl2br(htmlentities($datalog['error'])));
                 $app->tpl->setVar("config_error_tstamp", date($app->lng('conf_format_datetime'), $datalog['tstamp']));
             }
         }
     }
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf;
     $app->uses('ini_parser,getconf');
     $read_limits = array('limit_cgi', 'limit_ssi', 'limit_perl', 'limit_ruby', 'limit_python', 'force_suexec', 'limit_hterror', 'limit_wildcard', 'limit_ssl');
     $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = " . $app->functions->intval(@$this->dataRecord["parent_domain_id"]));
     //* Client: If the logged in user is not admin and has no sub clients (no reseller)
     if ($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
         // Get the limits of the client
         $client_group_id = $_SESSION["s"]["user"]["default_group"];
         $client = $app->db->queryOneRecord("SELECT client.limit_web_subdomain, client.default_webserver, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = {$client_group_id}");
         //* Get global web config
         $web_config = $app->getconf->get_server_config($parent_domain['server_id'], 'web');
         //PHP Version Selection (FastCGI)
         $server_type = 'apache';
         if (!empty($web_config['server_type'])) {
             $server_type = $web_config['server_type'];
         }
         if ($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') {
             $this->dataRecord['php'] = 'php-fpm';
         }
         if ($this->dataRecord['php'] == 'php-fpm') {
             $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = " . $parent_domain['server_id'] . " AND (client_id = 0 OR client_id=" . $_SESSION['s']['user']['client_id'] . ")");
         }
         if ($this->dataRecord['php'] == 'fast-cgi') {
             $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = " . $parent_domain['server_id'] . " AND (client_id = 0 OR client_id=" . $_SESSION['s']['user']['client_id'] . ")");
         }
         $php_select = "<option value=''>Default</option>";
         if (is_array($php_records) && !empty($php_records)) {
             foreach ($php_records as $php_record) {
                 if ($this->dataRecord['php'] == 'php-fpm') {
                     $php_version = $php_record['name'] . ':' . $php_record['php_fpm_init_script'] . ':' . $php_record['php_fpm_ini_dir'] . ':' . $php_record['php_fpm_pool_dir'];
                 } else {
                     $php_version = $php_record['name'] . ':' . $php_record['php_fastcgi_binary'] . ':' . $php_record['php_fastcgi_ini_dir'];
                 }
                 $selected = $php_version == $this->dataRecord["fastcgi_php_version"] ? 'SELECTED' : '';
                 $php_select .= "<option value='{$php_version}' {$selected}>" . $php_record['name'] . "</option>\r\n";
             }
         }
         $app->tpl->setVar("fastcgi_php_version", $php_select);
         unset($php_records);
         // add limits to template to be able to hide settings
         foreach ($read_limits as $limit) {
             $app->tpl->setVar($limit, $client[$limit]);
         }
         //* Reseller: If the logged in user is not admin and has sub clients (is a reseller)
     } elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
         // Get the limits of the client
         $client_group_id = $_SESSION["s"]["user"]["default_group"];
         $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_subdomain, client.default_webserver, client.contact_name, CONCAT(client.company_name,' :: ',client.contact_name) as contactname, sys_group.name, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = {$client_group_id}");
         //* Get global web config
         $web_config = $app->getconf->get_server_config($parent_domain['server_id'], 'web');
         //PHP Version Selection (FastCGI)
         $server_type = 'apache';
         if (!empty($web_config['server_type'])) {
             $server_type = $web_config['server_type'];
         }
         if ($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') {
             $this->dataRecord['php'] = 'php-fpm';
         }
         if ($this->dataRecord['php'] == 'php-fpm') {
             $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = " . $parent_domain['server_id'] . " AND (client_id = 0 OR client_id=" . $_SESSION['s']['user']['client_id'] . ")");
         }
         if ($this->dataRecord['php'] == 'fast-cgi') {
             $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = " . $parent_domain['server_id'] . " AND (client_id = 0 OR client_id=" . $_SESSION['s']['user']['client_id'] . ")");
         }
         $php_select = "<option value=''>Default</option>";
         if (is_array($php_records) && !empty($php_records)) {
             foreach ($php_records as $php_record) {
                 if ($this->dataRecord['php'] == 'php-fpm') {
                     $php_version = $php_record['name'] . ':' . $php_record['php_fpm_init_script'] . ':' . $php_record['php_fpm_ini_dir'] . ':' . $php_record['php_fpm_pool_dir'];
                 } else {
                     $php_version = $php_record['name'] . ':' . $php_record['php_fastcgi_binary'] . ':' . $php_record['php_fastcgi_ini_dir'];
                 }
                 $selected = $php_version == $this->dataRecord["fastcgi_php_version"] ? 'SELECTED' : '';
                 $php_select .= "<option value='{$php_version}' {$selected}>" . $php_record['name'] . "</option>\r\n";
             }
         }
         $app->tpl->setVar("fastcgi_php_version", $php_select);
         unset($php_records);
         // add limits to template to be able to hide settings
         foreach ($read_limits as $limit) {
             $app->tpl->setVar($limit, $client[$limit]);
         }
         //* Admin: If the logged in user is admin
     } else {
         //* get global web config
         $web_config = $app->getconf->get_server_config($parent_domain['server_id'], 'web');
         //PHP Version Selection (FastCGI)
         $server_type = 'apache';
         if (!empty($web_config['server_type'])) {
             $server_type = $web_config['server_type'];
         }
         if ($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') {
             $this->dataRecord['php'] = 'php-fpm';
         }
         if ($this->dataRecord['php'] == 'php-fpm') {
             $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = " . $parent_domain['server_id']);
         }
         if ($this->dataRecord['php'] == 'fast-cgi') {
             $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = " . $parent_domain['server_id']);
         }
         $php_select = "<option value=''>Default</option>";
         if (is_array($php_records) && !empty($php_records)) {
             foreach ($php_records as $php_record) {
                 if ($this->dataRecord['php'] == 'php-fpm') {
                     $php_version = $php_record['name'] . ':' . $php_record['php_fpm_init_script'] . ':' . $php_record['php_fpm_ini_dir'] . ':' . $php_record['php_fpm_pool_dir'];
                 } else {
                     $php_version = $php_record['name'] . ':' . $php_record['php_fastcgi_binary'] . ':' . $php_record['php_fastcgi_ini_dir'];
                 }
                 $selected = $php_version == $this->dataRecord["fastcgi_php_version"] ? 'SELECTED' : '';
                 $php_select .= "<option value='{$php_version}' {$selected}>" . $php_record['name'] . "</option>\r\n";
             }
         }
         $app->tpl->setVar("fastcgi_php_version", $php_select);
         unset($php_records);
         foreach ($read_limits as $limit) {
             $app->tpl->setVar($limit, $limit == 'force_suexec' ? 'n' : 'y');
         }
         // Directive Snippets
         $php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y'");
         $php_directive_snippets_txt = '';
         if (is_array($php_directive_snippets) && !empty($php_directive_snippets)) {
             foreach ($php_directive_snippets as $php_directive_snippet) {
                 $php_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">[' . $php_directive_snippet['name'] . ']<pre class="addPlaceholderContent" style="display:none;">' . $php_directive_snippet['snippet'] . '</pre></a> ';
             }
         }
         if ($php_directive_snippets_txt == '') {
             $php_directive_snippets_txt = '------';
         }
         $app->tpl->setVar("php_directive_snippets_txt", $php_directive_snippets_txt);
         if ($server_type == 'apache') {
             $apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y'");
             $apache_directive_snippets_txt = '';
             if (is_array($apache_directive_snippets) && !empty($apache_directive_snippets)) {
                 foreach ($apache_directive_snippets as $apache_directive_snippet) {
                     $apache_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">[' . $apache_directive_snippet['name'] . ']<pre class="addPlaceholderContent" style="display:none;">' . $apache_directive_snippet['snippet'] . '</pre></a> ';
                 }
             }
             if ($apache_directive_snippets_txt == '') {
                 $apache_directive_snippets_txt = '------';
             }
             $app->tpl->setVar("apache_directive_snippets_txt", $apache_directive_snippets_txt);
         }
         if ($server_type == 'nginx') {
             $nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y'");
             $nginx_directive_snippets_txt = '';
             if (is_array($nginx_directive_snippets) && !empty($nginx_directive_snippets)) {
                 foreach ($nginx_directive_snippets as $nginx_directive_snippet) {
                     $nginx_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">[' . $nginx_directive_snippet['name'] . ']<pre class="addPlaceholderContent" style="display:none;">' . $nginx_directive_snippet['snippet'] . '</pre></a> ';
                 }
             }
             if ($nginx_directive_snippets_txt == '') {
                 $nginx_directive_snippets_txt = '------';
             }
             $app->tpl->setVar("nginx_directive_snippets_txt", $nginx_directive_snippets_txt);
         }
         $proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y'");
         $proxy_directive_snippets_txt = '';
         if (is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)) {
             foreach ($proxy_directive_snippets as $proxy_directive_snippet) {
                 $proxy_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">[' . $proxy_directive_snippet['name'] . ']<pre class="addPlaceholderContent" style="display:none;">' . $proxy_directive_snippet['snippet'] . '</pre></a> ';
             }
         }
         if ($proxy_directive_snippets_txt == '') {
             $proxy_directive_snippets_txt = '------';
         }
         $app->tpl->setVar("proxy_directive_snippets_txt", $proxy_directive_snippets_txt);
     }
     $ssl_domain_select = '';
     $tmp = $app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id = " . $this->id);
     $ssl_domains = array($tmp["domain"], 'www.' . $tmp["domain"]);
     if (is_array($ssl_domains)) {
         foreach ($ssl_domains as $ssl_domain) {
             $selected = $ssl_domain == $this->dataRecord['ssl_domain'] ? 'SELECTED' : '';
             $ssl_domain_select .= "<option value='{$ssl_domain}' {$selected}>{$ssl_domain}</option>\r\n";
         }
     }
     if ($this->id > 0) {
         $app->tpl->setVar('fixed_folder', 'y');
         $app->tpl->setVar('server_id_value', $parent_domain['server_id']);
     } else {
         $app->tpl->setVar('fixed_folder', 'n');
         $app->tpl->setVar('server_id_value', $parent_domain['server_id']);
     }
     $app->tpl->setVar("ssl_domain", $ssl_domain_select);
     unset($ssl_domain_select);
     unset($ssl_domains);
     unset($ssl_domain);
     $tmp_txt = $this->dataRecord['traffic_quota_lock'] == 'y' ? '<b>(' . $app->tform->lng('traffic_quota_exceeded_txt') . ')</b>' : '';
     $app->tpl->setVar("traffic_quota_exceeded_txt", $tmp_txt);
     $app->uses('ini_parser,getconf');
     $settings = $app->getconf->get_global_config('domains');
     if ($settings['use_domain_module'] == 'y') {
         /*
          * The domain-module is in use.
          */
         $domains = $app->tools_sites->getDomainModuleDomains();
         $domain_select = '';
         $selected_domain = '';
         if (is_array($domains) && sizeof($domains) > 0) {
             /* We have domains in the list, so create the drop-down-list */
             foreach ($domains as $domain) {
                 $domain_select .= "<option value=" . $domain['domain_id'];
                 if ('.' . $domain['domain'] == substr($this->dataRecord["domain"], -strlen($domain['domain']) - 1)) {
                     $domain_select .= " selected";
                     $selected_domain = $domain['domain'];
                 }
                 $domain_select .= ">" . $app->functions->idn_decode($domain['domain']) . "</option>\r\n";
             }
         } else {
             /*
              * We have no domains in the domain-list. This means, we can not add ANY new domain.
              * To avoid, that the variable "domain_option" is empty and so the user can
              * free enter a domain, we have to create a empty option!
              */
             $domain_select .= "<option value=''></option>\r\n";
         }
         $app->tpl->setVar("domain_option", $domain_select);
         $this->dataRecord['domain'] = substr($this->dataRecord["domain"], 0, strlen($this->dataRecord['domain']) - strlen($selected_domain) - 1);
     } else {
         // 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"]);
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf;
     // If user is admin, we will allow him to select to whom this record belongs
     if ($_SESSION["s"]["user"]["typ"] == 'admin') {
         // Getting Domains of the user
         $sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0 ORDER by name";
         $clients = $app->db->queryAllRecords($sql);
         $client_select = '';
         if ($_SESSION["s"]["user"]["typ"] == 'admin') {
             $client_select .= "<option value='0'></option>";
         }
         $tmp_data_record = $app->tform->getDataRecord($this->id);
         if (is_array($clients)) {
             foreach ($clients as $client) {
                 $selected = $client["groupid"] == @$tmp_data_record["sys_groupid"] ? 'SELECTED' : '';
                 $client_select .= "<option value='{$client['groupid']}' {$selected}>{$client['name']}</option>\r\n";
             }
         }
         $app->tpl->setVar("client_group_id", $client_select);
     } else {
         if ($app->auth->has_clients($_SESSION['s']['user']['userid'])) {
             // Get the limits of the client
             $client_group_id = $_SESSION["s"]["user"]["default_group"];
             $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = {$client_group_id}");
             // Fill the client select field
             $sql = "SELECT groupid, name FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = " . $client['client_id'] . " ORDER BY name";
             $clients = $app->db->queryAllRecords($sql);
             $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = " . $client['client_id']);
             $client_select = '<option value="' . $tmp['groupid'] . '">' . $client['contact_name'] . '</option>';
             $tmp_data_record = $app->tform->getDataRecord($this->id);
             if (is_array($clients)) {
                 foreach ($clients as $client) {
                     $selected = @($client["groupid"] == $tmp_data_record["sys_groupid"]) ? 'SELECTED' : '';
                     $client_select .= "<option value='{$client['groupid']}' {$selected}>{$client['name']}</option>\r\n";
                 }
             }
             $app->tpl->setVar("client_group_id", $client_select);
         }
     }
     parent::onShowEnd();
 }
Exemple #25
0
 function onShowEnd()
 {
     global $app;
     $sql = "SELECT template_id,template_name FROM client_template WHERE template_type = 'a' ORDER BY template_name ASC";
     $tpls = $app->db->queryAllRecords($sql);
     $option = '';
     $tpl = array();
     foreach ($tpls as $item) {
         $option .= '<option value="' . $item['template_id'] . '|' . $item['template_name'] . '">' . $item['template_name'] . '</option>';
         $tpl[$item['template_id']] = $item['template_name'];
     }
     $app->tpl->setVar('tpl_add_select', $option);
     // check for new-style records
     $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']];
                 $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;
         $result = $app->db->queryOneRecord($sql);
         $tplAdd = explode("/", $result['template_additional']);
         $text = '';
         foreach ($tplAdd as $item) {
             if (trim($item) != '') {
                 if ($text != '') {
                     $text .= '';
                 }
                 $text .= '<li>' . $tpl[$item] . '<a href="#" class="button icons16 icoDelete"></a></li>';
             }
         }
     }
     $app->tpl->setVar('template_additional_list', $text);
     $app->tpl->setVar('app_module', 'client');
     //* Set the 'customer no' default value
     if ($this->id == 0) {
         //* get the system config
         $app->uses('getconf');
         $system_config = $app->getconf->get_global_config();
         if ($system_config['misc']['customer_no_template'] != '') {
             //* Set customer no default
             $customer_no = $app->functions->intval($system_config['misc']['customer_no_start'] + $system_config['misc']['customer_no_counter']);
             $customer_no_string = str_replace('[CUSTOMER_NO]', $customer_no, $system_config['misc']['customer_no_template']);
             $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);
             */
         }
     }
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf;
     $tmp_parts = explode(":", $this->dataRecord["transport"]);
     if (!empty($this->id) && !stristr($this->dataRecord["transport"], ':')) {
         $rec["type"] = 'custom';
     } else {
         if (empty($this->id) && empty($tmp_parts[0])) {
             $rec["type"] = 'smtp';
         } else {
             $rec["type"] = $tmp_parts[0];
         }
     }
     if (!empty($tmp_parts[2])) {
         $dest = @$tmp_parts[1] . ':' . @$tmp_parts[2];
     } elseif (!empty($tmp_parts[1])) {
         $dest = $tmp_parts[1];
     } else {
         $dest = $this->dataRecord["transport"];
     }
     if (@substr($dest, 0, 1) == '[') {
         $rec["mx"] = 'checked="CHECKED"';
         $rec["destination"] = @str_replace(']', '', @str_replace('[', '', $dest));
     } else {
         $rec["mx"] = '';
         $rec["destination"] = @$dest;
     }
     $types = array('smtp' => 'smtp', 'uucp' => 'uucp', 'slow' => 'slow', 'error' => 'error', 'custom' => 'custom', '' => 'null');
     $type_select = '';
     if (is_array($types)) {
         foreach ($types as $key => $val) {
             $selected = $key == $rec["type"] ? 'SELECTED' : '';
             $type_select .= "<option value='{$key}' {$selected}>{$val}</option>\r\n";
         }
     }
     $rec["type"] = $type_select;
     $app->tpl->setVar($rec);
     unset($type);
     unset($types);
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf;
     $rec = $app->tform->getDataRecord($this->id);
     $app->tpl->setVar("email", $rec['email']);
     // Get the spamfilter policys for the user
     $tmp_user = $app->db->queryOneRecord("SELECT policy_id FROM spamfilter_users WHERE email = '" . $app->db->quote($rec['email']) . "'");
     $sql = "SELECT id, policy_name FROM spamfilter_policy WHERE " . $app->tform->getAuthSQL('r');
     $policys = $app->db->queryAllRecords($sql);
     $policy_select = "<option value='0'>" . $app->tform->lng("no_policy") . "</option>";
     if (is_array($policys)) {
         foreach ($policys as $p) {
             $selected = $p["id"] == $tmp_user["policy_id"] ? 'SELECTED' : '';
             $policy_select .= "<option value='{$p['id']}' {$selected}>{$p['policy_name']}</option>\r\n";
         }
     }
     $app->tpl->setVar("policy", $policy_select);
     unset($policys);
     unset($policy_select);
     unset($tmp_user);
     parent::onShowEnd();
 }
Exemple #28
0
 function onShowEnd()
 {
     global $app, $conf;
     // If user is admin, we will allow him to select to whom this record belongs
     if ($_SESSION["s"]["user"]["typ"] == 'admin') {
         // Getting Domains of the user
         $sql = "SELECT 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 ORDER BY client.company_name, client.contact_name, sys_group.name";
         $clients = $app->db->queryAllRecords($sql);
         $client_select = '';
         if ($_SESSION["s"]["user"]["typ"] == 'admin') {
             $client_select .= "<option value='0'></option>";
         }
         //$tmp_data_record = $app->tform->getDataRecord($this->id);
         if (is_array($clients)) {
             foreach ($clients as $client) {
                 $selected = @(is_array($this->dataRecord) && ($client["groupid"] == $this->dataRecord['client_group_id'] || $client["groupid"] == $this->dataRecord['sys_groupid'])) ? 'SELECTED' : '';
                 $client_select .= "<option value='{$client['groupid']}' {$selected}>{$client['contactname']}</option>\r\n";
             }
         }
         $app->tpl->setVar("client_group_id", $client_select);
     } else {
         if ($app->auth->has_clients($_SESSION['s']['user']['userid'])) {
             // Get the limits of the client
             $client_group_id = intval($_SESSION["s"]["user"]["default_group"]);
             $client = $app->db->queryOneRecord("SELECT client.client_id, sys_group.name, client.contact_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.groupid = {$client_group_id}");
             // Fill the client select field
             $sql = "SELECT 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 client.parent_client_id = " . $client['client_id'] . " ORDER BY client.company_name, client.contact_name, sys_group.name";
             $clients = $app->db->queryAllRecords($sql);
             $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = " . $client['client_id']);
             $client_select = '<option value="' . $tmp['groupid'] . '">' . $client['contactname'] . '</option>';
             //$tmp_data_record = $app->tform->getDataRecord($this->id);
             if (is_array($clients)) {
                 foreach ($clients as $client) {
                     $selected = @(is_array($this->dataRecord) && ($client["groupid"] == $this->dataRecord['client_group_id'] || $client["groupid"] == $this->dataRecord['sys_groupid'])) ? 'SELECTED' : '';
                     $client_select .= "<option value='{$client['groupid']}' {$selected}>{$client['contactname']}</option>\r\n";
                 }
             }
             $app->tpl->setVar("client_group_id", $client_select);
         }
     }
     if ($this->id > 0) {
         //* we are editing a existing record
         $app->tpl->setVar("edit_disabled", 1);
         $app->tpl->setVar("server_id_value", $this->dataRecord["server_id"]);
     } else {
         $app->tpl->setVar("edit_disabled", 0);
     }
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf;
     //* Client: If the logged in user is not admin and has no sub clients (no rseller)
     if ($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
         //* Get the limits of the client
         $client_group_id = $_SESSION["s"]["user"]["default_group"];
         $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.limit_openvz_vm_template_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = {$client_group_id}");
         //* Fill the template_id field
         if ($client['limit_openvz_vm_template_id'] == 0) {
             $sql = 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name';
         } else {
             $sql = 'SELECT template_id,template_name FROM openvz_template WHERE template_id = ' . $client['limit_openvz_vm_template_id'] . ' ORDER BY template_name';
         }
         $records = $app->db->queryAllRecords($sql);
         if (is_array($records)) {
             foreach ($records as $rec) {
                 $selected = @($rec["template_id"] == $this->dataRecord["template_id"]) ? 'SELECTED' : '';
                 $template_id_select .= "<option value='{$rec['template_id']}' {$selected}>{$rec['template_name']}</option>\r\n";
             }
         }
         $app->tpl->setVar("template_id_select", $template_id_select);
         //* Reseller: If the logged in user is not admin and has sub clients (is a rseller)
     } elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
         //* Get the limits of the client
         $client_group_id = $_SESSION["s"]["user"]["default_group"];
         $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.limit_openvz_vm_template_id, CONCAT(client.company_name,' :: ',client.contact_name) as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = {$client_group_id}");
         //* Fill the client select field
         $sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(client.company_name,' :: ',client.contact_name) as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = " . $client['client_id'] . " ORDER BY sys_group.name";
         $records = $app->db->queryAllRecords($sql);
         $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = " . $client['client_id']);
         $client_select = '<option value="' . $tmp['groupid'] . '">' . $client['name'] . ' :: ' . $client['contactname'] . '</option>';
         //$tmp_data_record = $app->tform->getDataRecord($this->id);
         if (is_array($records)) {
             foreach ($records as $rec) {
                 $selected = @(is_array($this->dataRecord) && ($client["groupid"] == $this->dataRecord['client_group_id'] || $client["groupid"] == $this->dataRecord['sys_groupid'])) ? 'SELECTED' : '';
                 $client_select .= "<option value='{$rec['groupid']}' {$selected}>{$rec['name']} :: {$rec['contactname']}</option>\r\n";
             }
         }
         $app->tpl->setVar("client_group_id", $client_select);
         //* Fill the template_id field
         if ($client['limit_openvz_vm_template_id'] == 0) {
             $sql = 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name';
         } else {
             $sql = 'SELECT template_id,template_name FROM openvz_template WHERE template_id = ' . $client['limit_openvz_vm_template_id'] . ' ORDER BY template_name';
         }
         $records = $app->db->queryAllRecords($sql);
         if (is_array($records)) {
             foreach ($records as $rec) {
                 $selected = @($rec["template_id"] == $this->dataRecord["template_id"]) ? 'SELECTED' : '';
                 $template_id_select .= "<option value='{$rec['template_id']}' {$selected}>{$rec['template_name']}</option>\r\n";
             }
         }
         $app->tpl->setVar("template_id_select", $template_id_select);
         //* Admin: If the logged in user is admin
     } else {
         //* Fill the client select field
         $sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(client.company_name,' :: ',client.contact_name) as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 ORDER BY sys_group.name";
         $clients = $app->db->queryAllRecords($sql);
         $client_select = "<option value='0'></option>";
         //$tmp_data_record = $app->tform->getDataRecord($this->id);
         if (is_array($clients)) {
             foreach ($clients as $client) {
                 $selected = @(is_array($this->dataRecord) && ($client["groupid"] == $this->dataRecord['client_group_id'] || $client["groupid"] == $this->dataRecord['sys_groupid'])) ? 'SELECTED' : '';
                 $client_select .= "<option value='{$client['groupid']}' {$selected}>{$client['name']} :: {$client['contactname']}</option>\r\n";
             }
         }
         $app->tpl->setVar("client_group_id", $client_select);
         //* Fill the template_id field
         $sql = 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name';
         $records = $app->db->queryAllRecords($sql);
         if (is_array($records)) {
             $template_id_select = '';
             foreach ($records as $rec) {
                 $selected = @($rec["template_id"] == $this->dataRecord["template_id"]) ? 'SELECTED' : '';
                 $template_id_select .= "<option value='{$rec['template_id']}' {$selected}>{$rec['template_name']}</option>\r\n";
             }
         }
         $app->tpl->setVar("template_id_select", $template_id_select);
     }
     //* 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 = ".$client['default_webserver']." AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
     if (isset($this->dataRecord["server_id"])) {
         $vm_server_id = $app->functions->intval($this->dataRecord["server_id"]);
     } else {
         $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE vserver_server = 1 AND mirror_server_id = 0 ORDER BY server_name LIMIT 0,1');
         $vm_server_id = $tmp['server_id'];
     }
     $sql = "SELECT ip_address FROM openvz_ip WHERE reserved = 'n' AND (vm_id = 0 or vm_id = '" . $this->id . "') AND server_id = " . $app->functions->intval($vm_server_id) . " ORDER BY ip_address";
     $ips = $app->db->queryAllRecords($sql);
     $ip_select = "";
     if (is_array($ips)) {
         foreach ($ips as $ip) {
             $selected = $ip["ip_address"] == $this->dataRecord["ip_address"] ? 'SELECTED' : '';
             $ip_select .= "<option value='{$ip['ip_address']}' {$selected}>{$ip['ip_address']}</option>\r\n";
         }
     }
     $app->tpl->setVar("ip_address", $ip_select);
     unset($tmp);
     unset($ips);
     if ($this->id > 0) {
         //* we are editing a existing record
         $app->tpl->setVar("edit_disabled", 1);
         $app->tpl->setVar("server_id_value", $this->dataRecord["server_id"]);
         $app->tpl->setVar("ostemplate_id_value", $this->dataRecord["ostemplate_id"]);
     } else {
         $app->tpl->setVar("edit_disabled", 0);
     }
     // Datepicker
     $date_format = $app->lng('conf_format_dateshort');
     $trans = array("d" => "dd", "m" => "mm", "Y" => "yy");
     $date_format = strtr($date_format, $trans);
     $app->tpl->setVar("date_format", $date_format);
     $app->tpl->setVar("daynamesmin_su", $app->lng('daynamesmin_su'));
     $app->tpl->setVar("daynamesmin_mo", $app->lng('daynamesmin_mo'));
     $app->tpl->setVar("daynamesmin_tu", $app->lng('daynamesmin_tu'));
     $app->tpl->setVar("daynamesmin_we", $app->lng('daynamesmin_we'));
     $app->tpl->setVar("daynamesmin_th", $app->lng('daynamesmin_th'));
     $app->tpl->setVar("daynamesmin_fr", $app->lng('daynamesmin_fr'));
     $app->tpl->setVar("daynamesmin_sa", $app->lng('daynamesmin_sa'));
     $app->tpl->setVar("daynames_sunday", $app->lng('daynames_sunday'));
     $app->tpl->setVar("daynames_monday", $app->lng('daynames_monday'));
     $app->tpl->setVar("daynames_tuesday", $app->lng('daynames_tuesday'));
     $app->tpl->setVar("daynames_wednesday", $app->lng('daynames_wednesday'));
     $app->tpl->setVar("daynames_thursday", $app->lng('daynames_thursday'));
     $app->tpl->setVar("daynames_friday", $app->lng('daynames_friday'));
     $app->tpl->setVar("daynames_saturday", $app->lng('daynames_saturday'));
     $app->tpl->setVar("monthnamesshort_jan", $app->lng('monthnamesshort_jan'));
     $app->tpl->setVar("monthnamesshort_feb", $app->lng('monthnamesshort_feb'));
     $app->tpl->setVar("monthnamesshort_mar", $app->lng('monthnamesshort_mar'));
     $app->tpl->setVar("monthnamesshort_apr", $app->lng('monthnamesshort_apr'));
     $app->tpl->setVar("monthnamesshort_may", $app->lng('monthnamesshort_may'));
     $app->tpl->setVar("monthnamesshort_jun", $app->lng('monthnamesshort_jun'));
     $app->tpl->setVar("monthnamesshort_jul", $app->lng('monthnamesshort_jul'));
     $app->tpl->setVar("monthnamesshort_aug", $app->lng('monthnamesshort_aug'));
     $app->tpl->setVar("monthnamesshort_sep", $app->lng('monthnamesshort_sep'));
     $app->tpl->setVar("monthnamesshort_oct", $app->lng('monthnamesshort_oct'));
     $app->tpl->setVar("monthnamesshort_nov", $app->lng('monthnamesshort_nov'));
     $app->tpl->setVar("monthnamesshort_dec", $app->lng('monthnamesshort_dec'));
     $app->tpl->setVar("datepicker_nextText", $app->lng('datepicker_nextText'));
     $app->tpl->setVar("datepicker_prevText", $app->lng('datepicker_prevText'));
     parent::onShowEnd();
 }
 function onShowEnd()
 {
     global $app, $conf, $interfaceConf;
     if ($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
         // Get the limits of the client
         $client_group_id = $_SESSION["s"]["user"]["default_group"];
         $client = $app->db->queryOneRecord("SELECT default_dbserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = {$client_group_id}");
         // Set the webserver to the default server of the client
         $tmp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = {$client['default_dbserver']}");
         $app->tpl->setVar("server_id", "<option value='{$client['default_dbserver']}'>{$tmp['server_name']}</option>");
         unset($tmp);
     } elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
         // Get the limits of the client
         $client_group_id = $_SESSION["s"]["user"]["default_group"];
         $client = $app->db->queryOneRecord("SELECT client.client_id, limit_web_domain, default_webserver, contact_name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = {$client_group_id}");
         // Set the webserver to the default server of the client
         $tmp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = {$client['default_webserver']}");
         $app->tpl->setVar("server_id", "<option value='{$client['default_webserver']}'>{$tmp['server_name']}</option>");
         unset($tmp);
     } else {
         // The user is admin
         if ($this->id > 0) {
             $server_id = $this->dataRecord["server_id"];
         } else {
             // Get the first server ID
             $tmp = $app->db->queryOneRecord("SELECT server_id FROM server WHERE web_server = 1 ORDER BY server_name LIMIT 0,1");
             $server_id = $tmp['server_id'];
         }
     }
     /*
      * If the names are restricted -> remove the restriction, so that the
      * data can be edited
      */
     //* Get the database name and database user prefix
     $app->uses('getconf,tools_sites');
     $global_config = $app->getconf->get_global_config('sites');
     $dbname_prefix = $app->tools_sites->replacePrefix($global_config['dbname_prefix'], $this->dataRecord);
     if ($this->dataRecord['database_name'] != "") {
         /* REMOVE the restriction */
         $app->tpl->setVar("database_name", $app->tools_sites->removePrefix($this->dataRecord['database_name'], $this->dataRecord['database_name_prefix'], $dbname_prefix));
     }
     $app->tpl->setVar("database_name_prefix", $app->tools_sites->getPrefix($this->dataRecord['database_name_prefix'], $dbname_prefix, $global_config['dbname_prefix']));
     if ($this->id > 0) {
         //* we are editing a existing record
         $app->tpl->setVar("edit_disabled", 1);
         $app->tpl->setVar("server_id_value", $this->dataRecord["server_id"]);
         $app->tpl->setVar("database_charset_value", $this->dataRecord["database_charset"]);
     } else {
         $app->tpl->setVar("edit_disabled", 0);
     }
     parent::onShowEnd();
 }