ISPConfig module for simplify the creation of websites and DNS zones in a only step
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

200 rindas
8.8 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(',', $this->revendedor_grupos));
  72. echo(' El temp registros en dns_soa usando grupo reseller ' .$tmp['number']);*/
  73. /* $sumaTotal = 0;
  74. $todosLosGrupos = explode(',', $this->revendedor_grupos);
  75. foreach($todosLosGrupos as $grupos) {
  76. $tmpReventaALL = $app->db->queryOneRecord(
  77. "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", $grupos);
  78. $sql = "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ". $grupos;
  79. echo(' Valores ' . $tmpReventaALL['number']);
  80. $sumaTotal =+ $tmpReventaALL['number'];
  81. echo($sumaTotal);
  82. }*/
  83. /*if($tmp['number'] >= $reseller['number']) {
  84. $app->error($app->tform->wordbook["limit_dns_zone_txt"]);
  85. return true;
  86. }*/
  87. }
  88. }
  89. return false;
  90. }
  91. }
  92. public function limClienteWebDominio(){
  93. global $app, $conf;
  94. //Si el cliente esta vacío es admin.
  95. if($this->cliente){
  96. if($this->cliente["limit_web_domain"] >= 0) {
  97. $tmp = $app->db->queryOneRecord(
  98. "SELECT count(domain_id) as number FROM web_domain
  99. WHERE sys_groupid = ? and type = 'vhost'", $this->cliente_grupo_id);
  100. if($tmp["number"] >= $this->cliente["limit_web_domain"]) {
  101. $app->error($app->tform->wordbook["limit_web_domain_txt"]);
  102. return true;
  103. }
  104. }
  105. //* If the client belongs to a reseller, we will check against the reseller Limit too
  106. if($this->cliente['parent_client_id'] != 0) {
  107. //* first we need to know the groups of this reseller
  108. $this->getRevendedor();
  109. $reseller = $app->db->queryOneRecord(
  110. "SELECT limit_web_domain as number, contact_firstname FROM client WHERE client_id = ?", $this->cliente['parent_client_id']);
  111. //echo(' Cliente Reventa limites DNS ' . $reseller['number']);
  112. // Check if the user may add another item
  113. if($reseller['number'] >= 0) {
  114. $tmpCliente = $app->db->queryOneRecord(
  115. "SELECT count(domain_id) as number FROM web_domain
  116. WHERE sys_groupid = ? and type = 'vhost'", $this->cliente_grupo_id);
  117. $tmpReventa = $app->db->queryOneRecord(
  118. "SELECT count(domain_id) as number FROM web_domain
  119. WHERE sys_groupid = ? and type = 'vhost'", $this->revendedor_grupo_def);
  120. $totalCreado = $tmpCliente['number'] + $tmpReventa['number'];
  121. if($totalCreado >= $reseller['number']) {
  122. $app->error($reseller['contact_firstname'] . '. ' . $app->tform->wordbook["limit_web_domain_txt"]);
  123. return true;
  124. }
  125. }
  126. }
  127. return false;
  128. }
  129. }
  130. public function limClienteDB(){
  131. global $app, $conf;
  132. //Si el cliente esta vacío es admin.
  133. if($this->cliente){
  134. if($this->cliente["limit_database"] >= 0) {
  135. $tmp = $app->db->queryOneRecord(
  136. "SELECT count(database_id) as number
  137. FROM web_database WHERE sys_groupid = ?", $this->cliente_grupo_id);
  138. if($tmp["number"] >= $this->cliente["limit_database"]) {
  139. $app->error($app->tform->wordbook["limit_database_txt"]);
  140. return true;
  141. }
  142. }
  143. //* If the client belongs to a reseller, we will check against the reseller Limit too
  144. if($this->cliente['parent_client_id'] != 0) {
  145. //* first we need to know the groups of this reseller
  146. $this->getRevendedor();
  147. $reseller = $app->db->queryOneRecord(
  148. "SELECT limit_database as number, contact_firstname FROM client WHERE client_id = ?", $this->cliente['parent_client_id']);
  149. //echo(' Cliente Reventa limites DNS ' . $reseller['number']);
  150. // Check if the user may add another item
  151. if($reseller['number'] >= 0) {
  152. $tmpCliente = $app->db->queryOneRecord(
  153. "SELECT count(database_id) as number
  154. FROM web_database WHERE sys_groupid = ?", $this->cliente_grupo_id);
  155. $tmpReventa = $app->db->queryOneRecord(
  156. "SELECT count(database_id) as number
  157. FROM web_database WHERE sys_groupid = ?", $this->revendedor_grupo_def);
  158. $totalCreado = $tmpCliente['number'] + $tmpReventa['number'];
  159. if($totalCreado >= $reseller['number']) {
  160. $app->error($reseller['contact_firstname'] . '. ' . $app->tform->wordbook["limit_database_txt"]);
  161. return true;
  162. }
  163. }
  164. }
  165. return false;
  166. }
  167. }
  168. }
  169. ?>