Project

General

Profile

Download (19.5 KB) Statistics
| Branch: | Tag: | Revision:
1 7ed0e844 Warren Baker
<?php
2
/*
3 aaec5634 Renato Botelho
 * services_unbound.php
4 df6cb8fe Stephen Beaver
 *
5 aaec5634 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 2a2396a6 Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 aaec5634 Renato Botelho
 * Copyright (c) 2014 Warren Baker (warren@pfsense.org)
8
 * All rights reserved.
9 df6cb8fe Stephen Beaver
 *
10 aaec5634 Renato Botelho
 * Redistribution and use in source and binary forms, with or without
11
 * modification, are permitted provided that the following conditions are met:
12 df6cb8fe Stephen Beaver
 *
13 aaec5634 Renato Botelho
 * 1. Redistributions of source code must retain the above copyright notice,
14
 *    this list of conditions and the following disclaimer.
15 df6cb8fe Stephen Beaver
 *
16 aaec5634 Renato Botelho
 * 2. Redistributions in binary form must reproduce the above copyright
17
 *    notice, this list of conditions and the following disclaimer in
18
 *    the documentation and/or other materials provided with the
19
 *    distribution.
20 df6cb8fe Stephen Beaver
 *
21 aaec5634 Renato Botelho
 * 3. All advertising materials mentioning features or use of this software
22
 *    must display the following acknowledgment:
23
 *    "This product includes software developed by the pfSense Project
24
 *    for use in the pfSense® software distribution. (http://www.pfsense.org/).
25 df6cb8fe Stephen Beaver
 *
26 aaec5634 Renato Botelho
 * 4. The names "pfSense" and "pfSense Project" must not be used to
27
 *    endorse or promote products derived from this software without
28
 *    prior written permission. For written permission, please contact
29
 *    coreteam@pfsense.org.
30 df6cb8fe Stephen Beaver
 *
31 aaec5634 Renato Botelho
 * 5. Products derived from this software may not be called "pfSense"
32
 *    nor may "pfSense" appear in their names without prior written
33
 *    permission of the Electric Sheep Fencing, LLC.
34 df6cb8fe Stephen Beaver
 *
35 aaec5634 Renato Botelho
 * 6. Redistributions of any form whatsoever must retain the following
36
 *    acknowledgment:
37 df6cb8fe Stephen Beaver
 *
38 aaec5634 Renato Botelho
 * "This product includes software developed by the pfSense Project
39
 * for use in the pfSense software distribution (http://www.pfsense.org/).
40 df6cb8fe Stephen Beaver
 *
41 aaec5634 Renato Botelho
 * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
42
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
44
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
45
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
50
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52
 * OF THE POSSIBILITY OF SUCH DAMAGE.
53 df6cb8fe Stephen Beaver
 */
54 7ed0e844 Warren Baker
55
##|+PRIV
56 0b8328c5 jim-p
##|*IDENT=page-services-dnsresolver
57 5230f468 jim-p
##|*NAME=Services: DNS Resolver
58 7ed0e844 Warren Baker
##|*DESCR=Allow access to the 'Services: DNS Resolver' page.
59
##|*MATCH=services_unbound.php*
60 9c8a7b13 Stephen Beaver
##|-PRIV
61 7ed0e844 Warren Baker
62
require_once("guiconfig.inc");
63
require_once("unbound.inc");
64 97517b69 doktornotor
require_once("pfsense-utils.inc");
65 4dbcf2fb Renato Botelho
require_once("system.inc");
66 7ed0e844 Warren Baker
67 be11b6f1 Warren Baker
if (!is_array($config['unbound'])) {
68 2783e408 Renato Botelho
	$config['unbound'] = array();
69 be11b6f1 Warren Baker
}
70
71 7ed0e844 Warren Baker
$a_unboundcfg =& $config['unbound'];
72
73 932711c7 Matt Smith
if (!is_array($a_unboundcfg['hosts'])) {
74
	$a_unboundcfg['hosts'] = array();
75 be11b6f1 Warren Baker
}
76
77 932711c7 Matt Smith
$a_hosts =& $a_unboundcfg['hosts'];
78 7ed0e844 Warren Baker
79 932711c7 Matt Smith
if (!is_array($a_unboundcfg['domainoverrides'])) {
80
	$a_unboundcfg['domainoverrides'] = array();
81 be11b6f1 Warren Baker
}
82
83 932711c7 Matt Smith
$a_domainOverrides = &$a_unboundcfg['domainoverrides'];
84 7ed0e844 Warren Baker
85 932711c7 Matt Smith
if (isset($a_unboundcfg['enable'])) {
86 fe9d4894 Renato Botelho
	$pconfig['enable'] = true;
87 be11b6f1 Warren Baker
}
88 932711c7 Matt Smith
if (isset($a_unboundcfg['dnssec'])) {
89 fe9d4894 Renato Botelho
	$pconfig['dnssec'] = true;
90 be11b6f1 Warren Baker
}
91 932711c7 Matt Smith
if (isset($a_unboundcfg['forwarding'])) {
92 fe9d4894 Renato Botelho
	$pconfig['forwarding'] = true;
93 be11b6f1 Warren Baker
}
94 932711c7 Matt Smith
if (isset($a_unboundcfg['regdhcp'])) {
95 fe9d4894 Renato Botelho
	$pconfig['regdhcp'] = true;
96 be11b6f1 Warren Baker
}
97 932711c7 Matt Smith
if (isset($a_unboundcfg['regdhcpstatic'])) {
98 fe9d4894 Renato Botelho
	$pconfig['regdhcpstatic'] = true;
99 be11b6f1 Warren Baker
}
100 615ae81f Renato Botelho
101 932711c7 Matt Smith
$pconfig['port'] = $a_unboundcfg['port'];
102
$pconfig['custom_options'] = base64_decode($a_unboundcfg['custom_options']);
103 615ae81f Renato Botelho
104 932711c7 Matt Smith
if (empty($a_unboundcfg['active_interface'])) {
105 2783e408 Renato Botelho
	$pconfig['active_interface'] = array();
106 be11b6f1 Warren Baker
} else {
107 932711c7 Matt Smith
	$pconfig['active_interface'] = explode(",", $a_unboundcfg['active_interface']);
108 be11b6f1 Warren Baker
}
109 51c224bc sbeaver
110 932711c7 Matt Smith
if (empty($a_unboundcfg['outgoing_interface'])) {
111 2783e408 Renato Botelho
	$pconfig['outgoing_interface'] = array();
112 be11b6f1 Warren Baker
} else {
113 932711c7 Matt Smith
	$pconfig['outgoing_interface'] = explode(",", $a_unboundcfg['outgoing_interface']);
114 be11b6f1 Warren Baker
}
115 615ae81f Renato Botelho
116 ca47c065 NOYB
if (empty($a_unboundcfg['system_domain_local_zone_type'])) {
117
	$pconfig['system_domain_local_zone_type'] = "transparent";
118
} else {
119
	$pconfig['system_domain_local_zone_type'] = $a_unboundcfg['system_domain_local_zone_type'];
120
}
121
122 7ed0e844 Warren Baker
if ($_POST) {
123 2783e408 Renato Botelho
	if ($_POST['apply']) {
124
		$retval = services_unbound_configure();
125
		$savemsg = get_std_save_message($retval);
126
		if ($retval == 0) {
127
			clear_subsystem_dirty('unbound');
128 fe9d4894 Renato Botelho
		}
129 2783e408 Renato Botelho
		/* Update resolv.conf in case the interface bindings exclude localhost. */
130
		system_resolvconf_generate();
131 4dbcf2fb Renato Botelho
		/* Start or restart dhcpleases when it's necessary */
132
		system_dhcpleases_configure();
133 2783e408 Renato Botelho
	} else {
134 7aeae838 Matt Smith
		$pconfig = $_POST;
135
		unset($input_errors);
136
137 932711c7 Matt Smith
		if (isset($pconfig['enable']) && isset($config['dnsmasq']['enable'])) {
138
			if ($pconfig['port'] == $config['dnsmasq']['port']) {
139 4bb7c0d1 bruno
				$input_errors[] = gettext("The DNS Forwarder is enabled using this port. Choose a non-conflicting port, or disable the DNS Forwarder.");
140 e92ee598 Phil Davis
			}
141 fe9d4894 Renato Botelho
		}
142 615ae81f Renato Botelho
143 7b03ef63 Chris Buechler
		// forwarding mode requires having valid DNS servers
144
		if (isset($pconfig['forwarding'])) {
145
			$founddns = false;
146
			if (isset($config['system']['dnsallowoverride'])) {
147 5e946f38 Chris Buechler
				$dns_servers = get_dns_servers();
148
				if (is_array($dns_servers)) {
149
					foreach ($dns_servers as $dns_server) {
150
						if (!ip_in_subnet($dns_server, "127.0.0.0/8")) {
151 7b03ef63 Chris Buechler
							$founddns = true;
152
						}
153
					}
154
				}
155
			}
156
			if (is_array($config['system']['dnsserver'])) {
157
				foreach ($config['system']['dnsserver'] as $dnsserver) {
158
					if (is_ipaddr($dnsserver)) {
159
						$founddns = true;
160
					}
161
				}
162
			}
163
			if ($founddns == false) {
164 ff2c0021 doktornotor
				$input_errors[] = gettext("At least one DNS server must be specified under System &gt; General Setup to enable Forwarding mode.");
165 7b03ef63 Chris Buechler
			}
166
		}
167
168 932711c7 Matt Smith
		if (empty($pconfig['active_interface'])) {
169 4bb7c0d1 bruno
			$input_errors[] = gettext("One or more Network Interfaces must be selected for binding.");
170 932711c7 Matt Smith
		} else if (!isset($config['system']['dnslocalhost']) && (!in_array("lo0", $pconfig['active_interface']) && !in_array("all", $pconfig['active_interface']))) {
171 4bb7c0d1 bruno
			$input_errors[] = gettext("This system is configured to use the DNS Resolver as its DNS server, so Localhost or All must be selected in Network Interfaces.");
172 fe9d4894 Renato Botelho
		}
173 7ed0e844 Warren Baker
174 932711c7 Matt Smith
		if (empty($pconfig['outgoing_interface'])) {
175 4bb7c0d1 bruno
			$input_errors[] = gettext("One or more Outgoing Network Interfaces must be selected.");
176 fe9d4894 Renato Botelho
		}
177 7ed0e844 Warren Baker
178 932711c7 Matt Smith
		if ($pconfig['port'] && !is_port($pconfig['port'])) {
179 2fabe5fa Stephen Beaver
			$input_errors[] = gettext("A valid port number must be specified.");
180 fe9d4894 Renato Botelho
		}
181 fff4a9d1 Warren Baker
182 932711c7 Matt Smith
		if (is_array($pconfig['active_interface']) && !empty($pconfig['active_interface'])) {
183
			$display_active_interface = $pconfig['active_interface'];
184
			$pconfig['active_interface'] = implode(",", $pconfig['active_interface']);
185 fe9d4894 Renato Botelho
		}
186 7ed0e844 Warren Baker
187 97517b69 doktornotor
		if ((isset($pconfig['regdhcp']) || isset($pconfig['regdhcpstatic'])) && !is_dhcp_server_enabled()) {
188
			$input_errors[] = gettext("DHCP Server must be enabled for DHCP Registration to work in DNS Resolver.");
189
		}
190
191 932711c7 Matt Smith
		$display_custom_options = $pconfig['custom_options'];
192
		$pconfig['custom_options'] = base64_encode(str_replace("\r\n", "\n", $pconfig['custom_options']));
193
194
		if (is_array($pconfig['outgoing_interface']) && !empty($pconfig['outgoing_interface'])) {
195
			$display_outgoing_interface = $pconfig['outgoing_interface'];
196
			$pconfig['outgoing_interface'] = implode(",", $pconfig['outgoing_interface']);
197 fe9d4894 Renato Botelho
		}
198 188609c6 Warren Baker
199 932711c7 Matt Smith
		$test_output = array();
200
		if (test_unbound_config($pconfig, $test_output)) {
201
			$input_errors[] = gettext("The generated config file cannot be parsed by unbound. Please correct the following errors:");
202
			$input_errors = array_merge($input_errors, $test_output);
203
		}
204 7ed0e844 Warren Baker
205 2783e408 Renato Botelho
		if (!$input_errors) {
206 932711c7 Matt Smith
			$a_unboundcfg['enable'] = isset($pconfig['enable']);
207 439ba83c NOYB
			$a_unboundcfg['port'] = $pconfig['port'];
208 932711c7 Matt Smith
			$a_unboundcfg['dnssec'] = isset($pconfig['dnssec']);
209
			$a_unboundcfg['forwarding'] = isset($pconfig['forwarding']);
210
			$a_unboundcfg['regdhcp'] = isset($pconfig['regdhcp']);
211
			$a_unboundcfg['regdhcpstatic'] = isset($pconfig['regdhcpstatic']);
212
			$a_unboundcfg['active_interface'] = $pconfig['active_interface'];
213
			$a_unboundcfg['outgoing_interface'] = $pconfig['outgoing_interface'];
214 ca47c065 NOYB
			$a_unboundcfg['system_domain_local_zone_type'] = $pconfig['system_domain_local_zone_type'];
215 932711c7 Matt Smith
			$a_unboundcfg['custom_options'] = $pconfig['custom_options'];
216
217 4bb7c0d1 bruno
			write_config(gettext("DNS Resolver configured."));
218 2783e408 Renato Botelho
			mark_subsystem_dirty('unbound');
219
		}
220 932711c7 Matt Smith
221
		$pconfig['active_interface'] = $display_active_interface;
222
		$pconfig['outgoing_interface'] = $display_outgoing_interface;
223
		$pconfig['custom_options'] = $display_custom_options;
224 2783e408 Renato Botelho
	}
225 7ed0e844 Warren Baker
}
226
227 c154cd7d NOYB
if ($pconfig['custom_options']) {
228
	$customoptions = true;
229
} else {
230
	$customoptions = false;
231
}
232
233 f2bc186f Warren Baker
if ($_GET['act'] == "del") {
234 2783e408 Renato Botelho
	if ($_GET['type'] == 'host') {
235
		if ($a_hosts[$_GET['id']]) {
236
			unset($a_hosts[$_GET['id']]);
237
			write_config();
238
			mark_subsystem_dirty('unbound');
239
			header("Location: services_unbound.php");
240
			exit;
241
		}
242
	} elseif ($_GET['type'] == 'doverride') {
243
		if ($a_domainOverrides[$_GET['id']]) {
244
			unset($a_domainOverrides[$_GET['id']]);
245
			write_config();
246
			mark_subsystem_dirty('unbound');
247
			header("Location: services_unbound.php");
248
			exit;
249
		}
250
	}
251 f2bc186f Warren Baker
}
252
253 7aeae838 Matt Smith
function build_if_list($selectedifs) {
254 51c224bc sbeaver
	$interface_addresses = get_possible_listen_ips(true);
255
	$iflist = array('options' => array(), 'selected' => array());
256
257 4bb7c0d1 bruno
	$iflist['options']['all']	= gettext("All");
258 7aeae838 Matt Smith
	if (empty($selectedifs) || empty($selectedifs[0]) || in_array("all", $selectedifs)) {
259 7275a7a2 Stephen Beaver
		array_push($iflist['selected'], "all");
260 7aeae838 Matt Smith
	}
261 51c224bc sbeaver
262
	foreach ($interface_addresses as $laddr => $ldescr) {
263
		$iflist['options'][$laddr] = htmlspecialchars($ldescr);
264
265 20db3e1a Phil Davis
		if ($selectedifs && in_array($laddr, $selectedifs)) {
266 51c224bc sbeaver
			array_push($iflist['selected'], $laddr);
267 20db3e1a Phil Davis
		}
268 51c224bc sbeaver
	}
269
270
	unset($interface_addresses);
271
272
	return($iflist);
273
}
274
275 c8f6b745 k-paulius
$pgtitle = array(gettext("Services"), gettext("DNS Resolver"), gettext("General Settings"));
276 de02dc29 Phil Davis
$pglinks = array("", "@self", "@self");
277 db88a3a2 Phil Davis
$shortcut_section = "resolver";
278 7ed0e844 Warren Baker
279 51c224bc sbeaver
include_once("head.inc");
280 7ed0e844 Warren Baker
281 20db3e1a Phil Davis
if ($input_errors) {
282 51c224bc sbeaver
	print_input_errors($input_errors);
283 20db3e1a Phil Davis
}
284 51c224bc sbeaver
285 20db3e1a Phil Davis
if ($savemsg) {
286 51c224bc sbeaver
	print_info_box($savemsg, 'success');
287 20db3e1a Phil Davis
}
288 51c224bc sbeaver
289 7aeae838 Matt Smith
if (is_subsystem_dirty('unbound')) {
290 2fabe5fa Stephen Beaver
	print_apply_box(gettext("The DNS resolver configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
291 7aeae838 Matt Smith
}
292
293 51c224bc sbeaver
$tab_array = array();
294 c8f6b745 k-paulius
$tab_array[] = array(gettext("General Settings"), true, "services_unbound.php");
295
$tab_array[] = array(gettext("Advanced Settings"), false, "services_unbound_advanced.php");
296 51c224bc sbeaver
$tab_array[] = array(gettext("Access Lists"), false, "/services_unbound_acls.php");
297
display_top_tabs($tab_array, true);
298
299
$form = new Form();
300
301
$section = new Form_Section('General DNS Resolver Options');
302
303
$section->addInput(new Form_Checkbox(
304
	'enable',
305
	'Enable',
306
	'Enable DNS resolver',
307
	$pconfig['enable']
308
));
309
310
$section->addInput(new Form_Input(
311
	'port',
312
	'Listen Port',
313 d5a9e030 NOYB
	'number',
314 3e568739 NOYB
	$pconfig['port'],
315
	['placeholder' => '53']
316 51c224bc sbeaver
))->setHelp('The port used for responding to DNS queries. It should normally be left blank unless another service needs to bind to TCP/UDP port 53.');
317
318 7aeae838 Matt Smith
$activeiflist = build_if_list($pconfig['active_interface']);
319 51c224bc sbeaver
320
$section->addInput(new Form_Select(
321
	'active_interface',
322 57965f9b Phil Davis
	'*Network Interfaces',
323 7aeae838 Matt Smith
	$activeiflist['selected'],
324
	$activeiflist['options'],
325 51c224bc sbeaver
	true
326 ec51be45 PiBa-NL
))->addClass('general', 'resizable')->setHelp('Interface IPs used by the DNS Resolver for responding to queries from clients. If an interface has both IPv4 and IPv6 IPs, both are used. Queries to other interface IPs not selected below are discarded. ' .
327 51c224bc sbeaver
			'The default behavior is to respond to queries on every available IPv4 and IPv6 address.');
328
329 7aeae838 Matt Smith
$outiflist = build_if_list($pconfig['outgoing_interface']);
330
331 51c224bc sbeaver
$section->addInput(new Form_Select(
332
	'outgoing_interface',
333 57965f9b Phil Davis
	'*Outgoing Network Interfaces',
334 7aeae838 Matt Smith
	$outiflist['selected'],
335
	$outiflist['options'],
336 51c224bc sbeaver
	true
337 ec51be45 PiBa-NL
))->addClass('general', 'resizable')->setHelp('Utilize different network interface(s) that the DNS Resolver will use to send queries to authoritative servers and receive their replies. By default all interfaces are used.');
338 51c224bc sbeaver
339 ca47c065 NOYB
$section->addInput(new Form_Select(
340
	'system_domain_local_zone_type',
341 57965f9b Phil Davis
	'*System Domain Local Zone Type',
342 ca47c065 NOYB
	$pconfig['system_domain_local_zone_type'],
343 9a83872f NOYB
	unbound_local_zone_types()
344 ca47c065 NOYB
))->setHelp('The local-zone type used for the pfSense system domain (System | General Setup | Domain).  Transparent is the default.  Local-Zone type descriptions are available in the unbound.conf(5) manual pages.');
345
346 51c224bc sbeaver
$section->addInput(new Form_Checkbox(
347
	'dnssec',
348
	'DNSSEC',
349
	'Enable DNSSEC Support',
350
	$pconfig['dnssec']
351
));
352
353
$section->addInput(new Form_Checkbox(
354
	'forwarding',
355
	'DNS Query Forwarding',
356
	'Enable Forwarding Mode',
357
	$pconfig['forwarding']
358 1d0322b5 doktornotor
))->setHelp(sprintf('If this option is set, DNS queries will be forwarded to the upstream DNS servers defined under'.
359 ff2c0021 doktornotor
					' %sSystem &gt; General Setup%s or those obtained via DHCP/PPP on WAN'.
360 1d0322b5 doktornotor
					' (if DNS Server Override is enabled there).','<a href="system.php">','</a>'));
361 51c224bc sbeaver
362
$section->addInput(new Form_Checkbox(
363
	'regdhcp',
364
	'DHCP Registration',
365
	'Register DHCP leases in the DNS Resolver',
366
	$pconfig['regdhcp']
367
))->setHelp(sprintf('If this option is set, then machines that specify their hostname when requesting a DHCP lease will be registered'.
368
					' in the DNS Resolver, so that their name can be resolved.'.
369 ff2c0021 doktornotor
					' The domain in %sSystem &gt; General Setup%s should also be set to the proper value.','<a href="system.php">','</a>'));
370 51c224bc sbeaver
371
$section->addInput(new Form_Checkbox(
372
	'regdhcpstatic',
373
	'Static DHCP',
374
	'Register DHCP static mappings in the DNS Resolver',
375
	$pconfig['regdhcpstatic']
376 2fabe5fa Stephen Beaver
))->setHelp(sprintf('If this option is set, then DHCP static mappings will be registered in the DNS Resolver, so that their name can be resolved. '.
377 ff2c0021 doktornotor
					'The domain in %sSystem &gt; General Setup%s should also be set to the proper value.','<a href="system.php">','</a>'));
378 51c224bc sbeaver
379 2c95f1cd Phil Davis
$btnadv = new Form_Button(
380
	'btnadvcustom',
381 faab522f Renato Botelho
	'Custom options',
382 3314e626 jim-p
	null,
383
	'fa-cog'
384 51c224bc sbeaver
);
385
386 49d3b157 NOYB
$btnadv->setAttribute('type','button')->addClass('btn-info btn-sm');
387 51c224bc sbeaver
388
$section->addInput(new Form_StaticText(
389 2c95f1cd Phil Davis
	'Display Custom Options',
390
	$btnadv
391 51c224bc sbeaver
));
392
393 1fcfea39 Stephen Beaver
$section->addInput(new Form_Textarea (
394 51c224bc sbeaver
	'custom_options',
395
	'Custom options',
396
	$pconfig['custom_options']
397 46a8a9cf NOYB
))->setHelp('Enter any additional configuration parameters to add to the DNS Resolver configuration here, separated by a newline.');
398 51c224bc sbeaver
399
$form->add($section);
400
print($form);
401
?>
402 932711c7 Matt Smith
403 8fd9052f Colin Fleming
<script type="text/javascript">
404 51c224bc sbeaver
//<![CDATA[
405 20db3e1a Phil Davis
events.push(function() {
406 51c224bc sbeaver
407 2c95f1cd Phil Davis
	// Show advanced custom options ==============================================
408
	var showadvcustom = false;
409
410
	function show_advcustom(ispageload) {
411
		var text;
412
		// On page load decide the initial state based on the data.
413
		if (ispageload) {
414 28e3d579 NewEraCracker
			showadvcustom = <?=($customoptions ? 'true' : 'false');?>;
415 2c95f1cd Phil Davis
		} else {
416
			// It was a click, swap the state.
417
			showadvcustom = !showadvcustom;
418
		}
419
420
		hideInput('custom_options', !showadvcustom);
421
422
		if (showadvcustom) {
423
			text = "<?=gettext('Hide Custom Options');?>";
424
		} else {
425
			text = "<?=gettext('Display Custom Options');?>";
426
		}
427
		$('#btnadvcustom').html('<i class="fa fa-cog"></i> ' + text);
428
	}
429
430 d3a3eef0 Francisco Cavalcante
	// If the enable checkbox is not checked, hide all inputs
431
	function hideGeneral() {
432 51c224bc sbeaver
		var hide = ! $('#enable').prop('checked');
433
434 d3a3eef0 Francisco Cavalcante
		hideMultiClass('general', hide);
435
		hideInput('port', hide);
436
		hideSelect('system_domain_local_zone_type', hide);
437
		hideCheckbox('dnssec', hide);
438
		hideCheckbox('forwarding', hide);
439
		hideCheckbox('regdhcp', hide);
440
		hideCheckbox('regdhcpstatic', hide);
441 2c95f1cd Phil Davis
		hideInput('btnadvcustom', hide);
442
		hideInput('custom_options', hide || !showadvcustom);
443 51c224bc sbeaver
	}
444
445 2c95f1cd Phil Davis
	// Un-hide additional controls
446
	$('#btnadvcustom').click(function(event) {
447
		show_advcustom();
448 51c224bc sbeaver
	});
449
450 d3a3eef0 Francisco Cavalcante
	// When 'enable' is clicked, disable/enable the following hide inputs
451 51c224bc sbeaver
	$('#enable').click(function() {
452 d3a3eef0 Francisco Cavalcante
		hideGeneral();
453 51c224bc sbeaver
	});
454
455
	// On initial load
456 20db3e1a Phil Davis
	if ($('#custom_options').val().length == 0) {
457 df6cb8fe Stephen Beaver
		hideInput('custom_options', true);
458
	}
459
460 d3a3eef0 Francisco Cavalcante
	hideGeneral();
461 2c95f1cd Phil Davis
	show_advcustom(true);
462 51c224bc sbeaver
463
});
464
//]]>
465
</script>
466
467
<div class="panel panel-default">
468 f17594c7 Sjon Hortensius
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Host Overrides")?></h2></div>
469 51c224bc sbeaver
	<div class="panel-body table-responsive">
470 91677170 PiBa-NL
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
471 51c224bc sbeaver
			<thead>
472 2783e408 Renato Botelho
				<tr>
473 51c224bc sbeaver
					<th><?=gettext("Host")?></th>
474
					<th><?=gettext("Domain")?></th>
475
					<th><?=gettext("IP")?></th>
476
					<th><?=gettext("Description")?></th>
477 21d973b2 Phil Davis
					<th><?=gettext("Actions")?></th>
478 2783e408 Renato Botelho
				</tr>
479 51c224bc sbeaver
			</thead>
480
			<tbody>
481
<?php
482
$i = 0;
483
foreach ($a_hosts as $hostent):
484
?>
485 2783e408 Renato Botelho
				<tr>
486 51c224bc sbeaver
					<td>
487 c8a7d17c NOYB
						<?=$hostent['host']?>
488 51c224bc sbeaver
					</td>
489
					<td>
490 c8a7d17c NOYB
						<?=$hostent['domain']?>
491 51c224bc sbeaver
					</td>
492
					<td>
493 de038a27 Stephen Beaver
						<?=$hostent['ip']?>
494 51c224bc sbeaver
					</td>
495
					<td>
496
						<?=htmlspecialchars($hostent['descr'])?>
497
					</td>
498
					<td>
499 33f0b0d5 Stephen Beaver
						<a class="fa fa-pencil"	title="<?=gettext('Edit host override')?>" href="services_unbound_host_edit.php?id=<?=$i?>"></a>
500
						<a class="fa fa-trash"	title="<?=gettext('Delete host override')?>" href="services_unbound.php?type=host&amp;act=del&amp;id=<?=$i?>"></a>
501 51c224bc sbeaver
					</td>
502 2783e408 Renato Botelho
				</tr>
503 51c224bc sbeaver
504
<?php
505
	if ($hostent['aliases']['item'] && is_array($hostent['aliases']['item'])):
506
		foreach ($hostent['aliases']['item'] as $alias):
507
?>
508 2783e408 Renato Botelho
				<tr>
509 51c224bc sbeaver
					<td>
510 c8a7d17c NOYB
						<?=$alias['host']?>
511 51c224bc sbeaver
					</td>
512
					<td>
513 c8a7d17c NOYB
						<?=$alias['domain']?>
514 51c224bc sbeaver
					</td>
515
					<td>
516 4bb7c0d1 bruno
						<?=gettext("Alias for ");?><?=$hostent['host'] ? $hostent['host'] . '.' . $hostent['domain'] : $hostent['domain']?>
517 51c224bc sbeaver
					</td>
518
					<td>
519 39bd0b51 Stephen Beaver
						<i class="fa fa-angle-double-right text-info"></i>
520 51c224bc sbeaver
						<?=htmlspecialchars($alias['description'])?>
521
					</td>
522
					<td>
523 91677170 PiBa-NL
						<a class="fa fa-pencil"	title="<?=gettext('Edit host override')?>" 	href="services_unbound_host_edit.php?id=<?=$i?>"></a>
524 51c224bc sbeaver
					</td>
525 2783e408 Renato Botelho
				</tr>
526 51c224bc sbeaver
<?php
527
		endforeach;
528
	endif;
529
	$i++;
530
endforeach;
531
?>
532
			</tbody>
533
		</table>
534
	</div>
535
</div>
536
537 c10cb196 Stephen Beaver
<nav class="action-buttons">
538 782922c2 Stephen Beaver
	<a href="services_unbound_host_edit.php" class="btn btn-sm btn-success">
539 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
540 782922c2 Stephen Beaver
		<?=gettext('Add')?>
541
	</a>
542 51c224bc sbeaver
</nav>
543
544
<div class="panel panel-default">
545 f17594c7 Sjon Hortensius
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Domain Overrides")?></h2></div>
546 51c224bc sbeaver
	<div class="panel-body table-responsive">
547 91677170 PiBa-NL
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
548 51c224bc sbeaver
			<thead>
549 2783e408 Renato Botelho
				<tr>
550 51c224bc sbeaver
					<th><?=gettext("Domain")?></th>
551
					<th><?=gettext("IP")?></th>
552
					<th><?=gettext("Description")?></th>
553 21d973b2 Phil Davis
					<th><?=gettext("Actions")?></th>
554 2783e408 Renato Botelho
				</tr>
555 51c224bc sbeaver
			</thead>
556
557
			<tbody>
558
<?php
559
$i = 0;
560
foreach ($a_domainOverrides as $doment):
561
?>
562 2783e408 Renato Botelho
				<tr>
563 51c224bc sbeaver
					<td>
564 c8a7d17c NOYB
						<?=$doment['domain']?>&nbsp;
565 51c224bc sbeaver
					</td>
566
					<td>
567
						<?=$doment['ip']?>&nbsp;
568
					</td>
569
					<td>
570
						<?=htmlspecialchars($doment['descr'])?>&nbsp;
571
					</td>
572
					<td>
573 33f0b0d5 Stephen Beaver
						<a class="fa fa-pencil"	title="<?=gettext('Edit domain override')?>" href="services_unbound_domainoverride_edit.php?id=<?=$i?>"></a>
574
						<a class="fa fa-trash"	title="<?=gettext('Delete domain override')?>" href="services_unbound.php?act=del&amp;type=doverride&amp;id=<?=$i?>"></a>
575 51c224bc sbeaver
					</td>
576 2783e408 Renato Botelho
				</tr>
577 51c224bc sbeaver
<?php
578
	$i++;
579
endforeach;
580
?>
581
			</tbody>
582
		</table>
583
	</div>
584
</div>
585
586 c10cb196 Stephen Beaver
<nav class="action-buttons">
587 782922c2 Stephen Beaver
	<a href="services_unbound_domainoverride_edit.php" class="btn btn-sm btn-success">
588 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
589 782922c2 Stephen Beaver
		<?=gettext('Add')?>
590
	</a>
591 51c224bc sbeaver
</nav>
592 782922c2 Stephen Beaver
593 35681930 Stephen Beaver
<div class="infoblock">
594 f6aebbcc NewEraCracker
	<?php print_info_box(sprintf(gettext("If the DNS Resolver is enabled, the DHCP".
595 782922c2 Stephen Beaver
		" service (if enabled) will automatically serve the LAN IP".
596
		" address as a DNS server to DHCP clients so they will use".
597 520ee1d0 Phil Davis
		" the DNS Resolver. If Forwarding is enabled, the DNS Resolver will use the DNS servers".
598 ff2c0021 doktornotor
		" entered in %sSystem &gt; General Setup%s".
599 520ee1d0 Phil Davis
		" or those obtained via DHCP or PPP on WAN if &quot;Allow".
600 782922c2 Stephen Beaver
		" DNS server list to be overridden by DHCP/PPP on WAN&quot;".
601 f6aebbcc NewEraCracker
		" is checked."), '<a href="system.php">', '</a>'), 'info', false); ?>
602 782922c2 Stephen Beaver
</div>
603 82afb104 Stephen Beaver
604 6f65dc19 Chris Buechler
<?php include("foot.inc");