Bladeren bron

Solucionado problema. Cuando se esta logueado con un usuario y se usaba webdns, automáticamente el usuario pasaba a ser admin. Solucionado.

develop
David Ramos 8 jaren geleden
bovenliggende
commit
91497b8cba
10 gewijzigde bestanden met toevoegingen van 629 en 279 verwijderingen
  1. +0
    -0
      clases/limites.inc.php
  2. +251
    -0
      database_user_edit.php
  3. +134
    -0
      form/database_user.tform.php
  4. +2
    -2
      form/new_service_webdns.tform.php
  5. +25
    -0
      lib/lang/en_database_user.lng
  6. +25
    -0
      lib/lang/es_database_user.lng
  7. +6
    -6
      lib/module.conf.php
  8. +116
    -268
      new_service_webdns.php
  9. +67
    -0
      templates/database_user_edit.htm
  10. +3
    -3
      templates/new_service_webdns.htm

+ 0
- 0
clases/limites.inc.php Bestand weergeven


+ 251
- 0
database_user_edit.php Bestand weergeven

@@ -0,0 +1,251 @@
<?php
/*
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/


/******************************************
* Begin Form configuration
******************************************/

$tform_def_file = "form/database_user.tform.php";

/******************************************
* End Form configuration
******************************************/

require_once '../../lib/config.inc.php';
require_once '../../lib/app.inc.php';

//* Check permissions for module
$app->auth->check_module_permissions('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 = '<option value="'.$tmp['groupid'].'">'.$client['contact_name'].'</option>';
//$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 .= "<option value='$rec[groupid]' $selected>$rec[contactname]</option>\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 = "<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':'';
$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->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"].'<br />';

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"]).'<br />';

//* 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.').'<br />';
}

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"].'<br />';
//* Database password shall not be empty
if($this->dataRecord['database_password'] == '') $app->tform->errorMessage .= $app->tform->wordbook["database_password_error_empty"].'<br />';

//* 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"]).'<br />';

//* 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.').'<br />';
}

/* 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();

?>

+ 134
- 0
form/database_user.tform.php Bestand weergeven

@@ -0,0 +1,134 @@
<?php

/*
Form Definition

Tabledefinition

Datatypes:
- INTEGER (Forces the input to Int)
- DOUBLE
- CURRENCY (Formats the values to currency notation)
- VARCHAR (no format check, maxlength: 255)
- TEXT (no format check)
- DATE (Dateformat, automatic conversion to timestamps)

Formtype:
- TEXT (Textfield)
- TEXTAREA (Textarea)
- PASSWORD (Password textfield, input is not shown when edited)
- SELECT (Select option field)
- RADIO
- CHECKBOX
- CHECKBOXARRAY
- FILE

VALUE:
- Wert oder Array

Hint:
The ID field of the database table is not part of the datafield definition.
The ID field must be always auto incement (int or bigint).

Search:
- searchable = 1 or searchable = 2 include the field in the search
- searchable = 1: this field will be the title of the search result
- searchable = 2: this field will be included in the description of the search result


*/

$form["title"] = "Database User";
$form["description"] = "";
$form["name"] = "database_user";
$form["action"] = "database_user_edit.php";
$form["db_table"] = "web_database_user";
$form["db_table_idx"] = "database_user_id";
$form["db_history"] = "yes";
$form["tab_default"] = "database_user";
$form["list_default"] = "database_user_list.php";
$form["auth"] = 'yes'; // yes / no

$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete

$form["tabs"]['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
//#################################
)
);


?>

+ 2
- 2
form/new_service_webdns.tform.php Bestand weergeven

@@ -67,8 +67,8 @@ $form["title"] = "Nuevo servicio Web";
$form["description"] = "";
$form["name"] = "new_service_webdns";
$form["action"] = "new_service_webdns.php";
//$form["db_table"] = "web_database_user";
//$form["db_table_idx"] = "database_user_id";
$form["db_table"] = "server";
$form["db_table_idx"] = "server_id";
$form["db_history"] = "yes";
$form["tab_default"] = "webdns";
$form["auth"] = 'yes'; // yes / no


+ 25
- 0
lib/lang/en_database_user.lng Bestand weergeven

@@ -0,0 +1,25 @@
<?php
$wb["database_user_txt"] = 'Database user';
$wb["database_password_txt"] = 'Database password';
$wb["password_strength_txt"] = 'Password strength';
$wb["client_txt"] = 'Client';
$wb["active_txt"] = 'Active';
$wb["database_user_error_empty"] = 'Database user is empty.';
$wb["database_user_error_unique"] = 'There is already a database user with this name on the server. To get a unique name, e.g. prepend your domain name to the username.';
$wb["database_user_error_regex"] = 'Invalid database user name. The username may contain these characters: a-z, A-Z, 0-9 and the underscore. Length: 2 - 64 characters.';
$wb["database_user_error_len"] = 'Database username - {user} - too long. The max. database username length incl. prefix is 16 chars.';
$wb["btn_save_txt"] = 'Save';
$wb["btn_cancel_txt"] = 'Cancel';
$wb['generate_password_txt'] = 'Generate Password';
$wb['repeat_password_txt'] = 'Repeat Password';
$wb['password_mismatch_txt'] = 'The passwords do not match.';
$wb['password_match_txt'] = 'The passwords do match.';
$wb['globalsearch_resultslimit_of_txt'] = "of";
$wb['globalsearch_resultslimit_results_txt'] = "results";
$wb['globalsearch_noresults_text_txt'] = "No results.";
$wb['globalsearch_noresults_limit_txt'] = "0 results";
$wb['globalsearch_searchfield_watermark_txt'] = "Search";
$wb['globalsearch_suggestions_text_txt'] = "Suggestions";
$wb['limit_database_user_txt'] = "The max. number of database users is reached.";
$wb['database_password_error_empty'] = 'Database password is empty.';
?>

+ 25
- 0
lib/lang/es_database_user.lng Bestand weergeven

@@ -0,0 +1,25 @@
<?php
$wb['database_user_txt'] = 'Usuario de la base de datos';
$wb['database_password_txt'] = 'Contraseña de la base de datos';
$wb['password_strength_txt'] = 'Fortaleza de la contraseña';
$wb['client_txt'] = 'Cliente';
$wb['active_txt'] = 'Habilitado';
$wb['database_user_error_empty'] = 'El usuario de la base de datos está vacío.';
$wb['database_user_error_unique'] = 'Ya existe un usuario de base de datos con ese nombre en el servidor. Para obtener un nombre único, eje. agregue el nombre de dominio al inicio del nombre de usuario.';
$wb['database_user_error_regex'] = 'Nombre de usuario de base de datos inválido. El nombre de usuario debe contener estos caracteres: a-z, A-Z, 0-9 y guión bajo. Largo: 2 - 64 caracteres.';
$wb['database_user_error_len'] = 'El nombre de usuario de base de datos - {user} - es muy largo. El largo máx. del nombre de usuario incluyendo el prefijo es de 16 caracteres.';
$wb['btn_save_txt'] = 'Guardar';
$wb['btn_cancel_txt'] = 'Cancelar';
$wb['generate_password_txt'] = 'Generar contraseña';
$wb['repeat_password_txt'] = 'Repetir contraseña';
$wb['password_mismatch_txt'] = 'Las contraseñas no coinciden.';
$wb['password_match_txt'] = 'Las contraseñas coinciden.';
$wb['globalsearch_resultslimit_of_txt'] = 'de';
$wb['globalsearch_resultslimit_results_txt'] = 'resultados';
$wb['globalsearch_noresults_text_txt'] = 'Sin resultados.';
$wb['globalsearch_noresults_limit_txt'] = '0 resultados';
$wb['globalsearch_searchfield_watermark_txt'] = 'Buscar';
$wb['globalsearch_suggestions_text_txt'] = 'Sugerencias';
$wb['limit_database_user_txt'] = 'The max. number of database users is reached.';
$wb['database_password_error_empty'] = 'Database password is empty.';
?>

+ 6
- 6
lib/module.conf.php Bestand weergeven

@@ -26,18 +26,18 @@ $module['tab_width'] = '';
// Make sure that the items array is empty
$items = array();

// Add a menu item with the label 'Send message'
// Add a menu item with the label 'Nuevo servicio web'
$items[] = array( 'title' => 'Nuevo servicio web',
'target' => 'content',
'link' => 'webdns/new_service_webdns.php',
'html_id' => 'new_service_webdns'
);
/*$items[] = array( 'title' => 'La BD',
$items[] = array( 'title' => 'Usuario DB',
'target' => 'content',
'link' => 'webdns/database_edit.php',
'html_id' =>'db_service'
);
'link' => 'webdns/database_user_edit.php',
//'html_id' =>'db_service'
);
/*
$items[] = array( 'title' => 'El FTP',
'target' => 'content',
'link' => 'webdns/ftp_user_edit.php',


+ 116
- 268
new_service_webdns.php Bestand weergeven

@@ -162,18 +162,17 @@ class page_action extends tform_actions {
$global_config = $app->getconf->get_global_config('sites');
$dbuser_prefix = $app->tools_sites->replacePrefix($global_config['dbuser_prefix'], $this->dataRecord);
$ftpuser_prefix = $app->tools_sites->replacePrefix($global_config['ftpuser_prefix'], $this->dataRecord);
$this->dataRecord['username_prefix'] = $ftpuser_prefix;
$this->dataRecord['database_user_prefix'] = $dbuser_prefix;
//$valor2 = $this->dataRecord['database_user_prefix'] = $dbuser_prefix;
//print('Campos Record ' . print($this->dataRecord['username_prefix']) . ' username ' . $this->dataRecord['database_user_prefix'] );
$this->valor_prefix = $this->dataRecord['database_user_prefix'] = $dbuser_prefix;
$this->valor_prefix_ftp = $this->dataRecord['username_prefix'] = $ftpuser_prefix;

//echo('(1)Prefix ' . $this->valor_prefix . '(2)Prefix ftp ' . $this->valor_prefix_ftp );


if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
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"]).'<br />';

@@ -190,7 +189,7 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
}
$this->dataRecord['server_id'] = 0; // we need this on all servers
//echo('Usuarios ' .$this->dataRecord['database_user'] . ' Prefix ' . $this->dataRecord['database_user_prefix'] . ' Mas ' . $dbuser_prefix);
if ($this->dataRecord['database_user'] != ""){
/* REMOVE the restriction */
@@ -228,7 +227,7 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)

function generaNombreFTP(){
$this->tratarVariablesPrefix();

//echo ('PreFIX Valor ' . $dbuser_prefix_valor);
@@ -287,36 +286,7 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)


function generaNombreBD(){
global $app, $conf, $interfaceConf;

//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);

$dbuser_prefix_valor = $app->tpl->setVar("database_name", $app->tools_sites->removePrefix($this->dataRecord['database_name'], $this->dataRecord['database_name_prefix'], $dbname_prefix));
//echo ('El prefix ' . $dbuser_prefix);
$this->dataRecord['database_user_prefix'] = $dbuser_prefix_valor;
//echo ('PreFIX ' . '{user}' . str_replace('{user}', htmlentities($dbuser_prefix . $this->dataRecord['database_user'], ENT_QUOTES, 'UTF-8')));
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"]).'<br />';

//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.').'<br />';
}

/* 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
*/
$this->tratarVariablesPrefix();

//echo ('PreFIX Valor ' . $dbuser_prefix_valor);
@@ -374,145 +344,6 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
return true;
}*/

function crearBaseDatosFtpClientes($remoto){
global $app, $conf;

$fields = $app->tform->encode($this->dataRecord, $app->tform->getCurrentTab(), true);

$app->uses('ini_parser,getconf');
$server_config_array = $app->getconf->get_global_config();

$generated_usernameBBDD = $this->generaNombreBD();
//print "<pre>"; print_r($generated_usernameBBDD); print "</pre>\n";
$sitio_id = $app->db->queryOneRecord(
'SELECT domain_id, domain FROM web_domain WHERE domain = "'.$fields['domain'].'"');
print_r($fields);
//echo(' Campo en formulario ' . $fields['database_user_prefix']);
//print "<pre>"; print_r($camDnsRR); print "</pre>\n";
//$camDnsRR = $app->db->queryOneRecord('SELECT server_id, zone FROM dns_rr WHERE name LIKE "'.$this->dominio.'."');
//print "<pre>"; print_r($fields['client_id']); print "</pre>\n";

//echo(' El nuevo prefix ' . $this->valor_prefix_ftp);
$clavePass = $this->generaPass();
//*Recupero todos los prefix necesarios
/*$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);*/

echo('Mierda Clientes' . $this->valor_prefix . ' Mas mierda ' . $fields['database_user_prefix'] . ' Y mas ' . $this->dataRecord['database_user_prefix']);
//añado database user con su prefix
$db_user_params = array(
'server_id' => $this->bbdd_serv,
'sysgroup_id' => $this->sys_grupo_id,
'sys_userid' => $this->sys_usuario_id,
'sys_perm_other' => '-',
'database_user' => $generated_usernameBBDD,
'database_user_prefix' => $fields['database_user_prefix'],
'database_password' => $clavePass
);

$this->usuario_db_txt = $db_user_params['database_user'];
$this->pass_db_txt = $db_user_params['database_password'];

print "<pre> USUARIO BBDD "; print_r($db_user_params); print "</pre>\n";
//print "<br>". $this->cli_id;
//print "<br>". $this->usuario_db_txt;
//print "<br>". $this->pass_db_txt;
//print "<pre>"; print_r($fields); print "</pre>\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');
// add database
$paramsBD = array(
'server_id' => $this->bbdd_serv, //$camDnsRR['server_id'],
'sysgroup_id' => $this->sys_grupo_id, //$fields['client_group_id'],
'parent_domain_id' => $sitio_id['domain_id'],
'type' => 'mysql',
'database_quota' => '-1',
'database_name' => $generated_usernameBBDD,
'database_name_prefix' => $this->valor_prefix,
'database_user_id' => $db_user_id,
'database_charset' => 'utf8',
'remote_access' => 'n',
'remote_ips' => '-1',
'active' => 'y'
);
print "<pre> BBDD "; print_r($paramsBD); print "</pre>\n";

$this->nombre_db_txt = $paramsBD['database_name'];

// $db_id = $remoto->sites_database_add($this->cli_id,/*$fields['client_group_id'],*/ $paramsBD);
$this->urlBBDD($db_id, $this->bbdd_serv);
//echo('Id de la BBDD ' . $db_id);
// get site data para usarlo en la creación de la cuenta ftp, otra forma de cargar una tupla dandole un id
//$app->uses('remoting_lib');
$app->remoting_lib->loadFormDef('../sites/form/web_vhost_domain.tform.php');
$site_data = $app->remoting_lib->getDataRecord($sitio_id);
$this->nombre_user_ftp = $this->generaNombreFTP();
// add ftp user
$ftp_params = array(
'server_id' => $this->web_serv, //$camDnsRR['server_id'],
'parent_domain_id' => $sitio_id['domain_id'],
'username' => $this->valor_prefix_ftp . $this->nombre_user_ftp,
'username_prefix' => $this->valor_prefix_ftp,
'password' => $clavePass,
'quota_size' => '-1',
'dir' => $site_data['0']['document_root'],
'uid' => $site_data['0']['system_user'],
'gid' => $site_data['0']['system_group'],
'sys_groupid' => $site_data['0']['sys_groupid'],
'quota_files' => '-1',
'ul_ratio' => '-1',
'dl_ratio' => '-1',
'ul_bandwidth' => '-1',
'dl_bandwidth' => '-1',
'active' => 'y',
);
$this->usuario_ftp_txt = $ftp_params['username'];
$this->pass_ftp_txt = $ftp_params['password'];
//print "<pre> FTP "; print_r($ftp_params); print "</pre>\n";
//print "<pre>"; print_r($site_data); print "</pre>\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);

echo '<br><div class="alert alert-success"><br>
Altas de BBDD y FTP, ¡Correctas!<br><br>
Usuario BBDD: <b>'. $this->usuario_db_txt .'</b><br>Contraseña: <b>' . $this->pass_db_txt . '
</b><br>Nombre BBDD: <b>' . $this->nombre_db_txt . '</b><br>
<br>Usuario FTP: <b>'. $this->usuario_ftp_txt .'</b><br>Contraseña: <b>' . $this->pass_ftp_txt . '</b><br><br>
</div></br>';

//$hoy = date("d-m-Y H:i:s");

$html_resultado = '<br><br><b>BBDD</b><br>
Usuario: <b>'. $this->usuario_db_txt .'</b><br>
Nombre Base de Datos: <b>' . $this->nombre_db_txt .'</b><br>
Clave: <b>' . $this->pass_db_txt . '</b><br><br>
<b>FTP</b><br>
Usuario: <b>'. $this->usuario_ftp_txt .'</b><br>
Clave: <b>' . $this->pass_ftp_txt . '</b><br><br>
<b> </b><br>Nuevo dominio: <b>'. $fields['domain'].'</b><br><br>';

$eldom = $fields['domain'];
echo '<form method="post" id="formulario" action="webdns/pdf_o6h.php" target="_blank">';
echo '<input id="pdf_power" name="pdf_power" type="hidden" value="'.$html_resultado.'">';
echo '<input id="nombre_bd" name="nombre_bd" type="hidden" value="'.$this->nombre_db_txt.'">';
echo '<input id="usuario_bd" name="usuario_bd" type="hidden" value="'.$this->usuario_db_txt.'">';
echo '<input id="pass_bd" name="pass_bd" type="hidden" value="'.$this->pass_db_txt.'">';
echo '<input id="usuario_ftp" name="usuario_ftp" type="hidden" value="'.$this->usuario_ftp_txt.'">';
echo '<input id="pass_ftp" name="pass_ftp" type="hidden" value="'.$this->pass_ftp_txt.'">';
echo '<input id="ip4" name="ip4" type="hidden" value="'.$this->ip4_pdf.'">';
echo '<input id="url_db" name="url_db" type="hidden" value="'.$this->url_db.'">';
echo '<input id="dominio_nuevo" name="dominio_nuevo" type="hidden" value="'.$eldom.'">';
echo '<input type="submit" class="btn btn-default formbutton-success" value="Descargar PDF">';
echo '</form>';

echo '<div id="resp"></div>';
}

function crearBaseDatosFtp($remoto){
global $app, $conf;

@@ -525,20 +356,17 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
//print "<pre>"; print_r($generated_usernameBBDD); print "</pre>\n";
$sitio_id = $app->db->queryOneRecord(
'SELECT domain_id, domain FROM web_domain WHERE domain = "'.$fields['domain'].'"');
print_r($fields);
//print_r($fields);
//echo(' Campo en formulario ' . $fields['database_user_prefix']);
//print "<pre>"; print_r($camDnsRR); print "</pre>\n";
//$camDnsRR = $app->db->queryOneRecord('SELECT server_id, zone FROM dns_rr WHERE name LIKE "'.$this->dominio.'."');
//print "<pre>"; print_r($fields['client_id']); print "</pre>\n";

echo(' El nuevo prefix ' . $this->valor_prefix_ftp);
// echo(' El nuevo prefix ' . $this->valor_prefix_ftp);
$clavePass = $this->generaPass();
//*Recupero todos los prefix necesarios
/*$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);*/
echo(' Mierda de siempre ' . $this->valor_prefix . ' Mas mierda ' . $fields['database_user_prefix'] . ' Y mas ' . $this->dataRecord['database_user_prefix']);
//echo('Mierda Clientes' . $this->valor_prefix . ' Mas mierda ' . $fields['database_user_prefix'] . ' Y mas ' . $this->dataRecord['database_user_prefix']);
//añado database user con su prefix
$db_user_params = array(
'server_id' => $this->bbdd_serv,
@@ -553,14 +381,24 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
$this->usuario_db_txt = $db_user_params['database_user'];
$this->pass_db_txt = $db_user_params['database_password'];

print "<pre> USUARIO BBDD "; print_r($db_user_params); print "</pre>\n";
//print "<pre> USUARIO BBDD "; print_r($db_user_params); print "</pre>\n";
//print "<br>". $this->cli_id;
//print "<br>". $this->usuario_db_txt;
//print "<br>". $this->pass_db_txt;
//print "<pre>"; print_r($fields); print "</pre>\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;
//echo(' El cliente en webdns ' . $this->cli_id);
$db_user_id = $remoto2->sites_database_user_add(1, $this->cli_id, $db_user_params, 'sites:web_database_user:on_after_insert');
/*$sql = "INSERT INTO web_database_user (dbtable,dbidx,server_id,action,tstamp,user,data) VALUES (?, ?, ?, ?, ?, ?, ?)";
$app->db->query($sql, $db_table, $dbidx, $server_id, $action, time(), $username, $diffstr);
*/
//$app->tform->datalogSave('INSERT', 'database_user_id', array(), $db_user_params);
//$app->db->datalogSave('web_database_user', 'INSERT', 'database_user_id', 1, array(), $db_user_params);
//$db_user_id = $app->db->datalogInsert('web_database_user', $db_user_params, 'database_user_id');

// add database
$paramsBD = array(
'server_id' => $this->bbdd_serv, //$camDnsRR['server_id'],
@@ -576,15 +414,15 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
'remote_ips' => '-1',
'active' => 'y'
);
print "<pre> BBDD "; print_r($paramsBD); print "</pre>\n";
//print "<pre> BBDD "; print_r($paramsBD); print "</pre>\n";

$this->nombre_db_txt = $paramsBD['database_name'];

// $db_id = $remoto->sites_database_add($this->cli_id,/*$fields['client_group_id'],*/ $paramsBD);
$db_id = $remoto->sites_database_add($this->cli_id,/*$fields['client_group_id'],*/ $paramsBD);
$this->urlBBDD($db_id, $this->bbdd_serv);
//echo('Id de la BBDD ' . $db_id);
// get site data para usarlo en la creación de la cuenta ftp, otra forma de cargar una tupla dandole un id
// get site data para usarlo en la creación de la cuenta ftp, otra forma de cargar una tupla dandole un id
//$app->uses('remoting_lib');
$app->remoting_lib->loadFormDef('../sites/form/web_vhost_domain.tform.php');
$site_data = $app->remoting_lib->getDataRecord($sitio_id);
@@ -613,8 +451,8 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
$this->pass_ftp_txt = $ftp_params['password'];
//print "<pre> FTP "; print_r($ftp_params); print "</pre>\n";
//print "<pre>"; print_r($site_data); print "</pre>\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);
//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);

echo '<br><div class="alert alert-success"><br>
Altas de BBDD y FTP, ¡Correctas!<br><br>
@@ -692,14 +530,6 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
//Expresiones regulares para comprobar si es subdominio
function comprobarSubDominios($subdom) {
global $app, $conf;
//echo(' Subdominio en funcion ' . $subdom);
//Se comprueba que el campo para el dominio no este vacío.
/* if($subdom == ''){
$this->es_subdominio = false;
$this->dominio_error = true;
$app->tform->errorMessage = "El campo para el dominio, esta vacío.";
//$app->tform->wordbook['error_dominio_mas_puntos'];
}*/

$patronSubDominos = "/(.*?)\.(.*)$/";
$patronWWW = "/^w{3}/";
@@ -752,30 +582,28 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
$this->sys_grupo_id = $_SESSION["s"]["user"]["sys_groupid"];

} else {


//Captura de los distintos ids del cliente y usuario de sistema.
//combinando un query a las dos tablas sys_group y sys_user que comparten el client_id.
//print "<pre>Seleccionado: "; print_r($fields['client_group_id']); print "</pre>\n";
if($fields['client_group_id']==0) {
//En la tabla sys_user el client_id 0 es admin. En sys_group este valor es 0
$this->cli_id = 0;
//En la tabla dns_soa y dns_rr se guarda el valor 0 en sys_groupid cuando es admin.NO ESTO NO ES ASÍ
$this->cli_grupo_id = 1;
$this->sys_usuario_id = 1;//$this->cli_id;
$this->sys_grupo_id = 0;//$this->cli_grupo_id;
}else{
$client = $app->db->queryOneRecord(
'SELECT sys_user.sys_userid, sys_user.sys_groupid, sys_user.default_group, sys_user.client_id
FROM sys_group, sys_user
WHERE sys_group.client_id = sys_user.client_id and sys_group.groupid = ?', $fields['client_group_id']);
$this->cli_id = $client['client_id'];
$this->cli_grupo_id = $client['default_group'];
$this->sys_usuario_id = $client['sys_userid'];
$this->sys_grupo_id = $client['sys_groupid'];
}
}
//Captura de los distintos ids del cliente y usuario de sistema.
//combinando un query a las dos tablas sys_group y sys_user que comparten el client_id.
//print "<pre>Seleccionado: "; print_r($fields['client_group_id']); print "</pre>\n";
if($fields['client_group_id']==0) {
//En la tabla sys_user el client_id 0 es admin. En sys_group este valor es 0
$this->cli_id = 0;
//En la tabla dns_soa y dns_rr se guarda el valor 0 en sys_groupid cuando es admin.NO ESTO NO ES ASÍ
$this->cli_grupo_id = 1;
$this->sys_usuario_id = 1;//$this->cli_id;
$this->sys_grupo_id = 0;//$this->cli_grupo_id;
}else{
$client = $app->db->queryOneRecord(
'SELECT sys_user.sys_userid, sys_user.sys_groupid, sys_user.default_group, sys_user.client_id
FROM sys_group, sys_user
WHERE sys_group.client_id = sys_user.client_id and sys_group.groupid = ?', $fields['client_group_id']);
$this->cli_id = $client['client_id'];
$this->cli_grupo_id = $client['default_group'];
$this->sys_usuario_id = $client['sys_userid'];
$this->sys_grupo_id = $client['sys_groupid'];
}
}
//print "<pre>Valores : "; print_r($this->cli_id); print "</pre>\n";
//print "Valores " . $this->cli_id . ' ' . $this->cli_grupo_id . ' ' . $this->sys_usuario_id . ' ' . $this->sys_grupo_id;
@@ -839,7 +667,7 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
//print_r($camDominio);
//print_r($camDnsRR);

//Si el dominio NO existe mostramos mensaje de error y salimos de la ejecución
//Si el dominio NO existe mostramos mensaje de error y salimos de la ejecución
if(!$camDominio['origin']){
$this->subdom_error = true;
$app->tform->errorMessage = $app->tform->wordbook['error_no_existe_dominio_padre'];
@@ -849,7 +677,7 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
return $this->subdom_error;

} else {
//Parametros para la creación de subdominios
//Parametros para la creación de subdominios
$paramSubDominios = array(
'server_id' => $camDnsRR['server_id'],
'zone' => $camDnsRR['zone'],
@@ -873,8 +701,7 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
//print "<pre>"; print_r($paramSubDominios); print "</pre>\n";
//Inserto en bbdd usando la clase remoto que se la he pasado en parámetros de la función
//$resultado = $remoto->insert_query('../dns/form/dns_a.tform.php', $fields['client_id'], $paramSubDominios);
$app->db->datalogInsert('dns_rr', $paramSubDominios, 'id');
// $resultado = $remoto->insert_query('form/dns_a_webdns.tform.php', $this->cli_id, /*$fields['client_group_id'],*/ $paramSubDominios);
$resultado = $remoto->insert_query('form/dns_a_webdns.tform.php', $this->cli_id, /*$fields['client_group_id'],*/ $paramSubDominios);
echo '<br><div class="alert alert-success"><br>
Se ha dado de alta Web y Subdominio, <b>'.$this->subdominio.'</b>, ¡Correctamente!
<br><br></div></br>';
@@ -978,14 +805,6 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
$global_config_sitio = $app->getconf->get_global_config('sites');
$global_config_dns = $app->getconf->get_global_config('dns');

/* $server_id = intval($global_config_sitio['default_webserver']);
if(!$server_id){
$default_web_server = $app->db->queryOneRecord("SELECT server_id FROM server WHERE web_server = ? ORDER BY server_id LIMIT 0,1", 1);
$server_id = $default_web_server['server_id'];
}
$web_config = $app->getconf->get_server_config($server_id, 'web');
echo(' Server id ' . $server_id . ' default web ' . $default_web_server . ' webConfig ' . print_r($web_config));
*/
if(!$global_config_dns['default_dnsserver']) {
$app->tform->errorMessage = $app->tform->wordbook['error_no_servidor_default']. 'DNS.';
$this->onError();
@@ -1050,7 +869,7 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
//Captura de las ips del servidor dns
if($this->cli_id == 0){
//Compruebo si hay datos para el client_id 0 y si no existe pruebo con el 1.
//Alguno de los dos tiene que existir por configuración de ispconfig.
//Alguno de los dos tiene que existir por configuración de ispconfig.
$this->ip4_servidor_dns = $app->db->queryOneRecord(
'SELECT ip_type, ip_address FROM server_ip
WHERE client_id = "0" AND server_id = "'.$this->dns_serv.'" AND ip_type="IPv4"');
@@ -1169,7 +988,7 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
//Captura de las ips del servidor bbdd
if($this->cli_id == 0){
//Compruebo si hay datos para el client_id 0 y si no existe pruebo con el 1.
//Alguno de los dos tiene que existir por configuración de ispconfig.
//Alguno de los dos tiene que existir por configuración de ispconfig.
$this->ip4_servidor_bbdd = $app->db->queryOneRecord(
'SELECT ip_type, ip_address FROM server_ip
WHERE client_id = "0" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv4"');
@@ -1397,7 +1216,7 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
//}
return false;
}
//Comprobación de que tenemos instalada nuestra plantilla
function plantillaWebDNS(){
global $app;
@@ -1408,7 +1227,7 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16)
return true;
}
}
//Comprueba que no exista el dominio y que no tenga sitio web, puede tener sitio web y no tener dns.
function existeDominio($campos){
global $app, $conf;
@@ -1521,7 +1340,7 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/
} // end foreach
// Insert the soa record
//$sys_userid = $this->cli_id;//$cliente_id_seleccionado;//$fields['client_group_id'];
$sys_userid = $this->cli_id;//$cliente_id_seleccionado;//$fields['client_group_id'];
$origin = $vars['origin'];
$ns = $vars['ns'];
$mbox = str_replace('@', '.', $vars['mbox']);
@@ -1591,10 +1410,10 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/
'type' => 'vhost',
'domain' => $fields['domain'],
'server_id' => $this->web_serv,// $web_servidor, //$server_id,//$dns_servidor['default_webserver'],
//IMPORTANTE. Aquí no se ponen los campos sys_userid ni sys_groupid, el evento on_after_insert
//IMPORTANTE. Aquí­ no se ponen los campos sys_userid ni sys_groupid, el evento on_after_insert
//'sys_userid' => $sysUsuarioId, //$fields['client_group_id'],//$sys_userid,
//'sys_groupid' => $cliente_groupid,
'ip_address' => '*', //$dns_ip_servidor['ip_address'],
'ip_address' => '*', //$dns_ip_servidor['ip_address'],
'ipv6_address' => $this->ip6_servidor_web['ip_address'], //$this->ip6_ultima['ip_address'], //$dns_ip_servidor_ipv6['ip_address'],
'traffic_quota' => '-1',
'hd_quota' => '0',
@@ -1639,37 +1458,41 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/
print "<pre>";print_r($fields);print "</pre>\n";*/
//print "<pre>Formulario ";print_r($formulario);print "</pre>\n";
//$this->crearBaseDatosFtp($remote);
//print 'DNS IPV6 ' . $dns_ip_servidor_ipv6['ip_address'];

//IMPORTANTE. El último parámetro es para lanzar un evento que llama a la función on_after_insert
//que prepara los campos document_root, system_user y system_group
//$site_id = $remoto->insert_query('../sites/form/web_vhost_domain.tform.php', $fields['client_group_id'], $paramsite, 'sites:web_vhost_domain:on_after_insert');
// $remoto->insert_query('../sites/form/web_vhost_domain.tform.php', $this->cli_id, /*$cliente_id_seleccionado,*/ $paramsite, 'sites:web_vhost_domain:on_after_insert');
$site_id = $remoto->insert_query('../sites/form/web_vhost_domain.tform.php', $this->cli_id, /*$cliente_id_seleccionado,*/ $paramsite, 'sites:web_vhost_domain:on_after_insert');
//print 'Sitio id '. $site_id;
print('(3)Final crearDnsSitioWeb');
}

function onSubmit() {
global $app, $conf;

/* $sesionesLog = $_SESSION["s"]["user"]["typ"];
/*$sesionesLog = $_SESSION["s"]["user"]["typ"];
$sesionesLog2 = $_SESSION["s"]["user"];
$sesiones = $_SESSION;
$sesionId = $_SESSION["s"]["id"];*/
print_r($sesiones);
print_r($sesionesLog2);*/
//print_r($sesiones);
//print('la ssessison es ' .$ssionId);
//print_r($sesionesLog2);

//echo('(Sub)Prefix ' . $this->valor_prefix . '(Sub)Prefix ftp ' . $this->valor_prefix_ftp );
if($this->plantillaWebDNS()){
return;
}

//Carga de campos del formulario.
$fields = $app->tform->encode($this->dataRecord, $app->tform->getCurrentTab(), true);

//Creo la clase remote para usar las librerias
$remote = new remote_actions;
/*$sitiosBoom = new sitios_remoting;
$sitiosBoom->test();*/

if($this->tieneServidorIPs()){
return;
}
@@ -1707,17 +1530,17 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/
echo ('Tabla sys_user --> sys_groupid ' . $this->sys_grupo_id . " <br>");*/
//print "Subdomino: " . $this->subdomino . "</p>\n Dominio: " . $this->domino;
if($this->comprobarSubDominios($fields['domain'])){
print('(1)crearSubDominio');
$this->crearSubDominio($remote, $fields['domain']);
/*if(!$this->subdom_error){
if(!$this->subdom_error){
$this->crearSitioWebSubdominio($remote);
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])){
$this->crearBaseDatosFtpClientes($remote);
}else{
//if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])){
// $this->crearBaseDatosFtpClientes($remote);
//}else{
$this->crearBaseDatosFtp($remote);
}
}*/
//}
}

} else {
if(!$this->dominio_error){
@@ -1728,32 +1551,57 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/
Altas Web y DNS del dominio <b>'.$fields['domain'].'</b>, ¡Creadas correctamente!
<br><br></div></br>';

//IMPORTANTE, es necesario cargar nuestro formulario para poder ejecutar la función que crea
//la base de datos y el ftp ya que hay datos que tomamos de él antes de ejecutarla.
// $app->tform->loadFormDef('form/new_service_webdns.tform.php');
/* if(!$app->auth->is_admin()){
//if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])){
$this->crearBaseDatosFtpClientes($remote);
}else{
echo('Esto es mental ' . $app->auth->is_admin());
$this->crearBaseDatosFtp($remote);
}*/
//IMPORTANTE, es necesario cargar nuestro formulario para poder ejecutar la función que crea
//la base de datos y el ftp ya que hay datos que tomamos de él antes de ejecutarla.
$app->tform->loadFormDef('form/new_service_webdns.tform.php');
//if(!$app->auth->is_admin()){
//if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])){
//$this->crearBaseDatosFtpClientes($remote);
//}else{
//echo('Esto es mental ' . $app->auth->is_admin());
$this->crearBaseDatosFtp($remote);
//}
//}
}else{
$this->onError();
return;
}
}
//parent::onSubmit();
}
}

/*class sitios_remoting extends remoting_sites {
public function test(){
echo('Texto test');
}
}*/

class remote_actions extends remoting {
public function insert_query($formdef_file, $client_id, $params, $event_identifier = '') {
global $app;

/*$sql = $this->insertQueryPrepare($formdef_file, $client_id, $params);
echo(' Query ' . $sql);
$app->uses('remoting_lib');
$app->remoting_lib->loadUserProfile();*/
//return $app->db->query($sql);//$this->insertQueryExecute($sql, $params, $event_identifier);
//echo(' insertQueryPrepare ' . $this->insertQueryExecute($sql, $params, $event_identifier));
return $this->insertQuery($formdef_file, $client_id, $params, $event_identifier);
}

public function sites_database_user_add($session_id, $client_id, $params, $event_identifier = '')
{
global $app;
/*if(!$this->checkPerm($session_id, 'sites_database_user_add')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}*/
//echo(' el loadUserProfile ' . $app->remoting_lib->loadUserProfile($client_id));
return $this->insertQuery('../sites/form/database_user.tform.php', $client_id, $params, $event_identifier);
}

public function sites_database_add($client_id, $params){
global $app, $conf;

@@ -1791,7 +1639,7 @@ $page = new page_action;
$page->onLoad();


//IMPORTENTE, es necesario estas líneas para que el botón del pdf funcione. Activa el javascript
//IMPORTENTE, es necesario estas líneas para que el botón del pdf funcione. Activa el javascript
//echo '<script type="text/javascript">';
//echo 'alert (password(7, false, 1));';
//echo '</script>';
@@ -1799,7 +1647,7 @@ $page->onLoad();

?>

<!--IMPORTENTE, es necesario estas líneas para que el botón del pdf funcione. Activa el javascript -->
<!--IMPORTENTE, es necesario estas líneas para que el botón del pdf funcione. Activa el javascript -->
<script type="text/javascript">

/*var test = "PARALACLAVE";
@@ -1850,4 +1698,4 @@ function password(minLength, special, num_special){
return password;
}*/

</script>
</script>

+ 67
- 0
templates/database_user_edit.htm Bestand weergeven

@@ -0,0 +1,67 @@
<div class='page-header'>
<h1><tmpl_var name="list_head_txt"></h1>
</div>
<p><tmpl_var name="list_desc_txt"></p>


<tmpl_if name="is_admin">
<div class="form-group">
<label for="client_group_id" class="col-sm-3 control-label">{tmpl_var name='client_txt'}</label>
<div class="col-sm-9"><select name="client_group_id" id="client_group_id" class="form-control">
{tmpl_var name='client_group_id'}
</select></div>
</div>
</tmpl_if>
<tmpl_if name="is_reseller">
<div class="form-group">
<label for="client_group_id" class="col-sm-3 control-label">{tmpl_var name='client_txt'}</label>
<div class="col-sm-9"><select name="client_group_id" id="client_group_id" class="form-control">
{tmpl_var name='client_group_id'}
</select></div>
</div>
</tmpl_if>
<div class="form-group">
<label for="database_user" class="col-sm-3 control-label">{tmpl_var name='database_user_txt'}</label>
<div class="col-sm-9">
<div class="input-group">
<span class="input-group-addon" id="database_user-desc">{tmpl_var name='database_user_prefix'}</span>
<input type="text" name="database_user" id="database_user" value="{tmpl_var name='database_user'}" class="form-control" aria-describedby="database_user-desc" />
</div>
</div>
</div>
<div class="form-group">
<label for="database_password" class="col-sm-3 control-label">{tmpl_var name='database_password_txt'}</label>
<div class="col-sm-9">
<div class="input-group">
<input type="password" name="database_password" id="database_password" value="{tmpl_var name='database_password'}" class="form-control" autocomplete="off" onkeyup="pass_check(this.value);checkPassMatch('database_password','repeat_password');" />
<span class="input-group-btn">
<button class="btn btn-default" type="button" onclick="generatePassword('database_password','repeat_password');">{tmpl_var name='generate_password_txt'}</button>
</span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='password_strength_txt'}</label>
<div class="col-sm-9 checkbox">
<div id="passBar"></div>
<span id="passText">&nbsp;</span>
</div>
</div>
<div class="form-group">
<label for="repeat_password" class="col-sm-3 control-label">{tmpl_var name='repeat_password_txt'}</label>
<div class="col-sm-9"><input type="password" name="repeat_password" id="repeat_password" value="" class="form-control" autocomplete="off" onkeyup="checkPassMatch('database_password','repeat_password');" /></div></div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<div id="confirmpasswordError" style="display:none;" class="confirmpassworderror">{tmpl_var name='password_mismatch_txt'}</div>
<div id="confirmpasswordOK" style="display:none;" class="confirmpasswordok">{tmpl_var name='password_match_txt'}</div>
</div>
</div>

<input type="hidden" name="id" value="{tmpl_var name='id'}">

<div class="clear"><div class="right">
<button class="btn btn-default formbutton-success" type="button" value="{tmpl_var name='btn_save_txt'}" data-submit-form="pageForm" data-form-action="sites/database_user_edit.php">{tmpl_var name='btn_save_txt'}</button>
<button class="btn btn-default formbutton-default" type="button" value="{tmpl_var name='btn_cancel_txt'}" data-load-content="sites/database_user_list.php">{tmpl_var name='btn_cancel_txt'}</button>
</div></div>

+ 3
- 3
templates/new_service_webdns.htm Bestand weergeven

@@ -23,11 +23,11 @@
</div>
</tmpl_if>
<div class="col-sm-9">
<!--div class="col-sm-9">
<div class="input-group">
<span class="input-group-addon" id="username-desc">{tmpl_var name='username_prefix'}</span>
<!--input type="text" name="username" id="username" value="{tmpl_var name='username'}" class="form-control" aria-describedby="username-desc" / -->
</div>
<!--/div>
</div>
<br>
@@ -40,7 +40,7 @@
<input type="text" name="database_user" id="database_user" value="{tmpl_var name='database_user'}" class="form-control" aria-describedby="database_user-desc" />
</div>
</div>
</div>
</div--!>
</div>



Laden…
Annuleren
Opslaan