Project

General

Profile

Download (10.4 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
32
require("guiconfig.inc");
33
34 4d6ba181 Scott Ullrich
$pconfig['enable']  = isset($config['dnsmasq']['enable']);
35 5b237745 Scott Ullrich
$pconfig['regdhcp'] = isset($config['dnsmasq']['regdhcp']);
36
37 4d6ba181 Scott Ullrich
if (!is_array($config['dnsmasq']['hosts'])) 
38 5b237745 Scott Ullrich
	$config['dnsmasq']['hosts'] = array();
39 0c2b5df7 Scott Ullrich
40 4d6ba181 Scott Ullrich
if (!is_array($config['dnsmasq']['domainoverrides'])) 
41 0c2b5df7 Scott Ullrich
       $config['dnsmasq']['domainoverrides'] = array();
42
43 5b237745 Scott Ullrich
hosts_sort();
44 4d6ba181 Scott Ullrich
45
$a_hosts 	   = &$config['dnsmasq']['hosts'];
46 0c2b5df7 Scott Ullrich
$a_domainOverrides = &$config['dnsmasq']['domainoverrides'];
47 5b237745 Scott Ullrich
48
if ($_POST) {
49
50
	$pconfig = $_POST;
51
52
	$config['dnsmasq']['enable'] = ($_POST['enable']) ? true : false;
53
	$config['dnsmasq']['regdhcp'] = ($_POST['regdhcp']) ? true : false;
54
55
	write_config();
56 f0fe3d30 Scott Ullrich
57 5b237745 Scott Ullrich
	$retval = 0;
58 920b3bb0 Scott Ullrich
59
	config_lock();
60
	$retval = services_dnsmasq_configure();
61
	config_unlock();
62
63 5b237745 Scott Ullrich
	$savemsg = get_std_save_message($retval);
64
65
	if ($retval == 0) {
66
		if (file_exists($d_hostsdirty_path))
67
			unlink($d_hostsdirty_path);
68
	}
69
}
70
71
if ($_GET['act'] == "del") {
72 0c2b5df7 Scott Ullrich
       if ($_GET['type'] == 'host') {
73
               if ($a_hosts[$_GET['id']]) {
74
                       unset($a_hosts[$_GET['id']]);
75
                       write_config();
76 4d6ba181 Scott Ullrich
                       touch($d_hostsdirty_path);
77 0c2b5df7 Scott Ullrich
                       header("Location: services_dnsmasq.php");
78
                       exit;
79
               }
80
       }
81
       elseif ($_GET['type'] == 'doverride') {
82
               if ($a_domainOverrides[$_GET['id']]) {
83
                       unset($a_domainOverrides[$_GET['id']]);
84
                       write_config();
85 4d6ba181 Scott Ullrich
                       touch($d_hostsdirty_path);
86 0c2b5df7 Scott Ullrich
                       header("Location: services_dnsmasq.php");
87
                       exit;
88
               }
89
       }
90 5b237745 Scott Ullrich
}
91 0c2b5df7 Scott Ullrich
92 b63695db Scott Ullrich
$pgtitle = "Services: DNS forwarder";
93
include("head.inc");
94 0c2b5df7 Scott Ullrich
95 5b237745 Scott Ullrich
?>
96
97
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
98
<?php include("fbegin.inc"); ?>
99 74f446e8 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
100 5b237745 Scott Ullrich
<form action="services_dnsmasq.php" method="post">
101
<?php if ($savemsg) print_info_box($savemsg); ?>
102
<?php if (file_exists($d_hostsdirty_path)): ?><p>
103
<?php print_info_box_np("The DNS forwarder configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
104
<?php endif; ?>
105 4d6ba181 Scott Ullrich
	<table width="100%" border="0" cellpadding="6" cellspacing="0">
106 f0fe3d30 Scott Ullrich
                <tr>
107
                  <td class="vtable"><p>
108 5b237745 Scott Ullrich
                      <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable'] == "yes") echo "checked";?>>
109
                      <strong>Enable DNS forwarder<br>
110
                      </strong></p></td>
111
                </tr>
112 f0fe3d30 Scott Ullrich
                <tr>
113
                  <td class="vtable"><p>
114 5b237745 Scott Ullrich
                      <input name="regdhcp" type="checkbox" id="regdhcp" value="yes" <?php if ($pconfig['regdhcp'] == "yes") echo "checked";?>>
115
                      <strong>Register DHCP leases in DNS forwarder<br>
116 f0fe3d30 Scott Ullrich
                      </strong>If this option is set, then machines that specify
117
                      their hostname when requesting a DHCP lease will be registered
118
                      in the DNS forwarder, so that their name can be resolved.
119
                      You should also set the domain in <a href="system.php">System:
120 5b237745 Scott Ullrich
                      General setup</a> to the proper value.</p>
121
                    </td>
122
                </tr>
123 f0fe3d30 Scott Ullrich
                <tr>
124
                  <td> <input name="submit" type="submit" class="formbtn" value="Save">
125 5b237745 Scott Ullrich
                  </td>
126
                </tr>
127 f0fe3d30 Scott Ullrich
                <tr>
128 5b237745 Scott Ullrich
                  <td><p><span class="vexpl"><span class="red"><strong>Note:<br>
129 f0fe3d30 Scott Ullrich
                      </strong></span>If the DNS forwarder is enabled, the DHCP
130
                      service (if enabled) will automatically serve the LAN IP
131
                      address as a DNS server to DHCP clients so they will use
132
                      the forwarder. The DNS forwarder will use the DNS servers
133
                      entered in <a href="system.php">System: General setup</a>
134
                      or those obtained via DHCP or PPP on WAN if the &quot;Allow
135 dacefa7f Scott Ullrich
                      DNS server list to be overridden by DHCP/PPP on WAN&quot;
136 f0fe3d30 Scott Ullrich
                      is checked. If you don't use that option (or if you use
137
                      a static IP address on WAN), you must manually specify at
138
                      least one DNS server on the <a href="system.php">System:
139 5b237745 Scott Ullrich
                      General setup</a> page.<br>
140
                      <br>
141 f0fe3d30 Scott Ullrich
                      You may enter records that override the results from the
142 dacefa7f Scott Ullrich
                      forwarders below.</span></p></td>
143 5b237745 Scott Ullrich
                </tr>
144 4d6ba181 Scott Ullrich
        </table>
145
        &nbsp;<br>
146
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
147 5b237745 Scott Ullrich
                <tr>
148
                  <td width="20%" class="listhdrr">Host</td>
149
                  <td width="25%" class="listhdrr">Domain</td>
150
                  <td width="20%" class="listhdrr">IP</td>
151
                  <td width="25%" class="listhdr">Description</td>
152
                  <td width="10%" class="list"></td>
153
				</tr>
154
			  <?php $i = 0; foreach ($a_hosts as $hostent): ?>
155
                <tr>
156 835f9aca Bill Marquette
                  <td class="listlr" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
157 5b237745 Scott Ullrich
                    <?=strtolower($hostent['host']);?>&nbsp;
158
                  </td>
159 835f9aca Bill Marquette
                  <td class="listr" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
160 5b237745 Scott Ullrich
                    <?=strtolower($hostent['domain']);?>&nbsp;
161
                  </td>
162 835f9aca Bill Marquette
                  <td class="listr" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
163 5b237745 Scott Ullrich
                    <?=$hostent['ip'];?>&nbsp;
164
                  </td>
165 835f9aca Bill Marquette
                  <td class="listbg" ondblclick="document.location='services_dnsmasq_edit.php?id=<?=$i;?>';">
166 f0fe3d30 Scott Ullrich
                    <font color="#FFFFFF"><?=htmlspecialchars($hostent['descr']);?>&nbsp;
167 5b237745 Scott Ullrich
                  </td>
168 ebe566eb Bill Marquette
                  <td valign="middle" nowrap class="list">
169
                    <table border="0" cellspacing="0" cellpadding="1">
170
                      <tr>
171 677c0869 Erik Kristensen
                        <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>
172
                        <td><a href="services_dnsmasq.php?type=host&act=del&id=<?=$i;?>" onclick="return confirm('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>
173 ebe566eb Bill Marquette
		      </tr>
174
                   </table>
175
                </tr>
176
		<?php $i++; endforeach; ?>
177 f0fe3d30 Scott Ullrich
                <tr>
178 5b237745 Scott Ullrich
                  <td class="list" colspan="4"></td>
179 ebe566eb Bill Marquette
                  <td class="list">
180
                    <table border="0" cellspacing="0" cellpadding="1">
181
                      <tr>
182 677c0869 Erik Kristensen
                        <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>
183 ebe566eb Bill Marquette
                      </tr>
184
                    </table>
185 ed137452 Scott Ullrich
		   </td>
186 4d6ba181 Scott Ullrich
	</table>
187 0c2b5df7 Scott Ullrich
<!-- update to enable domain overrides -->
188 4d6ba181 Scott Ullrich
        <table width="100%" border="0" cellpadding="6" cellspacing="0">
189 c21d4582 Scott Ullrich
	       <tr><td>&nbsp;</td></tr>
190 0c2b5df7 Scott Ullrich
               <tr>
191
                 <td><p>Below you can override an entire domain by specifying an
192
                        authoritative dns server to be queried for that domain.</p></td>
193
               </tr>
194 4d6ba181 Scott Ullrich
        </table>
195
	&nbsp;<br>
196
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
197 0c2b5df7 Scott Ullrich
               <tr>
198
                 <td width="35%" class="listhdrr">Domain</td>
199
                 <td width="20%" class="listhdrr">IP</td>
200
                 <td width="35%" class="listhdr">Description</td>
201
                 <td width="10%" class="list"></td>
202
                              </tr>
203
                        <?php $i = 0; foreach ($a_domainOverrides as $doment): ?>
204
               <tr>
205
                 <td class="listlr">
206
                   <?=strtolower($doment['domain']);?>&nbsp;
207
                 </td>
208
                 <td class="listr">
209
                   <?=$doment['ip'];?>&nbsp;
210
                 </td>
211 5015bd61 Scott Ullrich
                 <td class="listbg"><font color="#FFFFFF">
212 0c2b5df7 Scott Ullrich
                   <?=htmlspecialchars($doment['descr']);?>&nbsp;
213
                 </td>
214 677c0869 Erik Kristensen
                 <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>
215
                    &nbsp;<a href="services_dnsmasq.php?act=del&type=doverride&id=<?=$i;?>" onclick="return confirm('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>
216 0c2b5df7 Scott Ullrich
                              </tr>
217
                        <?php $i++; endforeach; ?>
218
               <tr>
219
                 <td class="list" colspan="3"></td>
220 677c0869 Erik Kristensen
                 <td class="list"> <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>
221 0c2b5df7 Scott Ullrich
	       </tr>
222 4d6ba181 Scott Ullrich
        </table>
223
        </form>
224 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
225
</body>
226
</html>