|
|
@@ -569,13 +569,15 @@ class page_action extends tform_actions { |
|
|
|
|
|
|
|
|
//Captura de los distintos ids del cliente y usuario de sistema. |
|
|
//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. |
|
|
//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) { |
|
|
if($fields['client_group_id']==0) { |
|
|
//En la tabla sys_user el userid 1 es admin. No esta en sys_group. |
|
|
|
|
|
$this->cli_id = 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//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. |
|
|
//En la tabla dns_soa y dns_rr se guarda el valor 0 en sys_groupid cuando es admin. |
|
|
$this->cli_grupo_id = 0; |
|
|
$this->cli_grupo_id = 0; |
|
|
$this->sys_usuario_id = $this->cli_id; |
|
|
|
|
|
$this->sys_grupo_id = $this->cli_grupo_id; |
|
|
|
|
|
|
|
|
$this->sys_usuario_id = 1;//$this->cli_id; |
|
|
|
|
|
$this->sys_grupo_id = 0;//$this->cli_grupo_id; |
|
|
}else{ |
|
|
}else{ |
|
|
$client = $app->db->queryOneRecord( |
|
|
$client = $app->db->queryOneRecord( |
|
|
'SELECT sys_user.sys_userid, sys_user.sys_groupid, sys_user.default_group, sys_user.client_id |
|
|
'SELECT sys_user.sys_userid, sys_user.sys_groupid, sys_user.default_group, sys_user.client_id |
|
|
@@ -586,7 +588,10 @@ class page_action extends tform_actions { |
|
|
$this->cli_grupo_id = $client['default_group']; |
|
|
$this->cli_grupo_id = $client['default_group']; |
|
|
$this->sys_usuario_id = $client['sys_userid']; |
|
|
$this->sys_usuario_id = $client['sys_userid']; |
|
|
$this->sys_grupo_id = $client['sys_groupid']; |
|
|
$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; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Crear subdominio |
|
|
//Crear subdominio |
|
|
@@ -785,17 +790,32 @@ class page_action extends tform_actions { |
|
|
$global_config_sitio = $app->getconf->get_global_config('sites'); |
|
|
$global_config_sitio = $app->getconf->get_global_config('sites'); |
|
|
$global_config_dns = $app->getconf->get_global_config('dns'); |
|
|
$global_config_dns = $app->getconf->get_global_config('dns'); |
|
|
|
|
|
|
|
|
|
|
|
if(!$global_config_dns['default_dnsserver']) { |
|
|
|
|
|
$app->tform->errorMessage = $app->tform->wordbook['error_no_servidor_default']. 'DNS.'; |
|
|
|
|
|
$this->onError(); |
|
|
|
|
|
return true; |
|
|
|
|
|
} else if(!$global_config_sitio['default_webserver']) { |
|
|
|
|
|
$app->tform->errorMessage = $app->tform->wordbook['error_no_servidor_default']. 'WEB.'; |
|
|
|
|
|
$this->onError(); |
|
|
|
|
|
return true; |
|
|
|
|
|
} else if(!$global_config_sitio['default_dbserver']) { |
|
|
|
|
|
$app->tform->errorMessage = $app->tform->wordbook['error_no_servidor_default']. 'DB.'; |
|
|
|
|
|
$this->onError(); |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//print "<pre>WEB SERVER por defecto ";print_r($global_config_sitio);print "</pre>\n"; |
|
|
//print "<pre>WEB SERVER por defecto ";print_r($global_config_sitio);print "</pre>\n"; |
|
|
//print "<pre>DNS SERVER por defecto ";print_r($global_config_dns);print "</pre>\n"; |
|
|
//print "<pre>DNS SERVER por defecto ";print_r($global_config_dns);print "</pre>\n"; |
|
|
|
|
|
|
|
|
//El cliente 1 es admin. |
|
|
//El cliente 1 es admin. |
|
|
//Recupero los servidores asignados por defecto y se los asigno a admin o al usuario |
|
|
//Recupero los servidores asignados por defecto y se los asigno a admin o al usuario |
|
|
//que no tenga asignado ninguno. |
|
|
//que no tenga asignado ninguno. |
|
|
if($this->cli_id == 1) { |
|
|
|
|
|
|
|
|
if($this->cli_id == 0) { |
|
|
$this->dns_serv = $global_config_dns['default_dnsserver'];//1; |
|
|
$this->dns_serv = $global_config_dns['default_dnsserver'];//1; |
|
|
$this->web_serv = $global_config_sitio['default_webserver'];//1; |
|
|
$this->web_serv = $global_config_sitio['default_webserver'];//1; |
|
|
$this->bbdd_serv = $global_config_sitio['default_dbserver'];//1; |
|
|
$this->bbdd_serv = $global_config_sitio['default_dbserver'];//1; |
|
|
$this->ftp_serv = $global_config_sitio['default_webserver'];//1; |
|
|
$this->ftp_serv = $global_config_sitio['default_webserver'];//1; |
|
|
|
|
|
//print "<pre>tieneServidorIPs el cli_id "; print_r($this->cli_id . ' el servidor ' . $this->dns_serv); print "</pre>\n"; |
|
|
}else{ |
|
|
}else{ |
|
|
$servidores = $app->db->queryOneRecord( |
|
|
$servidores = $app->db->queryOneRecord( |
|
|
"SELECT client_id, dns_servers, web_servers, db_servers FROM client |
|
|
"SELECT client_id, dns_servers, web_servers, db_servers FROM client |
|
|
@@ -832,7 +852,7 @@ class page_action extends tform_actions { |
|
|
|
|
|
|
|
|
//El cliente 1 es admin |
|
|
//El cliente 1 es admin |
|
|
//Captura de las ips del servidor dns |
|
|
//Captura de las ips del servidor dns |
|
|
if($this->cli_id == 1){ |
|
|
|
|
|
|
|
|
if($this->cli_id == 0){ |
|
|
//Compruebo si hay datos para el client_id 0 y si no existe pruebo con el 1. |
|
|
//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( |
|
|
$this->ip4_servidor_dns = $app->db->queryOneRecord( |
|
|
@@ -896,7 +916,7 @@ class page_action extends tform_actions { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Captura de las ips del servidor web |
|
|
//Captura de las ips del servidor web |
|
|
if($this->cli_id == 1){ |
|
|
|
|
|
|
|
|
if($this->cli_id == 0){ |
|
|
//Compruebo si hay datos para el client_id 0 y si no existe pruebo con el 1. |
|
|
//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_web = $app->db->queryOneRecord( |
|
|
$this->ip4_servidor_web = $app->db->queryOneRecord( |
|
|
@@ -906,7 +926,7 @@ class page_action extends tform_actions { |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
WHERE client_id = "0" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv6"'); |
|
|
WHERE client_id = "0" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv6"'); |
|
|
|
|
|
|
|
|
if(!$this->ip4_servidor_web){ |
|
|
|
|
|
|
|
|
/*if(!$this->ip4_servidor_web){ |
|
|
$this->ip4_servidor_web = $app->db->queryOneRecord( |
|
|
$this->ip4_servidor_web = $app->db->queryOneRecord( |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
WHERE client_id = "1" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv4"'); |
|
|
WHERE client_id = "1" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv4"'); |
|
|
@@ -915,7 +935,7 @@ class page_action extends tform_actions { |
|
|
$this->ip6_servidor_web = $app->db->queryOneRecord( |
|
|
$this->ip6_servidor_web = $app->db->queryOneRecord( |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
WHERE client_id = "1" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv6"'); |
|
|
WHERE client_id = "1" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv6"'); |
|
|
} |
|
|
|
|
|
|
|
|
}*/ |
|
|
}else{//Comprobamos si el cliente tiene servidor asignado |
|
|
}else{//Comprobamos si el cliente tiene servidor asignado |
|
|
$this->ip4_servidor_web = $app->db->queryOneRecord( |
|
|
$this->ip4_servidor_web = $app->db->queryOneRecord( |
|
|
'SELECT ip_type, ip_address |
|
|
'SELECT ip_type, ip_address |
|
|
@@ -932,26 +952,26 @@ class page_action extends tform_actions { |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
WHERE client_id = "0" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv4"'); |
|
|
WHERE client_id = "0" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv4"'); |
|
|
|
|
|
|
|
|
if(!$this->ip4_servidor_web){ |
|
|
|
|
|
|
|
|
/*if(!$this->ip4_servidor_web){ |
|
|
$this->ip4_servidor_web = $app->db->queryOneRecord( |
|
|
$this->ip4_servidor_web = $app->db->queryOneRecord( |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
WHERE client_id = "1" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv4"'); |
|
|
WHERE client_id = "1" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv4"'); |
|
|
} |
|
|
|
|
|
|
|
|
}*/ |
|
|
} |
|
|
} |
|
|
if(!$this->ip6_servidor_web){ |
|
|
if(!$this->ip6_servidor_web){ |
|
|
$this->ip6_servidor_web = $app->db->queryOneRecord( |
|
|
$this->ip6_servidor_web = $app->db->queryOneRecord( |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
WHERE client_id = "0" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv6"'); |
|
|
WHERE client_id = "0" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv6"'); |
|
|
|
|
|
|
|
|
if(!$this->ip6_servidor_web){ |
|
|
|
|
|
|
|
|
/*if(!$this->ip6_servidor_web){ |
|
|
$this->ip6_servidor_web = $app->db->queryOneRecord( |
|
|
$this->ip6_servidor_web = $app->db->queryOneRecord( |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
WHERE client_id = "1" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv6"'); |
|
|
WHERE client_id = "1" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv6"'); |
|
|
} |
|
|
|
|
|
|
|
|
}*/ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
//Captura de las ips del servidor bbdd |
|
|
//Captura de las ips del servidor bbdd |
|
|
if($this->cli_id == 1){ |
|
|
|
|
|
|
|
|
if($this->cli_id == 0){ |
|
|
//Compruebo si hay datos para el client_id 0 y si no existe pruebo con el 1. |
|
|
//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( |
|
|
$this->ip4_servidor_bbdd = $app->db->queryOneRecord( |
|
|
@@ -961,7 +981,7 @@ class page_action extends tform_actions { |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
WHERE client_id = "0" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv6"'); |
|
|
WHERE client_id = "0" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv6"'); |
|
|
|
|
|
|
|
|
if(!$this->ip4_servidor_bbdd){ |
|
|
|
|
|
|
|
|
/*if(!$this->ip4_servidor_bbdd){ |
|
|
$this->ip4_servidor_bbdd = $app->db->queryOneRecord( |
|
|
$this->ip4_servidor_bbdd = $app->db->queryOneRecord( |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
WHERE client_id = "1" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv4"'); |
|
|
WHERE client_id = "1" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv4"'); |
|
|
@@ -970,7 +990,7 @@ class page_action extends tform_actions { |
|
|
$this->ip6_servidor_bbdd = $app->db->queryOneRecord( |
|
|
$this->ip6_servidor_bbdd = $app->db->queryOneRecord( |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
WHERE client_id = "1" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv6"'); |
|
|
WHERE client_id = "1" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv6"'); |
|
|
} |
|
|
|
|
|
|
|
|
}*/ |
|
|
}else{//Comprobamos si el cliente tiene servidor asignado |
|
|
}else{//Comprobamos si el cliente tiene servidor asignado |
|
|
$this->ip4_servidor_bbdd = $app->db->queryOneRecord( |
|
|
$this->ip4_servidor_bbdd = $app->db->queryOneRecord( |
|
|
'SELECT ip_type, ip_address |
|
|
'SELECT ip_type, ip_address |
|
|
@@ -990,22 +1010,22 @@ class page_action extends tform_actions { |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
WHERE client_id = "0" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv4"'); |
|
|
WHERE client_id = "0" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv4"'); |
|
|
|
|
|
|
|
|
if(!$this->ip4_servidor_bbdd){ |
|
|
|
|
|
|
|
|
/*if(!$this->ip4_servidor_bbdd){ |
|
|
$this->ip4_servidor_bbdd = $app->db->queryOneRecord( |
|
|
$this->ip4_servidor_bbdd = $app->db->queryOneRecord( |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
WHERE client_id = "1" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv4"'); |
|
|
WHERE client_id = "1" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv4"'); |
|
|
} |
|
|
|
|
|
|
|
|
}*/ |
|
|
} |
|
|
} |
|
|
if(!$this->ip6_servidor_bbdd){ |
|
|
if(!$this->ip6_servidor_bbdd){ |
|
|
$this->ip6_servidor_bbdd = $app->db->queryOneRecord( |
|
|
$this->ip6_servidor_bbdd = $app->db->queryOneRecord( |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
WHERE client_id = "0" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv6"'); |
|
|
WHERE client_id = "0" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv6"'); |
|
|
|
|
|
|
|
|
if(!$this->ip6_servidor_bbdd){ |
|
|
|
|
|
|
|
|
/*if(!$this->ip6_servidor_bbdd){ |
|
|
$this->ip6_servidor_bbdd = $app->db->queryOneRecord( |
|
|
$this->ip6_servidor_bbdd = $app->db->queryOneRecord( |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
'SELECT ip_type, ip_address FROM server_ip |
|
|
WHERE client_id = "1" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv6"'); |
|
|
WHERE client_id = "1" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv6"'); |
|
|
} |
|
|
|
|
|
|
|
|
}*/ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
//para el servidor ftp no se hacen comprobaciones |
|
|
//para el servidor ftp no se hacen comprobaciones |
|
|
@@ -1181,6 +1201,17 @@ class page_action extends tform_actions { |
|
|
//} |
|
|
//} |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Comprobación de que tenemos instalada nuestra plantilla |
|
|
|
|
|
function plantillaWebDNS(){ |
|
|
|
|
|
global $app; |
|
|
|
|
|
|
|
|
|
|
|
if(!$app->db->queryOneRecord("SELECT name FROM dns_template WHERE name = 'webdns'")) { |
|
|
|
|
|
$app->tform->errorMessage = $app->tform->wordbook['error_plantilla_webdns']; |
|
|
|
|
|
$this->onError(); |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//Comprueba que no exista el dominio y que no tenga sitio web, puede tener sitio web y no tener dns. |
|
|
//Comprueba que no exista el dominio y que no tenga sitio web, puede tener sitio web y no tener dns. |
|
|
function existeDominio($campos){ |
|
|
function existeDominio($campos){ |
|
|
@@ -1429,6 +1460,10 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ |
|
|
|
|
|
|
|
|
function onSubmit() { |
|
|
function onSubmit() { |
|
|
global $app, $conf; |
|
|
global $app, $conf; |
|
|
|
|
|
|
|
|
|
|
|
if($this->plantillaWebDNS()){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
//Carga de campos del formulario. |
|
|
//Carga de campos del formulario. |
|
|
$fields = $app->tform->encode($this->dataRecord, $app->tform->getCurrentTab(), true); |
|
|
$fields = $app->tform->encode($this->dataRecord, $app->tform->getCurrentTab(), true); |
|
|
|
|
|
|
|
|
|