ISPConfig module for simplify the creation of websites and DNS zones in a only step
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

190 satır
8.2 KiB

  1. <?php
  2. /*
  3. PHP por David Ramos García, Open6Hosting <dramos@open6hosting.com>
  4. Clase para el control de los límites de los usuarios con el módulo WebDNS.
  5. 2017, All rights reserved.
  6. */
  7. require_once '../../lib/app.inc.php';
  8. global $app;
  9. $app->uses('tform,tform_actions');
  10. $app->load('tform_actions');
  11. class limites {
  12. public $cliente;
  13. public $cliente_grupo_id;
  14. public function __construct($cliente_group_id){
  15. global $app, $conf;
  16. $this->cliente = $client = $app->db->queryOneRecord(
  17. "SELECT limit_dns_zone, limit_web_domain, limit_database, parent_client_id
  18. FROM sys_group, client
  19. WHERE sys_group.client_id = client.client_id
  20. and sys_group.groupid = ?", $cliente_group_id);
  21. $this->cliente_grupo_id = $cliente_group_id;
  22. }
  23. public $revendedor;
  24. public $revendedor_grupos;
  25. public $revendedor_grupo_def;
  26. public function getRevendedor(){
  27. global $app, $conf;
  28. $tmpReseller = $app->db->queryOneRecord(
  29. "SELECT userid, groups, default_group
  30. FROM sys_user
  31. WHERE client_id = ?", $this->cliente['parent_client_id']);
  32. $this->revendedor = $tmpReseller['userid'];
  33. $this->revendedor_grupos = $tmpReseller['groups'];
  34. $this->revendedor_grupo_def = $tmpReseller['default_group'];
  35. }
  36. public function limClienteDns(){
  37. global $app, $conf;
  38. //Si el cliente esta vacío es admin.
  39. if($this->cliente){
  40. //echo(' Usuario grupo es ' .$this->cliente_grupo_id);
  41. if($this->cliente["limit_dns_zone"] >= 0) {
  42. $tmp = $app->db->queryOneRecord(
  43. "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", $this->cliente_grupo_id);
  44. if($tmp["number"] >= $this->cliente["limit_dns_zone"]) {
  45. $app->error($app->tform->wordbook["limit_dns_zone_txt"]);
  46. return true;
  47. }
  48. }
  49. //* If the client belongs to a reseller, we will check against the reseller Limit too
  50. if($this->cliente['parent_client_id'] != 0) {
  51. //* first we need to know the groups of this reseller
  52. $this->getRevendedor();
  53. //echo(' Valores '.$this->revendedor . ' otro ' . $this->revendedor_grupos . ' y otro ' .$this->revendedor_grupo_def);
  54. //echo(' El cliente es ' . $this->cliente['parent_client_id']);
  55. $reseller = $app->db->queryOneRecord(
  56. "SELECT limit_dns_zone as number, contact_firstname FROM client WHERE client_id = ?", $this->cliente['parent_client_id']);
  57. //echo(' Cliente Reventa limites DNS ' . $reseller['number']);
  58. // Check if the user may add another item
  59. if($reseller['number'] >= 0) {
  60. $tmpCliente = $app->db->queryOneRecord(
  61. "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", $this->cliente_grupo_id);
  62. $tmpReventa = $app->db->queryOneRecord(
  63. "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", $this->revendedor_grupo_def);
  64. $totalCreado = $tmpCliente['number'] + $tmpReventa['number'];
  65. //echo(' Total creado ' . $totalCreado . ' el array ' . print_r($reseller). ' Y ' . $reseller['number']);
  66. if($totalCreado >= $reseller['number']) {
  67. $app->error($reseller['contact_firstname'] . '. ' . $app->tform->wordbook["limit_dns_zone_txt"]);
  68. return true;
  69. }
  70. /*$tmp = $app->db->queryOneRecord(
  71. "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", explode(',', $reseller_groups));
  72. echo(' El temp registros en dns_soa usando grupo reseller ' .$tmp['number']);*/
  73. /*if($tmp['number'] >= $reseller['number']) {
  74. $app->error($app->tform->wordbook["limit_dns_zone_txt"]. ' Dentro Limites');
  75. return true;
  76. }*/
  77. }
  78. }
  79. return false;
  80. }
  81. }
  82. public function limClienteWebDominio(){
  83. global $app, $conf;
  84. //Si el cliente esta vacío es admin.
  85. if($this->cliente){
  86. if($this->cliente["limit_web_domain"] >= 0) {
  87. $tmp = $app->db->queryOneRecord(
  88. "SELECT count(domain_id) as number FROM web_domain
  89. WHERE sys_groupid = ? and type = 'vhost'", $this->cliente_grupo_id);
  90. if($tmp["number"] >= $this->cliente["limit_web_domain"]) {
  91. $app->error($app->tform->wordbook["limit_web_domain_txt"]);
  92. return true;
  93. }
  94. }
  95. //* If the client belongs to a reseller, we will check against the reseller Limit too
  96. if($this->cliente['parent_client_id'] != 0) {
  97. //* first we need to know the groups of this reseller
  98. $this->getRevendedor();
  99. $reseller = $app->db->queryOneRecord(
  100. "SELECT limit_web_domain as number, contact_firstname FROM client WHERE client_id = ?", $this->cliente['parent_client_id']);
  101. //echo(' Cliente Reventa limites DNS ' . $reseller['number']);
  102. // Check if the user may add another item
  103. if($reseller['number'] >= 0) {
  104. $tmpCliente = $app->db->queryOneRecord(
  105. "SELECT count(domain_id) as number FROM web_domain
  106. WHERE sys_groupid = ? and type = 'vhost'", $this->cliente_grupo_id);
  107. $tmpReventa = $app->db->queryOneRecord(
  108. "SELECT count(domain_id) as number FROM web_domain
  109. WHERE sys_groupid = ? and type = 'vhost'", $this->revendedor_grupo_def);
  110. $totalCreado = $tmpCliente['number'] + $tmpReventa['number'];
  111. if($totalCreado >= $reseller['number']) {
  112. $app->error($reseller['contact_firstname'] . '. ' . $app->tform->wordbook["limit_web_domain_txt"]);
  113. return true;
  114. }
  115. }
  116. }
  117. return false;
  118. }
  119. }
  120. public function limClienteDB(){
  121. global $app, $conf;
  122. //Si el cliente esta vacío es admin.
  123. if($this->cliente){
  124. if($this->cliente["limit_database"] >= 0) {
  125. $tmp = $app->db->queryOneRecord(
  126. "SELECT count(database_id) as number
  127. FROM web_database WHERE sys_groupid = ?", $this->cliente_grupo_id);
  128. if($tmp["number"] >= $this->cliente["limit_database"]) {
  129. $app->error($app->tform->wordbook["limit_database_txt"]);
  130. return true;
  131. }
  132. }
  133. //* If the client belongs to a reseller, we will check against the reseller Limit too
  134. if($this->cliente['parent_client_id'] != 0) {
  135. //* first we need to know the groups of this reseller
  136. $this->getRevendedor();
  137. $reseller = $app->db->queryOneRecord(
  138. "SELECT limit_database as number, contact_firstname FROM client WHERE client_id = ?", $this->cliente['parent_client_id']);
  139. //echo(' Cliente Reventa limites DNS ' . $reseller['number']);
  140. // Check if the user may add another item
  141. if($reseller['number'] >= 0) {
  142. $tmpCliente = $app->db->queryOneRecord(
  143. "SELECT count(database_id) as number
  144. FROM web_database WHERE sys_groupid = ?", $this->cliente_grupo_id);
  145. $tmpReventa = $app->db->queryOneRecord(
  146. "SELECT count(database_id) as number
  147. FROM web_database WHERE sys_groupid = ?", $this->revendedor_grupo_def);
  148. $totalCreado = $tmpCliente['number'] + $tmpReventa['number'];
  149. if($totalCreado >= $reseller['number']) {
  150. $app->error($reseller['contact_firstname'] . '. ' . $app->tform->wordbook["limit_database_txt"]);
  151. return true;
  152. }
  153. }
  154. }
  155. return false;
  156. }
  157. }
  158. }
  159. ?>