| @@ -387,11 +387,11 @@ class page_action extends tform_actions { | |||
| $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']); | |||
| //echo('Cliente ' . $this->cli_id . ' cli grupo ' . $this->cli_grupo_id . ' sys user ' . $this->sys_usuario_id . ' sys grupo ' . $this->sys_grupo_id); | |||
| //añado database user con su prefix | |||
| $db_user_params = array( | |||
| 'server_id' => $this->bbdd_serv, | |||
| 'sysgroup_id' => $this->cli_grupo_id,//$this->sys_grupo_id, | |||
| 'sysgroup_id' => $this->cli_grupo_id, //$this->sys_grupo_id, | |||
| 'sys_userid' => $this->sys_usuario_id, | |||
| 'sys_perm_other' => '-', | |||
| 'database_user' => $generated_usernameBBDD, | |||
| @@ -408,24 +408,22 @@ class page_action extends tform_actions { | |||
| //print "<br>". $this->pass_db_txt; | |||
| //print "<pre>"; print_r($fields); print "</pre>\n"; | |||
| //IMPORTANTE. PARA QUE EL PLUGING FUNCIONE HAY QUE CARGAR ANTES EL FORMULARIO | |||
| //DE LO QUE SE QUIERE CREAR EN ESTE CASO SITIO WEB | |||
| //$tform_def_file = "../sites/form/database_user.tform.php"; | |||
| //$app->tform->loadFormDef($tform_def_file); | |||
| $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'); | |||
| $this->cli_grupo_id, $db_user_params, 'sites:web_database_user:on_after_insert'); | |||
| //echo('El id ' . $this->id); | |||
| // $remoto2 = new remote_actions; | |||
| // $remoto->sites_database_user_after_add($this->cli_grupo_id, $db_user_params); | |||
| $remoto2 = new remote_actions; | |||
| $remoto->sites_database_user_after_add($this->cli_grupo_id, $db_user_params); | |||
| //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'], | |||
| 'sysgroup_id' => $this->cli_grupo_id,//$this->sys_grupo_id, //$fields['client_group_id'], | |||
| 'sysgroup_id' => $this->cli_grupo_id, //$this->sys_grupo_id, //$fields['client_group_id'], | |||
| 'parent_domain_id' => $sitio_id['domain_id'], | |||
| 'type' => 'mysql', | |||
| 'database_quota' => '-1', | |||
| @@ -441,13 +439,13 @@ class page_action extends tform_actions { | |||
| $this->nombre_db_txt = $paramsBD['database_name']; | |||
| //IMPORTANTE. COMPROBAR EL VALOR QUE HAY QUE ENVIAR, SI ES CLI GRUPO Ó CLI ID | |||
| $db_id = $remoto->sites_database_add($this->cli_grupo_id, /*$this->cli_id,*//*$fields['client_group_id'],*/ $paramsBD); | |||
| $db_id = $remoto->sites_database_add($this->cli_grupo_id, /*$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'); | |||
| // $app->remoting_lib->loadFormDef('../sites/form/web_vhost_domain.tform.php'); | |||
| // $site_data = $app->remoting_lib->getDataRecord($sitio_id); | |||
| // $site_data = $remoto->getDataRecordWebDNS($sitio_id); | |||
| @@ -620,14 +618,15 @@ class page_action extends tform_actions { | |||
| }else{ | |||
| //echo('Quien es else ' . $_SESSION["s"]["user"]["typ"]); | |||
| $client = $app->db->queryOneRecord( | |||
| 'SELECT sys_user.sys_userid, sys_user.sys_groupid, sys_user.default_group, sys_user.client_id | |||
| 'SELECT sys_user.userid, 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 = $this->cli_grupo_id;//$client['sys_groupid']; | |||
| $this->sys_usuario_id = $client['userid'];//$client['sys_userid']; | |||
| $this->sys_grupo_id = $this->cli_grupo_id;//$client['sys_groupid']; | |||
| //echo('Es cliente cli_id ' . $this->cli_id . ' cli_grupo_id ' . $this->cli_grupo_id . ' sys_usuario ' . $this->sys_usuario_id . ' sys_grupo ' . $this->sys_grupo_id); | |||
| } | |||
| } | |||
| //print "<pre>Valores : "; print_r($this->cli_id); print "</pre>\n"; | |||
| @@ -728,7 +727,7 @@ class page_action extends tform_actions { | |||
| //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); | |||
| $resultado = $remoto->insert_query('form/dns_a_webdns.tform.php', $this->cli_id, /*$fields['client_group_id'],*/ $paramSubDominios); | |||
| $remoto->dns_registro_tipo_a_after_insert(); | |||
| //$remoto->dns_registro_tipo_a_after_insert(); | |||
| 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>'; | |||
| @@ -796,18 +795,25 @@ class page_action extends tform_actions { | |||
| ); | |||
| //print "<pre> Parametros:"; print_r($paramsite); print "</pre>\n"; | |||
| /*print '<pre> cliente id ' . $fields['client_id']; | |||
| print "<pre>";print_r($fields);print "</pre>\n" . $fields['client_id'];*/ | |||
| //print '<pre>DNS IPV6 ' . $dns_ip_servidor_ipv6['ip_address']; | |||
| //$tform_def_file2 = "../sites/form/web_vhost_domain.tform.php"; | |||
| //$app->tform->loadFormDef($tform_def_file2); | |||
| //IMPORTANTE. PARA QUE EL PLUGING FUNCIONE HAY QUE CARGAR ANTES EL FORMULARIO | |||
| //DE LO QUE SE QUIERE CREAR EN ESTE CASO SITIO WEB | |||
| $tform_def_file = "../sites/form/web_vhost_domain.tform.php"; | |||
| $app->tform->loadFormDef($tform_def_file); | |||
| //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, $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'); | |||
| //IMPORTANTE. HAY QUE CARGAR EL FORMULARIO DE WEBDNS PARA QUE ENCUENTRE EL TAB. | |||
| $tform_def_file = "form/new_service_webdns.tform.php"; | |||
| $app->tform->loadFormDef($tform_def_file); | |||
| } | |||
| public $ip4_servidor_dns; | |||
| @@ -1565,7 +1571,7 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||
| echo ('Tabla sys_user --> userid ' . $this->sys_usuario_id . " <br>"); | |||
| 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'])){ | |||
| if($this->comprobarSubDominios($fields['domain'])){ | |||
| $this->crearSubDominio($remote, $fields['domain']); | |||
| if(!$this->subdom_error){ | |||
| @@ -1578,17 +1584,17 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||
| //} | |||
| } | |||
| } else {*/ | |||
| // if(!$this->dominio_error){ | |||
| // $this->crearDnsSitioWeb($remote); | |||
| } else { | |||
| if(!$this->dominio_error){ | |||
| $this->crearDnsSitioWeb($remote); | |||
| //$variablePHP = "<script> document.write(test) </script>"; | |||
| //Si todo va bien, el resultado de la web y dns | |||
| echo '<br><div class="alert alert-success"><br> | |||
| 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. | |||
| //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 el 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'])){ | |||
| @@ -1598,12 +1604,12 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||
| $this->crearBaseDatosFtp($remote); | |||
| //} | |||
| //} | |||
| /* }else{ | |||
| }else{ | |||
| $this->onError(); | |||
| return; | |||
| }*/ | |||
| } | |||
| //} | |||
| } | |||
| //parent::onSubmit(); | |||
| } | |||
| } | |||