| @@ -414,9 +414,11 @@ class page_action extends tform_actions { | |||||
| $generated_usernameBBDD = $this->generaNombreBD();//$fields['client_id'].substr(sha1(rand()), 0, 10);//client_prefix.substr(sha1(rand()), 0, 8); | $generated_usernameBBDD = $this->generaNombreBD();//$fields['client_id'].substr(sha1(rand()), 0, 10);//client_prefix.substr(sha1(rand()), 0, 8); | ||||
| //print "<pre>"; print_r($generated_usernameBBDD); print "</pre>\n"; | //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'].'"'); | |||||
| $sitio_id = $app->db->queryOneRecord( | |||||
| 'SELECT domain_id, domain FROM web_domain WHERE domain = "'.$fields['domain'].'"'); | |||||
| //print "<pre>"; print_r($camDnsRR); print "</pre>\n"; | //print "<pre>"; print_r($camDnsRR); print "</pre>\n"; | ||||
| $camDnsRR = $app->db->queryOneRecord('SELECT server_id, zone FROM dns_rr WHERE name LIKE "'.$this->dominio.'%"'); | |||||
| $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"; | //print "<pre>"; print_r($fields['client_id']); print "</pre>\n"; | ||||
| $clavePass = $this->generaPass(); | $clavePass = $this->generaPass(); | ||||
| @@ -427,12 +429,16 @@ class page_action extends tform_actions { | |||||
| //$dbname_prefix = $app->tools_sites->replacePrefix($global_config['dbname_prefix'], $this->dataRecord); | //$dbname_prefix = $app->tools_sites->replacePrefix($global_config['dbname_prefix'], $this->dataRecord); | ||||
| $ftpuser_prefix = $app->tools_sites->replacePrefix($global_config['ftpuser_prefix'], $this->dataRecord); | $ftpuser_prefix = $app->tools_sites->replacePrefix($global_config['ftpuser_prefix'], $this->dataRecord); | ||||
| /*$this->sys_usuario_id = $this->cli_id; | |||||
| $this->sys_grupo_id = $this->cli_grupo_id;*/ | |||||
| //"sys_userid" => $sysUsuarioId, //$fields['client_group_id'],//$sys_userid, | |||||
| //"sys_groupid" => $cliente_groupid, //$client_group_id, | |||||
| // añado database user con su prefix | // añado database user con su prefix | ||||
| $db_user_params = array( | $db_user_params = array( | ||||
| 'server_id' => $camDnsRR['server_id'], | |||||
| 'sysgroup_id' => $fields['client_group_id'], | |||||
| 'sys_userid' => $fields['client_group_id'], | |||||
| 'server_id' => $this->bbdd_serv, //$camDnsRR['server_id'], | |||||
| 'sysgroup_id' => $this->sys_grupo_id, //$fields['client_group_id'], | |||||
| 'sys_userid' => $this->sys_usuario_id, //$fields['client_group_id'], | |||||
| 'database_user' => $generated_usernameBBDD, //$dbuser_prefix3 . $generated_usernameBBDD, | 'database_user' => $generated_usernameBBDD, //$dbuser_prefix3 . $generated_usernameBBDD, | ||||
| 'database_user_prefix' => $this->valor_prefix, | 'database_user_prefix' => $this->valor_prefix, | ||||
| 'database_password' => $clavePass//substr(sha1($dbuser_prefix . $generated_usernameBBDD), 0, 16) | 'database_password' => $clavePass//substr(sha1($dbuser_prefix . $generated_usernameBBDD), 0, 16) | ||||
| @@ -447,12 +453,12 @@ class page_action extends tform_actions { | |||||
| //print "<br>". $this->pass_db_txt; | //print "<br>". $this->pass_db_txt; | ||||
| //print "<pre>"; print_r($fields); print "</pre>\n"; | //print "<pre>"; print_r($fields); print "</pre>\n"; | ||||
| $db_user_id = $remoto->insert_query('../sites/form/database_user.tform.php', $fields['client_group_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,/*$fields['client_group_id'],*/ $db_user_params, 'sites:web_database_user:on_after_insert'); | |||||
| // add database | // add database | ||||
| $paramsBD = array( | $paramsBD = array( | ||||
| 'server_id' => $camDnsRR['server_id'], | |||||
| 'sysgroup_id' => $fields['client_group_id'], | |||||
| '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'], | 'parent_domain_id' => $sitio_id['domain_id'], | ||||
| 'type' => 'mysql', | 'type' => 'mysql', | ||||
| 'database_quota' => '-1', | 'database_quota' => '-1', | ||||
| @@ -470,7 +476,7 @@ class page_action extends tform_actions { | |||||
| $this->nombre_db_txt = $paramsBD['database_name']; | $this->nombre_db_txt = $paramsBD['database_name']; | ||||
| $remoto->sites_database_add($fields['client_group_id'], $paramsBD); | |||||
| $remoto->sites_database_add($this->cli_id,/*$fields['client_group_id'],*/ $paramsBD); | |||||
| // 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->uses('remoting_lib'); | ||||
| @@ -480,7 +486,7 @@ class page_action extends tform_actions { | |||||
| $this->nombre_user_ftp = $this->generaNombreFTP(); | $this->nombre_user_ftp = $this->generaNombreFTP(); | ||||
| // add ftp user | // add ftp user | ||||
| $ftp_params = array( | $ftp_params = array( | ||||
| 'server_id' => $camDnsRR['server_id'], | |||||
| 'server_id' => $this->web_serv, //$camDnsRR['server_id'], | |||||
| 'parent_domain_id' => $sitio_id['domain_id'], | 'parent_domain_id' => $sitio_id['domain_id'], | ||||
| 'username' => $this->valor_prefix_ftp . $this->nombre_user_ftp, //$ftpuser_prefix . $generated_username, | 'username' => $this->valor_prefix_ftp . $this->nombre_user_ftp, //$ftpuser_prefix . $generated_username, | ||||
| 'username_prefix' => $this->valor_prefix_ftp, | 'username_prefix' => $this->valor_prefix_ftp, | ||||
| @@ -873,8 +879,14 @@ class page_action extends tform_actions { | |||||
| public $ip6_servidor_dns; | public $ip6_servidor_dns; | ||||
| public $ip4_servidor_web; | public $ip4_servidor_web; | ||||
| public $ip6_servidor_web; | public $ip6_servidor_web; | ||||
| public $ip4_servidor_bbdd; | |||||
| public $ip6_servidor_bbdd; | |||||
| public $ip4_servidor_ftp; | |||||
| public $ip6_servidor_ftp; | |||||
| public $dns_serv; | public $dns_serv; | ||||
| public $web_serv; | public $web_serv; | ||||
| public $bbdd_serv; | |||||
| public $ftp_serv; | |||||
| function tieneServidorIPs(){ | function tieneServidorIPs(){ | ||||
| global $app, $conf; | global $app, $conf; | ||||
| @@ -885,19 +897,30 @@ class page_action extends tform_actions { | |||||
| if($this->cli_id == 1) { | if($this->cli_id == 1) { | ||||
| $this->dns_serv = 1; | $this->dns_serv = 1; | ||||
| $this->web_serv = 1; | $this->web_serv = 1; | ||||
| $this->bbdd_serv = 1; | |||||
| //$this->ftp_serv = 1; | |||||
| }else{ | }else{ | ||||
| $servidores = $app->db->queryOneRecord( | $servidores = $app->db->queryOneRecord( | ||||
| "SELECT client_id, dns_servers, web_servers FROM client | |||||
| "SELECT client_id, dns_servers, web_servers, db_servers FROM client | |||||
| WHERE client_id = ". $this->cli_id); | WHERE client_id = ". $this->cli_id); | ||||
| $this->dns_serv = $servidores['dns_servers']; | $this->dns_serv = $servidores['dns_servers']; | ||||
| $this->web_serv = $servidores['web_servers']; | $this->web_serv = $servidores['web_servers']; | ||||
| $this->bbdd_serv = $servidores['db_servers']; | |||||
| //Si el cliente no tiene asignado un servidor se añade por defecto al 1 | //Si el cliente no tiene asignado un servidor se añade por defecto al 1 | ||||
| if(!$this->dns_serv || !$this->web_serv){ | |||||
| if(!$this->dns_serv){ | |||||
| $this->dns_serv = 1; | $this->dns_serv = 1; | ||||
| } | |||||
| //Si el cliente no tiene asignado un servidor se añade por defecto al 1 | |||||
| if(!$this->web_serv){ | |||||
| $this->web_serv = 1; | $this->web_serv = 1; | ||||
| } | } | ||||
| //Si el cliente no tiene asignado un servidor se añade por defecto al 1 | |||||
| if(!$this->bbdd_serv){ | |||||
| $this->bbdd_serv = 1; | |||||
| } | |||||
| } | } | ||||
| /*print "<pre>DNS SERVER ";print_r($this->dns_serv);print "</pre>\n"; | /*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";*/ | ||||
| @@ -985,9 +1008,6 @@ class page_action extends tform_actions { | |||||
| $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"'); | ||||
| /*$this->ip6_servidor_dns = $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"');*/ | |||||
| } | } | ||||
| if(!$this->ip6_servidor_web){ | if(!$this->ip6_servidor_web){ | ||||
| $this->ip6_servidor_web = $app->db->queryOneRecord( | $this->ip6_servidor_web = $app->db->queryOneRecord( | ||||
| @@ -1036,13 +1056,76 @@ class page_action extends tform_actions { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| //Captura de las ips del servidor bbdd | |||||
| if($this->cli_id == 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. | |||||
| $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"'); | |||||
| $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->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 = "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 | |||||
| FROM server_ip | |||||
| WHERE client_id = "'.$this->cli_id.'" AND server_id = "'.$this->bbdd_serv.'" AND ip_type="IPv4"'); | |||||
| $this->ip6_servidor_bbdd = $app->db->queryOneRecord( | |||||
| 'SELECT ip_type, ip_address | |||||
| FROM server_ip | |||||
| WHERE client_id = "'.$this->cli_id.'" AND server_id = "'.$this->bbdd_serv.'"AND ip_type="IPv6"'); | |||||
| //si no tiene asignado le damos el de admin. | |||||
| if(!$this->ip4_servidor_bbdd){ | |||||
| //Compruebo si hay datos para el client_id 0 y si no existe pruebo con el 1. Es admin ya que este cliente no tiene ip4 ni ip6 asignadas | |||||
| //Tomamos las de admin. | |||||
| //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"'); | |||||
| //$this->ip6_servidor_bbdd = $app->db->queryOneRecord('SELECT ip_type, ip_address FROM server_ip WHERE client_id = "0" AND ip_type="IPv6"'); | |||||
| 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){ | |||||
| //Compruebo si hay datos para el client_id 0 y si no existe pruebo con el 1. Es admin ya que este cliente no tiene ip4 ni ip6 asignadas | |||||
| //Tomamos las de admin. | |||||
| //Alguno de los dos tiene que existir por configuración de ispconfig. | |||||
| $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){ | |||||
| $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"'); | |||||
| } | |||||
| } | |||||
| } | |||||
| //$la_ip4 = $app->db->queryOneRecord("SELECT ip_type, ip_address FROM server_ip WHERE ip_type='IPv4'"); | //$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']; | $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"; | /*print "<pre>IP4 DNS ";print_r($this->ip4_servidor_dns);print "</pre>\n"; | ||||
| print "<pre>IP6 DNS ";print_r($this->ip6_servidor_dns);print "</pre>\n"; | print "<pre>IP6 DNS ";print_r($this->ip6_servidor_dns);print "</pre>\n"; | ||||
| print "<pre>IP4 WEB ";print_r($this->ip4_servidor_web);print "</pre>\n"; | print "<pre>IP4 WEB ";print_r($this->ip4_servidor_web);print "</pre>\n"; | ||||
| print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n"; | |||||
| print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n"; | |||||
| print "<pre>IP4 BBDD ";print_r($this->ip4_servidor_bbdd);print "</pre>\n"; | |||||
| print "<pre>IP6 BBDD ";print_r($this->ip6_servidor_bbdd);print "</pre>\n"; | |||||
| echo('El cliente ' . $this->cli_id . '<br>');*/ | echo('El cliente ' . $this->cli_id . '<br>');*/ | ||||
| if(!$this->ip4_servidor_dns['ip_address'] || !$this->ip6_servidor_dns['ip_address']){ | if(!$this->ip4_servidor_dns['ip_address'] || !$this->ip6_servidor_dns['ip_address']){ | ||||
| $app->tform->errorMessage = $app->tform->wordbook['error_no_ip']; | $app->tform->errorMessage = $app->tform->wordbook['error_no_ip']; | ||||
| @@ -1053,6 +1136,11 @@ class page_action extends tform_actions { | |||||
| $app->tform->errorMessage = $app->tform->wordbook['error_no_ip']; | $app->tform->errorMessage = $app->tform->wordbook['error_no_ip']; | ||||
| $this->onError(); | $this->onError(); | ||||
| return true; | return true; | ||||
| } | |||||
| if(!$this->ip4_servidor_bbdd['ip_address'] || !$this->ip6_servidor_bbdd['ip_address']){ | |||||
| $app->tform->errorMessage = $app->tform->wordbook['error_no_ip']; | |||||
| $this->onError(); | |||||
| return true; | |||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -1431,7 +1519,7 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||||
| $this->crearSubDominio($remote, $fields['domain']); | $this->crearSubDominio($remote, $fields['domain']); | ||||
| if(!$this->subdom_error){ | if(!$this->subdom_error){ | ||||
| $this->crearSitioWebSubdominio($remote); | $this->crearSitioWebSubdominio($remote); | ||||
| //$this->crearBaseDatosFtp($remote); | |||||
| $this->crearBaseDatosFtp($remote); | |||||
| } | } | ||||
| } else { | } else { | ||||
| @@ -1446,7 +1534,7 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||||
| //IMPORTANTE, es necesario cargar nuestro formulario para poder ejecutar la función que crea | //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. | //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'); | $app->tform->loadFormDef('form/new_service_webdns.tform.php'); | ||||
| //$this->crearBaseDatosFtp($remote); | |||||
| $this->crearBaseDatosFtp($remote); | |||||
| }else{ | }else{ | ||||
| $this->onError(); | $this->onError(); | ||||
| return; | return; | ||||