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

---
 interface/web/tools/dns_import_tupa.php                   |    2 
 interface/web/dns/form/dns_soa.tform.php                  |    2 
 interface/web/dns/form/dns_ns.tform.php                   |    2 
 interface/web/dns/form/dns_spf.tform.php                  |    2 
 remoting_client/examples/dns_a_add.php                    |    2 
 interface/web/dns/form/dns_a.tform.php                    |    2 
 remoting_client/examples/dns_rp_add.php                   |    2 
 remoting_client/examples/dns_mx_add.php                   |    2 
 remoting_client/examples/dns_cname_add.php                |    2 
 install/sql/ispconfig3.sql                                |    9 +-
 interface/web/dns/form/dns_ptr.tform.php                  |    2 
 install/sql/incremental/upd_dev_collection.sql            |    8 +
 server/plugins-available/apache2_plugin.inc.php           |   60 +++++++++++++++
 interface/web/admin/form/directive_snippets.tform.php     |   11 ++
 server/plugins-available/nginx_plugin.inc.php             |   20 +++++
 remoting_client/examples/dns_hinfo_add.php                |    2 
 interface/lib/classes/validate_dkim.inc.php               |    6 +
 remoting_client/examples/dns_ns_add.php                   |    2 
 interface/web/dns/list/dns_a.list.php                     |    2 
 interface/web/dns/form/dns_cname.tform.php                |    2 
 remoting_client/examples/dns_zone_add.php                 |    4 
 interface/web/dns/form/dns_srv.tform.php                  |    2 
 interface/web/dns/form/dns_rp.tform.php                   |    2 
 interface/web/dns/form/dns_mx.tform.php                   |    2 
 remoting_client/examples/dns_aaaa_add.php                 |    2 
 interface/web/dns/form/dns_hinfo.tform.php                |    2 
 interface/web/dns/form/dns_aaaa.tform.php                 |    2 
 remoting_client/examples/dns_srv_add.php                  |    2 
 interface/web/mail/templates/mail_domain_edit.htm         |    2 
 interface/web/admin/templates/directive_snippets_edit.htm |   12 ++
 remoting_client/examples/dns_ptr_add.php                  |    2 
 remoting_client/examples/dns_alias_add.php                |    2 
 interface/web/dns/form/dns_alias.tform.php                |    2 
 interface/web/dns/form/dns_dkim.tform.php                 |    2 
 interface/web/dns/form/dns_txt.tform.php                  |    2 
 server/plugins-available/bind_dlz_plugin.inc.php          |    2 
 remoting_client/examples/dns_txt_add.php                  |    2 
 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 6eea12b..4395655 100644
--- a/install/sql/incremental/upd_dev_collection.sql
+++ b/install/sql/incremental/upd_dev_collection.sql
@@ -20,7 +20,7 @@
 refresh=7200
 retry=540
 expire=604800
-minimum=86400
+minimum=3600
 ttl=3600
 
 [DNS_RECORDS]
@@ -134,3 +134,9 @@
 ) 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+difGAuBlCy0qsRM4mfERcTFfGygsBUF/xFxE/EQ8RixwIbi/j7il8R3iE8qwuxAXMJxuuFiTvNMYleb/E0gXiI+c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cRkfjc/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 5011f16..a020d02 100644
--- a/install/sql/ispconfig3.sql
+++ b/install/sql/ispconfig3.sql
@@ -442,6 +442,7 @@
   `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 @@
   `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 @@
   `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 @@
 -- 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 71fd8c5..5d7fb8f 100644
--- a/interface/lib/classes/validate_dkim.inc.php
+++ b/interface/lib/classes/validate_dkim.inc.php
@@ -62,8 +62,10 @@
 	 */
 	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 8db725b..0c2502c 100644
--- a/interface/web/admin/form/directive_snippets.tform.php
+++ b/interface/web/admin/form/directive_snippets.tform.php
@@ -105,6 +105,17 @@
 			'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 7729fc1..21b7686 100644
--- a/interface/web/admin/templates/directive_snippets_edit.htm
+++ b/interface/web/admin/templates/directive_snippets_edit.htm
@@ -18,6 +18,12 @@
                 <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>
                 <div class="col-sm-9">
@@ -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 95aa5b8..cd5a3eb 100644
--- a/interface/web/dns/form/dns_a.tform.php
+++ b/interface/web/dns/form/dns_a.tform.php
@@ -133,7 +133,7 @@
 					'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 47bbac3..d381d51 100644
--- a/interface/web/dns/form/dns_aaaa.tform.php
+++ b/interface/web/dns/form/dns_aaaa.tform.php
@@ -126,7 +126,7 @@
 					'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 663bf84..defcda0 100644
--- a/interface/web/dns/form/dns_alias.tform.php
+++ b/interface/web/dns/form/dns_alias.tform.php
@@ -142,7 +142,7 @@
 					'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 957e6e1..5fdf8c9 100644
--- a/interface/web/dns/form/dns_cname.tform.php
+++ b/interface/web/dns/form/dns_cname.tform.php
@@ -140,7 +140,7 @@
 					'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 bbc1214..550255d 100644
--- a/interface/web/dns/form/dns_dkim.tform.php
+++ b/interface/web/dns/form/dns_dkim.tform.php
@@ -120,7 +120,7 @@
 							'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 231bdfc..76c8c79 100644
--- a/interface/web/dns/form/dns_hinfo.tform.php
+++ b/interface/web/dns/form/dns_hinfo.tform.php
@@ -132,7 +132,7 @@
 					'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 d5faeeb..9aace37 100644
--- a/interface/web/dns/form/dns_mx.tform.php
+++ b/interface/web/dns/form/dns_mx.tform.php
@@ -141,7 +141,7 @@
 					'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 82b3090..063a896 100644
--- a/interface/web/dns/form/dns_ns.tform.php
+++ b/interface/web/dns/form/dns_ns.tform.php
@@ -140,7 +140,7 @@
 					'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 59a91e7..4cc0462 100644
--- a/interface/web/dns/form/dns_ptr.tform.php
+++ b/interface/web/dns/form/dns_ptr.tform.php
@@ -140,7 +140,7 @@
 					'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 35b8e55..5f4610a 100644
--- a/interface/web/dns/form/dns_rp.tform.php
+++ b/interface/web/dns/form/dns_rp.tform.php
@@ -133,7 +133,7 @@
 					'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 1e4f9a6..02afa86 100644
--- a/interface/web/dns/form/dns_soa.tform.php
+++ b/interface/web/dns/form/dns_soa.tform.php
@@ -197,7 +197,7 @@
 					'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 00ccb76..ea2cf83 100644
--- a/interface/web/dns/form/dns_spf.tform.php
+++ b/interface/web/dns/form/dns_spf.tform.php
@@ -127,7 +127,7 @@
 					'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 2f35fd5..ee0674f 100644
--- a/interface/web/dns/form/dns_srv.tform.php
+++ b/interface/web/dns/form/dns_srv.tform.php
@@ -131,7 +131,7 @@
 					'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 70e0fc5..01b731a 100644
--- a/interface/web/dns/form/dns_txt.tform.php
+++ b/interface/web/dns/form/dns_txt.tform.php
@@ -137,7 +137,7 @@
 					'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 3b47cf1..65429df 100644
--- a/interface/web/dns/list/dns_a.list.php
+++ b/interface/web/dns/list/dns_a.list.php
@@ -132,7 +132,7 @@
 	'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 f56c27d..307b0d1 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 b45a11b..b81a83b 100644
--- a/interface/web/tools/dns_import_tupa.php
+++ b/interface/web/tools/dns_import_tupa.php
@@ -96,7 +96,7 @@
 					$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 6bcb33c..b669daa 100644
--- a/remoting_client/examples/dns_a_add.php
+++ b/remoting_client/examples/dns_a_add.php
@@ -23,7 +23,7 @@
 		'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 4ee460b..eff4148 100644
--- a/remoting_client/examples/dns_aaaa_add.php
+++ b/remoting_client/examples/dns_aaaa_add.php
@@ -23,7 +23,7 @@
 		'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 5b1c684..dd8a4da 100644
--- a/remoting_client/examples/dns_alias_add.php
+++ b/remoting_client/examples/dns_alias_add.php
@@ -23,7 +23,7 @@
 		'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 2d70ca6..7731a54 100644
--- a/remoting_client/examples/dns_cname_add.php
+++ b/remoting_client/examples/dns_cname_add.php
@@ -23,7 +23,7 @@
 		'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 a0a8c47..106c790 100644
--- a/remoting_client/examples/dns_hinfo_add.php
+++ b/remoting_client/examples/dns_hinfo_add.php
@@ -23,7 +23,7 @@
 		'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 b1e9617..d083821 100644
--- a/remoting_client/examples/dns_mx_add.php
+++ b/remoting_client/examples/dns_mx_add.php
@@ -23,7 +23,7 @@
 		'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 d650d2a..381041a 100644
--- a/remoting_client/examples/dns_ns_add.php
+++ b/remoting_client/examples/dns_ns_add.php
@@ -23,7 +23,7 @@
 		'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 6d4ccab..a2dbdf5 100644
--- a/remoting_client/examples/dns_ptr_add.php
+++ b/remoting_client/examples/dns_ptr_add.php
@@ -23,7 +23,7 @@
 		'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 a30b703..27329bb 100644
--- a/remoting_client/examples/dns_rp_add.php
+++ b/remoting_client/examples/dns_rp_add.php
@@ -23,7 +23,7 @@
 		'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 75c7df4..6270db7 100644
--- a/remoting_client/examples/dns_srv_add.php
+++ b/remoting_client/examples/dns_srv_add.php
@@ -23,7 +23,7 @@
 		'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 4ce025e..90f0609 100644
--- a/remoting_client/examples/dns_txt_add.php
+++ b/remoting_client/examples/dns_txt_add.php
@@ -23,7 +23,7 @@
 		'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 6772409..62937c0 100644
--- a/remoting_client/examples/dns_zone_add.php
+++ b/remoting_client/examples/dns_zone_add.php
@@ -25,8 +25,8 @@
 		'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 1676a1a..43b06f3 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -161,6 +161,26 @@
 			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 @@
 				$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 @@
 		// 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 fa839fe..89954cc 100644
--- a/server/plugins-available/bind_dlz_plugin.inc.php
+++ b/server/plugins-available/bind_dlz_plugin.inc.php
@@ -34,7 +34,7 @@
 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 de6a7a4..4ff3c8c 100644
--- a/server/plugins-available/nginx_plugin.inc.php
+++ b/server/plugins-available/nginx_plugin.inc.php
@@ -2461,6 +2461,26 @@
 		// 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);

--
Gitblit v1.9.1