Project

General

Profile

Download (14.3 KB) Statistics
| Branch: | Tag: | Revision:
1 d03efa9c Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	services_dyndns.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6 d03efa9c Scott Ullrich
7 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9 d03efa9c 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 d03efa9c 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 d03efa9c 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 d03efa9c 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 07bd3f83 Scott Ullrich
if (!is_array($config['dnsupdate'])) {
35
	$config['dnsupdate'] = array();
36
}
37
38 5b237745 Scott Ullrich
$pconfig['username'] = $config['dyndns']['username'];
39
$pconfig['password'] = $config['dyndns']['password'];
40
$pconfig['host'] = $config['dyndns']['host'];
41
$pconfig['mx'] = $config['dyndns']['mx'];
42
$pconfig['type'] = $config['dyndns']['type'];
43
$pconfig['enable'] = isset($config['dyndns']['enable']);
44
$pconfig['wildcard'] = isset($config['dyndns']['wildcard']);
45
46 07bd3f83 Scott Ullrich
$pconfig['dnsupdate_enable'] = isset($config['dnsupdate']['enable']);
47
$pconfig['dnsupdate_host'] = $config['dnsupdate']['host'];
48
$pconfig['dnsupdate_ttl'] = $config['dnsupdate']['ttl'];
49
if (!$pconfig['dnsupdate_ttl'])
50
	$pconfig['dnsupdate_ttl'] = 60;
51
$pconfig['dnsupdate_keydata'] = $config['dnsupdate']['keydata'];
52
$pconfig['dnsupdate_keyname'] = $config['dnsupdate']['keyname'];
53
$pconfig['dnsupdate_keytype'] = $config['dnsupdate']['keytype'];
54
if (!$pconfig['dnsupdate_keytype'])
55
	$pconfig['dnsupdate_keytype'] = "zone";
56 f9b5d5e5 Scott Ullrich
$pconfig['dnsupdate_server'] = $config['dnsupdate']['server'];
57 07bd3f83 Scott Ullrich
$pconfig['dnsupdate_usetcp'] = isset($config['dnsupdate']['usetcp']);
58
59 5b237745 Scott Ullrich
if ($_POST) {
60
61
	unset($input_errors);
62
	$pconfig = $_POST;
63
64
	/* input validation */
65 07bd3f83 Scott Ullrich
	$reqdfields = array();
66
	$reqdfieldsn = array();
67 5b237745 Scott Ullrich
	if ($_POST['enable']) {
68 07bd3f83 Scott Ullrich
		$reqdfields = array_merge($reqdfields, explode(" ", "host username password type"));
69
		$reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Hostname,Username,Password,Service type"));
70 5b237745 Scott Ullrich
	}
71 07bd3f83 Scott Ullrich
	if ($_POST['dnsupdate_enable']) {
72
		$reqdfields = array_merge($reqdfields, explode(" ", "dnsupdate_host dnsupdate_ttl dnsupdate_keyname dnsupdate_keydata"));
73
		$reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Hostname,TTL,Key name,Key"));
74
	}
75
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
76 d03efa9c Scott Ullrich
77 2ff8d4ad Scott Ullrich
	if($pconfig['type'] <> "zoneedit") {
78
		if (($_POST['host'] && !is_domain($_POST['host']))) {
79
			$input_errors[] = "The host name contains invalid characters.";
80
		}
81 5b237745 Scott Ullrich
	}
82
	if (($_POST['mx'] && !is_domain($_POST['mx']))) {
83
		$input_errors[] = "The MX contains invalid characters.";
84
	}
85
	if (($_POST['username'] && !is_dyndns_username($_POST['username']))) {
86
		$input_errors[] = "The username contains invalid characters.";
87
	}
88 d03efa9c Scott Ullrich
89 07bd3f83 Scott Ullrich
	if (($_POST['dnsupdate_host'] && !is_domain($_POST['dnsupdate_host']))) {
90
		$input_errors[] = "The DNS update host name contains invalid characters.";
91
	}
92
	if (($_POST['dnsupdate_ttl'] && !is_numericint($_POST['dnsupdate_ttl']))) {
93
		$input_errors[] = "The DNS update TTL must be an integer.";
94
	}
95
	if (($_POST['dnsupdate_keyname'] && !is_domain($_POST['dnsupdate_keyname']))) {
96
		$input_errors[] = "The DNS update key name contains invalid characters.";
97
	}
98 5b237745 Scott Ullrich
99
	if (!$input_errors) {
100 d03efa9c Scott Ullrich
		$config['dyndns']['type'] = $_POST['type'];
101 5b237745 Scott Ullrich
		$config['dyndns']['username'] = $_POST['username'];
102
		$config['dyndns']['password'] = $_POST['password'];
103
		$config['dyndns']['host'] = $_POST['host'];
104
		$config['dyndns']['mx'] = $_POST['mx'];
105
		$config['dyndns']['wildcard'] = $_POST['wildcard'] ? true : false;
106
		$config['dyndns']['enable'] = $_POST['enable'] ? true : false;
107 d03efa9c Scott Ullrich
108 07bd3f83 Scott Ullrich
		$config['dnsupdate']['enable'] = $_POST['dnsupdate_enable'] ? true : false;
109
		$config['dnsupdate']['host'] = $_POST['dnsupdate_host'];
110
		$config['dnsupdate']['ttl'] = $_POST['dnsupdate_ttl'];
111
		$config['dnsupdate']['keyname'] = $_POST['dnsupdate_keyname'];
112
		$config['dnsupdate']['keytype'] = $_POST['dnsupdate_keytype'];
113
		$config['dnsupdate']['keydata'] = $_POST['dnsupdate_keydata'];
114 f9b5d5e5 Scott Ullrich
		$config['dnsupdate']['server'] = $_POST['dnsupdate_server'];
115 07bd3f83 Scott Ullrich
		$config['dnsupdate']['usetcp'] = $_POST['dnsupdate_usetcp'] ? true : false;
116 d03efa9c Scott Ullrich
117 5b237745 Scott Ullrich
		write_config();
118 d03efa9c Scott Ullrich
119 5b237745 Scott Ullrich
		$retval = 0;
120 3851094f Scott Ullrich
121
		/* nuke the cache file */
122
		config_lock();
123
		services_dyndns_reset();
124
		$retval = services_dyndns_configure();
125
		$retval |= services_dnsupdate_process();
126
		config_unlock();
127 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
128
	}
129
}
130 4df96eff Scott Ullrich
131 d88c6a9f Scott Ullrich
$pgtitle = array("Services","Dynamic DNS client");
132 4df96eff Scott Ullrich
include("head.inc");
133
134 5b237745 Scott Ullrich
?>
135 4df96eff Scott Ullrich
136 5b237745 Scott Ullrich
<script language="JavaScript">
137
<!--
138
function enable_change(enable_change) {
139 07bd3f83 Scott Ullrich
	var endis;
140 d03efa9c Scott Ullrich
141 07bd3f83 Scott Ullrich
	endis = !(document.iform.enable.checked || enable_change);
142
	document.iform.host.disabled = endis;
143 9b8dc821 Scott Ullrich
	document.iform.mx.disabled = endis;
144 07bd3f83 Scott Ullrich
	document.iform.type.disabled = endis;
145 9b8dc821 Scott Ullrich
	document.iform.wildcard.disabled = endis;
146 07bd3f83 Scott Ullrich
	document.iform.username.disabled = endis;
147
	document.iform.password.disabled = endis;
148 d03efa9c Scott Ullrich
149 07bd3f83 Scott Ullrich
	endis = !(document.iform.dnsupdate_enable.checked || enable_change);
150
	document.iform.dnsupdate_host.disabled = endis;
151
	document.iform.dnsupdate_ttl.disabled = endis;
152
	document.iform.dnsupdate_keyname.disabled = endis;
153
	document.iform.dnsupdate_keytype[0].disabled = endis;
154
	document.iform.dnsupdate_keytype[1].disabled = endis;
155
	document.iform.dnsupdate_keytype[2].disabled = endis;
156
	document.iform.dnsupdate_keydata.disabled = endis;
157 f9b5d5e5 Scott Ullrich
	document.iform.dnsupdate_server.disabled = endis;
158 07bd3f83 Scott Ullrich
	document.iform.dnsupdate_usetcp.disabled = endis;
159 5b237745 Scott Ullrich
}
160
//-->
161
</script>
162
163
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
164
<?php include("fbegin.inc"); ?>
165
<?php if ($input_errors) print_input_errors($input_errors); ?>
166
<?php if ($savemsg) print_info_box($savemsg); ?>
167
            <form action="services_dyndns.php" method="post" name="iform" id="iform">
168
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
169 d03efa9c Scott Ullrich
                <tr>
170 07bd3f83 Scott Ullrich
                  <td colspan="2" valign="top" class="optsect_t">
171
				  <table border="0" cellspacing="0" cellpadding="0" width="100%">
172
				  <tr><td class="optsect_s"><strong>Dynamic DNS client</strong></td>
173
				  <td align="right" class="optsect_s"><input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)"> <strong>Enable</strong></td></tr>
174
				  </table></td>
175
                </tr>
176 d03efa9c Scott Ullrich
                <tr>
177 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Service type</td>
178
                  <td width="78%" class="vtable">
179 b5c78501 Seth Mos
			<select name="type" class="formselect" id="type">
180 89a75ca9 Bill Marquette
                      <?php
181 52e6fdfd Scott Dale
				$types = explode(",", "DNS-O-Matic, DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,ODS.org,ZoneEdit");
182
				$vals = explode(" ", "dnsomatic dyndns dyndns-static dyndns-custom dhs dyns easydns noip ods zoneedit");
183 89a75ca9 Bill Marquette
				$j = 0; for ($j = 0; $j < count($vals); $j++): ?>
184 d03efa9c Scott Ullrich
                      <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['type']) echo "selected";?>>
185 5b237745 Scott Ullrich
                      <?=htmlspecialchars($types[$j]);?>
186
                      </option>
187
                      <?php endfor; ?>
188
                    </select></td>
189
				</tr>
190 d03efa9c Scott Ullrich
                <tr>
191 52e6fdfd Scott Dale
                  <td width="22%" valign="top" class="vncellreq">Hostname/Interface</td>
192 d03efa9c Scott Ullrich
                  <td width="78%" class="vtable">
193 b5c78501 Seth Mos
                    <input name="host" type="text" class="formfld unknown" id="host" size="30" value="<?=htmlspecialchars($pconfig['host']);?>">
194 52e6fdfd Scott Dale
                    <br>
195
				    <span class="vexpl">
196
				    <span class="red"><strong>Note:<br></strong>
197
				    </span>
198
					Enter the complete host/domain name.  example:  myhost.dyndns.org
199
				    </span>
200
		          </td>
201
				</tr>
202 9b8dc821 Scott Ullrich
                <tr>
203
                  <td width="22%" valign="top" class="vncell">MX</td>
204
                  <td width="78%" class="vtable">
205 b5c78501 Seth Mos
                    <input name="mx" type="text" class="formfld unknown" id="mx" size="30" value="<?=htmlspecialchars($pconfig['mx']);?>">
206 9b8dc821 Scott Ullrich
                    <br>
207
					Note: With DynDNS service you can only use a hostname, not an IP address.
208
					<br>
209
                    Set this option only if you need a special MX record. Not
210
                    all services support this.</td>
211
				</tr>
212
                <tr>
213
                  <td width="22%" valign="top" class="vncellreq">Wildcards</td>
214
                  <td width="78%" class="vtable">
215
                    <input name="wildcard" type="checkbox" id="wildcard" value="yes" <?php if ($pconfig['wildcard']) echo "checked"; ?>>
216
                    Enable Wildcard</td>
217
				</tr>
218 d03efa9c Scott Ullrich
                <tr>
219 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Username</td>
220 d03efa9c Scott Ullrich
                  <td width="78%" class="vtable">
221 b5c78501 Seth Mos
                    <input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
222 5b237745 Scott Ullrich
                  </td>
223
                </tr>
224 d03efa9c Scott Ullrich
                <tr>
225 5b237745 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Password</td>
226 d03efa9c Scott Ullrich
                  <td width="78%" class="vtable">
227 b5c78501 Seth Mos
                    <input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
228 5b237745 Scott Ullrich
                  </td>
229
                </tr>
230 c0c2f422 Scott Ullrich
                <tr>
231
                  <td width="22%" valign="top">&nbsp;</td>
232
                  <td width="78%">
233
                    <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
234 2ff8d4ad Scott Ullrich
                  </td>
235 d03efa9c Scott Ullrich
                <tr>
236
                  <td colspan="2" class="list" height="12">&nbsp;</td>
237 2ff8d4ad Scott Ullrich
                </tr>
238 07bd3f83 Scott Ullrich
                </tr>
239 d03efa9c Scott Ullrich
                <tr>
240 07bd3f83 Scott Ullrich
                  <td colspan="2" valign="top" class="optsect_t">
241
				  <table border="0" cellspacing="0" cellpadding="0" width="100%">
242 183f3086 Bill Marquette
				  <tr><td class="optsect_s"><strong>RFC 2136 Dynamic DNS updates</strong></td>
243 07bd3f83 Scott Ullrich
				  <td align="right" class="optsect_s"><input name="dnsupdate_enable" type="checkbox" value="yes" <?php if ($pconfig['dnsupdate_enable']) echo "checked"; ?> onClick="enable_change(false)"> <strong>Enable</strong></td></tr>
244
				  </table></td>
245
                </tr>
246 d03efa9c Scott Ullrich
                <tr>
247 07bd3f83 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Hostname</td>
248 d03efa9c Scott Ullrich
                  <td width="78%" class="vtable">
249 b5c78501 Seth Mos
                    <input name="dnsupdate_host" type="text" class="formfld unknown" id="dnsupdate_host" size="30" value="<?=htmlspecialchars($pconfig['dnsupdate_host']);?>">
250 07bd3f83 Scott Ullrich
                  </td>
251
				</tr>
252
                <tr>
253
                  <td valign="top" class="vncellreq">TTL</td>
254
                  <td class="vtable">
255 b5c78501 Seth Mos
                    <input name="dnsupdate_ttl" type="text" class="formfld unknown" id="dnsupdate_ttl" size="6" value="<?=htmlspecialchars($pconfig['dnsupdate_ttl']);?>">
256 07bd3f83 Scott Ullrich
                  seconds</td>
257
                </tr>
258
                <tr>
259
                  <td valign="top" class="vncellreq">Key name</td>
260
                  <td class="vtable">
261 b5c78501 Seth Mos
                    <input name="dnsupdate_keyname" type="text" class="formfld unknown" id="dnsupdate_keyname" size="30" value="<?=htmlspecialchars($pconfig['dnsupdate_keyname']);?>">
262 d03efa9c Scott Ullrich
                    <br>
263 07bd3f83 Scott Ullrich
                    This must match the setting on the DNS server.</td>
264
                </tr>
265
                <tr>
266
                  <td valign="top" class="vncellreq">Key type </td>
267
                  <td class="vtable">
268
				  <input name="dnsupdate_keytype" type="radio" value="zone" <?php if ($pconfig['dnsupdate_keytype'] == "zone") echo "checked"; ?>> Zone &nbsp;
269
                  <input name="dnsupdate_keytype" type="radio" value="host" <?php if ($pconfig['dnsupdate_keytype'] == "host") echo "checked"; ?>> Host &nbsp;
270
                  <input name="dnsupdate_keytype" type="radio" value="user" <?php if ($pconfig['dnsupdate_keytype'] == "user") echo "checked"; ?>> User
271
				</tr>
272
                <tr>
273
                  <td valign="top" class="vncellreq">Key</td>
274
                  <td class="vtable">
275 b5c78501 Seth Mos
                    <input name="dnsupdate_keydata" type="text" class="formfld unknown" id="dnsupdate_keydata" size="70" value="<?=htmlspecialchars($pconfig['dnsupdate_keydata']);?>">
276 d03efa9c Scott Ullrich
                    <br>
277 07bd3f83 Scott Ullrich
                    Paste an HMAC-MD5 key here.</td>
278 f9b5d5e5 Scott Ullrich
		</tr>
279
                <tr>
280
                  <td width="22%" valign="top" class="vncellreq">Server</td>
281
                  <td width="78%" class="vtable">
282
                    <input name="dnsupdate_server" type="text" class+"formfld" id="dnsupdate_server" size="30" value="<?=htmlspecialchars($pconfig['dnsupdate_server'])?>">
283
                  </td>
284 07bd3f83 Scott Ullrich
                </tr>
285 d03efa9c Scott Ullrich
                <tr>
286 07bd3f83 Scott Ullrich
                  <td width="22%" valign="top" class="vncellreq">Protocol</td>
287 d03efa9c Scott Ullrich
                  <td width="78%" class="vtable">
288 07bd3f83 Scott Ullrich
                    <input name="dnsupdate_usetcp" type="checkbox" id="dnsupdate_usetcp" value="yes" <?php if ($pconfig['dnsupdate_usetcp']) echo "checked"; ?>>
289
                    <strong>Use TCP instead of UDP</strong></td>
290
				</tr>
291 d03efa9c Scott Ullrich
                <tr>
292 5b237745 Scott Ullrich
                  <td width="22%" valign="top">&nbsp;</td>
293 d03efa9c Scott Ullrich
                  <td width="78%">
294
                    <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
295 5b237745 Scott Ullrich
                  </td>
296
                </tr>
297 d03efa9c Scott Ullrich
                <tr>
298 5b237745 Scott Ullrich
                  <td width="22%" valign="top">&nbsp;</td>
299
                  <td width="78%"><span class="vexpl"><span class="red"><strong>Note:<br>
300 d03efa9c Scott Ullrich
                    </strong></span>You must configure a DNS server in <a href="system.php">System:
301
                    General setup</a> or allow the DNS server list to be overridden
302 07bd3f83 Scott Ullrich
                    by DHCP/PPP on WAN for dynamic DNS updates to work.</span></td>
303 5b237745 Scott Ullrich
                </tr>
304
              </table>
305
</form>
306
<script language="JavaScript">
307
<!--
308
enable_change(false);
309
//-->
310
</script>
311
<?php include("fend.inc"); ?>
312
</body>
313
</html>