diff --git a/database_user_edit.php b/database_user_edit.php
deleted file mode 100755
index be58678..0000000
--- a/database_user_edit.php
+++ /dev/null
@@ -1,251 +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']);
- $records = $app->functions->htmlentities($records);
- $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);
- $clients = $app->functions->htmlentities($clients);
- $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_user.tform.php b/form/database_user.tform.php
deleted file mode 100755
index 09d2c32..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/database_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} 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/new_service_webdns.php b/new_service_webdns.php
index 4af7c7b..6602778 100755
--- a/new_service_webdns.php
+++ b/new_service_webdns.php
@@ -408,7 +408,8 @@ class page_action extends tform_actions {
//print "
". $this->pass_db_txt;
//print "
"; print_r($fields); print "\n"; - $db_user_id = $remoto->insert_query('../sites/form/database_user.tform.php', $this->cli_id, $db_user_params, 'sites:web_database_user:on_after_insert'); + $db_user_id = $remoto->insert_query('../sites/form/database_user.tform.php', + $this->cli_id, $db_user_params, 'sites:web_database_user:on_after_insert'); //echo('El id ' . $this->id); $remoto2 = new remote_actions; $remoto->sites_database_user_after_add($this->cli_grupo_id, $db_user_params); @@ -476,7 +477,7 @@ class page_action extends tform_actions { //print "
"; print_r($site_data); print "\n"; //echo('El grupo del usuario es ' . $this->cli_grupo_id); $remoto->insert_query('../sites/form/ftp_user.tform.php', $this->cli_id,/*$fields['client_group_id'],*/ $ftp_params); - + $remoto->sites_ftp_user_after_insert(); echo '