tbrehm
2006-04-27 cef90d2f9ae449bafcf193212751ce2964192da1
interface/web/dns/soa_edit.php
@@ -1,6 +1,6 @@
<?php
/*
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
Copyright (c) 2005, Till Brehm, Falko Timme, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
@@ -56,6 +56,17 @@
        function onSubmit() {
                global $app, $conf;
                if($app->tform->getCurrentTab() == 'rr'){
                  parent::onSubmit();
                  return true;
                }
                if($this->dataRecord['id'] > 0){
                  if(!$app->tform->checkPerm($this->dataRecord['id'],'u')) $app->error($app->tform->wordbook['error_no_permission']);
                } else {
                  if(!$app->tform->checkPerm($this->dataRecord['id'],'i')) $app->error($app->tform->wordbook['error_no_permission']);
                }
                $app->uses('validate_dns');
                $app->tform->errorMessage .= $app->validate_dns->validate_soa($this->dataRecord);
@@ -66,7 +77,7 @@
                $update = 0;
                if($soa){
                  foreach($soa as $key => $val){
                    if($this->dataRecord[$key] != $val && $key != 'active') $update += 1;
                    if($this->dataRecord[$key] != $val && $key != 'active' && isset($this->dataRecord[$key])) $update += 1;
                  }
                } else { // new record
                  $update = 1;
@@ -184,13 +195,13 @@
                          }
                          if(!$ptr_soa_exist = $app->db->queryOneRecord("SELECT * FROM soa WHERE origin = '".$ptr_soa."'")){
                            $app->db->query("INSERT INTO soa (origin, ns, mbox, serial, refresh, retry, expire, minimum, ttl, active) VALUES ('".$ptr_soa."', '".trim($conf['default_ns'])."', '".trim($conf['default_mbox'])."', '".date("Ymd").'01'."', '".$conf['default_refresh']."', '".$conf['default_retry']."', '".$conf['default_expire']."', '".$conf['default_minimum_ttl']."', '".$conf['default_ttl']."', 'Y')");
                            $app->db->query("INSERT INTO soa (origin, ns, mbox, serial, refresh, retry, expire, minimum, ttl, active, sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other) VALUES ('".$ptr_soa."', '".trim($conf['default_ns'])."', '".trim($conf['default_mbox'])."', '".date("Ymd").'01'."', '".$conf['default_refresh']."', '".$conf['default_retry']."', '".$conf['default_expire']."', '".$conf['default_minimum_ttl']."', '".$conf['default_ttl']."', 'Y', '".$_SESSION['s']['user']['sys_userid']."', '".$_SESSION['s']['user']['sys_groupid']."', '".$_SESSION['s']['user']['sys_perm_user']."', '".$_SESSION['s']['user']['sys_perm_group']."', '".$_SESSION['s']['user']['sys_perm_other']."')");
                            $ptr_soa_id = $app->db->insertID();
                            $app->db->query("INSERT INTO rr (zone, name, type, data, aux, ttl) VALUES ('".$ptr_soa_id."', '".$d."', 'PTR', '".$ptr_soa_rr_data."', '0', '".$conf['default_ttl']."')");
                            $app->db->query("INSERT INTO rr (zone, name, type, data, aux, ttl, sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other) VALUES ('".$ptr_soa_id."', '".$d."', 'PTR', '".$ptr_soa_rr_data."', '0', '".$conf['default_ttl']."', '".$_SESSION['s']['user']['sys_userid']."', '".$_SESSION['s']['user']['sys_groupid']."', '".$_SESSION['s']['user']['sys_perm_user']."', '".$_SESSION['s']['user']['sys_perm_group']."', '".$_SESSION['s']['user']['sys_perm_other']."')");
                          } else {
                            if($ptr_soa_exist['active'] != 'Y') $app->db->query("UPDATE soa SET active = 'Y' WHERE id = ".$ptr_soa_exist['id']);
                            if(!$ptr_soa_rr_exist = $app->db->queryOneRecord("SELECT * FROM rr WHERE zone = '".$ptr_soa_exist['id']."' AND name = '".$d."' AND type = 'PTR'")){
                              $app->db->query("INSERT INTO rr (zone, name, type, data, aux, ttl) VALUES ('".$ptr_soa_exist['id']."', '".$d."', 'PTR', '".$ptr_soa_rr_data."', '0', '".$conf['default_ttl']."')");
                              $app->db->query("INSERT INTO rr (zone, name, type, data, aux, ttl, sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other) VALUES ('".$ptr_soa_exist['id']."', '".$d."', 'PTR', '".$ptr_soa_rr_data."', '0', '".$conf['default_ttl']."', '".$_SESSION['s']['user']['sys_userid']."', '".$_SESSION['s']['user']['sys_groupid']."', '".$_SESSION['s']['user']['sys_perm_user']."', '".$_SESSION['s']['user']['sys_perm_group']."', '".$_SESSION['s']['user']['sys_perm_other']."')");
                              // increase serial of PTR SOA
                              if(!in_array($ptr_soa_exist['id'], $increased_serials)){
                                $ptr_soa_new_serial = $app->validate_dns->increase_serial($ptr_soa_exist['serial']);