| @@ -19,8 +19,14 @@ $tform_def_file = "form/new_service_webdns.tform.php"; | |||
| //Check permissions for module | |||
| $app->auth->check_module_permissions('webdns'); | |||
| //Check the module permissions and redirect if not allowed. | |||
| /*if(!stristr($_SESSION['s']['user']['modules'],'customdns')) { | |||
| header('Location: ../index.php'); | |||
| die; | |||
| }*/ | |||
| //Loading classes a usar. | |||
| $app->uses('tpl,tform,tform_actions,remoting,tools_sites,remoting_lib,remoting_dns,validate_dns'); | |||
| $app->uses('tpl,tform,tform_actions,remoting,tools_sites,remoting_lib,remoting_dns'); | |||
| $app->load('tform_actions'); | |||
| @@ -77,7 +83,7 @@ class page_action extends tform_actions { | |||
| //echo('PRe antes ' . $ftpuser_prefix . ' DataRecord ' . print_r($this->dataRecord)); | |||
| //echo('PRe antes2 ' . print_r($global_config)); | |||
| //* Client: If the logged in user is not admin and has no sub clients (no reseller) | |||
| if ($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { | |||
| // Get the limits of the client | |||
| $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); | |||
| @@ -144,7 +150,7 @@ class page_action extends tform_actions { | |||
| parent::onShowEnd(); | |||
| } | |||
| public $valor_prefix; | |||
| public $valor_prefix_ftp; | |||
| @@ -196,8 +202,8 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16) | |||
| } else { | |||
| $app->tpl->setVar("database_user_prefix", $app->tools_sites->getPrefix($this->dataRecord['database_user_prefix'], $dbuser_prefix, $global_config['dbuser_prefix'])); | |||
| } | |||
| if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { | |||
| //* Reseller: If the logged in user is not admin and has sub clients (is a reseller) | |||
| if($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) { | |||
| $this->valor_prefix = $fields['database_user_prefix']; | |||
| } | |||
| } | |||
| @@ -700,7 +706,6 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16) | |||
| //Se comprueba que no tenga 3 w "www" al principio del nombre del dominio o subdomino | |||
| $encontradoWWW = preg_match($patronWWW, $subdom, $coincidencias); | |||
| //echo('Encontrado ' . $encontrado . ' Dominio ' . $subdom); | |||
| if($encontradoWWW){ | |||
| $app->tform->errorMessage = $app->tform->wordbook['error_dominio_www']; | |||
| return; | |||
| @@ -869,7 +874,7 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16) | |||
| //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); | |||
| $app->db->datalogInsert('dns_rr', $paramSubDominios, 'id'); | |||
| //$resultado = $remoto->insert_query('form/dns_a_webdns.tform.php', $this->cli_id, /*$fields['client_group_id'],*/ $paramSubDominios); | |||
| // $resultado = $remoto->insert_query('form/dns_a_webdns.tform.php', $this->cli_id, /*$fields['client_group_id'],*/ $paramSubDominios); | |||
| 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>'; | |||
| @@ -948,7 +953,7 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16) | |||
| //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, $paramsite, 'sites:web_vhost_domain:on_after_insert'); | |||
| } | |||
| public $ip4_servidor_dns; | |||
| @@ -973,6 +978,14 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16) | |||
| $global_config_sitio = $app->getconf->get_global_config('sites'); | |||
| $global_config_dns = $app->getconf->get_global_config('dns'); | |||
| /* $server_id = intval($global_config_sitio['default_webserver']); | |||
| if(!$server_id){ | |||
| $default_web_server = $app->db->queryOneRecord("SELECT server_id FROM server WHERE web_server = ? ORDER BY server_id LIMIT 0,1", 1); | |||
| $server_id = $default_web_server['server_id']; | |||
| } | |||
| $web_config = $app->getconf->get_server_config($server_id, 'web'); | |||
| echo(' Server id ' . $server_id . ' default web ' . $default_web_server . ' webConfig ' . print_r($web_config)); | |||
| */ | |||
| if(!$global_config_dns['default_dnsserver']) { | |||
| $app->tform->errorMessage = $app->tform->wordbook['error_no_servidor_default']. 'DNS.'; | |||
| $this->onError(); | |||
| @@ -1384,7 +1397,7 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16) | |||
| //} | |||
| return false; | |||
| } | |||
| //Comprobación de que tenemos instalada nuestra plantilla | |||
| function plantillaWebDNS(){ | |||
| global $app; | |||
| @@ -1395,29 +1408,24 @@ if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16) | |||
| 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){ | |||
| global $app, $conf; | |||
| //if($app->db->queryOneRecord('SELECT * FROM dns_soa WHERE origin LIKE "'.$campos['domain'].'%"')) { | |||
| if($app->db->queryOneRecord('SELECT * FROM dns_soa WHERE origin = "'.$campos['domain'].'."')) { | |||
| $app->tform->errorMessage = $app->tform->wordbook['domain_error_unique_webdns']; | |||
| $this->onError(); | |||
| return true; | |||
| if($app->db->queryOneRecord('SELECT * FROM dns_soa WHERE origin LIKE "'.$campos['domain'].'."')) { | |||
| $app->tform->errorMessage = $app->tform->wordbook['domain_error_unique']; | |||
| } | |||
| if($app->db->queryOneRecord('SELECT domain_id, domain FROM web_domain WHERE domain = "'.$campos['domain'].'"')) { | |||
| $app->tform->errorMessage = $app->tform->wordbook['error_sitio_web_existe']; | |||
| $this->onError(); | |||
| return true; | |||
| } | |||
| /*if($app->tform->errorsMessage) | |||
| //IMPORTANTE. AQUI CONTROLAMOS LOS ERRORES QUE SE VALIDAN EN EL FORMULARIO, EN ESTE CASO EL CAMPO DEL DOMINIO. | |||
| if($app->tform->errorMessage) | |||
| { | |||
| $this->onError(); | |||
| return true; | |||
| }*/ | |||
| } | |||
| } | |||
| public $ip4_ultima; | |||
| @@ -1513,7 +1521,7 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||
| } // end foreach | |||
| // Insert the soa record | |||
| $sys_userid = $this->cli_id;//$cliente_id_seleccionado;//$fields['client_group_id']; | |||
| //$sys_userid = $this->cli_id;//$cliente_id_seleccionado;//$fields['client_group_id']; | |||
| $origin = $vars['origin']; | |||
| $ns = $vars['ns']; | |||
| $mbox = str_replace('@', '.', $vars['mbox']); | |||
| @@ -1586,7 +1594,7 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||
| //IMPORTANTE. Aquí no se ponen los campos sys_userid ni sys_groupid, el evento on_after_insert | |||
| //'sys_userid' => $sysUsuarioId, //$fields['client_group_id'],//$sys_userid, | |||
| //'sys_groupid' => $cliente_groupid, | |||
| 'ip_address' => '*', //$dns_ip_servidor['ip_address'], | |||
| 'ip_address' => '*', //$dns_ip_servidor['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', | |||
| @@ -1640,16 +1648,10 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||
| //print 'Sitio id '. $site_id; | |||
| print('(3)Final crearDnsSitioWeb'); | |||
| } | |||
| /*$this->cli_id = $_SESSION["s"]["user"]["client_id"]; | |||
| $this->cli_grupo_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); | |||
| $this->sys_usuario_id = $_SESSION["s"]["user"]["sys_userid"]; | |||
| $this->sys_grupo_id = */ | |||
| function onSubmit() { | |||
| global $app, $conf; | |||
| /*if($_SESSION['s']['user']['typ'] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) | |||
| unset($this->dataRecord["client_group_id"]); | |||
| */ | |||
| /* $sesionesLog = $_SESSION["s"]["user"]["typ"]; | |||
| $sesionesLog2 = $_SESSION["s"]["user"]; | |||
| $sesiones = $_SESSION; | |||
| @@ -1662,7 +1664,6 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||
| return; | |||
| } | |||
| //Carga de campos del formulario. | |||
| $fields = $app->tform->encode($this->dataRecord, $app->tform->getCurrentTab(), true); | |||
| @@ -1705,7 +1706,6 @@ 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; | |||
| // echo('Subdominio ' . $fields['domain']); | |||
| if($this->comprobarSubDominios($fields['domain'])){ | |||
| print('(1)crearSubDominio'); | |||
| $this->crearSubDominio($remote, $fields['domain']); | |||
| @@ -1720,7 +1720,6 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||
| }*/ | |||
| } else { | |||
| print('(2)crearDnsSitioWeb'); | |||
| if(!$this->dominio_error){ | |||
| $this->crearDnsSitioWeb($remote); | |||
| //$variablePHP = "<script> document.write(test) </script>"; | |||
| @@ -1729,23 +1728,22 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/ | |||
| 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. | |||
| // $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'])){ | |||
| $this->crearBaseDatosFtpClientes($remote); | |||
| }else{ | |||
| echo('Esto es mental ' . $app->auth->is_admin()); | |||
| $this->crearBaseDatosFtp($remote); | |||
| }*/ | |||
| //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. | |||
| // $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'])){ | |||
| $this->crearBaseDatosFtpClientes($remote); | |||
| }else{ | |||
| echo('Esto es mental ' . $app->auth->is_admin()); | |||
| $this->crearBaseDatosFtp($remote); | |||
| }*/ | |||
| }else{ | |||
| $this->onError(); | |||
| return; | |||
| } | |||
| //if($_SESSION['s']['user']['typ'] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) unset($this->dataRecord["client_group_id"]); | |||
| } | |||
| } | |||
| } | |||