From 4f4b91f5d030756f4b50634cdd978c97dd16bb8d Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Sat, 11 Aug 2007 12:42:22 +0000
Subject: [PATCH] Improved the DNS manager.

---
 install/sql/ispconfig3.sql           | 19 +++++++------------
 interface/web/dns/dns_a_edit.php     | 19 +++++++++++++++++++
 interface/web/dns/dns_alias_edit.php | 18 ++++++++++++++++++
 interface/web/dns/dns_cname_edit.php | 18 ++++++++++++++++++
 interface/web/dns/dns_hinfo_edit.php | 18 ++++++++++++++++++
 interface/web/dns/dns_mx_edit.php    | 18 ++++++++++++++++++
 interface/web/dns/dns_ns_edit.php    | 18 ++++++++++++++++++
 interface/web/dns/dns_ptr_edit.php   | 18 ++++++++++++++++++
 interface/web/dns/dns_rp_edit.php    | 18 ++++++++++++++++++
 interface/web/dns/dns_srv_edit.php   | 18 ++++++++++++++++++
 interface/web/dns/dns_txt_edit.php   | 18 ++++++++++++++++++
 11 files changed, 188 insertions(+), 12 deletions(-)

diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql
index 1c5ad5c9df..61f7cd3607 100644
--- a/install/sql/ispconfig3.sql
+++ b/install/sql/ispconfig3.sql
@@ -77,20 +77,17 @@ CREATE TABLE `dns_rr` (
   `sys_perm_user` varchar(5) NOT NULL,
   `sys_perm_group` varchar(5) NOT NULL,
   `sys_perm_other` varchar(5) NOT NULL,
+  `server_id` int(11) NOT NULL default '1',
   `zone` int(10) unsigned NOT NULL,
   `name` char(64) NOT NULL,
-  `type` enum('A','AAAA','CNAME','HINFO','MX','NAPTR','NS','PTR','RP','SRV','TXT') default NULL,
+  `type` enum('A','AAAA','ALIAS','CNAME','HINFO','MX','NAPTR','NS','PTR','RP','SRV','TXT') default NULL,
   `data` char(128) NOT NULL,
-  `aux` int(10) unsigned NOT NULL,
+  `aux` int(10) unsigned NOT NULL default '0',
   `ttl` int(10) unsigned NOT NULL default '86400',
+  `active` enum('N','Y') NOT NULL default 'Y',
   PRIMARY KEY  (`id`),
   UNIQUE KEY `rr` (`zone`,`name`,`type`,`data`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-
--- 
--- Daten für Tabelle `dns_rr`
--- 
-
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 
 -- --------------------------------------------------------
 
@@ -105,6 +102,7 @@ CREATE TABLE `dns_soa` (
   `sys_perm_user` varchar(5) NOT NULL,
   `sys_perm_group` varchar(5) NOT NULL,
   `sys_perm_other` varchar(5) NOT NULL,
+  `server_id` int(11) NOT NULL default '1',
   `origin` char(255) NOT NULL,
   `ns` char(255) NOT NULL,
   `mbox` char(255) NOT NULL,
@@ -119,11 +117,8 @@ CREATE TABLE `dns_soa` (
   PRIMARY KEY  (`id`),
   UNIQUE KEY `origin` (`origin`),
   KEY `active` (`active`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 
--- 
--- Daten für Tabelle `dns_soa`
--- 
 
 
 -- --------------------------------------------------------
diff --git a/interface/web/dns/dns_a_edit.php b/interface/web/dns/dns_a_edit.php
index ed143424ec..c5a24d1e32 100644
--- a/interface/web/dns/dns_a_edit.php
+++ b/interface/web/dns/dns_a_edit.php
@@ -105,6 +105,25 @@ class page_action extends tform_actions {
 		
 		parent::onSubmit();
 	}
+	
+	function onAfterInsert() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
+	
+	function onAfterUpdate() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
+	
 }
 
 $page = new page_action;
diff --git a/interface/web/dns/dns_alias_edit.php b/interface/web/dns/dns_alias_edit.php
index f08280de65..f359fec69a 100644
--- a/interface/web/dns/dns_alias_edit.php
+++ b/interface/web/dns/dns_alias_edit.php
@@ -105,6 +105,24 @@ class page_action extends tform_actions {
 		
 		parent::onSubmit();
 	}
+	
+	function onAfterInsert() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
+	
+	function onAfterUpdate() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
 }
 
 $page = new page_action;
diff --git a/interface/web/dns/dns_cname_edit.php b/interface/web/dns/dns_cname_edit.php
index 7ea775cbea..8ad00dcbaf 100644
--- a/interface/web/dns/dns_cname_edit.php
+++ b/interface/web/dns/dns_cname_edit.php
@@ -105,6 +105,24 @@ class page_action extends tform_actions {
 		
 		parent::onSubmit();
 	}
+	
+	function onAfterInsert() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
+	
+	function onAfterUpdate() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
 }
 
 $page = new page_action;
diff --git a/interface/web/dns/dns_hinfo_edit.php b/interface/web/dns/dns_hinfo_edit.php
index b2286c2067..fd9341ec63 100644
--- a/interface/web/dns/dns_hinfo_edit.php
+++ b/interface/web/dns/dns_hinfo_edit.php
@@ -105,6 +105,24 @@ class page_action extends tform_actions {
 		
 		parent::onSubmit();
 	}
+	
+	function onAfterInsert() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
+	
+	function onAfterUpdate() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
 }
 
 $page = new page_action;
diff --git a/interface/web/dns/dns_mx_edit.php b/interface/web/dns/dns_mx_edit.php
index d21a99f351..90544da349 100644
--- a/interface/web/dns/dns_mx_edit.php
+++ b/interface/web/dns/dns_mx_edit.php
@@ -105,6 +105,24 @@ class page_action extends tform_actions {
 		
 		parent::onSubmit();
 	}
+	
+	function onAfterInsert() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
+	
+	function onAfterUpdate() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
 }
 
 $page = new page_action;
diff --git a/interface/web/dns/dns_ns_edit.php b/interface/web/dns/dns_ns_edit.php
index 17e466777c..6e777087ea 100644
--- a/interface/web/dns/dns_ns_edit.php
+++ b/interface/web/dns/dns_ns_edit.php
@@ -105,6 +105,24 @@ class page_action extends tform_actions {
 		
 		parent::onSubmit();
 	}
+	
+	function onAfterInsert() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
+	
+	function onAfterUpdate() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
 }
 
 $page = new page_action;
diff --git a/interface/web/dns/dns_ptr_edit.php b/interface/web/dns/dns_ptr_edit.php
index 1250523197..43356482fe 100644
--- a/interface/web/dns/dns_ptr_edit.php
+++ b/interface/web/dns/dns_ptr_edit.php
@@ -105,6 +105,24 @@ class page_action extends tform_actions {
 		
 		parent::onSubmit();
 	}
+	
+	function onAfterInsert() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
+	
+	function onAfterUpdate() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
 }
 
 $page = new page_action;
diff --git a/interface/web/dns/dns_rp_edit.php b/interface/web/dns/dns_rp_edit.php
index a97574a139..e8cb6847ec 100644
--- a/interface/web/dns/dns_rp_edit.php
+++ b/interface/web/dns/dns_rp_edit.php
@@ -105,6 +105,24 @@ class page_action extends tform_actions {
 		
 		parent::onSubmit();
 	}
+	
+	function onAfterInsert() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
+	
+	function onAfterUpdate() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
 }
 
 $page = new page_action;
diff --git a/interface/web/dns/dns_srv_edit.php b/interface/web/dns/dns_srv_edit.php
index 200c03ce0e..f6d362ffa4 100644
--- a/interface/web/dns/dns_srv_edit.php
+++ b/interface/web/dns/dns_srv_edit.php
@@ -105,6 +105,24 @@ class page_action extends tform_actions {
 		
 		parent::onSubmit();
 	}
+	
+	function onAfterInsert() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
+	
+	function onAfterUpdate() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
 }
 
 $page = new page_action;
diff --git a/interface/web/dns/dns_txt_edit.php b/interface/web/dns/dns_txt_edit.php
index d8e7da1e7f..ab923ebfb5 100644
--- a/interface/web/dns/dns_txt_edit.php
+++ b/interface/web/dns/dns_txt_edit.php
@@ -105,6 +105,24 @@ class page_action extends tform_actions {
 		
 		parent::onSubmit();
 	}
+	
+	function onAfterInsert() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
+	
+	function onAfterUpdate() {
+		global $app, $conf;
+		
+		// Update the serial number of the SOA record
+		$soa_id = intval($_POST["zone"]);
+		$serial = time();
+		$app->db->query("UPDATE dns_soa SET serial = $serial WHERE id = $soa_id");
+	}
 }
 
 $page = new page_action;
-- 
GitLab