Project

General

Profile

Download (11 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	services_dnsmasq.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6 f0fe3d30 Scott Ullrich
7 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Bob Zoller <bob@kludgebox.com> and Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9 f0fe3d30 Scott Ullrich
10 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12 f0fe3d30 Scott Ullrich
13 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15 f0fe3d30 Scott Ullrich
16 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19 f0fe3d30 Scott Ullrich
20 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31 70edf50d jim-p
/*
32 1d333258 Scott Ullrich
	pfSense_MODULE:	dnsforwarder
33
*/
34 5b237745 Scott Ullrich
35 6b07c15a Matthew Grooms
##|+PRIV
36
##|*IDENT=page-services-dnsforwarder
37
##|*NAME=Services: DNS Forwarder page
38
##|*DESCR=Allow access to the 'Services: DNS Forwarder' page.
39
##|*MATCH=services_dnsmasq.php*
40
##|-PRIV
41
42 5b237745 Scott Ullrich
require("guiconfig.inc");
43 7a927e67 Scott Ullrich
require_once("functions.inc");
44
require_once("filter.inc");
45
require_once("shaper.inc");
46 5b237745 Scott Ullrich
47 70edf50d jim-p
$pconfig['enable'] = isset($config['dnsmasq']['enable']);
48 5b237745 Scott Ullrich
$pconfig['regdhcp'] = isset($config['dnsmasq']['regdhcp']);
49 6a01ea44 Bill Marquette
$pconfig['regdhcpstatic'] = isset($config['dnsmasq']['regdhcpstatic']);
50 5b237745 Scott Ullrich
51 70edf50d jim-p
if (!is_array($config['dnsmasq']['hosts']))
52 5b237745 Scott Ullrich
	$config['dnsmasq']['hosts'] = array();
53 0c2b5df7 Scott Ullrich
54 70edf50d jim-p
if (!is_array($config['dnsmasq']['domainoverrides']))
55
	$config['dnsmasq']['domainoverrides'] = array();
56 0c2b5df7 Scott Ullrich
57 4d6ba181 Scott Ullrich
58 70edf50d jim-p
$a_hosts = &$config['dnsmasq']['hosts'];
59 0c2b5df7 Scott Ullrich
$a_domainOverrides = &$config['dnsmasq']['domainoverrides'];
60 5b237745 Scott Ullrich
61
if ($_POST) {
62
63
	$pconfig = $_POST;
64
65
	$config['dnsmasq']['enable'] = ($_POST['enable']) ? true : false;
66
	$config['dnsmasq']['regdhcp'] = ($_POST['regdhcp']) ? true : false;
67 6a01ea44 Bill Marquette
	$config['dnsmasq']['regdhcpstatic'] = ($_POST['regdhcpstatic']) ? true : false;
68 5b237745 Scott Ullrich
69
	write_config();
70 f0fe3d30 Scott Ullrich
71 5b237745 Scott Ullrich
	$retval = 0;
72 920b3bb0 Scott Ullrich
	$retval = services_dnsmasq_configure();
73 5b237745 Scott Ullrich
	$savemsg = get_std_save_message($retval);
74
75 020d757a Scott Ullrich
	// Relaod filter (we might need to sync to CARP hosts)
76
	filter_configure();
77
78 a368a026 Ermal Lu?i
	if ($retval == 0)
79
		clear_subsystem_dirty('hosts');
80 5b237745 Scott Ullrich
}
81
82
if ($_GET['act'] == "del") {
83 70edf50d jim-p
	if ($_GET['type'] == 'host') {
84
		if ($a_hosts[$_GET['id']]) {
85
			unset($a_hosts[$_GET['id']]);
86
			write_config();
87 a368a026 Ermal Lu?i
			mark_subsystem_dirty('hosts');
88 70edf50d jim-p
			header("Location: services_dnsmasq.php");
89
			exit;
90
		}
91
	}
92
	elseif ($_GET['type'] == 'doverride') {
93
		if ($a_domainOverrides[$_GET['id']]) {
94
			unset($a_domainOverrides[$_GET['id']]);
95
			write_config();
96 a368a026 Ermal Lu?i
			mark_subsystem_dirty('hosts');
97 70edf50d jim-p
			header("Location: services_dnsmasq.php");
98
			exit;
99
		}
100
	}
101 5b237745 Scott Ullrich
}
102 0c2b5df7 Scott Ullrich
103 beb2bc00 Rafael Lucas
$pgtitle = array(gettext("Services"),gettext("DNS forwarder"));
104 b63695db Scott Ullrich
include("head.inc");
105 0c2b5df7 Scott Ullrich
106 5b237745 Scott Ullrich
?>
107
108 6a01ea44 Bill Marquette
<script language="JavaScript">
109
<!--
110
function enable_change(enable_over) {
111
	var endis;
112
	endis = !(document.iform.enable.checked || enable_over);
113
	document.iform.regdhcp.disabled = endis;
114
	document.iform.regdhcpstatic.disabled = endis;
115
}
116
//-->
117
</script>
118
119 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
120
<?php include("fbegin.inc"); ?>
121 6a01ea44 Bill Marquette
<form action="services_dnsmasq.php" method="post" name="iform" id="iform">
122 5b237745 Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
123 a368a026 Ermal Lu?i
<?php if (is_subsystem_dirty('hosts')): ?><p>
124 619c72f9 Carlos Eduardo Ramos
<?php print_info_box_np(gettext("The DNS forwarder configuration has been changed") . ".<br>" . gettext("You must apply the changes in order for them to take effect."));?><br>
125 5b237745 Scott Ullrich
<?php endif; ?>
126 70edf50d jim-p
<table width="100%" border="0" cellpadding="6" cellspacing="0">
127
	<tr>
128
		<td class="vtable"><p>
129
			<input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable'] == "yes") echo "checked";?> onClick="enable_change(false)">
130
			<strong><?=gettext("Enable DNS forwarder");?><br>
131
			</strong></p></td>
132 98776e04 jim-p
		</tr>
133 70edf50d jim-p
	<tr>
134
		<td class="vtable"><p>
135
			<input name="regdhcp" type="checkbox" id="regdhcp" value="yes" <?php if ($pconfig['regdhcp'] == "yes") echo "checked";?>>
136
			<strong><?=gettext("Register DHCP leases in DNS forwarder");?><br>
137
			</strong><?php printf(gettext("If this option is set, then machines that specify".
138
			" their hostname when requesting a DHCP lease will be registered".
139
			" in the DNS forwarder, so that their name can be resolved.".
140
			" You should also set the domain in %sSystem:".
141
			" General setup%s to the proper value."),'<a href="system.php">','</a>')?></p>
142
		</td>
143
	</tr>
144
	<tr>
145
		<td class="vtable"><p>
146
			<input name="regdhcpstatic" type="checkbox" id="regdhcpstatic" value="yes" <?php if ($pconfig['regdhcpstatic'] == "yes") echo "checked";?>>
147
			<strong><?=gettext("Register DHCP static mappings in DNS forwarder");?><br>
148
			</strong><?php printf(gettext("If this option is set, then DHCP static mappings will ".
149
					"be registered in the DNS forwarder, so that their name can be ".
150
					"resolved. You should also set the domain in %s".
151
					"System: General setup%s to the proper value."),'<a href="system.php">','</a>');?></p>
152
		</td>
153
	</tr>
154
	<tr>
155
		<td>
156
			<input name="submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" onclick="enable_change(true)">
157
		</td>
158
	</tr>
159
	<tr>
160
		<td>
161
			<p><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br>
162
			</strong></span><?php printf(gettext("If the DNS forwarder is enabled, the DHCP".
163
			" service (if enabled) will automatically serve the LAN IP".
164
			" address as a DNS server to DHCP clients so they will use".
165
			" the forwarder. The DNS forwarder will use the DNS servers".
166
			" entered in %sSystem: General setup%s".
167
			" or those obtained via DHCP or PPP on WAN if the &quot;Allow".
168
			" DNS server list to be overridden by DHCP/PPP on WAN&quot;".
169
			" is checked. If you don't use that option (or if you use".
170
			" a static IP address on WAN), you must manually specify at".
171
			" least one DNS server on the %sSystem:".
172
			"General setup%s page."),'<a href="system.php">','</a>','<a href="system.php">','</a>');?><br>
173
			<br>
174
			<?=gettext("You may enter records that override the results from the".
175
			" forwarders below.");?></span></p>
176
		</td>
177
	</tr>
178
</table>
179
&nbsp;<br>
180
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="sortable">
181
	<thead>
182
	<tr>
183
		<td width="20%" class="listhdrr"><?=gettext("Host");?></td>
184
		<td width="25%" class="listhdrr"><?=gettext("Domain");?></td>
185
		<td width="20%" class="listhdrr"><?=gettext("IP");?></td>
186
		<td width="25%" class="listhdr"><?=gettext("Description");?></td>
187
		<td width="10%" class="list">
188 d415d821 Seth Mos
			<table border="0" cellspacing="0" cellpadding="1">
189 70edf50d jim-p
				<tr>
190
					<td width="17"></td>
191
					<td valign="middle"><a href="services_dnsmasq_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
192
				</tr>
193 d415d821 Seth Mos
			</table>
194 70edf50d jim-p
		</td>
195
	</tr>
196
	</thead>
197
	<tbody>
198
	<?php $i = 0; foreach ($a_hosts as $hostent): ?>
199
	<tr>
200
		<td class="listlr" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
201
			<?=strtolower($hostent['host']);?>&nbsp;
202
		</td>
203
		<td class="listr" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
204
			<?=strtolower($hostent['domain']);?>&nbsp;
205
		</td>
206
		<td class="listr" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
207
			<?=$hostent['ip'];?>&nbsp;
208
		</td>
209
		<td class="listbg" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
210
			<?=htmlspecialchars($hostent['descr']);?>&nbsp;
211
		</td>
212
		<td valign="middle" nowrap class="list">
213 d415d821 Seth Mos
			<table border="0" cellspacing="0" cellpadding="1">
214 70edf50d jim-p
				<tr>
215
					<td valign="middle"><a href="services_dnsmasq_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
216
					<td><a href="services_dnsmasq.php?type=host&act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this host?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
217
				</tr>
218 d415d821 Seth Mos
			</table>
219 70edf50d jim-p
	</tr>
220
	<?php $i++; endforeach; ?>
221
	</tbody>
222
	<tfoot>
223
	<tr>
224
		<td class="list" colspan="4"></td>
225
		<td class="list">
226
			<table border="0" cellspacing="0" cellpadding="1">
227
				<tr>
228
					<td width="17"></td>
229
					<td valign="middle"><a href="services_dnsmasq_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
230
				</tr>
231
			</table>
232
		</td>
233
	</tr>
234
	</tfoot>
235
</table>
236
<!-- update to enable domain overrides -->
237
<table width="100%" border="0" cellpadding="6" cellspacing="0">
238
	<tr><td>&nbsp;</td></tr>
239
	<tr>
240
		<td><p><?=gettext("Below you can override an entire domain by specifying an".
241
		" authoritative DNS server to be queried for that domain.");?></p></td>
242
	</tr>
243
</table>
244
&nbsp;<br>
245
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="sortable">
246
	<thead>
247
	<tr>
248
		<td width="35%" class="listhdrr"><?=gettext("Domain");?></td>
249
		<td width="20%" class="listhdrr"><?=gettext("IP");?></td>
250
		<td width="35%" class="listhdr"><?=gettext("Description");?></td>
251
		<td width="10%" class="list">
252
			<table border="0" cellspacing="0" cellpadding="1">
253
				<tr>
254
					<td width="17" heigth="17"></td>
255
					<td><a href="services_dnsmasq_domainoverride_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
256
				</tr>
257
			</table>
258
		</td>
259
	</tr>
260
	</thead>
261
	<tbody>
262
	<?php $i = 0; foreach ($a_domainOverrides as $doment): ?>
263
	<tr>
264
		<td class="listlr">
265
			<?=strtolower($doment['domain']);?>&nbsp;
266
		</td>
267
		<td class="listr">
268
			<?=$doment['ip'];?>&nbsp;
269
		</td>
270
		<td class="listbg">
271
			<?=htmlspecialchars($doment['descr']);?>&nbsp;
272
		</td>
273
		<td valign="middle" nowrap class="list"> <a href="services_dnsmasq_domainoverride_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
274
			&nbsp;<a href="services_dnsmasq.php?act=del&type=doverride&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this domain override?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
275
	</tr>
276
	<?php $i++; endforeach; ?>
277
	</tbody>
278
	<tfoot>
279
	<tr>
280
		<td class="list" colspan="3"></td>
281
		<td class="list">
282
		<table border="0" cellspacing="0" cellpadding="1">
283
			<tr>
284
				<td width="17" heigth="17"></td>
285
				<td><a href="services_dnsmasq_domainoverride_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
286
			</tr>
287
		</table>
288
		</td>
289
	</tr>
290
	</tfoot>
291
</table>
292
</form>
293 6a01ea44 Bill Marquette
<script language="JavaScript">
294
<!--
295
enable_change(false);
296
//-->
297
</script>
298 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
299
</body>
300
</html>