Project

General

Profile

Download (7.16 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/*
4
	services_dnsmasq.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Bob Zoller <bob@kludgebox.com> and Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9

    
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

    
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15

    
16
	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

    
20
	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
$pconfig['enable'] = isset($config['dnsmasq']['enable']);
35
$pconfig['regdhcp'] = isset($config['dnsmasq']['regdhcp']);
36

    
37
if (!is_array($config['dnsmasq']['hosts'])) {
38
	$config['dnsmasq']['hosts'] = array();
39
}
40
hosts_sort();
41
$a_hosts = &$config['dnsmasq']['hosts'];
42

    
43
if ($_POST) {
44

    
45
	$pconfig = $_POST;
46

    
47
	$config['dnsmasq']['enable'] = ($_POST['enable']) ? true : false;
48
	$config['dnsmasq']['regdhcp'] = ($_POST['regdhcp']) ? true : false;
49

    
50
	write_config();
51

    
52
	$retval = 0;
53
	if (!file_exists($d_sysrebootreqd_path)) {
54
		config_lock();
55
		$retval = services_dnsmasq_configure();
56
		config_unlock();
57
	}
58
	$savemsg = get_std_save_message($retval);
59

    
60
	if ($retval == 0) {
61
		if (file_exists($d_hostsdirty_path))
62
			unlink($d_hostsdirty_path);
63
	}
64
}
65

    
66
if ($_GET['act'] == "del") {
67
	if ($a_hosts[$_GET['id']]) {
68
		unset($a_hosts[$_GET['id']]);
69
		write_config();
70
		touch($d_hostsdirty_path);
71
		header("Location: services_dnsmasq.php");
72
		exit;
73
	}
74
}
75
?>
76
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
77
<html>
78
<head>
79
<title><?=gentitle("Services: DNS forwarder");?></title>
80
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
81
<link href="gui.css" rel="stylesheet" type="text/css">
82
</head>
83

    
84
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
85
<?php include("fbegin.inc"); ?>
86
<p class="pgtitle">Services: DNS forwarder</p>
87
<form action="services_dnsmasq.php" method="post">
88
<?php if ($savemsg) print_info_box($savemsg); ?>
89
<?php if (file_exists($d_hostsdirty_path)): ?><p>
90
<?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>
91
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
92
<?php endif; ?>
93
			  <table width="100%" border="0" cellpadding="6" cellspacing="0">
94
                <tr>
95
                  <td class="vtable"><p>
96
                      <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable'] == "yes") echo "checked";?>>
97
                      <strong>Enable DNS forwarder<br>
98
                      </strong></p></td>
99
                </tr>
100
                <tr>
101
                  <td class="vtable"><p>
102
                      <input name="regdhcp" type="checkbox" id="regdhcp" value="yes" <?php if ($pconfig['regdhcp'] == "yes") echo "checked";?>>
103
                      <strong>Register DHCP leases in DNS forwarder<br>
104
                      </strong>If this option is set, then machines that specify
105
                      their hostname when requesting a DHCP lease will be registered
106
                      in the DNS forwarder, so that their name can be resolved.
107
                      You should also set the domain in <a href="system.php">System:
108
                      General setup</a> to the proper value.</p>
109
                    </td>
110
                </tr>
111
                <tr>
112
                  <td> <input name="submit" type="submit" class="formbtn" value="Save">
113
                  </td>
114
                </tr>
115
                <tr>
116
                  <td><p><span class="vexpl"><span class="red"><strong>Note:<br>
117
                      </strong></span>If the DNS forwarder is enabled, the DHCP
118
                      service (if enabled) will automatically serve the LAN IP
119
                      address as a DNS server to DHCP clients so they will use
120
                      the forwarder. The DNS forwarder will use the DNS servers
121
                      entered in <a href="system.php">System: General setup</a>
122
                      or those obtained via DHCP or PPP on WAN if the &quot;Allow
123
                      DNS server list to be overridden by DHCP/PPP on WAN&quot;</span>
124
                      is checked. If you don't use that option (or if you use
125
                      a static IP address on WAN), you must manually specify at
126
                      least one DNS server on the <a href="system.php">System:
127
                      General setup</a> page.<br>
128
                      <br>
129
                      You may enter records that override the results from the
130
                      forwarders below.</p></td>
131
                </tr>
132
              </table>
133
              &nbsp;<br>
134
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
135
                <tr>
136
                  <td width="20%" class="listhdrr">Host</td>
137
                  <td width="25%" class="listhdrr">Domain</td>
138
                  <td width="20%" class="listhdrr">IP</td>
139
                  <td width="25%" class="listhdr">Description</td>
140
                  <td width="10%" class="list"></td>
141
				</tr>
142
			  <?php $i = 0; foreach ($a_hosts as $hostent): ?>
143
                <tr>
144
                  <td class="listlr">
145
                    <?=strtolower($hostent['host']);?>&nbsp;
146
                  </td>
147
                  <td class="listr">
148
                    <?=strtolower($hostent['domain']);?>&nbsp;
149
                  </td>
150
                  <td class="listr">
151
                    <?=$hostent['ip'];?>&nbsp;
152
                  </td>
153
                  <td class="listbg">
154
                    <font color="#FFFFFF"><?=htmlspecialchars($hostent['descr']);?>&nbsp;
155
                  </td>
156
                  <td valign="middle" nowrap class="list"> <a href="services_dnsmasq_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a>
157
                     &nbsp;<a href="services_dnsmasq.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this host?')"><img src="x.gif" width="17" height="17" border="0"></a></td>
158
				</tr>
159
			  <?php $i++; endforeach; ?>
160
                <tr>
161
                  <td class="list" colspan="4"></td>
162
                  <td class="list"> <a href="services_dnsmasq_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
163
				</tr>
164
              </table>
165
            </form>
166
<?php include("fend.inc"); ?>
167
</body>
168
</html>
(60-60/90)