Marius Cramer
2015-04-15 3a11d23a2f32a1b9b2ec43429917c000017c5eff
commit | author | age
c1418f 1 <?php
M 2
3 /*
4 Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9
10     * Redistributions of source code must retain the above copyright notice,
11       this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright notice,
13       this list of conditions and the following disclaimer in the documentation
14       and/or other materials provided with the distribution.
15     * Neither the name of ISPConfig nor the names of its contributors
16       may be used to endorse or promote products derived from this software without
17       specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 --UPDATED 08.2009--
31 Full SOAP support for ISPConfig 3.1.4 b
32 Updated by Arkadiusz Roch & Artur Edelman
33 Copyright (c) Tri-Plex technology
34
35 --UPDATED 08.2013--
36 Migrated into new remote classes system
37 by Marius Cramer <m.cramer@pixcept.de>
38
39 */
40
41 class remoting_dns extends remoting {
42     // DNS Function --------------------------------------------------------------------------------------------------
b1a6a5 43
c1418f 44     //* Create Zone with Template
M 45     public function dns_templatezone_add($session_id, $client_id, $template_id, $domain, $ip, $ns1, $ns2, $email)
b1a6a5 46     {
MC 47         global $app, $conf;
c1418f 48         if(!$this->checkPerm($session_id, 'dns_templatezone_add')) {
b1a6a5 49             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
MC 50             return false;
c1418f 51         }
M 52
cc7a82 53         $client = $app->db->queryOneRecord("SELECT default_dnsserver FROM client WHERE client_id = ?", $client_id);
c1418f 54         $server_id = $client["default_dnsserver"];
cc7a82 55         $template_record = $app->db->queryOneRecord("SELECT * FROM dns_template WHERE template_id = ?", $template_id);
b1a6a5 56         $fields = explode(',', $template_record['fields']);
c1418f 57         $tform_def_file = "../../web/dns/form/dns_soa.tform.php";
M 58         $app->uses('tform');
59         $app->tform->loadFormDef($tform_def_file);
60         $app->uses('tpl,validate_dns');
b1a6a5 61
c1418f 62         //* replace template placeholders
M 63         $tpl_content = $template_record['template'];
b1a6a5 64         if($domain != '') $tpl_content = str_replace('{DOMAIN}', $domain, $tpl_content);
MC 65         if($ip != '') $tpl_content = str_replace('{IP}', $ip, $tpl_content);
66         if($ns1 != '') $tpl_content = str_replace('{NS1}', $ns1, $tpl_content);
67         if($ns2 != '') $tpl_content = str_replace('{NS2}', $ns2, $tpl_content);
68         if($email != '') $tpl_content = str_replace('{EMAIL}', $email, $tpl_content);
69
c1418f 70         //* Parse the template
b1a6a5 71         $tpl_rows = explode("\n", $tpl_content);
c1418f 72         $section = '';
M 73         $vars = array();
74         $dns_rr = array();
75         foreach($tpl_rows as $row) {
76             $row = trim($row);
b1a6a5 77             if(substr($row, 0, 1) == '[') {
c1418f 78                 if($row == '[ZONE]') {
M 79                     $section = 'zone';
80                 } elseif($row == '[DNS_RECORDS]') {
81                     $section = 'dns_records';
82                 } else {
83                     die('Unknown section type');
84                 }
85             } else {
86                 if($row != '') {
87                     //* Handle zone section
88                     if($section == 'zone') {
b1a6a5 89                         $parts = explode('=', $row);
c1418f 90                         $key = trim($parts[0]);
M 91                         $val = trim($parts[1]);
92                         if($key != '') $vars[$key] = $val;
93                     }
94                     //* Handle DNS Record rows
95                     if($section == 'dns_records') {
b1a6a5 96                         $parts = explode('|', $row);
c1418f 97                         $dns_rr[] = array(
3a11d2 98                             'name' => $parts[1],
MC 99                             'type' => $parts[0],
100                             'data' => $parts[2],
101                             'aux'  => $parts[3],
102                             'ttl'  => $parts[4]
c1418f 103                         );
M 104                     }
105                 }
b1a6a5 106             }
c1418f 107         } // end foreach
b1a6a5 108
c1418f 109         if($vars['origin'] == '') $error .= $app->lng('error_origin_empty').'<br />';
M 110         if($vars['ns'] == '') $error .= $app->lng('error_ns_empty').'<br />';
111         if($vars['mbox'] == '') $error .= $app->lng('error_mbox_empty').'<br />';
112         if($vars['refresh'] == '') $error .= $app->lng('error_refresh_empty').'<br />';
113         if($vars['retry'] == '') $error .= $app->lng('error_retry_empty').'<br />';
114         if($vars['expire'] == '') $error .= $app->lng('error_expire_empty').'<br />';
115         if($vars['minimum'] == '') $error .= $app->lng('error_minimum_empty').'<br />';
b1a6a5 116         if($vars['ttl'] == '') $error .= $app->lng('error_ttl_empty').'<br />';
MC 117
c1418f 118         if($error == '') {
M 119             // Insert the soa record
cc7a82 120             $tmp = $app->db->queryOneRecord("SELECT userid,default_group FROM sys_user WHERE client_id = ?", $client_id);
c1418f 121             $sys_userid = $tmp['userid'];
M 122             $sys_groupid = $tmp['default_group'];
123             unset($tmp);
3a11d2 124             $origin = $vars['origin'];
MC 125             $ns = $vars['ns'];
126             $mbox = str_replace('@', '.', $vars['mbox']);
127             $refresh = $vars['refresh'];
128             $retry = $vars['retry'];
129             $expire = $vars['expire'];
130             $minimum = $vars['minimum'];
131             $ttl = $vars['ttl'];
132             $xfer = $vars['xfer'];
133             $also_notify = $vars['also_notify'];
134             $update_acl = $vars['update_acl'];
b1a6a5 135             $serial = $app->validate_dns->increase_serial(0);
3a11d2 136             $insert_data = array(
MC 137                 "sys_userid" => $sys_userid,
138                 "sys_groupid" => $sys_groupid,
139                 "sys_perm_user" => 'riud',
140                 "sys_perm_group" => 'riud',
141                 "sys_perm_other" => '',
142                 "server_id" => $server_id,
143                 "origin" => $origin,
144                 "ns" => $ns,
145                 "mbox" => $mbox,
146                 "serial" => $serial,
147                 "refresh" => $refresh,
148                 "retry" => $retry,
149                 "expire" => $expire,
150                 "minimum" => $minimum,
151                 "ttl" => $ttl,
152                 "active" => 'Y',
153                 "xfer" => $xfer,
154                 "also_notify" => $also_notify,
155                 "update_acl" => $update_acl
156             );
b1a6a5 157             $dns_soa_id = $app->db->datalogInsert('dns_soa', $insert_data, 'id');
c1418f 158             // Insert the dns_rr records
M 159             if(is_array($dns_rr) && $dns_soa_id > 0) {
160                 foreach($dns_rr as $rr) {
3a11d2 161                     $insert_data = array(
MC 162                         "sys_userid" => $sys_userid,
163                         "sys_groupid" => $sys_groupid,
164                         "sys_perm_user" => 'riud',
165                         "sys_perm_group" => 'riud',
166                         "sys_perm_other" => '',
167                         "server_id" => $server_id,
168                         "zone" => $dns_soa_id,
169                         "name" => $rr['name'],
170                         "type" => $rr['type'],
171                         "data" => $rr['data'],
172                         "aux" => $rr['aux'],
173                         "ttl" => $rr['ttl'],
174                         "active" => 'Y'
175                     );
c1418f 176                     $dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id');
M 177                 }
178             }
179             exit;
180         } else {
181             throw new SoapFault('permission_denied', $error);
182         }
183     }
b1a6a5 184
MC 185
c1418f 186     //* Get record details
M 187     public function dns_zone_get($session_id, $primary_id)
b1a6a5 188     {
c1418f 189         global $app;
b1a6a5 190
c1418f 191         if(!$this->checkPerm($session_id, 'dns_zone_get')) {
M 192             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
193             return false;
194         }
195         $app->uses('remoting_lib');
196         $app->remoting_lib->loadFormDef('../dns/form/dns_soa.tform.php');
197         return $app->remoting_lib->getDataRecord($primary_id);
198     }
199
b1a6a5 200     //* Get record id by origin
MC 201     public function dns_zone_get_id($session_id, $origin)
202     {
203         global $app;
204
205         if(!$this->checkPerm($session_id, 'dns_zone_get_id')) {
206             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
207             return false;
208         }
209
210         if(!preg_match('/^[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/i', $origin)){
211             throw new SoapFault('no_domain_found', 'Invalid domain name.');
212             return false;
213         }
214
cc7a82 215         $rec = $app->db->queryOneRecord("SELECT id FROM dns_soa WHERE origin like ?", $origin."%");
b1a6a5 216         if(isset($rec['id'])) {
MC 217             return $app->functions->intval($rec['id']);
218         } else {
219             throw new SoapFault('no_domain_found', 'There is no domain ID with informed domain name.');
220             return false;
221         }
222     }
223
c1418f 224     //* Add a record
M 225     public function dns_zone_add($session_id, $client_id, $params)
b1a6a5 226     {
c1418f 227         if(!$this->checkPerm($session_id, 'dns_zone_add')) {
M 228             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
229             return false;
230         }
b1a6a5 231         return $this->insertQuery('../dns/form/dns_soa.tform.php', $client_id, $params);
c1418f 232     }
b1a6a5 233
c1418f 234     //* Update a record
M 235     public function dns_zone_update($session_id, $client_id, $primary_id, $params)
b1a6a5 236     {
c1418f 237         if(!$this->checkPerm($session_id, 'dns_zone_update')) {
M 238             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
239             return false;
240         }
b1a6a5 241         $affected_rows = $this->updateQuery('../dns/form/dns_soa.tform.php', $client_id, $primary_id, $params);
c1418f 242         return $affected_rows;
M 243     }
b1a6a5 244
c1418f 245     //* Delete a record
M 246     public function dns_zone_delete($session_id, $primary_id)
b1a6a5 247     {
c1418f 248         if(!$this->checkPerm($session_id, 'dns_zone_delete')) {
M 249             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
250             return false;
251         }
b1a6a5 252         $affected_rows = $this->deleteQuery('../dns/form/dns_soa.tform.php', $primary_id);
c1418f 253         return $affected_rows;
M 254     }
b1a6a5 255
c1418f 256     // ----------------------------------------------------------------------------------------------------------------
b1a6a5 257
c1418f 258     //* Get record details
M 259     public function dns_aaaa_get($session_id, $primary_id)
b1a6a5 260     {
c1418f 261         global $app;
b1a6a5 262
c1418f 263         if(!$this->checkPerm($session_id, 'dns_aaaa_get')) {
M 264             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
265             return false;
266         }
267         $app->uses('remoting_lib');
268         $app->remoting_lib->loadFormDef('../dns/form/dns_aaaa.tform.php');
269         return $app->remoting_lib->getDataRecord($primary_id);
270     }
b1a6a5 271
c1418f 272     //* Add a record
M 273     public function dns_aaaa_add($session_id, $client_id, $params)
b1a6a5 274     {
c1418f 275         if(!$this->checkPerm($session_id, 'dns_aaaa_add')) {
M 276             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
277             return false;
278         }
b1a6a5 279         return $this->insertQuery('../dns/form/dns_aaaa.tform.php', $client_id, $params);
c1418f 280     }
b1a6a5 281
c1418f 282     //* Update a record
M 283     public function dns_aaaa_update($session_id, $client_id, $primary_id, $params)
b1a6a5 284     {
c1418f 285         if(!$this->checkPerm($session_id, 'dns_aaaa_update')) {
M 286             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
287             return false;
288         }
b1a6a5 289         $affected_rows = $this->updateQuery('../dns/form/dns_aaaa.tform.php', $client_id, $primary_id, $params);
c1418f 290         return $affected_rows;
M 291     }
b1a6a5 292
c1418f 293     //* Delete a record
M 294     public function dns_aaaa_delete($session_id, $primary_id)
b1a6a5 295     {
c1418f 296         if(!$this->checkPerm($session_id, 'dns_aaaa_delete')) {
M 297             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
298             return false;
299         }
b1a6a5 300         $affected_rows = $this->deleteQuery('../dns/form/dns_aaaa.tform.php', $primary_id);
c1418f 301         return $affected_rows;
M 302     }
303
304     // ----------------------------------------------------------------------------------------------------------------
b1a6a5 305
c1418f 306     //* Get record details
M 307     public function dns_a_get($session_id, $primary_id)
b1a6a5 308     {
c1418f 309         global $app;
b1a6a5 310
c1418f 311         if(!$this->checkPerm($session_id, 'dns_a_get')) {
M 312             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
313             return false;
314         }
315         $app->uses('remoting_lib');
316         $app->remoting_lib->loadFormDef('../dns/form/dns_a.tform.php');
317         return $app->remoting_lib->getDataRecord($primary_id);
318     }
b1a6a5 319
c1418f 320     //* Add a record
M 321     public function dns_a_add($session_id, $client_id, $params)
b1a6a5 322     {
c1418f 323         if(!$this->checkPerm($session_id, 'dns_a_add')) {
M 324             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
325             return false;
326         }
b1a6a5 327         return $this->insertQuery('../dns/form/dns_a.tform.php', $client_id, $params);
c1418f 328     }
b1a6a5 329
c1418f 330     //* Update a record
M 331     public function dns_a_update($session_id, $client_id, $primary_id, $params)
b1a6a5 332     {
c1418f 333         if(!$this->checkPerm($session_id, 'dns_a_update')) {
M 334             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
335             return false;
336         }
b1a6a5 337         $affected_rows = $this->updateQuery('../dns/form/dns_a.tform.php', $client_id, $primary_id, $params);
c1418f 338         return $affected_rows;
M 339     }
b1a6a5 340
c1418f 341     //* Delete a record
M 342     public function dns_a_delete($session_id, $primary_id)
b1a6a5 343     {
c1418f 344         if(!$this->checkPerm($session_id, 'dns_a_delete')) {
M 345             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
346             return false;
347         }
b1a6a5 348         $affected_rows = $this->deleteQuery('../dns/form/dns_a.tform.php', $primary_id);
c1418f 349         return $affected_rows;
M 350     }
b1a6a5 351
c1418f 352     // ----------------------------------------------------------------------------------------------------------------
b1a6a5 353
c1418f 354     //* Get record details
M 355     public function dns_alias_get($session_id, $primary_id)
b1a6a5 356     {
c1418f 357         global $app;
b1a6a5 358
c1418f 359         if(!$this->checkPerm($session_id, 'dns_alias_get')) {
M 360             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
361             return false;
362         }
363         $app->uses('remoting_lib');
364         $app->remoting_lib->loadFormDef('../dns/form/dns_alias.tform.php');
365         return $app->remoting_lib->getDataRecord($primary_id);
366     }
b1a6a5 367
c1418f 368     //* Add a record
M 369     public function dns_alias_add($session_id, $client_id, $params)
b1a6a5 370     {
c1418f 371         if(!$this->checkPerm($session_id, 'dns_alias_add')) {
M 372             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
373             return false;
374         }
b1a6a5 375         return $this->insertQuery('../dns/form/dns_alias.tform.php', $client_id, $params);
c1418f 376     }
b1a6a5 377
c1418f 378     //* Update a record
M 379     public function dns_alias_update($session_id, $client_id, $primary_id, $params)
b1a6a5 380     {
c1418f 381         if(!$this->checkPerm($session_id, 'dns_alias_update')) {
M 382             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
383             return false;
384         }
b1a6a5 385         $affected_rows = $this->updateQuery('../dns/form/dns_alias.tform.php', $client_id, $primary_id, $params);
c1418f 386         return $affected_rows;
M 387     }
b1a6a5 388
c1418f 389     //* Delete a record
M 390     public function dns_alias_delete($session_id, $primary_id)
b1a6a5 391     {
c1418f 392         if(!$this->checkPerm($session_id, 'dns_alias_delete')) {
M 393             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
394             return false;
395         }
b1a6a5 396         $affected_rows = $this->deleteQuery('../dns/form/dns_alias.tform.php', $primary_id);
c1418f 397         return $affected_rows;
M 398     }
b1a6a5 399
c1418f 400     // ----------------------------------------------------------------------------------------------------------------
b1a6a5 401
c1418f 402     //* Get record details
M 403     public function dns_cname_get($session_id, $primary_id)
b1a6a5 404     {
c1418f 405         global $app;
b1a6a5 406
c1418f 407         if(!$this->checkPerm($session_id, 'dns_cname_get')) {
M 408             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
409             return false;
410         }
411         $app->uses('remoting_lib');
412         $app->remoting_lib->loadFormDef('../dns/form/dns_cname.tform.php');
413         return $app->remoting_lib->getDataRecord($primary_id);
414     }
b1a6a5 415
c1418f 416     //* Add a record
M 417     public function dns_cname_add($session_id, $client_id, $params)
b1a6a5 418     {
c1418f 419         if(!$this->checkPerm($session_id, 'dns_cname_add')) {
M 420             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
421             return false;
422         }
b1a6a5 423         return $this->insertQuery('../dns/form/dns_cname.tform.php', $client_id, $params);
c1418f 424     }
b1a6a5 425
c1418f 426     //* Update a record
M 427     public function dns_cname_update($session_id, $client_id, $primary_id, $params)
b1a6a5 428     {
c1418f 429         if(!$this->checkPerm($session_id, 'dns_cname_update')) {
M 430             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
431             return false;
432         }
b1a6a5 433         $affected_rows = $this->updateQuery('../dns/form/dns_cname.tform.php', $client_id, $primary_id, $params);
c1418f 434         return $affected_rows;
M 435     }
b1a6a5 436
c1418f 437     //* Delete a record
M 438     public function dns_cname_delete($session_id, $primary_id)
b1a6a5 439     {
c1418f 440         if(!$this->checkPerm($session_id, 'dns_cname_delete')) {
M 441             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
442             return false;
443         }
b1a6a5 444         $affected_rows = $this->deleteQuery('../dns/form/dns_cname.tform.php', $primary_id);
c1418f 445         return $affected_rows;
M 446     }
b1a6a5 447
c1418f 448     // ----------------------------------------------------------------------------------------------------------------
b1a6a5 449
c1418f 450     //* Get record details
M 451     public function dns_hinfo_get($session_id, $primary_id)
b1a6a5 452     {
c1418f 453         global $app;
b1a6a5 454
c1418f 455         if(!$this->checkPerm($session_id, 'dns_hinfo_get')) {
M 456             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
457             return false;
458         }
459         $app->uses('remoting_lib');
460         $app->remoting_lib->loadFormDef('../dns/form/dns_hinfo.tform.php');
461         return $app->remoting_lib->getDataRecord($primary_id);
462     }
b1a6a5 463
c1418f 464     //* Add a record
M 465     public function dns_hinfo_add($session_id, $client_id, $params)
b1a6a5 466     {
c1418f 467         if(!$this->checkPerm($session_id, 'dns_hinfo_add')) {
M 468             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
469             return false;
470         }
b1a6a5 471         return $this->insertQuery('../dns/form/dns_hinfo.tform.php', $client_id, $params);
c1418f 472     }
b1a6a5 473
c1418f 474     //* Update a record
M 475     public function dns_hinfo_update($session_id, $client_id, $primary_id, $params)
b1a6a5 476     {
c1418f 477         if(!$this->checkPerm($session_id, 'dns_hinfo_update')) {
M 478             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
479             return false;
480         }
b1a6a5 481         $affected_rows = $this->updateQuery('../dns/form/dns_hinfo.tform.php', $client_id, $primary_id, $params);
c1418f 482         return $affected_rows;
M 483     }
b1a6a5 484
c1418f 485     //* Delete a record
M 486     public function dns_hinfo_delete($session_id, $primary_id)
b1a6a5 487     {
c1418f 488         if(!$this->checkPerm($session_id, 'dns_hinfo_delete')) {
M 489             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
490             return false;
491         }
b1a6a5 492         $affected_rows = $this->deleteQuery('../dns/form/dns_hinfo.tform.php', $primary_id);
c1418f 493         return $affected_rows;
M 494     }
b1a6a5 495
c1418f 496     // ----------------------------------------------------------------------------------------------------------------
b1a6a5 497
c1418f 498     //* Get record details
M 499     public function dns_mx_get($session_id, $primary_id)
b1a6a5 500     {
c1418f 501         global $app;
b1a6a5 502
c1418f 503         if(!$this->checkPerm($session_id, 'dns_mx_get')) {
M 504             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
505             return false;
506         }
507         $app->uses('remoting_lib');
508         $app->remoting_lib->loadFormDef('../dns/form/dns_mx.tform.php');
509         return $app->remoting_lib->getDataRecord($primary_id);
510     }
b1a6a5 511
c1418f 512     //* Add a record
M 513     public function dns_mx_add($session_id, $client_id, $params)
b1a6a5 514     {
c1418f 515         if(!$this->checkPerm($session_id, 'dns_mx_add')) {
M 516             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
517             return false;
518         }
b1a6a5 519         return $this->insertQuery('../dns/form/dns_mx.tform.php', $client_id, $params);
c1418f 520     }
b1a6a5 521
c1418f 522     //* Update a record
M 523     public function dns_mx_update($session_id, $client_id, $primary_id, $params)
b1a6a5 524     {
c1418f 525         if(!$this->checkPerm($session_id, 'dns_mx_update')) {
M 526             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
527             return false;
528         }
b1a6a5 529         $affected_rows = $this->updateQuery('../dns/form/dns_mx.tform.php', $client_id, $primary_id, $params);
c1418f 530         return $affected_rows;
M 531     }
b1a6a5 532
c1418f 533     //* Delete a record
M 534     public function dns_mx_delete($session_id, $primary_id)
b1a6a5 535     {
c1418f 536         if(!$this->checkPerm($session_id, 'dns_mx_delete')) {
M 537             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
538             return false;
539         }
b1a6a5 540         $affected_rows = $this->deleteQuery('../dns/form/dns_mx.tform.php', $primary_id);
c1418f 541         return $affected_rows;
M 542     }
b1a6a5 543
c1418f 544     // ----------------------------------------------------------------------------------------------------------------
b1a6a5 545
c1418f 546     //* Get record details
M 547     public function dns_ns_get($session_id, $primary_id)
b1a6a5 548     {
c1418f 549         global $app;
b1a6a5 550
c1418f 551         if(!$this->checkPerm($session_id, 'dns_ns_get')) {
M 552             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
553             return false;
554         }
555         $app->uses('remoting_lib');
556         $app->remoting_lib->loadFormDef('../dns/form/dns_ns.tform.php');
557         return $app->remoting_lib->getDataRecord($primary_id);
558     }
b1a6a5 559
c1418f 560     //* Add a record
M 561     public function dns_ns_add($session_id, $client_id, $params)
b1a6a5 562     {
c1418f 563         if(!$this->checkPerm($session_id, 'dns_ns_add')) {
M 564             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
565             return false;
566         }
b1a6a5 567         return $this->insertQuery('../dns/form/dns_ns.tform.php', $client_id, $params);
c1418f 568     }
b1a6a5 569
c1418f 570     //* Update a record
M 571     public function dns_ns_update($session_id, $client_id, $primary_id, $params)
b1a6a5 572     {
c1418f 573         if(!$this->checkPerm($session_id, 'dns_ns_update')) {
M 574             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
575             return false;
576         }
b1a6a5 577         $affected_rows = $this->updateQuery('../dns/form/dns_ns.tform.php', $client_id, $primary_id, $params);
c1418f 578         return $affected_rows;
M 579     }
b1a6a5 580
c1418f 581     //* Delete a record
M 582     public function dns_ns_delete($session_id, $primary_id)
b1a6a5 583     {
c1418f 584         if(!$this->checkPerm($session_id, 'dns_ns_delete')) {
M 585             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
586             return false;
587         }
b1a6a5 588         $affected_rows = $this->deleteQuery('../dns/form/dns_ns.tform.php', $primary_id);
c1418f 589         return $affected_rows;
M 590     }
b1a6a5 591
c1418f 592     // ----------------------------------------------------------------------------------------------------------------
b1a6a5 593
c1418f 594     //* Get record details
M 595     public function dns_ptr_get($session_id, $primary_id)
b1a6a5 596     {
c1418f 597         global $app;
b1a6a5 598
c1418f 599         if(!$this->checkPerm($session_id, 'dns_ptr_get')) {
M 600             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
601             return false;
602         }
603         $app->uses('remoting_lib');
604         $app->remoting_lib->loadFormDef('../dns/form/dns_ptr.tform.php');
605         return $app->remoting_lib->getDataRecord($primary_id);
606     }
b1a6a5 607
c1418f 608     //* Add a record
M 609     public function dns_ptr_add($session_id, $client_id, $params)
b1a6a5 610     {
c1418f 611         if(!$this->checkPerm($session_id, 'dns_ptr_add')) {
M 612             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
613             return false;
614         }
b1a6a5 615         return $this->insertQuery('../dns/form/dns_ptr.tform.php', $client_id, $params);
c1418f 616     }
b1a6a5 617
c1418f 618     //* Update a record
M 619     public function dns_ptr_update($session_id, $client_id, $primary_id, $params)
b1a6a5 620     {
c1418f 621         if(!$this->checkPerm($session_id, 'dns_ptr_update')) {
M 622             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
623             return false;
624         }
b1a6a5 625         $affected_rows = $this->updateQuery('../dns/form/dns_ptr.tform.php', $client_id, $primary_id, $params);
c1418f 626         return $affected_rows;
M 627     }
b1a6a5 628
c1418f 629     //* Delete a record
M 630     public function dns_ptr_delete($session_id, $primary_id)
b1a6a5 631     {
c1418f 632         if(!$this->checkPerm($session_id, 'dns_ptr_delete')) {
M 633             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
634             return false;
635         }
b1a6a5 636         $affected_rows = $this->deleteQuery('../dns/form/dns_ptr.tform.php', $primary_id);
c1418f 637         return $affected_rows;
M 638     }
b1a6a5 639
c1418f 640     // ----------------------------------------------------------------------------------------------------------------
b1a6a5 641
c1418f 642     //* Get record details
M 643     public function dns_rp_get($session_id, $primary_id)
b1a6a5 644     {
c1418f 645         global $app;
b1a6a5 646
c1418f 647         if(!$this->checkPerm($session_id, 'dns_rp_get')) {
M 648             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
649             return false;
650         }
651         $app->uses('remoting_lib');
652         $app->remoting_lib->loadFormDef('../dns/form/dns_rp.tform.php');
653         return $app->remoting_lib->getDataRecord($primary_id);
654     }
b1a6a5 655
c1418f 656     //* Add a record
M 657     public function dns_rp_add($session_id, $client_id, $params)
b1a6a5 658     {
c1418f 659         if(!$this->checkPerm($session_id, 'dns_rp_add')) {
M 660             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
661             return false;
662         }
b1a6a5 663         return $this->insertQuery('../dns/form/dns_rp.tform.php', $client_id, $params);
c1418f 664     }
b1a6a5 665
c1418f 666     //* Update a record
M 667     public function dns_rp_update($session_id, $client_id, $primary_id, $params)
b1a6a5 668     {
c1418f 669         if(!$this->checkPerm($session_id, 'dns_rp_update')) {
M 670             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
671             return false;
672         }
b1a6a5 673         $affected_rows = $this->updateQuery('../dns/form/dns_rp.tform.php', $client_id, $primary_id, $params);
c1418f 674         return $affected_rows;
M 675     }
b1a6a5 676
c1418f 677     //* Delete a record
M 678     public function dns_rp_delete($session_id, $primary_id)
b1a6a5 679     {
c1418f 680         if(!$this->checkPerm($session_id, 'dns_rp_delete')) {
M 681             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
682             return false;
683         }
b1a6a5 684         $affected_rows = $this->deleteQuery('../dns/form/dns_rp.tform.php', $primary_id);
c1418f 685         return $affected_rows;
M 686     }
b1a6a5 687
c1418f 688     // ----------------------------------------------------------------------------------------------------------------
b1a6a5 689
c1418f 690     //* Get record details
M 691     public function dns_srv_get($session_id, $primary_id)
b1a6a5 692     {
c1418f 693         global $app;
b1a6a5 694
c1418f 695         if(!$this->checkPerm($session_id, 'dns_srv_get')) {
M 696             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
697             return false;
698         }
699         $app->uses('remoting_lib');
700         $app->remoting_lib->loadFormDef('../dns/form/dns_srv.tform.php');
701         return $app->remoting_lib->getDataRecord($primary_id);
702     }
b1a6a5 703
c1418f 704     //* Add a record
M 705     public function dns_srv_add($session_id, $client_id, $params)
b1a6a5 706     {
c1418f 707         if(!$this->checkPerm($session_id, 'dns_srv_add')) {
M 708             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
709             return false;
710         }
b1a6a5 711         return $this->insertQuery('../dns/form/dns_srv.tform.php', $client_id, $params);
c1418f 712     }
b1a6a5 713
c1418f 714     //* Update a record
M 715     public function dns_srv_update($session_id, $client_id, $primary_id, $params)
b1a6a5 716     {
c1418f 717         if(!$this->checkPerm($session_id, 'dns_srv_update')) {
M 718             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
719             return false;
720         }
b1a6a5 721         $affected_rows = $this->updateQuery('../dns/form/dns_srv.tform.php', $client_id, $primary_id, $params);
c1418f 722         return $affected_rows;
M 723     }
b1a6a5 724
c1418f 725     //* Delete a record
M 726     public function dns_srv_delete($session_id, $primary_id)
b1a6a5 727     {
c1418f 728         if(!$this->checkPerm($session_id, 'dns_srv_delete')) {
M 729             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
730             return false;
731         }
b1a6a5 732         $affected_rows = $this->deleteQuery('../dns/form/dns_srv.tform.php', $primary_id);
c1418f 733         return $affected_rows;
M 734     }
b1a6a5 735
c1418f 736     // ----------------------------------------------------------------------------------------------------------------
b1a6a5 737
c1418f 738     //* Get record details
M 739     public function dns_txt_get($session_id, $primary_id)
b1a6a5 740     {
c1418f 741         global $app;
b1a6a5 742
c1418f 743         if(!$this->checkPerm($session_id, 'dns_txt_get')) {
M 744             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
745             return false;
746         }
747         $app->uses('remoting_lib');
748         $app->remoting_lib->loadFormDef('../dns/form/dns_txt.tform.php');
749         return $app->remoting_lib->getDataRecord($primary_id);
750     }
b1a6a5 751
c1418f 752     //* Add a record
M 753     public function dns_txt_add($session_id, $client_id, $params)
b1a6a5 754     {
c1418f 755         if(!$this->checkPerm($session_id, 'dns_txt_add')) {
M 756             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
757             return false;
758         }
b1a6a5 759         return $this->insertQuery('../dns/form/dns_txt.tform.php', $client_id, $params);
c1418f 760     }
b1a6a5 761
c1418f 762     //* Update a record
M 763     public function dns_txt_update($session_id, $client_id, $primary_id, $params)
b1a6a5 764     {
c1418f 765         if(!$this->checkPerm($session_id, 'dns_txt_update')) {
M 766             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
767             return false;
768         }
b1a6a5 769         $affected_rows = $this->updateQuery('../dns/form/dns_txt.tform.php', $client_id, $primary_id, $params);
c1418f 770         return $affected_rows;
M 771     }
b1a6a5 772
c1418f 773     //* Delete a record
M 774     public function dns_txt_delete($session_id, $primary_id)
b1a6a5 775     {
c1418f 776         if(!$this->checkPerm($session_id, 'dns_txt_delete')) {
M 777             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
778             return false;
779         }
b1a6a5 780         $affected_rows = $this->deleteQuery('../dns/form/dns_txt.tform.php', $primary_id);
c1418f 781         return $affected_rows;
M 782     }
783
784     /**
b1a6a5 785      * Get all DNS zone by user
MC 786      *@author Julio Montoya <gugli100@gmail.com> BeezNest 2010
787      */
788
789
790     public function dns_zone_get_by_user($session_id, $client_id, $server_id) {
791         global $app;
792         if(!$this->checkPerm($session_id, 'dns_zone_get')) {
c1418f 793             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
b1a6a5 794             return false;
MC 795         }
796         if (!empty($client_id) && !empty($server_id)) {
797             $server_id      = $app->functions->intval($server_id);
798             $client_id      = $app->functions->intval($client_id);
cc7a82 799             $sql            = "SELECT id, origin FROM dns_soa d INNER JOIN sys_user s on(d.sys_groupid = s.default_group) WHERE client_id = ? AND server_id = ?";
MC 800             $result         = $app->db->queryAllRecords($sql, $client_id, $server_id);
b1a6a5 801             return          $result;
MC 802         }
803         return false;
804     }
805
806
807
c1418f 808     /**
b1a6a5 809      *  Get all dns records for a zone
MC 810      * @param  int  session id
811      * @param  int  dns zone id
812      * @author Sebastian Mogilowski <sebastian@mogilowski.net> 2011
c1418f 813      */
M 814     public function dns_rr_get_all_by_zone($session_id, $zone_id) {
815         global $app;
816         if(!$this->checkPerm($session_id, 'dns_zone_get')) {
b1a6a5 817             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
MC 818             return false;
c1418f 819         }
cc7a82 820         $sql    = "SELECT * FROM dns_rr WHERE zone = ?";
MC 821         $result = $app->db->queryAllRecords($sql, $zone_id);
b1a6a5 822         return $result;
MC 823     }
c1418f 824
M 825     /**
b1a6a5 826      * Changes DNS zone status
MC 827      * @param  int  session id
828      * @param int  dns soa id
829      * @param string status active or inactive string
830      * @author Julio Montoya <gugli100@gmail.com> BeezNest 2010
c1418f 831      */
b1a6a5 832     public function dns_zone_set_status($session_id, $primary_id, $status) {
MC 833         global $app;
834         if(!$this->checkPerm($session_id, 'dns_zone_set_status')) {
835             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
836             return false;
837         }
838         if(in_array($status, array('active', 'inactive'))) {
839             if ($status == 'active') {
840                 $status = 'Y';
841             } else {
842                 $status = 'N';
843             }
cc7a82 844             $sql = "UPDATE dns_soa SET active = ? WHERE id = ?";
MC 845             $app->db->query($sql, $status, $primary_id);
b1a6a5 846             $result = $app->db->affectedRows();
MC 847             return $result;
848         } else {
c1418f 849             throw new SoapFault('status_undefined', 'The status is not available');
M 850             return false;
b1a6a5 851         }
MC 852     }
853
c1418f 854 }
M 855
b1a6a5 856 ?>