Project

General

Profile

Download (19.2 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 4dbcf2fb Renato Botelho
require_once("system.inc");
65 7ed0e844 Warren Baker
66 be11b6f1 Warren Baker
if (!is_array($config['unbound'])) {
67 2783e408 Renato Botelho
	$config['unbound'] = array();
68 be11b6f1 Warren Baker
}
69
70 7ed0e844 Warren Baker
$a_unboundcfg =& $config['unbound'];
71
72 932711c7 Matt Smith
if (!is_array($a_unboundcfg['hosts'])) {
73
	$a_unboundcfg['hosts'] = array();
74 be11b6f1 Warren Baker
}
75
76 932711c7 Matt Smith
$a_hosts =& $a_unboundcfg['hosts'];
77 7ed0e844 Warren Baker
78 932711c7 Matt Smith
if (!is_array($a_unboundcfg['domainoverrides'])) {
79
	$a_unboundcfg['domainoverrides'] = array();
80 be11b6f1 Warren Baker
}
81
82 932711c7 Matt Smith
$a_domainOverrides = &$a_unboundcfg['domainoverrides'];
83 7ed0e844 Warren Baker
84 932711c7 Matt Smith
if (isset($a_unboundcfg['enable'])) {
85 fe9d4894 Renato Botelho
	$pconfig['enable'] = true;
86 be11b6f1 Warren Baker
}
87 932711c7 Matt Smith
if (isset($a_unboundcfg['dnssec'])) {
88 fe9d4894 Renato Botelho
	$pconfig['dnssec'] = true;
89 be11b6f1 Warren Baker
}
90 932711c7 Matt Smith
if (isset($a_unboundcfg['forwarding'])) {
91 fe9d4894 Renato Botelho
	$pconfig['forwarding'] = true;
92 be11b6f1 Warren Baker
}
93 932711c7 Matt Smith
if (isset($a_unboundcfg['regdhcp'])) {
94 fe9d4894 Renato Botelho
	$pconfig['regdhcp'] = true;
95 be11b6f1 Warren Baker
}
96 932711c7 Matt Smith
if (isset($a_unboundcfg['regdhcpstatic'])) {
97 fe9d4894 Renato Botelho
	$pconfig['regdhcpstatic'] = true;
98 be11b6f1 Warren Baker
}
99 615ae81f Renato Botelho
100 932711c7 Matt Smith
$pconfig['port'] = $a_unboundcfg['port'];
101
$pconfig['custom_options'] = base64_decode($a_unboundcfg['custom_options']);
102 615ae81f Renato Botelho
103 932711c7 Matt Smith
if (empty($a_unboundcfg['active_interface'])) {
104 2783e408 Renato Botelho
	$pconfig['active_interface'] = array();
105 be11b6f1 Warren Baker
} else {
106 932711c7 Matt Smith
	$pconfig['active_interface'] = explode(",", $a_unboundcfg['active_interface']);
107 be11b6f1 Warren Baker
}
108 51c224bc sbeaver
109 932711c7 Matt Smith
if (empty($a_unboundcfg['outgoing_interface'])) {
110 2783e408 Renato Botelho
	$pconfig['outgoing_interface'] = array();
111 be11b6f1 Warren Baker
} else {
112 932711c7 Matt Smith
	$pconfig['outgoing_interface'] = explode(",", $a_unboundcfg['outgoing_interface']);
113 be11b6f1 Warren Baker
}
114 615ae81f Renato Botelho
115 ca47c065 NOYB
if (empty($a_unboundcfg['system_domain_local_zone_type'])) {
116
	$pconfig['system_domain_local_zone_type'] = "transparent";
117
} else {
118
	$pconfig['system_domain_local_zone_type'] = $a_unboundcfg['system_domain_local_zone_type'];
119
}
120
121 7ed0e844 Warren Baker
if ($_POST) {
122 2783e408 Renato Botelho
	if ($_POST['apply']) {
123
		$retval = services_unbound_configure();
124
		$savemsg = get_std_save_message($retval);
125
		if ($retval == 0) {
126
			clear_subsystem_dirty('unbound');
127 fe9d4894 Renato Botelho
		}
128 2783e408 Renato Botelho
		/* Update resolv.conf in case the interface bindings exclude localhost. */
129
		system_resolvconf_generate();
130 4dbcf2fb Renato Botelho
		/* Start or restart dhcpleases when it's necessary */
131
		system_dhcpleases_configure();
132 2783e408 Renato Botelho
	} else {
133 7aeae838 Matt Smith
		$pconfig = $_POST;
134
		unset($input_errors);
135
136 932711c7 Matt Smith
		if (isset($pconfig['enable']) && isset($config['dnsmasq']['enable'])) {
137
			if ($pconfig['port'] == $config['dnsmasq']['port']) {
138 4bb7c0d1 bruno
				$input_errors[] = gettext("The DNS Forwarder is enabled using this port. Choose a non-conflicting port, or disable the DNS Forwarder.");
139 e92ee598 Phil Davis
			}
140 fe9d4894 Renato Botelho
		}
141 615ae81f Renato Botelho
142 7b03ef63 Chris Buechler
		// forwarding mode requires having valid DNS servers
143
		if (isset($pconfig['forwarding'])) {
144
			$founddns = false;
145
			if (isset($config['system']['dnsallowoverride'])) {
146 5e946f38 Chris Buechler
				$dns_servers = get_dns_servers();
147
				if (is_array($dns_servers)) {
148
					foreach ($dns_servers as $dns_server) {
149
						if (!ip_in_subnet($dns_server, "127.0.0.0/8")) {
150 7b03ef63 Chris Buechler
							$founddns = true;
151
						}
152
					}
153
				}
154
			}
155
			if (is_array($config['system']['dnsserver'])) {
156
				foreach ($config['system']['dnsserver'] as $dnsserver) {
157
					if (is_ipaddr($dnsserver)) {
158
						$founddns = true;
159
					}
160
				}
161
			}
162
			if ($founddns == false) {
163 ff2c0021 doktornotor
				$input_errors[] = gettext("At least one DNS server must be specified under System &gt; General Setup to enable Forwarding mode.");
164 7b03ef63 Chris Buechler
			}
165
		}
166
167 932711c7 Matt Smith
		if (empty($pconfig['active_interface'])) {
168 4bb7c0d1 bruno
			$input_errors[] = gettext("One or more Network Interfaces must be selected for binding.");
169 932711c7 Matt Smith
		} else if (!isset($config['system']['dnslocalhost']) && (!in_array("lo0", $pconfig['active_interface']) && !in_array("all", $pconfig['active_interface']))) {
170 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.");
171 fe9d4894 Renato Botelho
		}
172 7ed0e844 Warren Baker
173 932711c7 Matt Smith
		if (empty($pconfig['outgoing_interface'])) {
174 4bb7c0d1 bruno
			$input_errors[] = gettext("One or more Outgoing Network Interfaces must be selected.");
175 fe9d4894 Renato Botelho
		}
176 7ed0e844 Warren Baker
177 932711c7 Matt Smith
		if ($pconfig['port'] && !is_port($pconfig['port'])) {
178 2fabe5fa Stephen Beaver
			$input_errors[] = gettext("A valid port number must be specified.");
179 fe9d4894 Renato Botelho
		}
180 fff4a9d1 Warren Baker
181 932711c7 Matt Smith
		if (is_array($pconfig['active_interface']) && !empty($pconfig['active_interface'])) {
182
			$display_active_interface = $pconfig['active_interface'];
183
			$pconfig['active_interface'] = implode(",", $pconfig['active_interface']);
184 fe9d4894 Renato Botelho
		}
185 7ed0e844 Warren Baker
186 932711c7 Matt Smith
		$display_custom_options = $pconfig['custom_options'];
187
		$pconfig['custom_options'] = base64_encode(str_replace("\r\n", "\n", $pconfig['custom_options']));
188
189
		if (is_array($pconfig['outgoing_interface']) && !empty($pconfig['outgoing_interface'])) {
190
			$display_outgoing_interface = $pconfig['outgoing_interface'];
191
			$pconfig['outgoing_interface'] = implode(",", $pconfig['outgoing_interface']);
192 fe9d4894 Renato Botelho
		}
193 188609c6 Warren Baker
194 932711c7 Matt Smith
		$test_output = array();
195
		if (test_unbound_config($pconfig, $test_output)) {
196
			$input_errors[] = gettext("The generated config file cannot be parsed by unbound. Please correct the following errors:");
197
			$input_errors = array_merge($input_errors, $test_output);
198
		}
199 7ed0e844 Warren Baker
200 2783e408 Renato Botelho
		if (!$input_errors) {
201 932711c7 Matt Smith
			$a_unboundcfg['enable'] = isset($pconfig['enable']);
202 439ba83c NOYB
			$a_unboundcfg['port'] = $pconfig['port'];
203 932711c7 Matt Smith
			$a_unboundcfg['dnssec'] = isset($pconfig['dnssec']);
204
			$a_unboundcfg['forwarding'] = isset($pconfig['forwarding']);
205
			$a_unboundcfg['regdhcp'] = isset($pconfig['regdhcp']);
206
			$a_unboundcfg['regdhcpstatic'] = isset($pconfig['regdhcpstatic']);
207
			$a_unboundcfg['active_interface'] = $pconfig['active_interface'];
208
			$a_unboundcfg['outgoing_interface'] = $pconfig['outgoing_interface'];
209 ca47c065 NOYB
			$a_unboundcfg['system_domain_local_zone_type'] = $pconfig['system_domain_local_zone_type'];
210 932711c7 Matt Smith
			$a_unboundcfg['custom_options'] = $pconfig['custom_options'];
211
212 4bb7c0d1 bruno
			write_config(gettext("DNS Resolver configured."));
213 2783e408 Renato Botelho
			mark_subsystem_dirty('unbound');
214
		}
215 932711c7 Matt Smith
216
		$pconfig['active_interface'] = $display_active_interface;
217
		$pconfig['outgoing_interface'] = $display_outgoing_interface;
218
		$pconfig['custom_options'] = $display_custom_options;
219 2783e408 Renato Botelho
	}
220 7ed0e844 Warren Baker
}
221
222 c154cd7d NOYB
if ($pconfig['custom_options']) {
223
	$customoptions = true;
224
} else {
225
	$customoptions = false;
226
}
227
228 f2bc186f Warren Baker
if ($_GET['act'] == "del") {
229 2783e408 Renato Botelho
	if ($_GET['type'] == 'host') {
230
		if ($a_hosts[$_GET['id']]) {
231
			unset($a_hosts[$_GET['id']]);
232
			write_config();
233
			mark_subsystem_dirty('unbound');
234
			header("Location: services_unbound.php");
235
			exit;
236
		}
237
	} elseif ($_GET['type'] == 'doverride') {
238
		if ($a_domainOverrides[$_GET['id']]) {
239
			unset($a_domainOverrides[$_GET['id']]);
240
			write_config();
241
			mark_subsystem_dirty('unbound');
242
			header("Location: services_unbound.php");
243
			exit;
244
		}
245
	}
246 f2bc186f Warren Baker
}
247
248 7aeae838 Matt Smith
function build_if_list($selectedifs) {
249 51c224bc sbeaver
	$interface_addresses = get_possible_listen_ips(true);
250
	$iflist = array('options' => array(), 'selected' => array());
251
252 4bb7c0d1 bruno
	$iflist['options']['all']	= gettext("All");
253 7aeae838 Matt Smith
	if (empty($selectedifs) || empty($selectedifs[0]) || in_array("all", $selectedifs)) {
254 7275a7a2 Stephen Beaver
		array_push($iflist['selected'], "all");
255 7aeae838 Matt Smith
	}
256 51c224bc sbeaver
257
	foreach ($interface_addresses as $laddr => $ldescr) {
258
		$iflist['options'][$laddr] = htmlspecialchars($ldescr);
259
260 20db3e1a Phil Davis
		if ($selectedifs && in_array($laddr, $selectedifs)) {
261 51c224bc sbeaver
			array_push($iflist['selected'], $laddr);
262 20db3e1a Phil Davis
		}
263 51c224bc sbeaver
	}
264
265
	unset($interface_addresses);
266
267
	return($iflist);
268
}
269
270 c8f6b745 k-paulius
$pgtitle = array(gettext("Services"), gettext("DNS Resolver"), gettext("General Settings"));
271 de02dc29 Phil Davis
$pglinks = array("", "@self", "@self");
272 db88a3a2 Phil Davis
$shortcut_section = "resolver";
273 7ed0e844 Warren Baker
274 51c224bc sbeaver
include_once("head.inc");
275 7ed0e844 Warren Baker
276 20db3e1a Phil Davis
if ($input_errors) {
277 51c224bc sbeaver
	print_input_errors($input_errors);
278 20db3e1a Phil Davis
}
279 51c224bc sbeaver
280 20db3e1a Phil Davis
if ($savemsg) {
281 51c224bc sbeaver
	print_info_box($savemsg, 'success');
282 20db3e1a Phil Davis
}
283 51c224bc sbeaver
284 7aeae838 Matt Smith
if (is_subsystem_dirty('unbound')) {
285 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."));
286 7aeae838 Matt Smith
}
287
288 51c224bc sbeaver
$tab_array = array();
289 c8f6b745 k-paulius
$tab_array[] = array(gettext("General Settings"), true, "services_unbound.php");
290
$tab_array[] = array(gettext("Advanced Settings"), false, "services_unbound_advanced.php");
291 51c224bc sbeaver
$tab_array[] = array(gettext("Access Lists"), false, "/services_unbound_acls.php");
292
display_top_tabs($tab_array, true);
293
294
$form = new Form();
295
296
$section = new Form_Section('General DNS Resolver Options');
297
298
$section->addInput(new Form_Checkbox(
299
	'enable',
300
	'Enable',
301
	'Enable DNS resolver',
302
	$pconfig['enable']
303
));
304
305
$section->addInput(new Form_Input(
306
	'port',
307
	'Listen Port',
308 d5a9e030 NOYB
	'number',
309 3e568739 NOYB
	$pconfig['port'],
310
	['placeholder' => '53']
311 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.');
312
313 7aeae838 Matt Smith
$activeiflist = build_if_list($pconfig['active_interface']);
314 51c224bc sbeaver
315
$section->addInput(new Form_Select(
316
	'active_interface',
317 57965f9b Phil Davis
	'*Network Interfaces',
318 7aeae838 Matt Smith
	$activeiflist['selected'],
319
	$activeiflist['options'],
320 51c224bc sbeaver
	true
321 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. ' .
322 51c224bc sbeaver
			'The default behavior is to respond to queries on every available IPv4 and IPv6 address.');
323
324 7aeae838 Matt Smith
$outiflist = build_if_list($pconfig['outgoing_interface']);
325
326 51c224bc sbeaver
$section->addInput(new Form_Select(
327
	'outgoing_interface',
328 57965f9b Phil Davis
	'*Outgoing Network Interfaces',
329 7aeae838 Matt Smith
	$outiflist['selected'],
330
	$outiflist['options'],
331 51c224bc sbeaver
	true
332 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.');
333 51c224bc sbeaver
334 ca47c065 NOYB
$section->addInput(new Form_Select(
335
	'system_domain_local_zone_type',
336 57965f9b Phil Davis
	'*System Domain Local Zone Type',
337 ca47c065 NOYB
	$pconfig['system_domain_local_zone_type'],
338 9a83872f NOYB
	unbound_local_zone_types()
339 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.');
340
341 51c224bc sbeaver
$section->addInput(new Form_Checkbox(
342
	'dnssec',
343
	'DNSSEC',
344
	'Enable DNSSEC Support',
345
	$pconfig['dnssec']
346
));
347
348
$section->addInput(new Form_Checkbox(
349
	'forwarding',
350
	'DNS Query Forwarding',
351
	'Enable Forwarding Mode',
352
	$pconfig['forwarding']
353 1d0322b5 doktornotor
))->setHelp(sprintf('If this option is set, DNS queries will be forwarded to the upstream DNS servers defined under'.
354 ff2c0021 doktornotor
					' %sSystem &gt; General Setup%s or those obtained via DHCP/PPP on WAN'.
355 1d0322b5 doktornotor
					' (if DNS Server Override is enabled there).','<a href="system.php">','</a>'));
356 51c224bc sbeaver
357
$section->addInput(new Form_Checkbox(
358
	'regdhcp',
359
	'DHCP Registration',
360
	'Register DHCP leases in the DNS Resolver',
361
	$pconfig['regdhcp']
362
))->setHelp(sprintf('If this option is set, then machines that specify their hostname when requesting a DHCP lease will be registered'.
363
					' in the DNS Resolver, so that their name can be resolved.'.
364 ff2c0021 doktornotor
					' The domain in %sSystem &gt; General Setup%s should also be set to the proper value.','<a href="system.php">','</a>'));
365 51c224bc sbeaver
366
$section->addInput(new Form_Checkbox(
367
	'regdhcpstatic',
368
	'Static DHCP',
369
	'Register DHCP static mappings in the DNS Resolver',
370
	$pconfig['regdhcpstatic']
371 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. '.
372 ff2c0021 doktornotor
					'The domain in %sSystem &gt; General Setup%s should also be set to the proper value.','<a href="system.php">','</a>'));
373 51c224bc sbeaver
374 2c95f1cd Phil Davis
$btnadv = new Form_Button(
375
	'btnadvcustom',
376 faab522f Renato Botelho
	'Custom options',
377 3314e626 jim-p
	null,
378
	'fa-cog'
379 51c224bc sbeaver
);
380
381 49d3b157 NOYB
$btnadv->setAttribute('type','button')->addClass('btn-info btn-sm');
382 51c224bc sbeaver
383
$section->addInput(new Form_StaticText(
384 2c95f1cd Phil Davis
	'Display Custom Options',
385
	$btnadv
386 51c224bc sbeaver
));
387
388 1fcfea39 Stephen Beaver
$section->addInput(new Form_Textarea (
389 51c224bc sbeaver
	'custom_options',
390
	'Custom options',
391
	$pconfig['custom_options']
392 46a8a9cf NOYB
))->setHelp('Enter any additional configuration parameters to add to the DNS Resolver configuration here, separated by a newline.');
393 51c224bc sbeaver
394
$form->add($section);
395
print($form);
396
?>
397 932711c7 Matt Smith
398 8fd9052f Colin Fleming
<script type="text/javascript">
399 51c224bc sbeaver
//<![CDATA[
400 20db3e1a Phil Davis
events.push(function() {
401 51c224bc sbeaver
402 2c95f1cd Phil Davis
	// Show advanced custom options ==============================================
403
	var showadvcustom = false;
404
405
	function show_advcustom(ispageload) {
406
		var text;
407
		// On page load decide the initial state based on the data.
408
		if (ispageload) {
409 28e3d579 NewEraCracker
			showadvcustom = <?=($customoptions ? 'true' : 'false');?>;
410 2c95f1cd Phil Davis
		} else {
411
			// It was a click, swap the state.
412
			showadvcustom = !showadvcustom;
413
		}
414
415
		hideInput('custom_options', !showadvcustom);
416
417
		if (showadvcustom) {
418
			text = "<?=gettext('Hide Custom Options');?>";
419
		} else {
420
			text = "<?=gettext('Display Custom Options');?>";
421
		}
422
		$('#btnadvcustom').html('<i class="fa fa-cog"></i> ' + text);
423
	}
424
425 d3a3eef0 Francisco Cavalcante
	// If the enable checkbox is not checked, hide all inputs
426
	function hideGeneral() {
427 51c224bc sbeaver
		var hide = ! $('#enable').prop('checked');
428
429 d3a3eef0 Francisco Cavalcante
		hideMultiClass('general', hide);
430
		hideInput('port', hide);
431
		hideSelect('system_domain_local_zone_type', hide);
432
		hideCheckbox('dnssec', hide);
433
		hideCheckbox('forwarding', hide);
434
		hideCheckbox('regdhcp', hide);
435
		hideCheckbox('regdhcpstatic', hide);
436 2c95f1cd Phil Davis
		hideInput('btnadvcustom', hide);
437
		hideInput('custom_options', hide || !showadvcustom);
438 51c224bc sbeaver
	}
439
440 2c95f1cd Phil Davis
	// Un-hide additional controls
441
	$('#btnadvcustom').click(function(event) {
442
		show_advcustom();
443 51c224bc sbeaver
	});
444
445 d3a3eef0 Francisco Cavalcante
	// When 'enable' is clicked, disable/enable the following hide inputs
446 51c224bc sbeaver
	$('#enable').click(function() {
447 d3a3eef0 Francisco Cavalcante
		hideGeneral();
448 51c224bc sbeaver
	});
449
450
	// On initial load
451 20db3e1a Phil Davis
	if ($('#custom_options').val().length == 0) {
452 df6cb8fe Stephen Beaver
		hideInput('custom_options', true);
453
	}
454
455 d3a3eef0 Francisco Cavalcante
	hideGeneral();
456 2c95f1cd Phil Davis
	show_advcustom(true);
457 51c224bc sbeaver
458
});
459
//]]>
460
</script>
461
462
<div class="panel panel-default">
463 f17594c7 Sjon Hortensius
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Host Overrides")?></h2></div>
464 51c224bc sbeaver
	<div class="panel-body table-responsive">
465 91677170 PiBa-NL
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
466 51c224bc sbeaver
			<thead>
467 2783e408 Renato Botelho
				<tr>
468 51c224bc sbeaver
					<th><?=gettext("Host")?></th>
469
					<th><?=gettext("Domain")?></th>
470
					<th><?=gettext("IP")?></th>
471
					<th><?=gettext("Description")?></th>
472 21d973b2 Phil Davis
					<th><?=gettext("Actions")?></th>
473 2783e408 Renato Botelho
				</tr>
474 51c224bc sbeaver
			</thead>
475
			<tbody>
476
<?php
477
$i = 0;
478
foreach ($a_hosts as $hostent):
479
?>
480 2783e408 Renato Botelho
				<tr>
481 51c224bc sbeaver
					<td>
482 c8a7d17c NOYB
						<?=$hostent['host']?>
483 51c224bc sbeaver
					</td>
484
					<td>
485 c8a7d17c NOYB
						<?=$hostent['domain']?>
486 51c224bc sbeaver
					</td>
487
					<td>
488 de038a27 Stephen Beaver
						<?=$hostent['ip']?>
489 51c224bc sbeaver
					</td>
490
					<td>
491
						<?=htmlspecialchars($hostent['descr'])?>
492
					</td>
493
					<td>
494 33f0b0d5 Stephen Beaver
						<a class="fa fa-pencil"	title="<?=gettext('Edit host override')?>" href="services_unbound_host_edit.php?id=<?=$i?>"></a>
495
						<a class="fa fa-trash"	title="<?=gettext('Delete host override')?>" href="services_unbound.php?type=host&amp;act=del&amp;id=<?=$i?>"></a>
496 51c224bc sbeaver
					</td>
497 2783e408 Renato Botelho
				</tr>
498 51c224bc sbeaver
499
<?php
500
	if ($hostent['aliases']['item'] && is_array($hostent['aliases']['item'])):
501
		foreach ($hostent['aliases']['item'] as $alias):
502
?>
503 2783e408 Renato Botelho
				<tr>
504 51c224bc sbeaver
					<td>
505 c8a7d17c NOYB
						<?=$alias['host']?>
506 51c224bc sbeaver
					</td>
507
					<td>
508 c8a7d17c NOYB
						<?=$alias['domain']?>
509 51c224bc sbeaver
					</td>
510
					<td>
511 4bb7c0d1 bruno
						<?=gettext("Alias for ");?><?=$hostent['host'] ? $hostent['host'] . '.' . $hostent['domain'] : $hostent['domain']?>
512 51c224bc sbeaver
					</td>
513
					<td>
514 39bd0b51 Stephen Beaver
						<i class="fa fa-angle-double-right text-info"></i>
515 51c224bc sbeaver
						<?=htmlspecialchars($alias['description'])?>
516
					</td>
517
					<td>
518 91677170 PiBa-NL
						<a class="fa fa-pencil"	title="<?=gettext('Edit host override')?>" 	href="services_unbound_host_edit.php?id=<?=$i?>"></a>
519 51c224bc sbeaver
					</td>
520 2783e408 Renato Botelho
				</tr>
521 51c224bc sbeaver
<?php
522
		endforeach;
523
	endif;
524
	$i++;
525
endforeach;
526
?>
527
			</tbody>
528
		</table>
529
	</div>
530
</div>
531
532 c10cb196 Stephen Beaver
<nav class="action-buttons">
533 782922c2 Stephen Beaver
	<a href="services_unbound_host_edit.php" class="btn btn-sm btn-success">
534 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
535 782922c2 Stephen Beaver
		<?=gettext('Add')?>
536
	</a>
537 51c224bc sbeaver
</nav>
538
539
<div class="panel panel-default">
540 f17594c7 Sjon Hortensius
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Domain Overrides")?></h2></div>
541 51c224bc sbeaver
	<div class="panel-body table-responsive">
542 91677170 PiBa-NL
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
543 51c224bc sbeaver
			<thead>
544 2783e408 Renato Botelho
				<tr>
545 51c224bc sbeaver
					<th><?=gettext("Domain")?></th>
546
					<th><?=gettext("IP")?></th>
547
					<th><?=gettext("Description")?></th>
548 21d973b2 Phil Davis
					<th><?=gettext("Actions")?></th>
549 2783e408 Renato Botelho
				</tr>
550 51c224bc sbeaver
			</thead>
551
552
			<tbody>
553
<?php
554
$i = 0;
555
foreach ($a_domainOverrides as $doment):
556
?>
557 2783e408 Renato Botelho
				<tr>
558 51c224bc sbeaver
					<td>
559 c8a7d17c NOYB
						<?=$doment['domain']?>&nbsp;
560 51c224bc sbeaver
					</td>
561
					<td>
562
						<?=$doment['ip']?>&nbsp;
563
					</td>
564
					<td>
565
						<?=htmlspecialchars($doment['descr'])?>&nbsp;
566
					</td>
567
					<td>
568 33f0b0d5 Stephen Beaver
						<a class="fa fa-pencil"	title="<?=gettext('Edit domain override')?>" href="services_unbound_domainoverride_edit.php?id=<?=$i?>"></a>
569
						<a class="fa fa-trash"	title="<?=gettext('Delete domain override')?>" href="services_unbound.php?act=del&amp;type=doverride&amp;id=<?=$i?>"></a>
570 51c224bc sbeaver
					</td>
571 2783e408 Renato Botelho
				</tr>
572 51c224bc sbeaver
<?php
573
	$i++;
574
endforeach;
575
?>
576
			</tbody>
577
		</table>
578
	</div>
579
</div>
580
581 c10cb196 Stephen Beaver
<nav class="action-buttons">
582 782922c2 Stephen Beaver
	<a href="services_unbound_domainoverride_edit.php" class="btn btn-sm btn-success">
583 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
584 782922c2 Stephen Beaver
		<?=gettext('Add')?>
585
	</a>
586 51c224bc sbeaver
</nav>
587 782922c2 Stephen Beaver
588 35681930 Stephen Beaver
<div class="infoblock">
589 f6aebbcc NewEraCracker
	<?php print_info_box(sprintf(gettext("If the DNS Resolver is enabled, the DHCP".
590 782922c2 Stephen Beaver
		" service (if enabled) will automatically serve the LAN IP".
591
		" address as a DNS server to DHCP clients so they will use".
592 520ee1d0 Phil Davis
		" the DNS Resolver. If Forwarding is enabled, the DNS Resolver will use the DNS servers".
593 ff2c0021 doktornotor
		" entered in %sSystem &gt; General Setup%s".
594 520ee1d0 Phil Davis
		" or those obtained via DHCP or PPP on WAN if &quot;Allow".
595 782922c2 Stephen Beaver
		" DNS server list to be overridden by DHCP/PPP on WAN&quot;".
596 f6aebbcc NewEraCracker
		" is checked."), '<a href="system.php">', '</a>'), 'info', false); ?>
597 782922c2 Stephen Beaver
</div>
598 82afb104 Stephen Beaver
599 6f65dc19 Chris Buechler
<?php include("foot.inc");