From b418037acae8a5d9a65dd55c58a003d393cadf21 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Wed, 15 Apr 2015 15:05:12 +0200
Subject: [PATCH] - ported some patches

---
 .../sql/incremental/upd_dev_collection.sql    |  8 ++-
 install/sql/ispconfig3.sql                    |  9 +--
 interface/lib/classes/validate_dkim.inc.php   |  6 +-
 .../admin/form/directive_snippets.tform.php   | 11 ++++
 .../templates/directive_snippets_edit.htm     | 12 +++-
 interface/web/dns/form/dns_a.tform.php        |  2 +-
 interface/web/dns/form/dns_aaaa.tform.php     |  2 +-
 interface/web/dns/form/dns_alias.tform.php    |  2 +-
 interface/web/dns/form/dns_cname.tform.php    |  2 +-
 interface/web/dns/form/dns_dkim.tform.php     |  2 +-
 interface/web/dns/form/dns_hinfo.tform.php    |  2 +-
 interface/web/dns/form/dns_mx.tform.php       |  2 +-
 interface/web/dns/form/dns_ns.tform.php       |  2 +-
 interface/web/dns/form/dns_ptr.tform.php      |  2 +-
 interface/web/dns/form/dns_rp.tform.php       |  2 +-
 interface/web/dns/form/dns_soa.tform.php      |  2 +-
 interface/web/dns/form/dns_spf.tform.php      |  2 +-
 interface/web/dns/form/dns_srv.tform.php      |  2 +-
 interface/web/dns/form/dns_txt.tform.php      |  2 +-
 interface/web/dns/list/dns_a.list.php         |  2 +-
 .../web/mail/templates/mail_domain_edit.htm   |  2 +-
 interface/web/tools/dns_import_tupa.php       |  2 +-
 remoting_client/examples/dns_a_add.php        |  2 +-
 remoting_client/examples/dns_aaaa_add.php     |  2 +-
 remoting_client/examples/dns_alias_add.php    |  2 +-
 remoting_client/examples/dns_cname_add.php    |  2 +-
 remoting_client/examples/dns_hinfo_add.php    |  2 +-
 remoting_client/examples/dns_mx_add.php       |  2 +-
 remoting_client/examples/dns_ns_add.php       |  2 +-
 remoting_client/examples/dns_ptr_add.php      |  2 +-
 remoting_client/examples/dns_rp_add.php       |  2 +-
 remoting_client/examples/dns_srv_add.php      |  2 +-
 remoting_client/examples/dns_txt_add.php      |  2 +-
 remoting_client/examples/dns_zone_add.php     |  4 +-
 .../plugins-available/apache2_plugin.inc.php  | 60 +++++++++++++++++++
 .../plugins-available/bind_dlz_plugin.inc.php |  2 +-
 server/plugins-available/nginx_plugin.inc.php | 20 +++++++
 37 files changed, 149 insertions(+), 39 deletions(-)

diff --git a/install/sql/incremental/upd_dev_collection.sql b/install/sql/incremental/upd_dev_collection.sql
index 6eea12b71a..4395655c62 100644
--- a/install/sql/incremental/upd_dev_collection.sql
+++ b/install/sql/incremental/upd_dev_collection.sql
@@ -20,7 +20,7 @@ mbox={EMAIL}.
 refresh=7200
 retry=540
 expire=604800
-minimum=86400
+minimum=3600
 ttl=3600
 
 [DNS_RECORDS]
@@ -134,3 +134,9 @@ CREATE TABLE `xmpp_user` (
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
 
 -- --------------------------------------------------------
+
+UPDATE `dbispconfig`.`sys_ini` SET `default_logo` = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABBCAYAAACU5+uOAAAItUlEQVR42u1dCWwVVRStUJZCK6HsFNAgWpaCJkKICZKApKUFhURQpEnZF4EEUJZYEEpBIamgkQpUQBZRW7YCBqQsggsQEAgKLbIGCYsSCNqyQ8D76h18Hd/MvJk/n/bXc5KT+TNz79vPzNv+/2FhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAe++s0akTsRZxMnE6cGkKcxkwhPofaBPwWRzxxB/EO8UGI8xhxEGoV8EscY8qBKFRcgdoFAhXHC+VUHAbHo5aBQASyrZwL5DoxEjUNeBXI9XIuEMEE1DTgVSA3FA3qIDEtBLnTQiBDUNOAV4EUKhpURojmZQQEAjwKgSwK0bykWQgEU74ABAKBABAIBOIJffoNrkRsS0whDiMO5uNw4gBiSxvfGOJrbDtMOgr2JNa18HmZmETsopnGp4h9xdF0TcQRb8NEPkawTzv2qaWIoybnZYRUBoJD+difGAuBlCy0qsRM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gUAEUpV4NEREstyDQNqjloFARVKL/xukrAvkGjGC09zGwfYKsQdqF/BTKMnEJcTtxC3EPAU3iic5cRkfjc/ZFvZuuZm4gXjOouG35LQ2Yfutkq/4pfpN/E9TDVCjQGkJqQExho+CjYlRPseRiQE3EIriaMZTw4K3mOJv23J8jme23RsEAMqqQJrb9PnnEbPEVpUAuJD4Mf/PoCqeONQCUJYFElGKf7ojpnqjUQtAWRdJaf1t2w8ofSAUBNKulATSEaUPhIpIRj9icbyFUgdCTSRTeR0i2HwfpQ0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQBnG392D9QU+JXhxAAAAAElFTkSuQmCC' WHERE `sys_ini`.`sysini_id` = 1;
+
+ALTER TABLE `directive_snippets` ADD `required_php_snippets` VARCHAR(255) NOT NULL DEFAULT '' AFTER `customer_viewable`;
+ALTER TABLE `dns_rr` CHANGE `ttl` `ttl` INT(11) UNSIGNED NOT NULL DEFAULT '3600';
+ALTER TABLE `dns_soa` CHANGE `minimum` `minimum` INT(11) UNSIGNED NOT NULL DEFAULT '3600', CHANGE `ttl` `ttl` INT(11) UNSIGNED NOT NULL DEFAULT '3600';
\ No newline at end of file
diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql
index 5011f16f9f..a020d028a4 100644
--- a/install/sql/ispconfig3.sql
+++ b/install/sql/ispconfig3.sql
@@ -442,6 +442,7 @@ CREATE TABLE IF NOT EXISTS `directive_snippets` (
   `type` varchar(255) DEFAULT NULL,
   `snippet` mediumtext,
   `customer_viewable` ENUM('n','y') NOT NULL DEFAULT 'n',
+  `required_php_snippets` varchar(255) NOT NULL DEFAULT '',
   `active` enum('n','y') NOT NULL DEFAULT 'y',
   PRIMARY KEY (`directive_snippets_id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
@@ -465,7 +466,7 @@ CREATE TABLE `dns_rr` (
   `type` enum('A','AAAA','ALIAS','CNAME','HINFO','MX','NAPTR','NS','PTR','RP','SRV','TXT') default NULL,
   `data` TEXT NOT NULL DEFAULT '',
   `aux` int(11) unsigned NOT NULL default '0',
-  `ttl` int(11) unsigned NOT NULL default '86400',
+  `ttl` int(11) unsigned NOT NULL default '3600',
   `active` enum('N','Y') NOT NULL default 'Y',
   `stamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
   `serial` int(10) unsigned default NULL,
@@ -517,8 +518,8 @@ CREATE TABLE `dns_soa` (
   `refresh` int(11) unsigned NOT NULL default '28800',
   `retry` int(11) unsigned NOT NULL default '7200',
   `expire` int(11) unsigned NOT NULL default '604800',
-  `minimum` int(11) unsigned NOT NULL default '86400',
-  `ttl` int(11) unsigned NOT NULL default '86400',
+  `minimum` int(11) unsigned NOT NULL default '3600',
+  `ttl` int(11) unsigned NOT NULL default '3600',
   `active` enum('N','Y') NOT NULL DEFAULT 'N',
   `xfer` varchar(255) NOT NULL DEFAULT '',
   `also_notify` varchar(255) default NULL,
@@ -2316,7 +2317,7 @@ INSERT INTO `country` (`iso`, `name`, `printable_name`, `iso3`, `numcode`, `eu`)
 -- Dumping data for table `dns_template`
 -- 
 
-INSERT INTO `dns_template` (`template_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `name`, `fields`, `template`, `visible`) VALUES (1, 1, 1, 'riud', 'riud', '', 'Default', 'DOMAIN,IP,NS1,NS2,EMAIL,DKIM', '[ZONE]\norigin={DOMAIN}.\nns={NS1}.\nmbox={EMAIL}.\nrefresh=7200\nretry=540\nexpire=604800\nminimum=86400\nttl=3600\n\n[DNS_RECORDS]\nA|{DOMAIN}.|{IP}|0|3600\nA|www|{IP}|0|3600\nA|mail|{IP}|0|3600\nNS|{DOMAIN}.|{NS1}.|0|3600\nNS|{DOMAIN}.|{NS2}.|0|3600\nMX|{DOMAIN}.|mail.{DOMAIN}.|10|3600\nTXT|{DOMAIN}.|v=spf1 mx a ~all|0|3600', 'y');
+INSERT INTO `dns_template` (`template_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `name`, `fields`, `template`, `visible`) VALUES (1, 1, 1, 'riud', 'riud', '', 'Default', 'DOMAIN,IP,NS1,NS2,EMAIL,DKIM', '[ZONE]\norigin={DOMAIN}.\nns={NS1}.\nmbox={EMAIL}.\nrefresh=7200\nretry=540\nexpire=604800\nminimum=3600\nttl=3600\n\n[DNS_RECORDS]\nA|{DOMAIN}.|{IP}|0|3600\nA|www|{IP}|0|3600\nA|mail|{IP}|0|3600\nNS|{DOMAIN}.|{NS1}.|0|3600\nNS|{DOMAIN}.|{NS2}.|0|3600\nMX|{DOMAIN}.|mail.{DOMAIN}.|10|3600\nTXT|{DOMAIN}.|v=spf1 mx a ~all|0|3600', 'y');
 
 
 -- --------------------------------------------------------
diff --git a/interface/lib/classes/validate_dkim.inc.php b/interface/lib/classes/validate_dkim.inc.php
index 71fd8c5454..5d7fb8f1e3 100644
--- a/interface/lib/classes/validate_dkim.inc.php
+++ b/interface/lib/classes/validate_dkim.inc.php
@@ -62,8 +62,10 @@ class validate_dkim {
 	 */
 	function check_template($field_name, $field_value, $validator) {
 		$dkim=false;
-		foreach($field_value as $field ) { if($field == 'DKIM') $dkim=true; }
-		if ($dkim && $field_value[0]!='DOMAIN') return $this->get_error($validator['errmsg']);
+		if(is_array($field_value) && !empty($field_value)){
+			foreach($field_value as $field ) { if($field == 'DKIM') $dkim=true; }
+			if ($dkim && $field_value[0]!='DOMAIN') return $this->get_error($validator['errmsg']);
+		}
 	}
 
 
diff --git a/interface/web/admin/form/directive_snippets.tform.php b/interface/web/admin/form/directive_snippets.tform.php
index 8db725b95f..0c2502c6c4 100644
--- a/interface/web/admin/form/directive_snippets.tform.php
+++ b/interface/web/admin/form/directive_snippets.tform.php
@@ -105,6 +105,17 @@ $form["tabs"]['directive_snippets'] = array (
 			'default' => 'y',
 			'value'  => array(0 => 'n', 1 => 'y')
 		),
+		'required_php_snippets' => array (
+			'datatype' => 'VARCHAR',
+			'formtype' => 'CHECKBOXARRAY',
+			'default' => '',
+			'datasource' => array (  'type' => 'SQL',
+				'querystring' => "SELECT directive_snippets_id,name FROM directive_snippets WHERE type = 'php' AND active = 'y'ORDER BY name",
+				'keyfield' => 'directive_snippets_id',
+				'valuefield' => 'name'
+			),
+			'separator' => ',',
+		),
 		//#################################
 		// ENDE Datatable fields
 		//#################################
diff --git a/interface/web/admin/templates/directive_snippets_edit.htm b/interface/web/admin/templates/directive_snippets_edit.htm
index 7729fc163d..21b76867ec 100644
--- a/interface/web/admin/templates/directive_snippets_edit.htm
+++ b/interface/web/admin/templates/directive_snippets_edit.htm
@@ -17,6 +17,12 @@
 			<div class="form-group">
                 <label for="snippet" class="col-sm-3 control-label">{tmpl_var name='snippet_txt'}</label>
                 <div class="col-sm-9"><textarea class="form-control" name="snippet" id="snippet" rows='10' cols='50'>{tmpl_var name='snippet'}</textarea></div><span class="nginx"> &nbsp; {tmpl_var name='variables_txt'}: </span><a href="javascript:void(0);" class="addPlaceholder nginx">{DOCROOT}</a><span class="nginx">, </span><a href="javascript:void(0);" class="addPlaceholder nginx">{FASTCGIPASS}</a>
+            </div>
+			<div class="form-group php">
+                <label class="col-sm-3 control-label">{tmpl_var name='required_php_snippets_txt'}</label>
+                <div class="col-sm-9">
+                    {tmpl_var name='required_php_snippets'}
+                </div>
             </div>
 			<div class="form-group">
                 <label class="col-sm-3 control-label">{tmpl_var name='customer_viewable_txt'}</label>
@@ -48,15 +54,19 @@
 	
 	if (jQuery('#type').val() != 'nginx' && jQuery('#type').val() != 'apache') {
 		jQuery('#customer_viewable').closest('div.ctrlHolder:visible').hide();
-	}else {
+		jQuery('.php:visible').hide();
+	} else {
 		jQuery('#customer_viewable').closest('div.ctrlHolder:hidden').show();
+		jQuery('.php:hidden').show();
 	}
     
     jQuery('#type').change(function(){
 		if (jQuery(this).val() != 'nginx' && jQuery(this).val() != 'apache') {
 			jQuery('#customer_viewable').closest('div.ctrlHolder:visible').hide();
+			jQuery('.php:visible').hide();
 		} else {
 			jQuery('#customer_viewable').closest('div.ctrlHolder:hidden').show();
+			jQuery('.php:hidden').show();
 		}
         if(jQuery(this).val() == 'nginx'){
             jQuery('.nginx:hidden').show();
diff --git a/interface/web/dns/form/dns_a.tform.php b/interface/web/dns/form/dns_a.tform.php
index 95aa5b81c0..cd5a3eb9ab 100644
--- a/interface/web/dns/form/dns_a.tform.php
+++ b/interface/web/dns/form/dns_a.tform.php
@@ -133,7 +133,7 @@ $form["tabs"]['dns'] = array (
 					'range' => '60:',
 					'errmsg'=> 'ttl_range_error'),
 			),
-			'default' => '86400',
+			'default' => '3600',
 			'value'  => '',
 			'width'  => '10',
 			'maxlength' => '10'
diff --git a/interface/web/dns/form/dns_aaaa.tform.php b/interface/web/dns/form/dns_aaaa.tform.php
index 47bbac39c2..d381d51879 100644
--- a/interface/web/dns/form/dns_aaaa.tform.php
+++ b/interface/web/dns/form/dns_aaaa.tform.php
@@ -126,7 +126,7 @@ $form["tabs"]['dns'] = array (
 					'range' => '60:',
 					'errmsg'=> 'ttl_range_error'),
 			),
-			'default' => '86400',
+			'default' => '3600',
 			'value'  => '',
 			'width'  => '10',
 			'maxlength' => '10'
diff --git a/interface/web/dns/form/dns_alias.tform.php b/interface/web/dns/form/dns_alias.tform.php
index 663bf84278..defcda0853 100644
--- a/interface/web/dns/form/dns_alias.tform.php
+++ b/interface/web/dns/form/dns_alias.tform.php
@@ -142,7 +142,7 @@ $form["tabs"]['dns'] = array (
 					'range' => '60:',
 					'errmsg'=> 'ttl_range_error'),
 			),
-			'default' => '86400',
+			'default' => '3600',
 			'value'  => '',
 			'width'  => '10',
 			'maxlength' => '10'
diff --git a/interface/web/dns/form/dns_cname.tform.php b/interface/web/dns/form/dns_cname.tform.php
index 957e6e19e5..5fdf8c9b4e 100644
--- a/interface/web/dns/form/dns_cname.tform.php
+++ b/interface/web/dns/form/dns_cname.tform.php
@@ -140,7 +140,7 @@ $form["tabs"]['dns'] = array (
 					'range' => '60:',
 					'errmsg'=> 'ttl_range_error'),
 			),
-			'default' => '86400',
+			'default' => '3600',
 			'value'  => '',
 			'width'  => '10',
 			'maxlength' => '10'
diff --git a/interface/web/dns/form/dns_dkim.tform.php b/interface/web/dns/form/dns_dkim.tform.php
index bbc1214f22..550255da46 100644
--- a/interface/web/dns/form/dns_dkim.tform.php
+++ b/interface/web/dns/form/dns_dkim.tform.php
@@ -120,7 +120,7 @@ $form["tabs"]['dns'] = array (
 							'range' => '60:',
 							'errmsg'=> 'ttl_range_error'),
 			),
-			'default' => '86400',
+			'default' => '3600',
 			'value'  => '',
 			'width'  => '10',
 			'maxlength' => '10'
diff --git a/interface/web/dns/form/dns_hinfo.tform.php b/interface/web/dns/form/dns_hinfo.tform.php
index 231bdfc65a..76c8c79dc0 100644
--- a/interface/web/dns/form/dns_hinfo.tform.php
+++ b/interface/web/dns/form/dns_hinfo.tform.php
@@ -132,7 +132,7 @@ $form["tabs"]['dns'] = array (
 					'range' => '60:',
 					'errmsg'=> 'ttl_range_error'),
 			),
-			'default' => '86400',
+			'default' => '3600',
 			'value'  => '',
 			'width'  => '10',
 			'maxlength' => '10'
diff --git a/interface/web/dns/form/dns_mx.tform.php b/interface/web/dns/form/dns_mx.tform.php
index d5faeebcfa..9aace37ae7 100644
--- a/interface/web/dns/form/dns_mx.tform.php
+++ b/interface/web/dns/form/dns_mx.tform.php
@@ -141,7 +141,7 @@ $form["tabs"]['dns'] = array (
 					'range' => '60:',
 					'errmsg'=> 'ttl_range_error'),
 			),
-			'default' => '86400',
+			'default' => '3600',
 			'value'  => '',
 			'width'  => '10',
 			'maxlength' => '10'
diff --git a/interface/web/dns/form/dns_ns.tform.php b/interface/web/dns/form/dns_ns.tform.php
index 82b30901fd..063a896de3 100644
--- a/interface/web/dns/form/dns_ns.tform.php
+++ b/interface/web/dns/form/dns_ns.tform.php
@@ -140,7 +140,7 @@ $form["tabs"]['dns'] = array (
 					'range' => '60:',
 					'errmsg'=> 'ttl_range_error'),
 			),
-			'default' => '86400',
+			'default' => '3600',
 			'value'  => '',
 			'width'  => '10',
 			'maxlength' => '10'
diff --git a/interface/web/dns/form/dns_ptr.tform.php b/interface/web/dns/form/dns_ptr.tform.php
index 59a91e7c8f..4cc0462522 100644
--- a/interface/web/dns/form/dns_ptr.tform.php
+++ b/interface/web/dns/form/dns_ptr.tform.php
@@ -140,7 +140,7 @@ $form["tabs"]['dns'] = array (
 					'range' => '60:',
 					'errmsg'=> 'ttl_range_error'),
 			),
-			'default' => '86400',
+			'default' => '3600',
 			'value'  => '',
 			'width'  => '10',
 			'maxlength' => '10'
diff --git a/interface/web/dns/form/dns_rp.tform.php b/interface/web/dns/form/dns_rp.tform.php
index 35b8e55ad1..5f4610a45b 100644
--- a/interface/web/dns/form/dns_rp.tform.php
+++ b/interface/web/dns/form/dns_rp.tform.php
@@ -133,7 +133,7 @@ $form["tabs"]['dns'] = array (
 					'range' => '60:',
 					'errmsg'=> 'ttl_range_error'),
 			),
-			'default' => '86400',
+			'default' => '3600',
 			'value'  => '',
 			'width'  => '10',
 			'maxlength' => '10'
diff --git a/interface/web/dns/form/dns_soa.tform.php b/interface/web/dns/form/dns_soa.tform.php
index 1e4f9a63e1..02afa86c53 100644
--- a/interface/web/dns/form/dns_soa.tform.php
+++ b/interface/web/dns/form/dns_soa.tform.php
@@ -197,7 +197,7 @@ $form["tabs"]['dns_soa'] = array (
 					'range' => '60:',
 					'errmsg'=> 'minimum_range_error'),
 			),
-			'default' => '86400',
+			'default' => '3600',
 			'value'  => '',
 			'width'  => '10',
 			'maxlength' => '10'
diff --git a/interface/web/dns/form/dns_spf.tform.php b/interface/web/dns/form/dns_spf.tform.php
index 00ccb7628c..ea2cf8310c 100644
--- a/interface/web/dns/form/dns_spf.tform.php
+++ b/interface/web/dns/form/dns_spf.tform.php
@@ -127,7 +127,7 @@ $form["tabs"]['dns'] = array (
 					'range' => '60:',
 					'errmsg'=> 'ttl_range_error'),
 			),
-			'default' => '86400',
+			'default' => '3600',
 			'value'  => '',
 			'width'  => '10',
 			'maxlength' => '10'
diff --git a/interface/web/dns/form/dns_srv.tform.php b/interface/web/dns/form/dns_srv.tform.php
index 2f35fd53dd..ee0674fd19 100644
--- a/interface/web/dns/form/dns_srv.tform.php
+++ b/interface/web/dns/form/dns_srv.tform.php
@@ -131,7 +131,7 @@ $form["tabs"]['dns'] = array (
 					'range' => '60:',
 					'errmsg'=> 'ttl_range_error'),
 			),
-			'default' => '86400',
+			'default' => '3600',
 			'value'  => '',
 			'width'  => '10',
 			'maxlength' => '10'
diff --git a/interface/web/dns/form/dns_txt.tform.php b/interface/web/dns/form/dns_txt.tform.php
index 70e0fc5f0d..01b731a2e4 100644
--- a/interface/web/dns/form/dns_txt.tform.php
+++ b/interface/web/dns/form/dns_txt.tform.php
@@ -137,7 +137,7 @@ $form["tabs"]['dns'] = array (
 					'range' => '60:',
 					'errmsg'=> 'ttl_range_error'),
 			),
-			'default' => '86400',
+			'default' => '3600',
 			'value'  => '',
 			'width'  => '10',
 			'maxlength' => '10'
diff --git a/interface/web/dns/list/dns_a.list.php b/interface/web/dns/list/dns_a.list.php
index 3b47cf10c2..65429dfa7b 100644
--- a/interface/web/dns/list/dns_a.list.php
+++ b/interface/web/dns/list/dns_a.list.php
@@ -132,7 +132,7 @@ $liste["item"][] = array( 'field'  => "type",
 	'prefix' => "",
 	'suffix' => "",
 	'width'  => "",
-	'value'  => array('A'=>'A', 'AAAA' => 'AAAA', 'ALIAS'=>'ALIAS', 'CNAME'=>'CNAME', 'HINFO'=>'HINFO', 'MX'=>'MX', 'NS'=>'NS', 'PTR'=>'PTR', 'RP'=>'RP', 'SRV'=>'SRV', 'TXT'=>'TXT'));
+	'value'  => array('A'=>'A', 'AAAA' => 'AAAA', 'ALIAS'=>'ALIAS', 'CNAME'=>'CNAME', 'HINFO'=>'HINFO', 'MX'=>'MX', 'NS'=>'NS', 'PTR'=>'PTR', 'RP'=>'RP', 'SPF'=>'SPF', 'SRV'=>'SRV', 'TXT'=>'TXT'));
 
 
 ?>
diff --git a/interface/web/mail/templates/mail_domain_edit.htm b/interface/web/mail/templates/mail_domain_edit.htm
index f56c27d878..307b0d1531 100644
--- a/interface/web/mail/templates/mail_domain_edit.htm
+++ b/interface/web/mail/templates/mail_domain_edit.htm
@@ -86,7 +86,7 @@
 			<tmpl_else>
 				<input type="hidden" name="domain_module" value="0" id="domain_module" />
 			</tmpl_if>
-            <div class="col-sm-3"></div><div class="col-sm-9"><button class="btn btn-default formbutton-default" type="button" data-toggle="collapse" data-target="#toggle-dkim" aria-expanded="false" aria-controls="toggle-dkim">{tmpl_var name='dkim_settings_txt'}</button></div>
+            <div class="col-sm-12"><button class="btn btn-default formbutton-default" type="button" data-toggle="collapse" data-target="#toggle-dkim" aria-expanded="false" aria-controls="toggle-dkim">{tmpl_var name='dkim_settings_txt'}</button></div>
             <div id="toggle-dkim" class="collapse">
               <div class="form-group">
                 <label class="col-sm-3 control-label">{tmpl_var name='dkim_txt'}</label>
diff --git a/interface/web/tools/dns_import_tupa.php b/interface/web/tools/dns_import_tupa.php
index b45a11b605..b81a83bdec 100644
--- a/interface/web/tools/dns_import_tupa.php
+++ b/interface/web/tools/dns_import_tupa.php
@@ -96,7 +96,7 @@ if(isset($_POST['start']) && $_POST['start'] == 1) {
 					$refresh = 7200;
 					$retry =  540;
 					$expire = 604800;
-					$minimum = 86400;
+					$minimum = 3600;
 					$ttl = $soa['ttl'];
 
 					$insert_data = array(
diff --git a/remoting_client/examples/dns_a_add.php b/remoting_client/examples/dns_a_add.php
index 6bcb33c668..b669daaa1c 100644
--- a/remoting_client/examples/dns_a_add.php
+++ b/remoting_client/examples/dns_a_add.php
@@ -23,7 +23,7 @@ try {
 		'type' => 'a',
 		'data' => '192.168.1.88',
 		'aux' => '0',
-		'ttl' => '86400',
+		'ttl' => '3600',
 		'active' => 'y',
 		'stamp' => 'CURRENT_TIMESTAMP',
 		'serial' => '1',
diff --git a/remoting_client/examples/dns_aaaa_add.php b/remoting_client/examples/dns_aaaa_add.php
index 4ee460b5be..eff4148f28 100644
--- a/remoting_client/examples/dns_aaaa_add.php
+++ b/remoting_client/examples/dns_aaaa_add.php
@@ -23,7 +23,7 @@ try {
 		'type' => 'aaaa',
 		'data' => '3ffe:b00:c18:3::a',
 		'aux' => '0',
-		'ttl' => '86400',
+		'ttl' => '3600',
 		'active' => 'y',
 		'stamp' => 'CURRENT_TIMESTAMP',
 		'serial' => '1',
diff --git a/remoting_client/examples/dns_alias_add.php b/remoting_client/examples/dns_alias_add.php
index 5b1c684cef..dd8a4da4b0 100644
--- a/remoting_client/examples/dns_alias_add.php
+++ b/remoting_client/examples/dns_alias_add.php
@@ -23,7 +23,7 @@ try {
 		'type' => 'alias',
 		'data' => 'hostmachine',
 		'aux' => '0',
-		'ttl' => '86400',
+		'ttl' => '3600',
 		'active' => 'y',
 		'stamp' => 'CURRENT_TIMESTAMP',
 		'serial' => '1',
diff --git a/remoting_client/examples/dns_cname_add.php b/remoting_client/examples/dns_cname_add.php
index 2d70ca65b4..7731a54730 100644
--- a/remoting_client/examples/dns_cname_add.php
+++ b/remoting_client/examples/dns_cname_add.php
@@ -23,7 +23,7 @@ try {
 		'type' => 'cname',
 		'data' => 'hostmachine',
 		'aux' => '0',
-		'ttl' => '86400',
+		'ttl' => '3600',
 		'active' => 'y',
 		'stamp' => 'CURRENT_TIMESTAMP',
 		'serial' => '1',
diff --git a/remoting_client/examples/dns_hinfo_add.php b/remoting_client/examples/dns_hinfo_add.php
index a0a8c47b3c..106c79083e 100644
--- a/remoting_client/examples/dns_hinfo_add.php
+++ b/remoting_client/examples/dns_hinfo_add.php
@@ -23,7 +23,7 @@ try {
 		'type' => 'hinfo',
 		'data' => '"Pentium Pro" Linux',
 		'aux' => '0',
-		'ttl' => '86400',
+		'ttl' => '3600',
 		'active' => 'y',
 		'stamp' => 'CURRENT_TIMESTAMP',
 		'serial' => '1',
diff --git a/remoting_client/examples/dns_mx_add.php b/remoting_client/examples/dns_mx_add.php
index b1e9617809..d0838216cd 100644
--- a/remoting_client/examples/dns_mx_add.php
+++ b/remoting_client/examples/dns_mx_add.php
@@ -23,7 +23,7 @@ try {
 		'type' => 'mx',
 		'data' => 'mail',
 		'aux' => '0',
-		'ttl' => '86400',
+		'ttl' => '3600',
 		'active' => 'y',
 		'stamp' => 'CURRENT_TIMESTAMP',
 		'serial' => '1',
diff --git a/remoting_client/examples/dns_ns_add.php b/remoting_client/examples/dns_ns_add.php
index d650d2a999..381041addf 100644
--- a/remoting_client/examples/dns_ns_add.php
+++ b/remoting_client/examples/dns_ns_add.php
@@ -23,7 +23,7 @@ try {
 		'type' => 'ns',
 		'data' => 'ns1',
 		'aux' => '0',
-		'ttl' => '86400',
+		'ttl' => '3600',
 		'active' => 'y',
 		'stamp' => 'CURRENT_TIMESTAMP',
 		'serial' => '1',
diff --git a/remoting_client/examples/dns_ptr_add.php b/remoting_client/examples/dns_ptr_add.php
index 6d4ccab9fa..a2dbdf54f5 100644
--- a/remoting_client/examples/dns_ptr_add.php
+++ b/remoting_client/examples/dns_ptr_add.php
@@ -23,7 +23,7 @@ try {
 		'type' => 'ptr',
 		'data' => 'webmaster.test.int.',
 		'aux' => '0',
-		'ttl' => '86400',
+		'ttl' => '3600',
 		'active' => 'y',
 		'stamp' => 'CURRENT_TIMESTAMP',
 		'serial' => '1',
diff --git a/remoting_client/examples/dns_rp_add.php b/remoting_client/examples/dns_rp_add.php
index a30b703701..27329bbe75 100644
--- a/remoting_client/examples/dns_rp_add.php
+++ b/remoting_client/examples/dns_rp_add.php
@@ -23,7 +23,7 @@ try {
 		'type' => 'rp',
 		'data' => 'webmaster.test.int. contactinfo.test.int',
 		'aux' => '0',
-		'ttl' => '86400',
+		'ttl' => '3600',
 		'active' => 'y',
 		'stamp' => 'CURRENT_TIMESTAMP',
 		'serial' => '1',
diff --git a/remoting_client/examples/dns_srv_add.php b/remoting_client/examples/dns_srv_add.php
index 75c7df4817..6270db75a4 100644
--- a/remoting_client/examples/dns_srv_add.php
+++ b/remoting_client/examples/dns_srv_add.php
@@ -23,7 +23,7 @@ try {
 		'type' => 'srv',
 		'data' => '0 9 server.test.int.',
 		'aux' => '0',
-		'ttl' => '86400',
+		'ttl' => '3600',
 		'active' => 'y',
 		'stamp' => 'CURRENT_TIMESTAMP',
 		'serial' => '1',
diff --git a/remoting_client/examples/dns_txt_add.php b/remoting_client/examples/dns_txt_add.php
index 4ce025e64f..90f06095ec 100644
--- a/remoting_client/examples/dns_txt_add.php
+++ b/remoting_client/examples/dns_txt_add.php
@@ -23,7 +23,7 @@ try {
 		'type' => 'txt',
 		'data' => 'any text can go here',
 		'aux' => '0',
-		'ttl' => '86400',
+		'ttl' => '3600',
 		'active' => 'y',
 		'stamp' => 'CURRENT_TIMESTAMP',
 		'serial' => '1',
diff --git a/remoting_client/examples/dns_zone_add.php b/remoting_client/examples/dns_zone_add.php
index 6772409682..62937c0bd3 100644
--- a/remoting_client/examples/dns_zone_add.php
+++ b/remoting_client/examples/dns_zone_add.php
@@ -25,8 +25,8 @@ try {
 		'refresh' => '28800',
 		'retry' => '7200',
 		'expire' => '604800',
-		'minimum' => '86400',
-		'ttl' => '86400',
+		'minimum' => '3600',
+		'ttl' => '3600',
 		'active' => 'y',
 		'xfer' => '',
 		'also_notify' => '',
diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index 1676a1a7a8..43b06f3dc5 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -161,6 +161,26 @@ class apache2_plugin {
 			if($master_php_ini_path != '' && substr($master_php_ini_path, -7) == 'php.ini' && is_file($master_php_ini_path)) {
 				$php_ini_content .= $app->system->file_get_contents($master_php_ini_path)."\n";
 			}
+			
+			if(intval($web_data['directive_snippets_id']) > 0){
+				$snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'nginx' AND active = 'y' AND customer_viewable = 'y'", intval($web_data['directive_snippets_id']));
+				if(isset($snippet['required_php_snippets']) && trim($snippet['required_php_snippets']) != ''){
+					$required_php_snippets = explode(',', trim($snippet['required_php_snippets']));
+					if(is_array($required_php_snippets) && !empty($required_php_snippets)){
+						foreach($required_php_snippets as $required_php_snippet){
+							$required_php_snippet = intval($required_php_snippet);
+							if($required_php_snippet > 0){
+								$php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet);
+								$php_snippet['snippet'] = trim($php_snippet['snippet']);
+								if($php_snippet['snippet'] != ''){
+									$web_data['custom_php_ini'] .= "\n".$php_snippet['snippet'];
+								}
+							}
+						}
+					}
+				}
+			}
+		
 			$php_ini_content .= str_replace("\r", '', trim($web_data['custom_php_ini']));
 			$app->system->file_put_contents($custom_php_ini_dir.'/php.ini', $php_ini_content);
 			$app->log('Info: rewrote custom php.ini for web ' . $web_data['domain_id'] . ' (' . $web_data['domain'] . ').', LOGLEVEL_DEBUG);
@@ -1008,6 +1028,26 @@ class apache2_plugin {
 				$php_ini_content .= $app->system->file_get_contents($master_php_ini_path)."\n";
 			}
 			$php_ini_content .= str_replace("\r", '', trim($data['new']['custom_php_ini']));
+			
+			if(intval($data['new']['directive_snippets_id']) > 0){
+				$snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'nginx' AND active = 'y' AND customer_viewable = 'y'", intval($data['new']['directive_snippets_id']));
+				if(isset($snippet['required_php_snippets']) && trim($snippet['required_php_snippets']) != ''){
+					$required_php_snippets = explode(',', trim($snippet['required_php_snippets']));
+					if(is_array($required_php_snippets) && !empty($required_php_snippets)){
+						foreach($required_php_snippets as $required_php_snippet){
+							$required_php_snippet = intval($required_php_snippet);
+							if($required_php_snippet > 0){
+								$php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet);
+								$php_snippet['snippet'] = trim($php_snippet['snippet']);
+								if($php_snippet['snippet'] != ''){
+									$php_ini_content .= "\n".$php_snippet['snippet'];
+								}
+							}
+						}
+					}
+				}
+			}
+		
 			$app->system->file_put_contents($custom_php_ini_dir.'/php.ini', $php_ini_content);
 		} else {
 			$has_custom_php_ini = false;
@@ -2864,6 +2904,26 @@ class apache2_plugin {
 		// Custom php.ini settings
 		$final_php_ini_settings = array();
 		$custom_php_ini_settings = trim($data['new']['custom_php_ini']);
+		
+		if(intval($data['new']['directive_snippets_id']) > 0){
+			$snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'apache' AND active = 'y' AND customer_viewable = 'y'", intval($data['new']['directive_snippets_id']));
+			if(isset($snippet['required_php_snippets']) && trim($snippet['required_php_snippets']) != ''){
+				$required_php_snippets = explode(',', trim($snippet['required_php_snippets']));
+				if(is_array($required_php_snippets) && !empty($required_php_snippets)){
+					foreach($required_php_snippets as $required_php_snippet){
+						$required_php_snippet = intval($required_php_snippet);
+						if($required_php_snippet > 0){
+							$php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet);
+							$php_snippet['snippet'] = trim($php_snippet['snippet']);
+							if($php_snippet['snippet'] != ''){
+								$custom_php_ini_settings .= "\n".$php_snippet['snippet'];
+							}
+						}
+					}
+				}
+			}
+		}
+		
 		if($custom_php_ini_settings != ''){
 			// Make sure we only have Unix linebreaks
 			$custom_php_ini_settings = str_replace("\r\n", "\n", $custom_php_ini_settings);
diff --git a/server/plugins-available/bind_dlz_plugin.inc.php b/server/plugins-available/bind_dlz_plugin.inc.php
index fa839fe04a..89954ccabb 100644
--- a/server/plugins-available/bind_dlz_plugin.inc.php
+++ b/server/plugins-available/bind_dlz_plugin.inc.php
@@ -34,7 +34,7 @@ TABLE STRUCTURE of the "named" database:
 CREATE TABLE IF NOT EXISTS `records` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `zone` varchar(255) NOT NULL,
-  `ttl` int(11) NOT NULL default '86400',
+  `ttl` int(11) NOT NULL default '3600',
   `type` varchar(255) NOT NULL,
   `host` varchar(255) NOT NULL default '@',
   `mx_priority` int(11) default NULL,
diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php
index de6a7a451c..4ff3c8c48e 100644
--- a/server/plugins-available/nginx_plugin.inc.php
+++ b/server/plugins-available/nginx_plugin.inc.php
@@ -2461,6 +2461,26 @@ class nginx_plugin {
 		// Custom php.ini settings
 		$final_php_ini_settings = array();
 		$custom_php_ini_settings = trim($data['new']['custom_php_ini']);
+		
+		if(intval($data['new']['directive_snippets_id']) > 0){
+			$snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'nginx' AND active = 'y' AND customer_viewable = 'y'", intval($data['new']['directive_snippets_id']));
+			if(isset($snippet['required_php_snippets']) && trim($snippet['required_php_snippets']) != ''){
+				$required_php_snippets = explode(',', trim($snippet['required_php_snippets']));
+				if(is_array($required_php_snippets) && !empty($required_php_snippets)){
+					foreach($required_php_snippets as $required_php_snippet){
+						$required_php_snippet = intval($required_php_snippet);
+						if($required_php_snippet > 0){
+							$php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet);
+							$php_snippet['snippet'] = trim($php_snippet['snippet']);
+							if($php_snippet['snippet'] != ''){
+								$custom_php_ini_settings .= "\n".$php_snippet['snippet'];
+							}
+						}
+					}
+				}
+			}
+		}
+		
 		if($custom_php_ini_settings != ''){
 			// Make sure we only have Unix linebreaks
 			$custom_php_ini_settings = str_replace("\r\n", "\n", $custom_php_ini_settings);
-- 
GitLab