| @@ -382,6 +382,7 @@ class page_action extends tform_actions { | |||
| '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' => $this->valor_prefix, | |||
| 'database_password' => $clavePass | |||
| @@ -390,7 +391,8 @@ class page_action extends tform_actions { | |||
| $this->usuario_db_txt = $db_user_params['database_user']; | |||
| $this->pass_db_txt = $db_user_params['database_password']; | |||
| //print "<pre>"; 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"; | |||
| @@ -412,7 +414,7 @@ class page_action extends tform_actions { | |||
| 'remote_ips' => '-1', | |||
| 'active' => 'y' | |||
| ); | |||
| //print "<pre>"; print_r($paramsBD); print "</pre>\n"; | |||
| //print "<pre> BBDD "; print_r($paramsBD); print "</pre>\n"; | |||
| //print "<pre>"; print_r($fields); print "</pre>\n"; | |||
| $this->nombre_db_txt = $paramsBD['database_name']; | |||
| @@ -448,9 +450,9 @@ class page_action extends tform_actions { | |||
| ); | |||
| $this->usuario_ftp_txt = $ftp_params['username']; | |||
| $this->pass_ftp_txt = $ftp_params['password']; | |||
| /*print "<pre>"; print_r($ftp_params); print "</pre>\n"; | |||
| print "<pre>"; print_r($site_data); print "</pre>\n"; | |||
| echo('El usuario es ' . $fields['client_group_id']);*/ | |||
| //print "<pre> FTP "; print_r($ftp_params); print "</pre>\n"; | |||
| //print "<pre>"; print_r($site_data); print "</pre>\n"; | |||
| //echo('El usuario es ' . $fields['client_group_id']); | |||
| $remoto->insert_query('../sites/form/ftp_user.tform.php', $fields['client_group_id'], $ftp_params); | |||
| echo '<br><div class="alert alert-success"><br> | |||
| @@ -491,8 +493,10 @@ class page_action extends tform_actions { | |||
| function urlBBDD($idBBDD, $servidor_id){ | |||
| global $app, $conf; | |||
| $dbData = $app->db->queryOneRecord("SELECT server_id, database_name FROM web_database WHERE database_id = ?", $idBBDD); | |||
| $serverData = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ?", $servidor_id); | |||
| $dbData = $app->db->queryOneRecord( | |||
| "SELECT server_id, database_name FROM web_database WHERE database_id = ?", $idBBDD); | |||
| $serverData = $app->db->queryOneRecord( | |||
| "SELECT server_name FROM server WHERE server_id = ?", $servidor_id); | |||
| $app->uses('getconf'); | |||
| $global_config = $app->getconf->get_global_config('sites'); | |||
| @@ -829,43 +833,6 @@ class page_action extends tform_actions { | |||
| $site_id = $remoto->insert_query('../sites/form/web_vhost_domain.tform.php', $this->cli_id, $paramsite, 'sites:web_vhost_domain:on_after_insert'); | |||
| } | |||
| function servidoresActivados(){ | |||
| global $app, $conf; | |||
| $servidores = $app->db->queryAllRecords( | |||
| 'SELECT server_id, server_name, web_server, dns_server, file_server, db_server FROM server'); | |||
| foreach($servidores as $servidor){ | |||
| $serv_web = $servidor['web_server']; | |||
| $serv_dns = $servidor['dns_server']; | |||
| $serv_ftp = $servidor['file_server']; | |||
| $serv_db = $servidor['db_server']; | |||
| $nombre_server = $servidor['server_name']; | |||
| //print "<pre>Todos los servidores ";print_r($servidor);print "</pre>\n"; | |||
| //Si alguno de los servidores no esta activo, mostramos error. | |||
| if($serv_web == 0){ | |||
| $app->tform->errorMessage = $app->tform->wordbook['error_activado_servidor'] . $nombre_server . ' el servicio WEB'; | |||
| $this->onError(); | |||
| return true; | |||
| } else if($serv_dns == 0){ | |||
| $app->tform->errorMessage = $app->tform->wordbook['error_activado_servidor'] . $nombre_server . ' el servicio DNS'; | |||
| $this->onError(); | |||
| return true; | |||
| } else if($serv_ftp == 0){ | |||
| $app->tform->errorMessage = $app->tform->wordbook['error_activado_servidor'] . $nombre_server . ' el servicio FTP'; | |||
| $this->onError(); | |||
| return true; | |||
| } else if($serv_db == 0){ | |||
| $app->tform->errorMessage = $app->tform->wordbook['error_activado_servidor'] . $nombre_server . ' el servicio DB'; | |||
| $this->onError(); | |||
| return true; | |||
| } | |||
| } | |||
| return false; | |||
| } | |||
| public $ip4_servidor_dns; | |||
| public $ip6_servidor_dns; | |||
| public $ip4_servidor_web; | |||
| @@ -898,7 +865,7 @@ class page_action extends tform_actions { | |||
| $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 = 1; | |||
| $this->ftp_serv = $global_config_sitio['default_webserver'];//1; | |||
| }else{ | |||
| $servidores = $app->db->queryOneRecord( | |||
| "SELECT client_id, dns_servers, web_servers, db_servers FROM client | |||
| @@ -907,6 +874,8 @@ class page_action extends tform_actions { | |||
| $this->dns_serv = $servidores['dns_servers']; | |||
| $this->web_serv = $servidores['web_servers']; | |||
| $this->bbdd_serv = $servidores['db_servers']; | |||
| //para el ftp el servidor es el mismo que para el sitio web. | |||
| $this->ftp_serv = $servidores['web_servers']; | |||
| //Si el cliente no tiene asignado un servidor se añade por defecto al 1 | |||
| if(!$this->dns_serv){ | |||
| @@ -921,9 +890,15 @@ class page_action extends tform_actions { | |||
| if(!$this->bbdd_serv){ | |||
| $this->bbdd_serv = $global_config_sitio['default_dbserver'];//1; | |||
| } | |||
| //Si el cliente no tiene asignado un servidor se añade por defecto al 1 | |||
| if(!$this->ftp_serv){ | |||
| $this->ftp_serv = $global_config_sitio['default_webserver'];//1; | |||
| } | |||
| } | |||
| /*print "<pre>DNS SERVER ";print_r($this->dns_serv);print "</pre>\n"; | |||
| print "<pre>WEB SERVER ";print_r($this->web_serv);print "</pre>\n";*/ | |||
| print "<pre>WEB SERVER ";print_r($this->web_serv);print "</pre>\n"; | |||
| print "<pre>DB SERVER ";print_r($this->bbdd_serv);print "</pre>\n"; | |||
| print "<pre>FTP SERVER ";print_r($this->ftp_serv);print "</pre>\n";*/ | |||
| //El cliente 1 es admin | |||
| //Captura de las ips del servidor dns | |||
| @@ -947,7 +922,8 @@ class page_action extends tform_actions { | |||
| 'SELECT ip_type, ip_address FROM server_ip | |||
| WHERE client_id = "1" AND server_id = "'.$this->dns_serv.'" AND ip_type="IPv6"'); | |||
| } | |||
| }else{//Comprobamos si el cliente tiene servidor asignado | |||
| }else{//Comprobamos si el cliente tiene servidor asignado, si no lo tiene asignamos el que admin a seleccionado | |||
| //para este servidor. | |||
| $this->ip4_servidor_dns = $app->db->queryOneRecord( | |||
| 'SELECT ip_type, ip_address | |||
| FROM server_ip | |||
| @@ -1102,6 +1078,10 @@ class page_action extends tform_actions { | |||
| } | |||
| } | |||
| } | |||
| //para el servidor ftp no se hacen comprobaciones | |||
| //ya que las ips son las mismas que para el servidor web. | |||
| //$la_ip4 = $app->db->queryOneRecord("SELECT ip_type, ip_address FROM server_ip WHERE ip_type='IPv4'"); | |||
| $this->ip4_pdf = $this->ip4_servidor_dns['ip_address'];//$dns_ip_servidor['ip_address'];//$la_ip4['ip_address']; | |||
| /*print "<pre>IP4 DNS ";print_r($this->ip4_servidor_dns);print "</pre>\n"; | |||
| @@ -1129,6 +1109,92 @@ class page_action extends tform_actions { | |||
| return false; | |||
| } | |||
| //Comprueba si los servidores asignados al usuario seleccionado tiene los servicios activos para cada caso. | |||
| function servidoresActivados(){ | |||
| global $app, $conf; | |||
| $servicio_web = $app->db->queryOneRecord( | |||
| 'SELECT server_id, web_server, server_name FROM server | |||
| WHERE server_id = "'.$this->web_serv.'"'); | |||
| $nom_serv_web = $servicio_web['server_name']; | |||
| $servicio_dns = $app->db->queryOneRecord( | |||
| 'SELECT server_id, dns_server, server_name FROM server | |||
| WHERE server_id = "'.$this->dns_serv.'"'); | |||
| $nom_serv_dns = $servicio_dns['server_name']; | |||
| $servicio_ftp = $app->db->queryOneRecord( | |||
| 'SELECT server_id, file_server, server_name FROM server | |||
| WHERE server_id = "'.$this->ftp_serv.'"'); | |||
| $nom_serv_ftp = $servicio_ftp['server_name']; | |||
| $servicio_db = $app->db->queryOneRecord( | |||
| 'SELECT server_id, db_server, server_name FROM server | |||
| WHERE server_id = "'.$this->bbdd_serv.'"'); | |||
| $nom_serv_db = $servicio_db['server_name']; | |||
| //print "<pre>Servidor WEB ";print_r($servicio_web);print "</pre>\n"; | |||
| if($servicio_web['web_server'] == 0){ | |||
| $app->tform->errorMessage = $app->tform->wordbook['error_activado_servidor'] . $nom_serv_web . ' el servicio WEB.'; | |||
| $this->onError(); | |||
| return true; | |||
| } | |||
| //print "<pre>Servidor DNS ";print_r($servicio_dns);print "</pre>\n"; | |||
| if($servicio_dns['dns_server'] == 0){ | |||
| $app->tform->errorMessage = $app->tform->wordbook['error_activado_servidor'] . $nom_serv_dns . ' el servicio DNS.'; | |||
| $this->onError(); | |||
| return true; | |||
| } | |||
| //print "<pre>Servidor FTP ";print_r($servicio_ftp);print "</pre>\n"; | |||
| if($servicio_ftp['file_server'] == 0){ | |||
| $app->tform->errorMessage = $app->tform->wordbook['error_activado_servidor'] . $nom_serv_ftp . ' el servicio FTP.'; | |||
| $this->onError(); | |||
| return true; | |||
| } | |||
| //print "<pre>Servidor DB ";print_r($servicio_db);print "</pre>\n"; | |||
| if($servicio_db['db_server'] == 0){ | |||
| $app->tform->errorMessage = $app->tform->wordbook['error_activado_servidor'] . $nom_serv_db . ' el servicio DB.'; | |||
| $this->onError(); | |||
| return true; | |||
| } | |||
| /*$servidores = $app->db->queryAllRecords( | |||
| 'SELECT server_id, server_name, web_server, dns_server, file_server, db_server FROM server'); | |||
| foreach($servidores as $servidor){ | |||
| $serv_web = $servidor['web_server']; | |||
| $serv_dns = $servidor['dns_server']; | |||
| $serv_ftp = $servidor['file_server']; | |||
| $serv_db = $servidor['db_server']; | |||
| $nombre_server = $servidor['server_name']; | |||
| //print "<pre>Todos los servidores ";print_r($servidor);print "</pre>\n"; | |||
| //Si alguno de los servidores no esta activo, mostramos error. | |||
| if($serv_web == 0){ | |||
| $app->tform->errorMessage = $app->tform->wordbook['error_activado_servidor'] . $nombre_server . ' el servicio WEB'; | |||
| $this->onError(); | |||
| return true; | |||
| } else if($serv_dns == 0){ | |||
| $app->tform->errorMessage = $app->tform->wordbook['error_activado_servidor'] . $nombre_server . ' el servicio DNS'; | |||
| $this->onError(); | |||
| return true; | |||
| } else if($serv_ftp == 0){ | |||
| $app->tform->errorMessage = $app->tform->wordbook['error_activado_servidor'] . $nombre_server . ' el servicio FTP'; | |||
| $this->onError(); | |||
| return true; | |||
| } else if($serv_db == 0){ | |||
| $app->tform->errorMessage = $app->tform->wordbook['error_activado_servidor'] . $nombre_server . ' el servicio DB'; | |||
| $this->onError(); | |||
| return true; | |||
| }*/ | |||
| //} | |||
| return false; | |||
| } | |||
| //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; | |||
| @@ -1181,7 +1247,7 @@ class page_action extends tform_actions { | |||
| //Tomamos el grupo del cliente o admin, se toma este valor y se captura el client_id y groupid de la tabla | |||
| //sys_group que esta asociada al desplegable de la vista, es en esta tabla donde también esta | |||
| //el client_id de admin. En la tabla client no esta el client_id de admin. | |||
| /* 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. | |||
| $cliente_id_seleccionado = 1; | |||
| //En la tabla dns_soa y dns_rr se guarda el valor 0 en sys_groupid cuando es admin. | |||
| @@ -1190,7 +1256,7 @@ class page_action extends tform_actions { | |||
| $cliente_id_seleccionadoCaptura = $app->db->queryOneRecord('SELECT client_id, groupid FROM sys_group WHERE groupid ="'. $fields['client_group_id'] . '"'); | |||
| $cliente_id_seleccionado = $cliente_id_seleccionadoCaptura['client_id']; | |||
| $cliente_groupid = $cliente_id_seleccionadoCaptura['groupid']; | |||
| }*/ | |||
| } | |||
| //IMPORTANTE. | |||
| @@ -1301,7 +1367,7 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||
| //Recuperamos los distintos servidores del cliente o admin. Uso la tabla client donde no esta admin, por esto | |||
| //grabo a fuego el servidor 1 que hasta el momento parece depender de la instalación de ispconfig y simpre | |||
| //será así ¿?. | |||
| if($fields['client_group_id']==0) { | |||
| /*if($fields['client_group_id']==0) { | |||
| //$servidores = $app->db->queryOneRecord("SELECT client_id, default_dnsserver, default_webserver FROM client WHERE client_id = ". $cliente_id_seleccionado); | |||
| $dns_servidor = 1; //$servidores['default_dnsserver']; | |||
| $web_servidor = 1; //$servidores['default_webserver']; | |||
| @@ -1310,7 +1376,7 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||
| $dns_servidor = $servidores['dns_servers']; | |||
| //$web_servidor = $servidores['default_webserver']; | |||
| $web_servidor = $servidores['web_servers']; | |||
| } | |||
| }*/ | |||
| //echo ('El servidor dns es ' . $dns_servidor. " y el servidor web es " . $web_servidor); | |||
| @@ -1389,7 +1455,7 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||
| //'sys_userid' => $sysUsuarioId, //$fields['client_group_id'],//$sys_userid, | |||
| //'sys_groupid' => $cliente_groupid, | |||
| 'ip_address' => '*', //$dns_ip_servidor['ip_address'], | |||
| 'ipv6_address' => $this->ip6_ultima['ip_address'], //$dns_ip_servidor_ipv6['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', | |||
| 'cgi' => 'y', | |||
| @@ -1439,7 +1505,7 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||
| //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'); | |||
| $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'); | |||
| $site_id = $remoto->insert_query('../sites/form/web_vhost_domain.tform.php', $cliente_id_seleccionado, $paramsite, 'sites:web_vhost_domain:on_after_insert'); | |||
| //print 'Sitio id '. $site_id; | |||
| } | |||
| @@ -1451,13 +1517,13 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||
| //Creo la clase remote para usar las librerias | |||
| $remote = new remote_actions; | |||
| if($this->servidoresActivados()){ | |||
| return; | |||
| } | |||
| if($this->tieneServidorIPs()){ | |||
| return; | |||
| } | |||
| if($this->servidoresActivados()){ | |||
| return; | |||
| } | |||
| if($this->existeDominio($fields)){ | |||
| return; | |||
| } | |||