Clase para el control de los límites de los usuarios con el módulo WebDNS. 2017, All rights reserved. */ require_once '../../lib/app.inc.php'; global $app; $app->uses('tform,tform_actions'); $app->load('tform_actions'); class limites { public $cliente; public $cliente_grupo_id; public function __construct($cliente_group_id){ global $app, $conf; $this->cliente = $client = $app->db->queryOneRecord( "SELECT limit_dns_zone, limit_web_domain, limit_database, parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $cliente_group_id); $this->cliente_grupo_id = $cliente_group_id; } public $revendedor; public $revendedor_grupos; public $revendedor_grupo_def; public function getRevendedor(){ global $app, $conf; $tmpReseller = $app->db->queryOneRecord( "SELECT userid, groups, default_group FROM sys_user WHERE client_id = ?", $this->cliente['parent_client_id']); $this->revendedor = $tmpReseller['userid']; $this->revendedor_grupos = $tmpReseller['groups']; $this->revendedor_grupo_def = $tmpReseller['default_group']; } public function limClienteDns(){ global $app, $conf; //Si el cliente esta vacío es admin. if($this->cliente){ //echo(' Usuario grupo es ' .$this->cliente_grupo_id); if($this->cliente["limit_dns_zone"] >= 0) { $tmp = $app->db->queryOneRecord( "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", $this->cliente_grupo_id); if($tmp["number"] >= $this->cliente["limit_dns_zone"]) { $app->error($app->tform->wordbook["limit_dns_zone_txt"]); return true; } } //* 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']); $reseller = $app->db->queryOneRecord( "SELECT limit_dns_zone as number, contact_firstname FROM client WHERE client_id = ?", $this->cliente['parent_client_id']); //echo(' Cliente Reventa limites DNS ' . $reseller['number']); // Check if the user may add another item if($reseller['number'] >= 0) { $tmpCliente = $app->db->queryOneRecord( "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", $this->cliente_grupo_id); $tmpReventa = $app->db->queryOneRecord( "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", $this->revendedor_grupo_def); $totalCreado = $tmpCliente['number'] + $tmpReventa['number']; //echo(' Total creado ' . $totalCreado . ' el array ' . print_r($reseller). ' Y ' . $reseller['number']); if($totalCreado >= $reseller['number']) { $app->error($reseller['contact_firstname'] . '. ' . $app->tform->wordbook["limit_dns_zone_txt"]); return true; } /*$tmp = $app->db->queryOneRecord( "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", explode(',', $reseller_groups)); echo(' El temp registros en dns_soa usando grupo reseller ' .$tmp['number']);*/ /*if($tmp['number'] >= $reseller['number']) { $app->error($app->tform->wordbook["limit_dns_zone_txt"]. ' Dentro Limites'); return true; }*/ } } return false; } } public function limClienteWebDominio(){ global $app, $conf; //Si el cliente esta vacío es admin. if($this->cliente){ if($this->cliente["limit_web_domain"] >= 0) { $tmp = $app->db->queryOneRecord( "SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = ? and type = 'vhost'", $this->cliente_grupo_id); if($tmp["number"] >= $this->cliente["limit_web_domain"]) { $app->error($app->tform->wordbook["limit_web_domain_txt"]); return true; } } //* 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(); $reseller = $app->db->queryOneRecord( "SELECT limit_web_domain as number, contact_firstname FROM client WHERE client_id = ?", $this->cliente['parent_client_id']); //echo(' Cliente Reventa limites DNS ' . $reseller['number']); // Check if the user may add another item if($reseller['number'] >= 0) { $tmpCliente = $app->db->queryOneRecord( "SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = ? and type = 'vhost'", $this->cliente_grupo_id); $tmpReventa = $app->db->queryOneRecord( "SELECT count(domain_id) as number FROM web_domain WHERE sys_groupid = ? and type = 'vhost'", $this->revendedor_grupo_def); $totalCreado = $tmpCliente['number'] + $tmpReventa['number']; if($totalCreado >= $reseller['number']) { $app->error($reseller['contact_firstname'] . '. ' . $app->tform->wordbook["limit_web_domain_txt"]); return true; } } } return false; } } public function limClienteDB(){ global $app, $conf; //Si el cliente esta vacío es admin. if($this->cliente){ if($this->cliente["limit_database"] >= 0) { $tmp = $app->db->queryOneRecord( "SELECT count(database_id) as number FROM web_database WHERE sys_groupid = ?", $this->cliente_grupo_id); if($tmp["number"] >= $this->cliente["limit_database"]) { $app->error($app->tform->wordbook["limit_database_txt"]); return true; } } //* 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(); $reseller = $app->db->queryOneRecord( "SELECT limit_database as number, contact_firstname FROM client WHERE client_id = ?", $this->cliente['parent_client_id']); //echo(' Cliente Reventa limites DNS ' . $reseller['number']); // Check if the user may add another item if($reseller['number'] >= 0) { $tmpCliente = $app->db->queryOneRecord( "SELECT count(database_id) as number FROM web_database WHERE sys_groupid = ?", $this->cliente_grupo_id); $tmpReventa = $app->db->queryOneRecord( "SELECT count(database_id) as number FROM web_database WHERE sys_groupid = ?", $this->revendedor_grupo_def); $totalCreado = $tmpCliente['number'] + $tmpReventa['number']; if($totalCreado >= $reseller['number']) { $app->error($reseller['contact_firstname'] . '. ' . $app->tform->wordbook["limit_database_txt"]); return true; } } } return false; } } } ?>