| @@ -9,6 +9,11 @@ Clase para el control de los límites de los usuarios con el módulo WebDNS. | |||||
| require_once '../../lib/app.inc.php'; | require_once '../../lib/app.inc.php'; | ||||
| global $app; | |||||
| $app->uses('tform,tform_actions'); | |||||
| $app->load('tform_actions'); | |||||
| class limites { | class limites { | ||||
| public $cliente; | public $cliente; | ||||
| @@ -17,26 +22,79 @@ class limites { | |||||
| public function __construct($cliente_group_id){ | public function __construct($cliente_group_id){ | ||||
| global $app, $conf; | global $app, $conf; | ||||
| $this->cliente = $client = $app->db->queryOneRecord( | $this->cliente = $client = $app->db->queryOneRecord( | ||||
| "SELECT limit_dns_zone, limit_web_domain, limit_database FROM sys_group, client | |||||
| "SELECT limit_dns_zone, limit_web_domain, limit_database, parent_client_id | |||||
| FROM sys_group, client | |||||
| WHERE sys_group.client_id = client.client_id | WHERE sys_group.client_id = client.client_id | ||||
| and sys_group.groupid = ?", $cliente_group_id); | and sys_group.groupid = ?", $cliente_group_id); | ||||
| $this->cliente_grupo_id = $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(){ | public function limClienteDns(){ | ||||
| global $app, $conf; | global $app, $conf; | ||||
| //Si el cliente esta vacío es admin. | //Si el cliente esta vacío es admin. | ||||
| if($this->cliente){ | if($this->cliente){ | ||||
| //echo(' Usuario grupo es ' .$this->cliente_grupo_id); | |||||
| if($this->cliente["limit_dns_zone"] >= 0) { | if($this->cliente["limit_dns_zone"] >= 0) { | ||||
| $tmp = $app->db->queryOneRecord( | $tmp = $app->db->queryOneRecord( | ||||
| "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", $this->cliente_grupo_id); | "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", $this->cliente_grupo_id); | ||||
| if($tmp["number"] >= $this->cliente["limit_dns_zone"]) { | if($tmp["number"] >= $this->cliente["limit_dns_zone"]) { | ||||
| $app->error($app->tform->wordbook["limit_dns_zone_txt"]); | $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; | return false; | ||||
| } | |||||
| } | } | ||||
| public function limClienteWebDominio(){ | public function limClienteWebDominio(){ | ||||
| @@ -53,8 +111,34 @@ class limites { | |||||
| return true; | 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; | return false; | ||||
| } | |||||
| } | } | ||||
| public function limClienteDB(){ | public function limClienteDB(){ | ||||
| @@ -67,10 +151,38 @@ class limites { | |||||
| FROM web_database WHERE sys_groupid = ?", $this->cliente_grupo_id); | FROM web_database WHERE sys_groupid = ?", $this->cliente_grupo_id); | ||||
| if($tmp["number"] >= $this->cliente["limit_database"]) { | if($tmp["number"] >= $this->cliente["limit_database"]) { | ||||
| $app->error($app->tform->wordbook["limit_database_txt"]); | $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; | return false; | ||||
| } | |||||
| } | } | ||||
| } | } | ||||