From 460d41095fad513b9c348143031255482f7c6d9f Mon Sep 17 00:00:00 2001 From: David Ramos Date: Fri, 1 Dec 2017 10:18:51 +0100 Subject: [PATCH] Eliminados archivos y comentarios innecesarios. --- database_edit.php | 513 ----------------------------------- database_user_edit.php | 249 ----------------- form/database.tform.php | 194 ------------- form/database_user.tform.php | 134 --------- form/ftp_user.tform.php | 303 --------------------- ftp_user_edit.php | 221 --------------- new_service_webdns.php | 6 +- templates/database_edit.htm | 157 ----------- templates/ftp_user_edit.htm | 67 ----- 9 files changed, 3 insertions(+), 1841 deletions(-) delete mode 100755 database_edit.php delete mode 100755 database_user_edit.php delete mode 100755 form/database.tform.php delete mode 100755 form/database_user.tform.php delete mode 100755 form/ftp_user.tform.php delete mode 100755 ftp_user_edit.php delete mode 100755 templates/database_edit.htm delete mode 100755 templates/ftp_user_edit.htm diff --git a/database_edit.php b/database_edit.php deleted file mode 100755 index 213063a..0000000 --- a/database_edit.php +++ /dev/null @@ -1,513 +0,0 @@ -auth->check_module_permissions('sites'); - -// Loading classes -$app->uses('tpl,tform,tform_actions'); -$app->load('tform_actions'); - -class page_action extends tform_actions { - - function onShowNew() { - global $app, $conf; - - // we will check only users, not admins - if($_SESSION["s"]["user"]["typ"] == 'user') { - if(!$app->tform->checkClientLimit('limit_database')) { - $app->error($app->tform->wordbook["limit_database_txt"]); - } - if(!$app->tform->checkResellerLimit('limit_database')) { - $app->error('Reseller: '.$app->tform->wordbook["limit_database_txt"]); - } - } else { - $settings = $app->getconf->get_global_config('sites'); - $app->tform->formDef['tabs']['database']['fields']['server_id']['default'] = intval($settings['default_dbserver']); - } - - parent::onShowNew(); - } - - 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 db_servers 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->queryAllRecords("SELECT server_id, server_name FROM server WHERE server_id IN ?", explode(',', $client['db_servers'])); - - $only_one_server = count($tmp) === 1; - $app->tpl->setVar('only_one_server', $only_one_server); - - if ($only_one_server) { - $app->tpl->setVar('server_id_value', $tmp[0]['server_id']); - } - - foreach ($tmp as $db_server) { - $options_db_servers .= ''; - } - - $app->tpl->setVar("server_id", $options_db_servers); - 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, db_servers, 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->queryAllRecords("SELECT server_id, server_name FROM server WHERE server_id IN ?", explode(',', $client['db_servers'])); - - $only_one_server = count($tmp) === 1; - $app->tpl->setVar('only_one_server', $only_one_server); - - if ($only_one_server) { - $app->tpl->setVar('server_id_value', $tmp[0]['server_id']); - } - - foreach ($tmp as $db_server) { - $options_db_servers .= ''; - } - - $app->tpl->setVar("server_id", $options_db_servers); - 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)); - } - - if($this->dataRecord['database_name'] == "") { - $app->tpl->setVar("database_name_prefix", $dbname_prefix); - } else { - $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 - $edit_disabled = @($_SESSION["s"]["user"]["typ"] == 'admin')? 0 : 1; //* admin can change the database-name - $app->tpl->setVar("edit_disabled", $edit_disabled); - $app->tpl->setVar("server_id_value", $this->dataRecord["server_id"]); - $app->tpl->setVar("database_charset_value", $this->dataRecord["database_charset"]); - $app->tpl->setVar("limit_database_quota", $this->dataRecord["database_quota"]); - } else { - $app->tpl->setVar("edit_disabled", 0); - } - - parent::onShowEnd(); - } - - function onSubmit() { - global $app, $conf; - - $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ? AND ".$app->tform->getAuthSQL('r'), @$this->dataRecord["parent_domain_id"]); - if(!$parent_domain || $parent_domain['domain_id'] != @$this->dataRecord['parent_domain_id']) $app->tform->errorMessage .= $app->tform->lng("no_domain_perm"); - - if($_SESSION["s"]["user"]["typ"] != 'admin') { - // Get the limits of the client - $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT db_servers, limit_database, limit_database_quota, parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.groupid = ?", $client_group_id); - - // When the record is updated - if($this->id > 0) { - // restore the server ID if the user is not admin and record is edited - $tmp = $app->db->queryOneRecord("SELECT server_id FROM web_database WHERE database_id = ?", $app->functions->intval($this->id)); - $this->dataRecord["server_id"] = $tmp["server_id"]; - unset($tmp); - //* Check client quota - if ($client['limit_database_quota'] >= 0) { - //* get the database 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); - //* get quota from other databases - $tmp = $app->db->queryOneRecord("SELECT sum(database_quota) as db_quota FROM web_database WHERE sys_groupid = ? AND database_name <> ?", $client_group_id, $dbname_prefix.$this->dataRecord['database_name']); - $used_quota = $app->functions->intval($tmp['db_quota']); - $new_db_quota = $app->functions->intval($this->dataRecord["database_quota"]); - if(($used_quota + $new_db_quota > $client['limit_database_quota']) || ($new_db_quota < 0 && $client['limit_database_quota'] >= 0)) { - $max_free_quota = floor($client['limit_database_quota'] - $used_quota); - if($max_free_quota < 0) { - $max_free_quota = 0; - } - $app->tform->errorMessage .= $app->tform->lng("limit_database_quota_free_txt").": ".$max_free_quota." MB
"; - $this->dataRecord['database_quota'] = $max_free_quota; - } - unset($tmp); - unset($global_config); - unset($dbname_prefix); - } - - if($client['parent_client_id'] > 0) { - // Get the limits of the reseller - $reseller = $app->db->queryOneRecord("SELECT limit_database, limit_database_quota FROM client WHERE client_id = ?", $client['parent_client_id']); - - //* Check the website quota of the client - if ($reseller['limit_database_quota'] >= 0) { - //* get the database 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); - //* get quota from other databases - $tmp = $app->db->queryOneRecord("SELECT sum(database_quota) as db_quota FROM web_database, sys_group, client WHERE web_database.sys_groupid=sys_group.groupid AND sys_group.client_id=client.client_id AND ? IN (client.parent_client_id, client.client_id) AND database_name <> ?", $client['parent_client_id'], $dbname_prefix.$this->dataRecord['database_name']); - - $used_quota = $app->functions->intval($tmp['db_quota']); - $new_db_quota = $app->functions->intval($this->dataRecord["database_quota"]); - if(($used_quota + $new_db_quota > $reseller["limit_database_quota"]) || ($new_db_quota < 0 && $reseller["limit_database_quota"] >= 0)) { - $max_free_quota = floor($reseller["limit_database_quota"] - $used_quota); - if($max_free_quota < 0) $max_free_quota = 0; - $app->tform->errorMessage .= $app->tform->lng("limit_database_quota_free_txt").": ".$max_free_quota." MB
"; - $this->dataRecord["database_quota"] = $max_free_quota; - } - unset($tmp); - unset($global_config); - unset($dbname_prefix); - } - } - // When the record is inserted - } else { - $client['db_servers_ids'] = explode(',', $client['db_servers']); - - // Check if chosen server is in authorized servers for this client - if (!(is_array($client['db_servers_ids']) && in_array($this->dataRecord["server_id"], $client['db_servers_ids'])) && $_SESSION["s"]["user"]["typ"] != 'admin') { - $app->error($app->tform->wordbook['error_not_allowed_server_id']); - } - - // Check if the user may add another database - if($client["limit_database"] >= 0) { - $tmp = $app->db->queryOneRecord("SELECT count(database_id) as number FROM web_database WHERE sys_groupid = ?", $client_group_id); - if($tmp["number"] >= $client["limit_database"]) { - $app->error($app->tform->wordbook["limit_database_txt"]); - } - } - - //* Check client quota - if ($client['limit_database_quota'] >= 0) { - $tmp = $app->db->queryOneRecord("SELECT sum(database_quota) as db_quota FROM web_database WHERE sys_groupid = ?", $client_group_id); - $db_quota = $tmp['db_quota']; - $new_db_quota = $app->functions->intval($this->dataRecord["database_quota"]); - if(($db_quota + $new_db_quota > $client['limit_database_quota']) || ($new_db_quota < 0 && $client['limit_database_quota'] >= 0)) { - $max_free_quota = floor($client['limit_database_quota'] - $db_quota); - if($max_free_quota < 0) $max_free_quota = 0; - $app->tform->errorMessage .= $app->tform->lng("limit_database_quota_free_txt").": ".$max_free_quota." MB
"; - $this->dataRecord['database_quota'] = $max_free_quota; - } - unset($tmp); - } - } - } else { - // check if client of database parent domain is client of db user! - $web_group = $app->db->queryOneRecord("SELECT sys_groupid FROM web_domain WHERE domain_id = ?", $this->dataRecord['parent_domain_id']); - if($this->dataRecord['database_user_id']) { - $group = $app->db->queryOneRecord("SELECT sys_groupid FROM web_database_user WHERE database_user_id = ?", $this->dataRecord['database_user_id']); - if($group['sys_groupid'] != $web_group['sys_groupid']) { - $app->error($app->tform->wordbook['database_client_differs_txt']); - } - } - if($this->dataRecord['database_ro_user_id']) { - $group = $app->db->queryOneRecord("SELECT sys_groupid FROM web_database_user WHERE database_user_id = ?", $this->dataRecord['database_ro_user_id']); - if($group['sys_groupid'] != $web_group['sys_groupid']) { - $app->error($app->tform->wordbook['database_client_differs_txt']); - } - } - } - - - parent::onSubmit(); - } - - function onBeforeUpdate() { - global $app, $conf, $interfaceConf; - - //* Site shall not be empty - if($this->dataRecord['parent_domain_id'] == 0) $app->tform->errorMessage .= $app->tform->lng("database_site_error_empty").'
'; - - //* 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); - - //* Prevent that the database name and charset is changed - $old_record = $app->tform->getDataRecord($this->id); - $dbname_prefix = $app->tools_sites->getPrefix($old_record['database_name_prefix'], $dbname_prefix); - $this->dataRecord['database_name_prefix'] = $dbname_prefix; - - //* Only admin can change the database name - if ($_SESSION["s"]["user"]["typ"] != 'admin') { - if($old_record["database_name"] != $dbname_prefix . $this->dataRecord["database_name"]) { - $app->tform->errorMessage .= $app->tform->wordbook["database_name_change_txt"].'
'; - } - } - if($old_record["database_charset"] != $this->dataRecord["database_charset"]) { - $app->tform->errorMessage .= $app->tform->wordbook["database_charset_change_txt"].'
'; - } - - if(!$this->dataRecord['database_user_id']) { - $app->tform->errorMessage .= $app->tform->wordbook["database_user_missing_txt"].'
'; - } - - //* Database username and database name shall not be empty - if($this->dataRecord['database_name'] == '') $app->tform->errorMessage .= $app->tform->wordbook["database_name_error_empty"].'
'; - - //* Check if the server has been changed - // We do this only for the admin or reseller users, as normal clients can not change the server ID anyway - if($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) { - if($old_record["server_id"] != $this->dataRecord["server_id"]) { - //* Add a error message and switch back to old server - $app->tform->errorMessage .= $app->lng('The Server can not be changed.'); - $this->dataRecord["server_id"] = $rec['server_id']; - } - } - unset($old_record); - - if(strlen($dbname_prefix . $this->dataRecord['database_name']) > 64) $app->tform->errorMessage .= str_replace('{db}', $dbname_prefix . $this->dataRecord['database_name'], $app->tform->wordbook["database_name_error_len"]).'
'; - - //* Check database name and user against blacklist - $dbname_blacklist = array($conf['db_database'], 'mysql'); - if(in_array($dbname_prefix . $this->dataRecord['database_name'], $dbname_blacklist)) { - $app->tform->errorMessage .= $app->lng('Database name not allowed.').'
'; - } - - if ($app->tform->errorMessage == ''){ - /* restrict the names if there is no error */ - /* crop user and db names if they are too long -> mysql: user: 16 chars / db: 64 chars */ - $this->dataRecord['database_name'] = substr($dbname_prefix . $this->dataRecord['database_name'], 0, 64); - } - - //* Check for duplicates - $tmp = $app->db->queryOneRecord("SELECT count(database_id) as dbnum FROM web_database WHERE database_name = ? AND server_id = ? AND database_id != ?", $this->dataRecord['database_name'], $this->dataRecord["server_id"], $this->id); - if($tmp['dbnum'] > 0) $app->tform->errorMessage .= $app->lng('database_name_error_unique').'
'; - - // get the web server ip (parent domain) - $tmp = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = ?", $this->dataRecord['parent_domain_id']); - if($tmp['server_id'] && $tmp['server_id'] != $this->dataRecord['server_id']) { - // we need remote access rights for this server, so get it's ip address - $server_config = $app->getconf->get_server_config($tmp['server_id'], 'server'); - if($server_config['ip_address']!='') { - if($this->dataRecord['remote_access'] != 'y'){ - $this->dataRecord['remote_ips'] = $server_config['ip_address']; - $this->dataRecord['remote_access'] = 'y'; - } else { - if($this->dataRecord['remote_ips'] != ''){ - if(preg_match('/(^|,)' . preg_quote($server_config['ip_address'], '/') . '(,|$)/', $this->dataRecord['remote_ips']) == false) { - $this->dataRecord['remote_ips'] .= ',' . $server_config['ip_address']; - } - $tmp = preg_split('/\s*,\s*/', $this->dataRecord['remote_ips']); - $tmp = array_unique($tmp); - $this->dataRecord['remote_ips'] = implode(',', $tmp); - unset($tmp); - } - } - } - } - - if ($app->tform->errorMessage == '') { - // force update of the used database user - if($this->dataRecord['database_user_id']) { - $user_old_rec = $app->db->queryOneRecord('SELECT * FROM `web_database_user` WHERE `database_user_id` = ?', $this->dataRecord['database_user_id']); - if($user_old_rec) { - $user_new_rec = $user_old_rec; - $user_new_rec['server_id'] = $this->dataRecord['server_id']; - $app->db->datalogSave('web_database_user', 'UPDATE', 'database_user_id', $this->dataRecord['database_user_id'], $user_old_rec, $user_new_rec); - } - } - if($this->dataRecord['database_ro_user_id']) { - $user_old_rec = $app->db->queryOneRecord('SELECT * FROM `web_database_user` WHERE `database_user_id` = ?', $this->dataRecord['database_ro_user_id']); - if($user_old_rec) { - $user_new_rec = $user_old_rec; - $user_new_rec['server_id'] = $this->dataRecord['server_id']; - $app->db->datalogSave('web_database_user', 'UPDATE', 'database_user_id', $this->dataRecord['database_ro_user_id'], $user_old_rec, $user_new_rec); - } - } - } - - parent::onBeforeUpdate(); - } - - function onBeforeInsert() { - global $app, $conf, $interfaceConf; - - //* Site shell not be empty - if($this->dataRecord['parent_domain_id'] == 0) $app->tform->errorMessage .= $app->tform->lng("database_site_error_empty").'
'; - - //* Database username and database name shall not be empty - if($this->dataRecord['database_name'] == '') $app->tform->errorMessage .= $app->tform->wordbook["database_name_error_empty"].'
'; - - //* 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); - $this->dataRecord['database_name_prefix'] = $dbname_prefix; - - if(strlen($dbname_prefix . $this->dataRecord['database_name']) > 64) $app->tform->errorMessage .= str_replace('{db}', $dbname_prefix . $this->dataRecord['database_name'], $app->tform->wordbook["database_name_error_len"]).'
'; - - //* Check database name and user against blacklist - $dbname_blacklist = array($conf['db_database'], 'mysql'); - if(in_array($dbname_prefix . $this->dataRecord['database_name'], $dbname_blacklist)) { - $app->tform->errorMessage .= $app->lng('Database name not allowed.').'
'; - } - - /* restrict the names */ - /* crop user and db names if they are too long -> mysql: user: 16 chars / db: 64 chars */ - if ($app->tform->errorMessage == ''){ - $this->dataRecord['database_name'] = substr($dbname_prefix . $this->dataRecord['database_name'], 0, 64); - } - - //* Check for duplicates - $tmp = $app->db->queryOneRecord("SELECT count(database_id) as dbnum FROM web_database WHERE database_name = ? AND server_id = ?", $this->dataRecord['database_name'], $this->dataRecord["server_id"]); - if($tmp['dbnum'] > 0) $app->tform->errorMessage .= $app->tform->lng('database_name_error_unique').'
'; - - // get the web server ip (parent domain) - $tmp = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = ?", $this->dataRecord['parent_domain_id']); - if($tmp['server_id'] && $tmp['server_id'] != $this->dataRecord['server_id']) { - // we need remote access rights for this server, so get it's ip address - $server_config = $app->getconf->get_server_config($tmp['server_id'], 'server'); - if($server_config['ip_address']!='') { - if($this->dataRecord['remote_access'] != 'y'){ - $this->dataRecord['remote_ips'] = $server_config['ip_address']; - $this->dataRecord['remote_access'] = 'y'; - } else { - if($this->dataRecord['remote_ips'] != ''){ - if(preg_match('/(^|,)' . preg_quote($server_config['ip_address'], '/') . '(,|$)/', $this->dataRecord['remote_ips']) == false) { - $this->dataRecord['remote_ips'] .= ',' . $server_config['ip_address']; - } - $tmp = preg_split('/\s*,\s*/', $this->dataRecord['remote_ips']); - $tmp = array_unique($tmp); - $this->dataRecord['remote_ips'] = implode(',', $tmp); - unset($tmp); - } - } - } - } - - if ($app->tform->errorMessage == '') { - // force update of the used database user - if($this->dataRecord['database_user_id']) { - $user_old_rec = $app->db->queryOneRecord('SELECT * FROM `web_database_user` WHERE `database_user_id` = ?', $this->dataRecord['database_user_id']); - if($user_old_rec) { - $user_new_rec = $user_old_rec; - $user_new_rec['server_id'] = $this->dataRecord['server_id']; - $app->db->datalogSave('web_database_user', 'UPDATE', 'database_user_id', $this->dataRecord['database_user_id'], $user_old_rec, $user_new_rec); - } - } - if($this->dataRecord['database_ro_user_id']) { - $user_old_rec = $app->db->queryOneRecord('SELECT * FROM `web_database_user` WHERE `database_user_id` = ?', $this->dataRecord['database_ro_user_id']); - if($user_old_rec) { - $user_new_rec = $user_old_rec; - $user_new_rec['server_id'] = $this->dataRecord['server_id']; - $app->db->datalogSave('web_database_user', 'UPDATE', 'database_user_id', $this->dataRecord['database_ro_user_id'], $user_old_rec, $user_new_rec); - } - } - } - - - parent::onBeforeInsert(); - } - - function onInsertSave($sql) { - global $app, $conf; - - $app->db->query($sql); - if($app->db->errorMessage != '') die($app->db->errorMessage); - $new_id = $app->db->insertID(); - - return $new_id; - } - - function onUpdateSave($sql) { - global $app; - if(!empty($sql) && !$app->tform->isReadonlyTab($app->tform->getCurrentTab(), $this->id)) { - - $app->db->query($sql); - if($app->db->errorMessage != '') die($app->db->errorMessage); - } - } - - function onAfterInsert() { - global $app, $conf; - - $app->uses('sites_database_plugin'); - $app->sites_database_plugin->processDatabaseInsert($this); - } - - function onAfterUpdate() { - global $app, $conf; - - $app->uses('sites_database_plugin'); - $app->sites_database_plugin->processDatabaseUpdate($this); - } - -} - -$page = new page_action; -$page->onLoad(); - -?> diff --git a/database_user_edit.php b/database_user_edit.php deleted file mode 100755 index 5224cc5..0000000 --- a/database_user_edit.php +++ /dev/null @@ -1,249 +0,0 @@ -auth->check_module_permissions('sites'); - -// Loading classes -$app->uses('tpl,tform,tform_actions'); -$app->load('tform_actions'); - -class page_action extends tform_actions { - - function onShowNew() { - global $app; - - // we will check only users, not admins - if($_SESSION['s']['user']['typ'] == 'user') { - if(!$app->tform->checkClientLimit('limit_database_user')) { - $app->error($app->tform->wordbook["limit_database_user_txt"]); - } - if(!$app->tform->checkResellerLimit('limit_database_user')) { - $app->error('Reseller: '.$app->tform->wordbook["limit_database_user_txt"]); - } - } - - parent::onShowNew(); - } - - function onShowEnd() { - global $app, $conf, $interfaceConf; - - /* - * If the names are restricted -> remove the restriction, so that the - * data can be edited - */ - - //* Get the database user prefix - $app->uses('getconf,tools_sites'); - $global_config = $app->getconf->get_global_config('sites'); - $dbuser_prefix = $app->tools_sites->replacePrefix($global_config['dbuser_prefix'], $this->dataRecord); - - 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.company_name, client.contact_name, client.client_id 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 = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; - $records = $app->db->queryAllRecords($sql, $client['client_id']); - $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client['client_id']); - $client_select = ''; - //$tmp_data_record = $app->tform->getDataRecord($this->id); - if(is_array($records)) { - foreach( $records as $rec) { - $selected = @(is_array($this->dataRecord) && ($rec["groupid"] == $this->dataRecord['client_group_id'] || $rec["groupid"] == $this->dataRecord['sys_groupid']))?'SELECTED':''; - $client_select .= "\r\n"; - } - } - $app->tpl->setVar("client_group_id", $client_select); - } elseif($_SESSION["s"]["user"]["typ"] == 'admin') { - // 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 = ""; - //$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':''; - $selected = @(is_array($this->dataRecord) && ($client["groupid"] == $this->dataRecord['client_group_id'] || $client["groupid"] == $this->dataRecord['sys_groupid']))?'SELECTED':''; - $client_select .= "\r\n"; - } - } - $app->tpl->setVar("client_group_id", $client_select); - } - - - if ($this->dataRecord['database_user'] != ""){ - /* REMOVE the restriction */ - $app->tpl->setVar("database_user", $app->tools_sites->removePrefix($this->dataRecord['database_user'], $this->dataRecord['database_user_prefix'], $dbuser_prefix)); - } - - if($this->dataRecord['database_user'] == "") { - $app->tpl->setVar("database_user_prefix", $dbuser_prefix); - } else { - $app->tpl->setVar("database_user_prefix", $app->tools_sites->getPrefix($this->dataRecord['database_user_prefix'], $dbuser_prefix, $global_config['dbuser_prefix'])); - } - - parent::onShowEnd(); - } - - function onSubmit() { - global $app; - - if($_SESSION['s']['user']['typ'] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) unset($this->dataRecord["client_group_id"]); - - parent::onSubmit(); - } - - function onBeforeUpdate() { - global $app, $conf, $interfaceConf; - - //* Get the database user prefix - $app->uses('getconf,tools_sites'); - $global_config = $app->getconf->get_global_config('sites'); - $dbuser_prefix = $app->tools_sites->replacePrefix($global_config['dbuser_prefix'], $this->dataRecord); - - $this->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM web_database_user WHERE database_user_id = ?", $this->id); - - $dbuser_prefix = $app->tools_sites->getPrefix($this->oldDataRecord['database_user_prefix'], $dbuser_prefix); - $this->dataRecord['database_user_prefix'] = $dbuser_prefix; - - //* Database username shall not be empty - if($this->dataRecord['database_user'] == '') $app->tform->errorMessage .= $app->tform->wordbook["database_user_error_empty"].'
'; - - if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16) $app->tform->errorMessage .= str_replace('{user}', htmlentities($dbuser_prefix . $this->dataRecord['database_user'], ENT_QUOTES, 'UTF-8'), $app->tform->wordbook["database_user_error_len"]).'
'; - - //* Check database user against blacklist - $dbuser_blacklist = array($conf['db_user'], 'mysql', 'root'); - if(in_array($dbuser_prefix . $this->dataRecord['database_user'], $dbuser_blacklist)) { - $app->tform->errorMessage .= $app->lng('Database user not allowed.').'
'; - } - - if ($app->tform->errorMessage == ''){ - /* restrict the names if there is no error */ - /* crop user and db names if they are too long -> mysql: user: 16 chars / db: 64 chars */ - $this->dataRecord['database_user'] = substr($dbuser_prefix . $this->dataRecord['database_user'], 0, 16); - } - - /* prepare password for MongoDB */ - // TODO: this still doens't work as when only the username changes we have no database_password. - // taking the one from oldData doesn't work as it's encrypted...shit! -/* - $this->dataRecord['database_password_mongo'] = $this->dataRecord['database_user'].":mongo:".$this->dataRecord['database_password']; - - $this->dataRecord['server_id'] = 0; // we need this on all servers -*/ - parent::onBeforeUpdate(); - } - - function onBeforeInsert() { - global $app, $conf, $interfaceConf; - - //* Database username shall not be empty - if($this->dataRecord['database_user'] == '') $app->tform->errorMessage .= $app->tform->wordbook["database_user_error_empty"].'
'; - - //* Database password shall not be empty - if($this->dataRecord['database_password'] == '') $app->tform->errorMessage .= $app->tform->wordbook["database_password_error_empty"].'
'; - - //* Get the database name and database user prefix - $app->uses('getconf,tools_sites'); - $global_config = $app->getconf->get_global_config('sites'); - $dbuser_prefix = $app->tools_sites->replacePrefix($global_config['dbuser_prefix'], $this->dataRecord); - - $this->dataRecord['database_user_prefix'] = $dbuser_prefix; - - if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16) $app->tform->errorMessage .= str_replace('{user}', htmlentities($dbuser_prefix . $this->dataRecord['database_user'], ENT_QUOTES, 'UTF-8'), $app->tform->wordbook["database_user_error_len"]).'
'; - - //* Check database user against blacklist - $dbuser_blacklist = array($conf['db_user'], 'mysql', 'root'); - if(is_array($dbuser_blacklist) && in_array($dbuser_prefix . $this->dataRecord['database_user'], $dbuser_blacklist)) { - $app->tform->errorMessage .= $app->lng('Database user not allowed.').'
'; - } - - /* restrict the names */ - /* crop user names if they are too long -> mysql: user: 16 chars / db: 64 chars */ - if ($app->tform->errorMessage == ''){ - $this->dataRecord['database_user'] = substr($dbuser_prefix . $this->dataRecord['database_user'], 0, 16); - } - - $this->dataRecord['server_id'] = 0; // we need this on all servers - - /* prepare password for MongoDB */ -// $this->dataRecord['database_password_mongo'] = $this->dataRecord['database_user'].":mongo:".$this->dataRecord['database_password']; - - parent::onBeforeInsert(); - } - - function onAfterInsert() { - global $app, $conf; - - if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) { - $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); - $app->db->query("UPDATE web_database_user SET sys_groupid = ?, sys_perm_group = 'riud' WHERE database_user_id = ?", $client_group_id, $this->id); - } - if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) { - $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); - $app->db->query("UPDATE web_database_user SET sys_groupid = ?, sys_perm_group = 'riud' WHERE database_user_id = ?", $client_group_id, $this->id); - } - } - - function onAfterUpdate() { - global $app, $conf; - - if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) { - $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); - $app->db->query("UPDATE web_database_user SET sys_groupid = ?, sys_perm_group = 'riud' WHERE database_user_id = ?", $client_group_id, $this->id); - } - if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) { - $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); - $app->db->query("UPDATE web_database_user SET sys_groupid = ?, sys_perm_group = 'riud' WHERE database_user_id = ?", $client_group_id, $this->id); - } - } - -} - -$page = new page_action; -$page->onLoad(); - -?> diff --git a/form/database.tform.php b/form/database.tform.php deleted file mode 100755 index aef56f5..0000000 --- a/form/database.tform.php +++ /dev/null @@ -1,194 +0,0 @@ - 0 id must match with id of current user -$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user -$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete -$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete -$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete - -$form["tabs"]['database'] = array ( - 'title' => "Database", - 'width' => 100, - 'template' => "templates/database_edit.htm", - 'fields' => array ( - //################################# - // Begin Datatable fields - //################################# - 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} AND db_server = 1 ORDER BY server_name', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'value' => '' - ), - 'parent_domain_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => "SELECT web_domain.domain_id, CONCAT(web_domain.domain, ' :: ', server.server_name) AS parent_domain FROM web_domain, server WHERE web_domain.type = 'vhost' AND web_domain.server_id = server.server_id AND {AUTHSQL::web_domain} ORDER BY web_domain.domain", - 'keyfield'=> 'domain_id', - 'valuefield'=> 'parent_domain' - ), - 'value' => array('0' => 'select_site_txt') - ), - 'type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'default' => 'mysql', - 'value' => array( - /*'mongo' => 'MongoDB',*/ - 'mysql' => 'MySQL' - ) - ), - 'database_name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'database_name_error_empty'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^[a-zA-Z0-9_]{2,64}$/', - 'errmsg'=> 'database_name_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255', - 'searchable' => 1 - ), - 'database_name_prefix' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '25' - ), - 'database_quota' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'ISINT', - 'errmsg'=> 'limit_database_quota_error_notint'), - ), - 'default' => '-1', - 'value' => '', - 'separator' => '', - 'width' => '10', - 'maxlength' => '10', - 'rows' => '', - 'cols' => '' - ), - 'database_user_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => "SELECT database_user_id,database_user FROM web_database_user WHERE {AUTHSQL} ORDER BY database_user", - 'keyfield'=> 'database_user_id', - 'valuefield'=> 'database_user' - ), - 'value' => array('0' => 'select_dbuser_txt') - ), - 'database_ro_user_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => "SELECT database_user_id,database_user FROM web_database_user WHERE {AUTHSQL} ORDER BY database_user", - 'keyfield'=> 'database_user_id', - 'valuefield'=> 'database_user' - ), - 'value' => array('0' => 'no_dbuser_txt') - ), - 'database_charset' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => array('' => 'DB-Default', 'latin1' => 'Latin 1', 'utf8' => 'UTF-8') - ), - 'remote_access' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n', 1 => 'y') - ), - 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'y', - 'value' => array(0 => 'n', 1 => 'y') - ), - 'remote_ips' => array ( - 'datatype' => 'TEXT', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'CUSTOM', - 'class' => 'validate_database', - 'function' => 'valid_ip_list', - 'errmsg' => 'database_remote_error_ips'), - ), - 'default' => '', - 'value' => '', - 'width' => '60', - 'searchable' => 2 - ), - //################################# - // ENDE Datatable fields - //################################# - ) -); - - -?> diff --git a/form/database_user.tform.php b/form/database_user.tform.php deleted file mode 100755 index 48a340e..0000000 --- a/form/database_user.tform.php +++ /dev/null @@ -1,134 +0,0 @@ - 0 id must match with id of current user -$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user -$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete -$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete -$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete - -$form["tabs"]['database_user'] = array ( - 'title' => "Database User", - 'width' => 100, - 'template' => "templates/new_service_webdns.htm", - 'fields' => array ( - //################################# - // Begin Datatable fields - //################################# - 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} AND db_server = 1 ORDER BY server_name', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'value' => '' - ), - 'database_user' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'database_user_error_empty'), - 1 => array ( 'type' => 'UNIQUE', - 'errmsg'=> 'database_user_error_unique'), - 2 => array ( 'type' => 'REGEX', - 'regex' => '/^[a-zA-Z0-9_]{2,64}$/', - 'errmsg'=> 'database_user_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255', - 'searchable' => 1 - ), - 'database_user_prefix' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '25' - ), - 'database_password' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'PASSWORD', - 'validators' => array( - 0 => array( - 'type' => 'CUSTOM', - 'class' => 'validate_password', - 'function' => 'password_check', - 'errmsg' => 'weak_password_txt' - ) - ), - 'encryption' => 'MYSQL', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' - ), - 'database_password_mongo' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'PASSWORD', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' - ), - //################################# - // ENDE Datatable fields - //################################# - ) -); - - -?> diff --git a/form/ftp_user.tform.php b/form/ftp_user.tform.php deleted file mode 100755 index 239bfdb..0000000 --- a/form/ftp_user.tform.php +++ /dev/null @@ -1,303 +0,0 @@ - 0 id must match with id of current user -$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user -$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete -$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete -$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete - -$form["tabs"]['ftp'] = array ( - 'title' => "FTP User", - 'width' => 100, - 'template' => "templates/ftp_user_edit.htm", - 'fields' => array ( - //################################# - // Begin Datatable fields - //################################# - 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'value' => '' - ), - 'parent_domain_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => "SELECT web_domain.domain_id, CONCAT(web_domain.domain, ' :: ', server.server_name) AS parent_domain FROM web_domain, server WHERE web_domain.type = 'vhost' AND web_domain.server_id = server.server_id AND {AUTHSQL::web_domain} ORDER BY web_domain.domain", - 'keyfield'=> 'domain_id', - 'valuefield'=> 'parent_domain' - ), - 'value' => '' - ), - 'username' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'UNIQUE', - 'errmsg'=> 'username_error_unique'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-@\+]{0,64}$/', - 'errmsg'=> 'username_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255', - 'searchable' => 1 - ), - 'username_prefix' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '25' - ), - 'password' => array ( - 'datatype' => 'VARCHAR', - 'validators' => array( - 0 => array( - 'type' => 'CUSTOM', - 'class' => 'validate_password', - 'function' => 'password_check', - 'errmsg' => 'weak_password_txt' - ) - ), - 'formtype' => 'PASSWORD', - 'encryption' => 'CRYPT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' - ), - 'quota_size' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'quota_size_error_empty'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^(\-1|[0-9]{1,10})$/', - 'errmsg'=> 'quota_size_error_regex'), - ), - 'default' => '-1', - 'value' => '', - 'width' => '7', - 'maxlength' => '7' - ), - 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'y', - 'value' => array(0 => 'n', 1 => 'y') - ), - //################################# - // ENDE Datatable fields - //################################# - ) -); - -if($app->auth->is_admin()) { - - $form["tabs"]['advanced'] = array ( - 'title' => "Options", - 'width' => 100, - 'template' => "templates/ftp_user_advanced.htm", - 'fields' => array ( - //################################# - // Begin Datatable fields - //################################# - 'uid' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'uid_error_empty'), - 1 => array( - 'type' => 'CUSTOM', - 'class' => 'validate_systemuser', - 'function' => 'check_sysuser', - 'check_names' => true, - 'errmsg' => 'invalid_system_user_or_group_txt' - ), - ), - 'default' => '0', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' - ), - 'gid' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'gid_error_empty'), - 1 => array( - 'type' => 'CUSTOM', - 'class' => 'validate_systemuser', - 'function' => 'check_sysgroup', - 'check_names' => true, - 'errmsg' => 'invalid_system_user_or_group_txt' - ), - ), - 'default' => '0', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' - ), - 'dir' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'directory_error_empty'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^\/[a-zA-Z0-9\ \.\-\_\/]{10,128}$/', - 'errmsg'=> 'directory_error_regex'), - 2 => array ( 'type' => 'CUSTOM', - 'class' => 'validate_ftpuser', - 'function' => 'ftp_dir', - 'errmsg' => 'directory_error_notinweb'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' - ), - 'quota_files' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '0', - 'value' => '', - 'width' => '7', - 'maxlength' => '7' - ), - 'ul_ratio' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '0', - 'value' => '', - 'width' => '7', - 'maxlength' => '7' - ), - 'dl_ratio' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '0', - 'value' => '', - 'width' => '7', - 'maxlength' => '7' - ), - 'ul_bandwidth' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '0', - 'value' => '', - 'width' => '7', - 'maxlength' => '7' - ), - 'dl_bandwidth' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '0', - 'value' => '', - 'width' => '7', - 'maxlength' => '7' - ), - //################################# - // ENDE Datatable fields - //################################# - ) - ); - -} else { - - $form["tabs"]['advanced'] = array ( - 'title' => "Options", - 'width' => 100, - 'template' => "templates/ftp_user_advanced_client.htm", - 'fields' => array ( - //################################# - // Begin Datatable fields - //################################# - 'dir' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'directory_error_empty'), - 1 => array ( 'type' => 'CUSTOM', - 'class' => 'validate_ftpuser', - 'function' => 'ftp_dir', - 'errmsg' => 'directory_error_notinweb'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' - ), - //################################# - // ENDE Datatable fields - //################################# - ) - ); - -} - -$form['tabs']['advanced']['fields']['expires'] = array( - 'datatype' => 'DATETIME', - 'formtype' => 'DATETIME' -); - - -?> diff --git a/ftp_user_edit.php b/ftp_user_edit.php deleted file mode 100755 index 9de400c..0000000 --- a/ftp_user_edit.php +++ /dev/null @@ -1,221 +0,0 @@ -auth->check_module_permissions('sites'); - -// Loading classes -$app->uses('tpl,tform,tform_actions'); -$app->load('tform_actions'); - -class page_action extends tform_actions { - - function onShowNew() { - global $app, $conf; - - // we will check only users, not admins - if($_SESSION["s"]["user"]["typ"] == 'user') { - if(!$app->tform->checkClientLimit('limit_ftp_user')) { - $app->error($app->tform->wordbook["limit_ftp_user_txt"]); - } - if(!$app->tform->checkResellerLimit('limit_ftp_user')) { - $app->error('Reseller: '.$app->tform->wordbook["limit_ftp_user_txt"]); - } - } - - parent::onShowNew(); - } - - 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)); - } - - if($this->dataRecord['username'] == "") { - $app->tpl->setVar("username_prefix", $ftpuser_prefix); - } else { - $app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $ftpuser_prefix, $global_config['ftpuser_prefix'])); - } - - parent::onShowEnd(); - } - - function onSubmit() { - global $app, $conf; - - // Get the record of the parent domain - if(isset($this->dataRecord["parent_domain_id"])) { - $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ? AND ".$app->tform->getAuthSQL('r'), @$this->dataRecord["parent_domain_id"]); - if(!$parent_domain || $parent_domain['domain_id'] != @$this->dataRecord['parent_domain_id']) $app->tform->errorMessage .= $app->tform->lng("no_domain_perm"); - } else { - $tmp = $app->tform->getDataRecord($this->id); - $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ? AND ".$app->tform->getAuthSQL('r'), $tmp["parent_domain_id"]); - if(!$parent_domain) $app->tform->errorMessage .= $app->tform->lng("no_domain_perm"); - unset($tmp); - } - - // Set a few fixed values - $this->dataRecord["server_id"] = $parent_domain["server_id"]; - - //die(print_r($this->dataRecord)); - - if(isset($this->dataRecord['username']) && trim($this->dataRecord['username']) == '') $app->tform->errorMessage .= $app->tform->lng('username_error_empty').'
'; - if(isset($this->dataRecord['username']) && empty($this->dataRecord['parent_domain_id'])) $app->tform->errorMessage .= $app->tform->lng('parent_domain_id_error_empty').'
'; - if(isset($this->dataRecord['dir']) && stristr($this->dataRecord['dir'], '..')) $app->tform->errorMessage .= $app->tform->lng('dir_dot_error').'
'; - if(isset($this->dataRecord['dir']) && stristr($this->dataRecord['dir'], './')) $app->tform->errorMessage .= $app->tform->lng('dir_slashdot_error').'
'; - - parent::onSubmit(); - } - - function onBeforeInsert() { - global $app, $conf, $interfaceConf; - - $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); - - $this->dataRecord['username_prefix'] = $ftpuser_prefix; - - if ($app->tform->errorMessage == '') { - $this->dataRecord['username'] = $ftpuser_prefix . $this->dataRecord['username']; - } - - parent::onBeforeInsert(); - } - - function onAfterInsert() { - global $app, $conf; - - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $this->dataRecord["parent_domain_id"]); - $server_id = $app->functions->intval($web["server_id"]); - $dir = $web["document_root"]; - $uid = $web["system_user"]; - $gid = $web["system_group"]; - - // Check system user and group - if($app->functions->is_allowed_user($uid) == false || $app->functions->is_allowed_group($gid) == false) { - $app->error('Invalid system user or group'); - } - - // The FTP user shall be owned by the same group then the website - $sys_groupid = $app->functions->intval($web['sys_groupid']); - - $sql = "UPDATE ftp_user SET server_id = ?, dir = ?, uid = ?, gid = ?, sys_groupid = ? WHERE ftp_user_id = ?"; - $app->db->query($sql, $server_id, $dir, $uid, $gid, $sys_groupid, $this->id); - } - - function onBeforeUpdate() { - global $app, $conf, $interfaceConf; - - /* - * If the names should be restricted -> do it! - */ - - $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); - - $old_record = $app->tform->getDataRecord($this->id); - $ftpuser_prefix = $app->tools_sites->getPrefix($old_record['username_prefix'], $ftpuser_prefix); - $this->dataRecord['username_prefix'] = $ftpuser_prefix; - - /* restrict the names */ - if ($app->tform->errorMessage == '') { - $this->dataRecord['username'] = $ftpuser_prefix . $this->dataRecord['username']; - } - } - - function onAfterUpdate() { - global $app, $conf; - - //* When the site of the FTP user has been changed - if(isset($this->dataRecord['parent_domain_id']) && $this->oldDataRecord['parent_domain_id'] != $this->dataRecord['parent_domain_id']) { - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $this->dataRecord["parent_domain_id"]); - $server_id = $app->functions->intval($web["server_id"]); - $dir = $web["document_root"]; - $uid = $web["system_user"]; - $gid = $web["system_group"]; - - // The FTP user shall be owned by the same group then the website - $sys_groupid = $app->functions->intval($web['sys_groupid']); - - $sql = "UPDATE ftp_user SET server_id = ?, dir = ?, uid = ?, gid = ?, sys_groupid = ? WHERE ftp_user_id = ?"; - $app->db->query($sql, $server_id, $dir, $uid, $gid, $sys_groupid, $this->id); - } - - //* 2. check to ensure that the FTP user path is not changed to a path outside of the docroot by a normal user - if(isset($this->dataRecord['dir']) && $this->dataRecord['dir'] != $this->oldDataRecord['dir'] && !$app->auth->is_admin()) { - $vd = new validate_ftpuser; - $error_message = $vd->ftp_dir('dir', $this->dataRecord['dir'], ''); - //* This check should normally never be triggered - //* Set the path to a safe path (web doc root). - if($error_message != '') { - $ftp_data = $app->db->queryOneRecord("SELECT parent_domain_id FROM ftp_user WHERE ftp_user_id = ?", $app->tform->primary_id); - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $ftp_data["parent_domain_id"]); - $dir = $web["document_root"]; - $sql = "UPDATE ftp_user SET dir = ? WHERE ftp_user_id = ?"; - $app->db->query($sql, $dir, $this->id); - $app->log("Error in FTP path settings of FTP user ".$this->dataRecord['username'], 1); - } - - } - - } - -} - -$page = new page_action; -$page->onLoad(); - -?> diff --git a/new_service_webdns.php b/new_service_webdns.php index 9dcaf3d..d2e6cb6 100755 --- a/new_service_webdns.php +++ b/new_service_webdns.php @@ -811,7 +811,7 @@ class page_action extends tform_actions { // client group id $res = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$app->functions->intval($fields['client_group_id'])); $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);//$res['groupid']; - echo ('El group id ' . $client_group_id . " "); + //echo ('El group id ' . $client_group_id . " "); //Carga del formulario dns_soa para guardar en base de datos @@ -964,7 +964,7 @@ $dns_ip_servidor_ipv6 = $app->db->queryOneRecord("SELECT ip_type, ip_address FRO $tform_def_file = "../sites/form/web_vhost_domain.tform.php"; $app->tform->loadFormDef($tform_def_file); - print_r($fields); + //print_r($fields); //echo('La sesión user id ' . $_SESSION['s']['user']['userid']); // add site $paramsite = array( @@ -1012,7 +1012,7 @@ $dns_ip_servidor_ipv6 = $app->db->queryOneRecord("SELECT ip_type, ip_address FRO ); //print 'Valores: ' . $dns_ip_servidor_ipv6 . " " . $formulario . " Parametros: " ; - print "
"; print_r($paramsite); print "
\n"; + //print "
"; print_r($paramsite); print "
\n"; /*print '
 cliente id ' . $fields['client_id'];
 		print "
";print_r($fields);print "
\n";*/ diff --git a/templates/database_edit.htm b/templates/database_edit.htm deleted file mode 100755 index 290ae30..0000000 --- a/templates/database_edit.htm +++ /dev/null @@ -1,157 +0,0 @@ - -

- - - - -
- - -
- - - -
-
-
- - - - -
- - -
- - - -
-
-
-
-
-
- -
-
-
- -
-
-
- -
-
- {tmpl_var name='database_name_prefix'} - - - - - -
-
-
-
- -
MB
-
-
- -
-
-
- -
- {tmpl_var name='optional_txt'} -
-
-
- - -
- - - -
-
-
-
- -
- {tmpl_var name='remote_access'} -
-
-
- -
-
- -
- {tmpl_var name='active'} -
-
- - - - -
- - -
- diff --git a/templates/ftp_user_edit.htm b/templates/ftp_user_edit.htm deleted file mode 100755 index 72ec55f..0000000 --- a/templates/ftp_user_edit.htm +++ /dev/null @@ -1,67 +0,0 @@ - -

- - - -
- -
-
-
- -
-
- {tmpl_var name='username_prefix'} - -
-
-
-
- -
-
- - - - -
-
-
-
- -
-
-   -
-
-
- -
-
-
- - -
-
-
- -
MB
-
-
- -
- {tmpl_var name='active'} -
-
- - - - -
- - -
\ No newline at end of file