Przeglądaj źródła

Limpieza del código en general. Se han añadido más comentarios para una mayor comprensión de este. Testeo intensivo.

develop
David Ramos 8 lat temu
rodzic
commit
ff3adb5136
2 zmienionych plików z 34 dodań i 137 usunięć
  1. +3
    -3
      clases/limites.inc.php
  2. +31
    -134
      new_service_webdns.php

+ 3
- 3
clases/limites.inc.php Wyświetl plik

@@ -32,7 +32,7 @@ class limites {
$this->cliente_grupo_id = $cliente_group_id;
}

//Comprobaciones en la carga del formulario.
public function limitesLoad(){
global $app;

@@ -89,7 +89,7 @@ class limites {
public $esReventa;
public $todosLosGrupos;
//public $gruposDelReventa;
//Comprobamos si es un reventa.
public function esRevendedor(){
global $app, $conf;
//PARA SABER QUIEN ES UN RESELLER
@@ -127,7 +127,7 @@ class limites {
//* If the client belongs to a reseller, we will check against the reseller Limit too
if($this->cliente['parent_client_id'] != 0) {
//* first we need to know the groups of this reseller
$this->getRevendedor();
//echo(' Valores '.$this->revendedor . ' otro ' . $this->revendedor_grupos . ' y otro ' .$this->revendedor_grupo_def);
//echo(' El cliente es ' . $this->cliente['parent_client_id']);


+ 31
- 134
new_service_webdns.php Wyświetl plik

@@ -402,7 +402,7 @@ class page_action extends tform_actions {
//$app->uses('remoting_lib');
//$app->remoting_lib->loadFormDef('../sites/form/web_vhost_domain.tform.php');
//IMPORTANTE. AL NO PODER USAR LA FUNCION getDataRecord YA QUE NOS HACE ADMIN.
//TENGO QUE LANZAR LA FUNCION sites_ftp_user_after_insert PARA SOLUCIONAR ESTE PROBLEMA.
//TENGO QUE LANZAR LA FUNCION sites_ftp_user_after_insert PARA SOLUCIONAR ESTE PROBLEMA Y NO getDataRecord().
//$site_data = $app->remoting_lib->getDataRecord($sitio_id);
//$site_data = $remoto->getDataRecordWebDNS($sitio_id);
@@ -441,7 +441,7 @@ class page_action extends tform_actions {
//Register for the events. NO FUNCIONA.
$app->plugin->registerEvent('sites:ftp_user:on_after_insert');
//Lo lanzo yo.
//LO LANZAMOS DE NUESTRA FUNCION EXTRAIDA Y MODIFICADA DEL PLUGING QUE SE TENDRÍA QUE EJECUTAR PERO NO LO HACE.WHY?
$remoto->sites_ftp_user_after_insert();

echo '<br><div class="alert alert-success"><br>
@@ -546,6 +546,7 @@ class page_action extends tform_actions {
public $sys_usuario_id;
public $sys_grupo_id;

//Control del usuario logeado y captura de sus variables de systema.
function controlUserGrupoId(){
global $app, $conf;

@@ -653,8 +654,6 @@ class page_action extends tform_actions {
$this->subdom_error = true;
$app->tform->errorMessage = $app->tform->wordbook['error_no_existe_dominio_padre'];
$this->onError();
//return;
//print 'No existe el dominio';
return $this->subdom_error;

} else {
@@ -772,6 +771,7 @@ class page_action extends tform_actions {
$app->tform->loadFormDef($tform_def_file);
}


public $ip4_servidor_dns;
public $ip6_servidor_dns;
public $ip4_servidor_web;
@@ -785,6 +785,7 @@ class page_action extends tform_actions {
public $bbdd_serv;
public $ftp_serv;


function tieneServidorIPs(){
global $app, $conf;
@@ -831,20 +832,20 @@ class page_action extends tform_actions {
//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
//Si el cliente no tiene asignado un servidor se añade por defecto al que hay en la configuración por defecto
if(!$this->dns_serv){
$this->dns_serv = $global_config_dns['default_dnsserver'];//1;
}
//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 que hay en la configuración por defecto
if(!$this->web_serv){
$this->web_serv = $global_config_sitio['default_webserver'];//1;
}
//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 que hay en la configuración por defecto
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
//Si el cliente no tiene asignado un servidor se añade por defecto al que hay en la configuración por defecto
if(!$this->ftp_serv){
$this->ftp_serv = $global_config_sitio['default_webserver'];//1;
}
@@ -858,7 +859,7 @@ class page_action extends tform_actions {
//Captura de las ips del servidor dns
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.
//Alguno de los dos tiene que existir por configuración de ispconfig.
$this->ip4_servidor_dns = $app->db->queryOneRecord(
'SELECT ip_type, ip_address FROM server_ip
WHERE client_id = "0" AND server_id = "'.$this->dns_serv.'" AND ip_type="IPv4"');
@@ -1173,36 +1174,6 @@ class page_action extends tform_actions {
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;
}
@@ -1254,12 +1225,12 @@ class page_action extends tform_actions {
"SELECT * FROM dns_template WHERE visible = 'Y' AND name = 'webdns'"); /*'open6hosting'");*/

/*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>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>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>DNS SERVER ";print_r($this->dns_serv);print "</pre>\n";
print "<pre>WEB SERVER ";print_r($this->web_serv);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>IP4 WEB ";print_r($this->ip4_servidor_web);print "</pre>\n";
print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/

//Si el servidor es el que tiene asignado el cliente o el de admin por defecto, le damos esta ip4
if($this->dns_serv && $this->ip4_servidor_dns){
@@ -1287,7 +1258,7 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/
$tpl_content = str_replace('{IPV6}', $this->ip6_ultima['ip_address'], /*$dns_ip_servidor_ipv6['ip_address'],*/ $tpl_content);


$enable_dnssec = 'N';//(($_POST['dns_dnssec'] == 'Y') ? 'Y' : 'N');
$enable_dnssec = 'N';
// Parse the template
$tpl_rows = explode("\n", $tpl_content);
@@ -1350,7 +1321,7 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/
"sys_perm_user" => 'riud',
"sys_perm_group" => 'riud',
"sys_perm_other" => '',
"server_id" => $this->dns_serv, //$dns_servidor,//$server_id,//$dns_servidor, //$server_id,//$dns_servidor['default_dnsserver'],
"server_id" => $this->dns_serv,
"origin" => $origin,
"ns" => $ns,
"mbox" => $mbox,
@@ -1478,7 +1449,6 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/
//print('la ssessison es ' .$ssionId);
//print_r($sesionesLog2);

//echo('(Sub)Prefix ' . $this->valor_prefix . '(Sub)Prefix ftp ' . $this->valor_prefix_ftp );
if($this->plantillaWebDNS()){
return;
}
@@ -1488,8 +1458,6 @@ 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;
/*$sitiosBoom = new sitios_remoting;
$sitiosBoom->test();*/

if($this->tieneServidorIPs()){
return;
@@ -1520,62 +1488,37 @@ print "<pre>IP6 WEB ";print_r($this->ip6_servidor_web);print "</pre>\n";*/
return;
}
/*echo ('Lo seleccionado ' . $fields['client_group_id'] . " <br>");
echo ('Tabla sys_group --> client id ' . $this->cli_id . " <br>");
echo ('Tabla sys_group --> groupid ' . $this->cli_grupo_id . " <br>");

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'])){
$this->crearSubDominio($remote, $fields['domain']);
if(!$this->subdom_error){
$this->crearSitioWebSubdominio($remote);
//if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])){
// $this->crearBaseDatosFtpClientes($remote);
//}else{
$this->crearBaseDatosFtp($remote);
//}
$this->crearBaseDatosFtp($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 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'])){
//$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 el antes de ejecutarla.
$app->tform->loadFormDef('form/new_service_webdns.tform.php');
$this->crearBaseDatosFtp($remote);
}else{
$this->onError();
return;
}
}
//parent::onSubmit();
}
}

/*class sitios_remoting extends remoting_sites {
public function test(){
echo('Texto test');
}
}*/


class remote_actions extends remoting {
public function insert_query($formdef_file, $client_id, $params, $event_identifier = '') {
@@ -1589,7 +1532,9 @@ class remote_actions extends remoting {
//echo(' insertQueryPrepare ' . $this->insertQueryExecute($sql, $params, $event_identifier));
return $this->insertQueryWebDNS($formdef_file, $client_id, $params, $event_identifier);
}

//------------------------------------------------------------------------------------------------------------
//IMPORTANTE. FUNCIONES EXTRAIDAS Y MODIFICADAS DE ISPCONFIG PARA SOLUCIONAR EL PROBLEMA DE AUTOLOGEO A ADMIN.
//------------------------------------------------------------------------------------------------------------
function insertQueryWebDNS($formdef_file, $client_id, $params, $event_identifier = '') {
//$sql = $app->remoting->insertQueryPrepare($formdef_file, $client_id, $params);
$sql = $this->insertQueryPrepareWebDNS($formdef_file, $client_id, $params);
@@ -1829,7 +1774,9 @@ class remote_actions extends remoting {
return $sql;
}
}

//----------------------------------------------------------------------------------
//IMPORTANTE. ESTA FUNCION ES COMO LO HACE ISPCONFIG NO EXTRAIDA PERO SI MODIFICADA.
//----------------------------------------------------------------------------------
public function sites_database_add($client_id, $params){
global $app, $conf;

@@ -1878,61 +1825,11 @@ $page->onLoad();

//IMPORTENTE, es necesario estas lí­neas para que el botón del pdf funcione. Activa el javascript
//echo '<script type="text/javascript">';
//echo 'alert (password(7, false, 1));';
//echo '</script>';


?>

<!--IMPORTENTE, es necesario estas lí­neas para que el botón del pdf funcione. Activa el javascript -->
<script type="text/javascript">

/*var test = "PARALACLAVE";
function getRandomInt(min, max){
return Math.floor(Math.random() * (max - min + 1)) + min;
}

var clave = password(7, false, 1);
function password(minLength, special, num_special){
minLength = minLength || 10;
if(minLength < 8) minLength = 8;
var maxLength = minLength + 5;
var length = getRandomInt(minLength, maxLength);
var alphachars = "abcdefghijkmnopqrstuvwxyz";
var upperchars = "ABCDEFGHJKLMNPQRSTUVWXYZ";
var numchars = "23456789";
var specialchars = "!@#_";
if(num_special == undefined) num_special = 0;
if(special != undefined && special == true) {
num_special = Math.floor(Math.random() * (length / 4)) + 1;
}
var numericlen = getRandomInt(1, 2);
var alphalen = length - num_special - numericlen;
var upperlen = Math.floor(alphalen / 2);
alphalen = alphalen - upperlen;
var password = "";
for(i = 0; i < alphalen; i++) {
password += alphachars.charAt(Math.floor(Math.random() * alphachars.length));
}
for(i = 0; i < upperlen; i++) {
password += upperchars.charAt(Math.floor(Math.random() * upperchars.length));
}
for(i = 0; i < num_special; i++) {
password += specialchars.charAt(Math.floor(Math.random() * specialchars.length));
}
for(i = 0; i < numericlen; i++) {
password += numchars.charAt(Math.floor(Math.random() * numchars.length));
}
password = password.split('').sort(function() { return 0.5 - Math.random(); }).join('');
return password;
}*/

</script>

Ładowanie…
Anuluj
Zapisz