Project

General

Profile

Download (18.9 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
				$input_errors[] = gettext("At least one DNS server must be specified under System>General Setup to enable Forwarding mode.");
164
			}
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 db88a3a2 Phil Davis
$shortcut_section = "resolver";
272 7ed0e844 Warren Baker
273 51c224bc sbeaver
include_once("head.inc");
274 7ed0e844 Warren Baker
275 20db3e1a Phil Davis
if ($input_errors) {
276 51c224bc sbeaver
	print_input_errors($input_errors);
277 20db3e1a Phil Davis
}
278 51c224bc sbeaver
279 20db3e1a Phil Davis
if ($savemsg) {
280 51c224bc sbeaver
	print_info_box($savemsg, 'success');
281 20db3e1a Phil Davis
}
282 51c224bc sbeaver
283 7aeae838 Matt Smith
if (is_subsystem_dirty('unbound')) {
284 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."));
285 7aeae838 Matt Smith
}
286
287 51c224bc sbeaver
$tab_array = array();
288 c8f6b745 k-paulius
$tab_array[] = array(gettext("General Settings"), true, "services_unbound.php");
289
$tab_array[] = array(gettext("Advanced Settings"), false, "services_unbound_advanced.php");
290 51c224bc sbeaver
$tab_array[] = array(gettext("Access Lists"), false, "/services_unbound_acls.php");
291
display_top_tabs($tab_array, true);
292
293
$form = new Form();
294
295
$section = new Form_Section('General DNS Resolver Options');
296
297
$section->addInput(new Form_Checkbox(
298
	'enable',
299
	'Enable',
300
	'Enable DNS resolver',
301
	$pconfig['enable']
302
));
303
304
$section->addInput(new Form_Input(
305
	'port',
306
	'Listen Port',
307 d5a9e030 NOYB
	'number',
308 3e568739 NOYB
	$pconfig['port'],
309
	['placeholder' => '53']
310 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.');
311
312 7aeae838 Matt Smith
$activeiflist = build_if_list($pconfig['active_interface']);
313 51c224bc sbeaver
314
$section->addInput(new Form_Select(
315
	'active_interface',
316
	'Network Interfaces',
317 7aeae838 Matt Smith
	$activeiflist['selected'],
318
	$activeiflist['options'],
319 51c224bc sbeaver
	true
320 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. ' .
321 51c224bc sbeaver
			'The default behavior is to respond to queries on every available IPv4 and IPv6 address.');
322
323 7aeae838 Matt Smith
$outiflist = build_if_list($pconfig['outgoing_interface']);
324
325 51c224bc sbeaver
$section->addInput(new Form_Select(
326
	'outgoing_interface',
327
	'Outgoing Network Interfaces',
328 7aeae838 Matt Smith
	$outiflist['selected'],
329
	$outiflist['options'],
330 51c224bc sbeaver
	true
331 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.');
332 51c224bc sbeaver
333 ca47c065 NOYB
$section->addInput(new Form_Select(
334
	'system_domain_local_zone_type',
335
	'System Domain Local Zone Type',
336
	$pconfig['system_domain_local_zone_type'],
337 9a83872f NOYB
	unbound_local_zone_types()
338 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.');
339
340 51c224bc sbeaver
$section->addInput(new Form_Checkbox(
341
	'dnssec',
342
	'DNSSEC',
343
	'Enable DNSSEC Support',
344
	$pconfig['dnssec']
345
));
346
347
$section->addInput(new Form_Checkbox(
348
	'forwarding',
349
	'DNS Query Forwarding',
350
	'Enable Forwarding Mode',
351
	$pconfig['forwarding']
352
));
353
354
$section->addInput(new Form_Checkbox(
355
	'regdhcp',
356
	'DHCP Registration',
357
	'Register DHCP leases in the DNS Resolver',
358
	$pconfig['regdhcp']
359
))->setHelp(sprintf('If this option is set, then machines that specify their hostname when requesting a DHCP lease will be registered'.
360
					' in the DNS Resolver, so that their name can be resolved.'.
361 bce2ce60 NOYB
					' The domain in %sSystem: General Setup%s should also be set to the proper value.','<a href="system.php">','</a>'));
362 51c224bc sbeaver
363
$section->addInput(new Form_Checkbox(
364
	'regdhcpstatic',
365
	'Static DHCP',
366
	'Register DHCP static mappings in the DNS Resolver',
367
	$pconfig['regdhcpstatic']
368 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. '.
369 bce2ce60 NOYB
					'The domain in %sSystem: General Setup%s should also be set to the proper value.','<a href="system.php">','</a>'));
370 51c224bc sbeaver
371 2c95f1cd Phil Davis
$btnadv = new Form_Button(
372
	'btnadvcustom',
373 faab522f Renato Botelho
	'Custom options',
374 3314e626 jim-p
	null,
375
	'fa-cog'
376 51c224bc sbeaver
);
377
378 49d3b157 NOYB
$btnadv->setAttribute('type','button')->addClass('btn-info btn-sm');
379 51c224bc sbeaver
380
$section->addInput(new Form_StaticText(
381 2c95f1cd Phil Davis
	'Display Custom Options',
382
	$btnadv
383 51c224bc sbeaver
));
384
385 1fcfea39 Stephen Beaver
$section->addInput(new Form_Textarea (
386 51c224bc sbeaver
	'custom_options',
387
	'Custom options',
388
	$pconfig['custom_options']
389 46a8a9cf NOYB
))->setHelp('Enter any additional configuration parameters to add to the DNS Resolver configuration here, separated by a newline.');
390 51c224bc sbeaver
391
$form->add($section);
392
print($form);
393
?>
394 932711c7 Matt Smith
395 8fd9052f Colin Fleming
<script type="text/javascript">
396 51c224bc sbeaver
//<![CDATA[
397 20db3e1a Phil Davis
events.push(function() {
398 51c224bc sbeaver
399 2c95f1cd Phil Davis
	// Show advanced custom options ==============================================
400
	var showadvcustom = false;
401
402
	function show_advcustom(ispageload) {
403
		var text;
404
		// On page load decide the initial state based on the data.
405
		if (ispageload) {
406 28e3d579 NewEraCracker
			showadvcustom = <?=($customoptions ? 'true' : 'false');?>;
407 2c95f1cd Phil Davis
		} else {
408
			// It was a click, swap the state.
409
			showadvcustom = !showadvcustom;
410
		}
411
412
		hideInput('custom_options', !showadvcustom);
413
414
		if (showadvcustom) {
415
			text = "<?=gettext('Hide Custom Options');?>";
416
		} else {
417
			text = "<?=gettext('Display Custom Options');?>";
418
		}
419
		$('#btnadvcustom').html('<i class="fa fa-cog"></i> ' + text);
420
	}
421
422 d3a3eef0 Francisco Cavalcante
	// If the enable checkbox is not checked, hide all inputs
423
	function hideGeneral() {
424 51c224bc sbeaver
		var hide = ! $('#enable').prop('checked');
425
426 d3a3eef0 Francisco Cavalcante
		hideMultiClass('general', hide);
427
		hideInput('port', hide);
428
		hideSelect('system_domain_local_zone_type', hide);
429
		hideCheckbox('dnssec', hide);
430
		hideCheckbox('forwarding', hide);
431
		hideCheckbox('regdhcp', hide);
432
		hideCheckbox('regdhcpstatic', hide);
433 2c95f1cd Phil Davis
		hideInput('btnadvcustom', hide);
434
		hideInput('custom_options', hide || !showadvcustom);
435 51c224bc sbeaver
	}
436
437 2c95f1cd Phil Davis
	// Un-hide additional controls
438
	$('#btnadvcustom').click(function(event) {
439
		show_advcustom();
440 51c224bc sbeaver
	});
441
442 d3a3eef0 Francisco Cavalcante
	// When 'enable' is clicked, disable/enable the following hide inputs
443 51c224bc sbeaver
	$('#enable').click(function() {
444 d3a3eef0 Francisco Cavalcante
		hideGeneral();
445 51c224bc sbeaver
	});
446
447
	// On initial load
448 20db3e1a Phil Davis
	if ($('#custom_options').val().length == 0) {
449 df6cb8fe Stephen Beaver
		hideInput('custom_options', true);
450
	}
451
452 d3a3eef0 Francisco Cavalcante
	hideGeneral();
453 2c95f1cd Phil Davis
	show_advcustom(true);
454 51c224bc sbeaver
455
});
456
//]]>
457
</script>
458
459
<div class="panel panel-default">
460 f17594c7 Sjon Hortensius
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Host Overrides")?></h2></div>
461 51c224bc sbeaver
	<div class="panel-body table-responsive">
462 91677170 PiBa-NL
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
463 51c224bc sbeaver
			<thead>
464 2783e408 Renato Botelho
				<tr>
465 51c224bc sbeaver
					<th><?=gettext("Host")?></th>
466
					<th><?=gettext("Domain")?></th>
467
					<th><?=gettext("IP")?></th>
468
					<th><?=gettext("Description")?></th>
469 21d973b2 Phil Davis
					<th><?=gettext("Actions")?></th>
470 2783e408 Renato Botelho
				</tr>
471 51c224bc sbeaver
			</thead>
472
			<tbody>
473
<?php
474
$i = 0;
475
foreach ($a_hosts as $hostent):
476
?>
477 2783e408 Renato Botelho
				<tr>
478 51c224bc sbeaver
					<td>
479 c8a7d17c NOYB
						<?=$hostent['host']?>
480 51c224bc sbeaver
					</td>
481
					<td>
482 c8a7d17c NOYB
						<?=$hostent['domain']?>
483 51c224bc sbeaver
					</td>
484
					<td>
485 de038a27 Stephen Beaver
						<?=$hostent['ip']?>
486 51c224bc sbeaver
					</td>
487
					<td>
488
						<?=htmlspecialchars($hostent['descr'])?>
489
					</td>
490
					<td>
491 33f0b0d5 Stephen Beaver
						<a class="fa fa-pencil"	title="<?=gettext('Edit host override')?>" href="services_unbound_host_edit.php?id=<?=$i?>"></a>
492
						<a class="fa fa-trash"	title="<?=gettext('Delete host override')?>" href="services_unbound.php?type=host&amp;act=del&amp;id=<?=$i?>"></a>
493 51c224bc sbeaver
					</td>
494 2783e408 Renato Botelho
				</tr>
495 51c224bc sbeaver
496
<?php
497
	if ($hostent['aliases']['item'] && is_array($hostent['aliases']['item'])):
498
		foreach ($hostent['aliases']['item'] as $alias):
499
?>
500 2783e408 Renato Botelho
				<tr>
501 51c224bc sbeaver
					<td>
502 c8a7d17c NOYB
						<?=$alias['host']?>
503 51c224bc sbeaver
					</td>
504
					<td>
505 c8a7d17c NOYB
						<?=$alias['domain']?>
506 51c224bc sbeaver
					</td>
507
					<td>
508 4bb7c0d1 bruno
						<?=gettext("Alias for ");?><?=$hostent['host'] ? $hostent['host'] . '.' . $hostent['domain'] : $hostent['domain']?>
509 51c224bc sbeaver
					</td>
510
					<td>
511 39bd0b51 Stephen Beaver
						<i class="fa fa-angle-double-right text-info"></i>
512 51c224bc sbeaver
						<?=htmlspecialchars($alias['description'])?>
513
					</td>
514
					<td>
515 91677170 PiBa-NL
						<a class="fa fa-pencil"	title="<?=gettext('Edit host override')?>" 	href="services_unbound_host_edit.php?id=<?=$i?>"></a>
516 51c224bc sbeaver
					</td>
517 2783e408 Renato Botelho
				</tr>
518 51c224bc sbeaver
<?php
519
		endforeach;
520
	endif;
521
	$i++;
522
endforeach;
523
?>
524
			</tbody>
525
		</table>
526
	</div>
527
</div>
528
529 c10cb196 Stephen Beaver
<nav class="action-buttons">
530 782922c2 Stephen Beaver
	<a href="services_unbound_host_edit.php" class="btn btn-sm btn-success">
531 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
532 782922c2 Stephen Beaver
		<?=gettext('Add')?>
533
	</a>
534 51c224bc sbeaver
</nav>
535
536
<div class="panel panel-default">
537 f17594c7 Sjon Hortensius
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Domain Overrides")?></h2></div>
538 51c224bc sbeaver
	<div class="panel-body table-responsive">
539 91677170 PiBa-NL
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
540 51c224bc sbeaver
			<thead>
541 2783e408 Renato Botelho
				<tr>
542 51c224bc sbeaver
					<th><?=gettext("Domain")?></th>
543
					<th><?=gettext("IP")?></th>
544
					<th><?=gettext("Description")?></th>
545 21d973b2 Phil Davis
					<th><?=gettext("Actions")?></th>
546 2783e408 Renato Botelho
				</tr>
547 51c224bc sbeaver
			</thead>
548
549
			<tbody>
550
<?php
551
$i = 0;
552
foreach ($a_domainOverrides as $doment):
553
?>
554 2783e408 Renato Botelho
				<tr>
555 51c224bc sbeaver
					<td>
556 c8a7d17c NOYB
						<?=$doment['domain']?>&nbsp;
557 51c224bc sbeaver
					</td>
558
					<td>
559
						<?=$doment['ip']?>&nbsp;
560
					</td>
561
					<td>
562
						<?=htmlspecialchars($doment['descr'])?>&nbsp;
563
					</td>
564
					<td>
565 33f0b0d5 Stephen Beaver
						<a class="fa fa-pencil"	title="<?=gettext('Edit domain override')?>" href="services_unbound_domainoverride_edit.php?id=<?=$i?>"></a>
566
						<a class="fa fa-trash"	title="<?=gettext('Delete domain override')?>" href="services_unbound.php?act=del&amp;type=doverride&amp;id=<?=$i?>"></a>
567 51c224bc sbeaver
					</td>
568 2783e408 Renato Botelho
				</tr>
569 51c224bc sbeaver
<?php
570
	$i++;
571
endforeach;
572
?>
573
			</tbody>
574
		</table>
575
	</div>
576
</div>
577
578 c10cb196 Stephen Beaver
<nav class="action-buttons">
579 782922c2 Stephen Beaver
	<a href="services_unbound_domainoverride_edit.php" class="btn btn-sm btn-success">
580 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
581 782922c2 Stephen Beaver
		<?=gettext('Add')?>
582
	</a>
583 51c224bc sbeaver
</nav>
584 782922c2 Stephen Beaver
585 35681930 Stephen Beaver
<div class="infoblock">
586 f6aebbcc NewEraCracker
	<?php print_info_box(sprintf(gettext("If the DNS Resolver is enabled, the DHCP".
587 782922c2 Stephen Beaver
		" service (if enabled) will automatically serve the LAN IP".
588
		" address as a DNS server to DHCP clients so they will use".
589 520ee1d0 Phil Davis
		" the DNS Resolver. If Forwarding is enabled, the DNS Resolver will use the DNS servers".
590 bce2ce60 NOYB
		" entered in %sSystem: General Setup%s".
591 520ee1d0 Phil Davis
		" or those obtained via DHCP or PPP on WAN if &quot;Allow".
592 782922c2 Stephen Beaver
		" DNS server list to be overridden by DHCP/PPP on WAN&quot;".
593 f6aebbcc NewEraCracker
		" is checked."), '<a href="system.php">', '</a>'), 'info', false); ?>
594 782922c2 Stephen Beaver
</div>
595 82afb104 Stephen Beaver
596 6f65dc19 Chris Buechler
<?php include("foot.inc");