diff --git a/clases/limites.inc.php b/clases/limites.inc.php index 634cbf4..3ad7989 100644 --- a/clases/limites.inc.php +++ b/clases/limites.inc.php @@ -56,7 +56,7 @@ class limites { //PARA SABER QUIEN ES UN RESELLER //SELECT client_id, company_name, limit_client FROM client WHERE limit_client > 0 OR limit_client = -1 $this->esReventa = $app->db->queryOneRecord( - "SELECT client_id, limit_client, contact_name + "SELECT client_id, limit_client, contact_name, limit_dns_zone FROM client WHERE limit_client > 0 OR limit_client = -1 AND client_id = ?", $this->cliente['client_id']); @@ -114,19 +114,21 @@ class limites { $this->esRevendedor(); - $sumaTotal = 0; - foreach($this->todosLosGrupos as $grupos) { - $tmpReventaALL = $app->db->queryOneRecord( - "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", $grupos); - - $sumaTotal += $tmpReventaALL['number']; - } + if($this->esReventa){ + + $sumaTotal = 0; + foreach($this->todosLosGrupos as $grupos) { + $tmpReventaALL = $app->db->queryOneRecord( + "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", $grupos); + + $sumaTotal += $tmpReventaALL['number']; + } - if($sumaTotal >= $this->cliente["limit_dns_zone"]) { - $app->error($this->esReventa['contact_name'] . '. ' . $app->tform->wordbook["limit_dns_zone_txt"]); - return true; + if($sumaTotal >= $this->cliente["limit_dns_zone"]) { + $app->error($this->esReventa['contact_name'] . '. ' . $app->tform->wordbook["limit_dns_zone_txt"]); + return true; + } } - return false; } } @@ -173,21 +175,21 @@ class limites { } $this->esRevendedor(); + if($this->esReventa){ + $sumaTotal = 0; + foreach($this->todosLosGrupos as $grupos) { + $tmpReventaALL = $app->db->queryOneRecord( + "SELECT count(domain_id) as number FROM web_domain + WHERE sys_groupid = ? and type = 'vhost'", $grupos); + + $sumaTotal += $tmpReventaALL['number']; + } - $sumaTotal = 0; - foreach($this->todosLosGrupos as $grupos) { - $tmpReventaALL = $app->db->queryOneRecord( - "SELECT count(domain_id) as number FROM web_domain - WHERE sys_groupid = ? and type = 'vhost'", $grupos); - - $sumaTotal += $tmpReventaALL['number']; - } - - if($sumaTotal >= $this->cliente["limit_web_domain"]) { - $app->error($this->esReventa['contact_name'] . '. ' . $app->tform->wordbook["limit_web_domain_txt"]); - return true; + if($sumaTotal >= $this->cliente["limit_web_domain"]) { + $app->error($this->esReventa['contact_name'] . '. ' . $app->tform->wordbook["limit_web_domain_txt"]); + return true; + } } - return false; } } @@ -234,21 +236,21 @@ class limites { } $this->esRevendedor(); + if($this->esReventa){ + $sumaTotal = 0; + foreach($this->todosLosGrupos as $grupos) { + $tmpReventaALL = $app->db->queryOneRecord( + "SELECT count(database_id) as number + FROM web_database WHERE sys_groupid = ?", $grupos); + + $sumaTotal += $tmpReventaALL['number']; + } - $sumaTotal = 0; - foreach($this->todosLosGrupos as $grupos) { - $tmpReventaALL = $app->db->queryOneRecord( - "SELECT count(database_id) as number - FROM web_database WHERE sys_groupid = ?", $grupos); - - $sumaTotal += $tmpReventaALL['number']; - } - - if($sumaTotal >= $this->cliente["limit_database"]) { - $app->error($this->esReventa['contact_name'] . '. ' . $app->tform->wordbook["limit_database_txt"]); - return true; + if($sumaTotal >= $this->cliente["limit_database"]) { + $app->error($this->esReventa['contact_name'] . '. ' . $app->tform->wordbook["limit_database_txt"]); + return true; + } } - return false; } } diff --git a/lib/lang/en_new_service_webdns.lng b/lib/lang/en_new_service_webdns.lng index 3cc30b3..73cfeb8 100755 --- a/lib/lang/en_new_service_webdns.lng +++ b/lib/lang/en_new_service_webdns.lng @@ -187,9 +187,11 @@ $wb['error_dominio_mas_puntos'] = 'El dominio no es correcto, hay 3 puntos o má $wb['error_dominio_www'] = 'El dominio no es correcto. No escriba "www" antes del dominio.'; $wb['error_no_existe_dominio_padre'] = 'El dominio padre para este subdominio, no existe.'; $wb['error_no_ip'] = 'Necesita añadir en la configuración '; +$wb['error_no_servidor_default'] = 'Necesita configurar un servidor por defecto para '; $wb['error_subdominio_existe'] = 'Este subdominio existe.'; $wb['error_sitio_web_existe'] = 'El dominio que intenta crear ya tiene sitio web.'; $wb['error_activado_servidor'] = 'Necesita activar en la configuración del servidor '; +$wb['error_plantilla_webdns'] = 'Necesita la plantilla dns para webdns.'; $wb["database_user_txt"] = 'Database user'; $wb["database_password_txt"] = 'Database password'; $wb["password_strength_txt"] = 'Password strength'; diff --git a/lib/lang/es_new_service_webdns.lng b/lib/lang/es_new_service_webdns.lng index fc14fcc..db33cef 100755 --- a/lib/lang/es_new_service_webdns.lng +++ b/lib/lang/es_new_service_webdns.lng @@ -187,9 +187,11 @@ $wb['error_dominio_mas_puntos'] = 'El dominio no es correcto, hay 3 puntos o má $wb['error_dominio_www'] = 'El dominio no es correcto. No escriba "www" antes del dominio.'; $wb['error_no_existe_dominio_padre'] = 'El dominio padre para este subdominio, no existe.'; $wb['error_no_ip'] = 'Necesita añadir en la configuración '; +$wb['error_no_servidor_default'] = 'Necesita configurar un servidor por defecto para '; $wb['error_subdominio_existe'] = 'Este subdominio existe.'; $wb['error_sitio_web_existe'] = 'El dominio que intenta crear ya tiene sitio web.'; $wb['error_activado_servidor'] = 'Necesita activar en la configuración del servidor '; +$wb['error_plantilla_webdns'] = 'Necesita la plantilla dns para webdns.'; $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'; diff --git a/new_service_webdns.php b/new_service_webdns.php index d213582..59be745 100755 --- a/new_service_webdns.php +++ b/new_service_webdns.php @@ -572,13 +572,15 @@ class page_action extends tform_actions { //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 "
Seleccionado: "; print_r($fields['client_group_id']); print "
\n"; 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. $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{ $client = $app->db->queryOneRecord( 'SELECT sys_user.sys_userid, sys_user.sys_groupid, sys_user.default_group, sys_user.client_id @@ -589,7 +591,10 @@ class page_action extends tform_actions { $this->cli_grupo_id = $client['default_group']; $this->sys_usuario_id = $client['sys_userid']; $this->sys_grupo_id = $client['sys_groupid']; - } + } + //print "
Valores : "; print_r($this->cli_id); print "
\n"; + //print "Valores " . $this->cli_id . ' ' . $this->cli_grupo_id . ' ' . $this->sys_usuario_id . ' ' . $this->sys_grupo_id; + } //Crear subdominio @@ -788,17 +793,32 @@ class page_action extends tform_actions { $global_config_sitio = $app->getconf->get_global_config('sites'); $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 "
WEB SERVER por defecto ";print_r($global_config_sitio);print "
\n"; //print "
DNS SERVER por defecto ";print_r($global_config_dns);print "
\n"; //El cliente 1 es admin. //Recupero los servidores asignados por defecto y se los asigno a admin o al usuario //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->web_serv = $global_config_sitio['default_webserver'];//1; $this->bbdd_serv = $global_config_sitio['default_dbserver'];//1; $this->ftp_serv = $global_config_sitio['default_webserver'];//1; + //print "
tieneServidorIPs el cli_id "; print_r($this->cli_id . ' el servidor ' . $this->dns_serv); print "
\n"; }else{ $servidores = $app->db->queryOneRecord( "SELECT client_id, dns_servers, web_servers, db_servers FROM client @@ -835,7 +855,7 @@ class page_action extends tform_actions { //El cliente 1 es admin //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. //Alguno de los dos tiene que existir por configuración de ispconfig. $this->ip4_servidor_dns = $app->db->queryOneRecord( @@ -899,7 +919,7 @@ class page_action extends tform_actions { } //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. //Alguno de los dos tiene que existir por configuración de ispconfig. $this->ip4_servidor_web = $app->db->queryOneRecord( @@ -909,7 +929,7 @@ class page_action extends tform_actions { 'SELECT ip_type, ip_address FROM server_ip 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( 'SELECT ip_type, ip_address FROM server_ip WHERE client_id = "1" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv4"'); @@ -918,7 +938,7 @@ class page_action extends tform_actions { $this->ip6_servidor_web = $app->db->queryOneRecord( 'SELECT ip_type, ip_address FROM server_ip WHERE client_id = "1" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv6"'); - } + }*/ }else{//Comprobamos si el cliente tiene servidor asignado $this->ip4_servidor_web = $app->db->queryOneRecord( 'SELECT ip_type, ip_address @@ -935,26 +955,26 @@ class page_action extends tform_actions { 'SELECT ip_type, ip_address FROM server_ip 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( 'SELECT ip_type, ip_address FROM server_ip WHERE client_id = "1" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv4"'); - } + }*/ } if(!$this->ip6_servidor_web){ $this->ip6_servidor_web = $app->db->queryOneRecord( 'SELECT ip_type, ip_address FROM server_ip 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( 'SELECT ip_type, ip_address FROM server_ip WHERE client_id = "1" AND server_id = "'.$this->web_serv.'" AND ip_type="IPv6"'); - } + }*/ } } //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. //Alguno de los dos tiene que existir por configuración de ispconfig. $this->ip4_servidor_bbdd = $app->db->queryOneRecord( @@ -964,7 +984,7 @@ class page_action extends tform_actions { 'SELECT ip_type, ip_address FROM server_ip 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( 'SELECT ip_type, ip_address FROM server_ip WHERE client_id = "1" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv4"'); @@ -973,7 +993,7 @@ class page_action extends tform_actions { $this->ip6_servidor_bbdd = $app->db->queryOneRecord( 'SELECT ip_type, ip_address FROM server_ip WHERE client_id = "1" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv6"'); - } + }*/ }else{//Comprobamos si el cliente tiene servidor asignado $this->ip4_servidor_bbdd = $app->db->queryOneRecord( 'SELECT ip_type, ip_address @@ -993,22 +1013,22 @@ class page_action extends tform_actions { 'SELECT ip_type, ip_address FROM server_ip 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( 'SELECT ip_type, ip_address FROM server_ip WHERE client_id = "1" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv4"'); - } + }*/ } if(!$this->ip6_servidor_bbdd){ $this->ip6_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="IPv6"'); - if(!$this->ip6_servidor_bbdd){ + /*if(!$this->ip6_servidor_bbdd){ $this->ip6_servidor_bbdd = $app->db->queryOneRecord( 'SELECT ip_type, ip_address FROM server_ip WHERE client_id = "1" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv6"'); - } + }*/ } } //para el servidor ftp no se hacen comprobaciones @@ -1184,6 +1204,17 @@ class page_action extends tform_actions { //} 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. function existeDominio($campos){ @@ -1432,6 +1463,10 @@ print "
IP6 WEB ";print_r($this->ip6_servidor_web);print "
\n";*/ function onSubmit() { global $app, $conf; + + if($this->plantillaWebDNS()){ + return; + } //Carga de campos del formulario. $fields = $app->tform->encode($this->dataRecord, $app->tform->getCurrentTab(), true);