Project

General

Profile

Download (10.4 KB) Statistics
| Branch: | Tag: | Revision:
1 f1f60c92 Ermal Luçi
<?php
2
/* $Id$ */
3
/*
4 4c3f9403 Ermal Luçi
	Copyright (C) 2008 Ermal Lu?i
5 f1f60c92 Ermal Luçi
	All rights reserved.
6
7
	Redistribution and use in source and binary forms, with or without
8
	modification, are permitted provided that the following conditions are met:
9
10
	1. Redistributions of source code must retain the above copyright notice,
11
	   this list of conditions and the following disclaimer.
12
13
	2. Redistributions in binary form must reproduce the above copyright
14
	   notice, this list of conditions and the following disclaimer in the
15
	   documentation and/or other materials provided with the distribution.
16
17
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
	POSSIBILITY OF SUCH DAMAGE.
27
*/
28 1d333258 Scott Ullrich
/*
29
	pfSense_MODULE:	dnsupdate
30
*/
31 f1f60c92 Ermal Luçi
32
require("guiconfig.inc");
33
34 6626eb26 Ermal Luçi
if (!is_array($config['dnsupdates']['dnsupdate'])) {
35 f1f60c92 Ermal Luçi
	$config['dnsupdates']['dnsupdate'] = array();
36 6626eb26 Ermal Luçi
}
37 f1f60c92 Ermal Luçi
38
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
39
40 6626eb26 Ermal Luçi
$id = $_GET['id'];
41
if (isset($_POST['id']))
42
	$id = $_POST['id'];
43
44
if (isset($id) && isset($a_rfc2136[$id])) {
45
	$pconfig['enable'] = isset($a_rfc2136[$id]['enable']);
46
	$pconfig['host'] = $a_rfc2136[$id]['host'];
47
	$pconfig['ttl'] = $a_rfc2136[$id]['ttl'];
48
	if (!$pconfig['ttl'])
49
		$pconfig['ttl'] = 60;
50
	$pconfig['keydata'] = $a_rfc2136[$id]['keydata'];
51
	$pconfig['keyname'] = $a_rfc2136[$id]['keyname'];
52
	$pconfig['keytype'] = $a_rfc2136[$id]['keytype'];
53
	if (!$pconfig['keytype'])
54
		$pconfig['keytype'] = "zone";
55
	$pconfig['server'] = $a_rfc2136[$id]['server'];
56
	$pconfig['interface'] = $a_rfc2136[$id]['interface'];
57
	$pconfig['usetcp'] = isset($a_rfc2136[$id]['usetcp']);
58 6d8dd98b jim-p
	$pconfig['usepublicip'] = isset($a_rfc2136[$id]['usepublicip']);
59 6626eb26 Ermal Luçi
	$pconfig['descr'] = $a_rfc2136[$id]['descr'];
60
61
}
62
63
if ($_POST) {
64
65
	unset($input_errors);
66
	$pconfig = $_POST;
67
68
	/* input validation */
69
	$reqdfields = array();
70
	$reqdfieldsn = array();
71
	$reqdfields = array_merge($reqdfields, explode(" ", "host ttl keyname keydata"));
72 c37eeb93 Carlos Eduardo Ramos
	$reqdfieldsn = array_merge($reqdfieldsn, array(gettext("Hostname"), gettext("TTL"), gettext("Key name"), gettext("Key")));
73 6626eb26 Ermal Luçi
74 1e9b4611 Renato Botelho
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
75 6626eb26 Ermal Luçi
76
	if (($_POST['host'] && !is_domain($_POST['host'])))  
77 bd758833 Rafael Lucas
		$input_errors[] = gettext("The DNS update host name contains invalid characters.");
78 6626eb26 Ermal Luçi
	if (($_POST['ttl'] && !is_numericint($_POST['ttl']))) 
79 bd758833 Rafael Lucas
		$input_errors[] = gettext("The DNS update TTL must be an integer.");
80 6626eb26 Ermal Luçi
	if (($_POST['keyname'] && !is_domain($_POST['keyname'])))
81 bd758833 Rafael Lucas
		$input_errors[] = gettext("The DNS update key name contains invalid characters.");
82 f1f60c92 Ermal Luçi
83 6626eb26 Ermal Luçi
	if (!$input_errors) {
84
		$rfc2136 = array();
85 d2ff48a0 Ermal
		$rfc2136['enable'] = $_POST['enable'] ? true : false;
86 6626eb26 Ermal Luçi
		$rfc2136['host'] = $_POST['host'];
87
		$rfc2136['ttl'] = $_POST['ttl'];
88
		$rfc2136['keyname'] = $_POST['keyname'];
89
		$rfc2136['keytype'] = $_POST['keytype'];
90
		$rfc2136['keydata'] = $_POST['keydata'];
91
		$rfc2136['server'] = $_POST['server'];
92
		$rfc2136['usetcp'] = $_POST['usetcp'] ? true : false;
93 6d8dd98b jim-p
		$rfc2136['usepublicip'] = $_POST['usepublicip'] ? true : false;
94 6626eb26 Ermal Luçi
		$rfc2136['interface'] = $_POST['interface'];
95
		$rfc2136['descr'] = $_POST['descr'];
96 f1f60c92 Ermal Luçi
97 6626eb26 Ermal Luçi
		if (isset($id) && $a_rfc2136[$id])
98
			$a_rfc2136[$id] = $rfc2136;
99
		else
100
			$a_rfc2136[] = $rfc2136;
101
102 bd758833 Rafael Lucas
		write_config(gettext("New/Edited RFC2136 dnsupdate entry was posted."));
103 6626eb26 Ermal Luçi
104 7c9da7be jim-p
		if ($_POST['Submit'] == gettext("Save & Force Update"))
105
			$retval = services_dnsupdate_process("", $rfc2136['host'], true);
106
		else
107
			$retval = services_dnsupdate_process();
108 6626eb26 Ermal Luçi
109
		header("Location: services_rfc2136.php");
110 f1f60c92 Ermal Luçi
		exit;
111 6626eb26 Ermal Luçi
	}
112 f1f60c92 Ermal Luçi
}
113
114 bd758833 Rafael Lucas
$pgtitle = array(gettext("Services"),gettext("RFC 2136 client"), gettext("Edit"));
115 f1f60c92 Ermal Luçi
include("head.inc");
116
117
?>
118
119
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
120
<?php include("fbegin.inc"); ?>
121
<?php if ($input_errors) print_input_errors($input_errors); ?>
122 6626eb26 Ermal Luçi
<?php if ($savemsg) print_info_box($savemsg); ?>
123
            <form action="services_rfc2136_edit.php" method="post" name="iform" id="iform">
124
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
125
			  	<tr>
126
                  <td colspan="2" valign="top" class="optsect_t">
127
				  <table border="0" cellspacing="0" cellpadding="0" width="100%">
128 bd758833 Rafael Lucas
				  	<tr><td class="optsect_s"><strong><?=gettext("RFC 2136 client");?></strong></td></tr>
129 6626eb26 Ermal Luçi
				  </table>
130
				  </td>
131
                </tr>
132 f1f60c92 Ermal Luçi
                <tr>
133 bd758833 Rafael Lucas
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Enable");?></td>
134 6626eb26 Ermal Luçi
				  <td width="78%" class="vtable">
135
				    <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?>>
136 f1f60c92 Ermal Luçi
				  </td>
137 6626eb26 Ermal Luçi
                </tr>
138
				<tr>
139 bd758833 Rafael Lucas
				   <td width="22%" valign="top" class="vncellreq"><?=gettext("Interface to monitor");?></td>  
140 6626eb26 Ermal Luçi
				   <td width="78%" class="vtable">
141
				   <select name="interface" class="formselect" id="interface">
142
				   <?php $iflist = get_configured_interface_with_descr();
143
				   		foreach ($iflist as $if => $ifdesc):?>
144
							<option value="<?=$if;?>" <?php if ($pconfig['interface'] == $if) echo "selected";?>><?=$ifdesc;?></option>
145
					<?php endforeach; ?>
146
					</select>
147
					</td>
148
					</td>
149
				</tr>	
150
                <tr>
151 bd758833 Rafael Lucas
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Hostname");?></td>
152 6626eb26 Ermal Luçi
                  <td width="78%" class="vtable">
153
                    <input name="host" type="text" class="formfld unknown" id="host" size="30" value="<?=htmlspecialchars($pconfig['host']);?>">
154 b9eccc77 Ermal
			<br/><span>Fully qualified hostname of the host to be updated</span>
155 f1f60c92 Ermal Luçi
                  </td>
156
				</tr>
157
                <tr>
158 3b0b4ea7 Carlos Eduardo Ramos
                  <td valign="top" class="vncellreq"><?=gettext("TTL"); ?></td>
159 6626eb26 Ermal Luçi
                  <td class="vtable">
160
                    <input name="ttl" type="text" class="formfld unknown" id="ttl" size="6" value="<?=htmlspecialchars($pconfig['ttl']);?>">
161 bd758833 Rafael Lucas
                  <?=gettext("seconds");?></td>
162 6626eb26 Ermal Luçi
                </tr>
163
                <tr>
164 bd758833 Rafael Lucas
                  <td valign="top" class="vncellreq"><?=gettext("Key name");?></td>
165 6626eb26 Ermal Luçi
                  <td class="vtable">
166
                    <input name="keyname" type="text" class="formfld unknown" id="keyname" size="30" value="<?=htmlspecialchars($pconfig['keyname']);?>">
167
                    <br>
168 bd758833 Rafael Lucas
                    <?=gettext("This must match the setting on the DNS server.");?></td>
169 6626eb26 Ermal Luçi
                </tr>
170
                <tr>
171 3b0b4ea7 Carlos Eduardo Ramos
                  <td valign="top" class="vncellreq"><?=gettext("Key type");?> </td>
172 6626eb26 Ermal Luçi
                  <td class="vtable">
173 3b0b4ea7 Carlos Eduardo Ramos
				  <input name="keytype" type="radio" value="zone" <?php if ($pconfig['keytype'] == "zone") echo "checked"; ?>> <?=gettext("Zone");?> &nbsp;
174
                  <input name="keytype" type="radio" value="host" <?php if ($pconfig['keytype'] == "host") echo "checked"; ?>> <?=gettext("Host");?> &nbsp;
175
                  <input name="keytype" type="radio" value="user" <?php if ($pconfig['keytype'] == "user") echo "checked"; ?>><?=gettext(" User");?>
176 f1f60c92 Ermal Luçi
				</tr>
177 6626eb26 Ermal Luçi
                <tr>
178 bd758833 Rafael Lucas
                  <td valign="top" class="vncellreq"><?=gettext("Key");?></td>
179 6626eb26 Ermal Luçi
                  <td class="vtable">
180
                    <input name="keydata" type="text" class="formfld unknown" id="keydata" size="70" value="<?=htmlspecialchars($pconfig['keydata']);?>">
181
                    <br>
182 bd758833 Rafael Lucas
                    <?=gettext("Paste an HMAC-MD5 key here.");?></td>
183 f1f60c92 Ermal Luçi
				</tr>
184 6626eb26 Ermal Luçi
                <tr>
185 bd758833 Rafael Lucas
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Server");?></td>
186 6626eb26 Ermal Luçi
                  <td width="78%" class="vtable">
187
                    <input name="server" type="text" class+"formfld" id="server" size="30" value="<?=htmlspecialchars($pconfig['server'])?>">
188
                  </td>
189
                </tr>
190
                <tr>
191 bd758833 Rafael Lucas
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
192 6626eb26 Ermal Luçi
                  <td width="78%" class="vtable">
193 bd758833 Rafael Lucas
                    <input name="usetcp" type="checkbox" id="usetcp" value="<?=gettext("yes");?>" <?php if ($pconfig['usetcp']) echo "checked"; ?>>
194
                    <strong><?=gettext("Use TCP instead of UDP");?></strong></td>
195 6626eb26 Ermal Luçi
				</tr>
196 6d8dd98b jim-p
		<tr>
197
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Use Public IP");?></td>
198
			<td width="78%" class="vtable">
199
				<input name="usepublicip" type="checkbox" id="usepublicip" value="<?=gettext("yes");?>" <?php if ($pconfig['usepublicip']) echo "checked"; ?>>
200
				<strong><?=gettext("If the interface IP is private, attempt to fetch and use the public IP instead.");?></strong>
201
			</td>
202
		</tr>
203 6626eb26 Ermal Luçi
                <tr>
204 bd758833 Rafael Lucas
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Description");?></td>
205 6626eb26 Ermal Luçi
                  <td width="78%" class="vtable">
206
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="60" value="<?=htmlspecialchars($pconfig['descr']);?>">
207
                  </td>
208
                </tr>
209
                <tr>
210
                  <td width="22%" valign="top">&nbsp;</td>
211
                  <td width="78%">
212 7c9da7be jim-p
					<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onClick="enable_change(true)">
213 bd758833 Rafael Lucas
					<a href="services_rfc2136.php"><input name="Cancel" type="button" class="formbtn" value="<?=gettext("Cancel");?>"></a>
214 7c9da7be jim-p
					<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save & Force Update");?>" onClick="enable_change(true)">
215 6626eb26 Ermal Luçi
					<?php if (isset($id) && $a_rfc2136[$id]): ?>
216 225a2f0b Scott Ullrich
						<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>">
217 6626eb26 Ermal Luçi
					<?php endif; ?>
218
                  </td>
219
                </tr>
220
                <tr>
221
                  <td width="22%" valign="top">&nbsp;</td>
222 16457bdd Renato Botelho
                  <td width="78%"><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br>
223 3b0b4ea7 Carlos Eduardo Ramos
                    </strong></span><?php printf(gettext("You must configure a DNS server in %sSystem: " .
224
                    "General setup %sor allow the DNS server list to be overridden " .
225
                    "by DHCP/PPP on WAN for dynamic DNS updates to work."),'<a href="system.php">', '</a>');?></span></td>
226 6626eb26 Ermal Luçi
                </tr>
227 f1f60c92 Ermal Luçi
              </table>
228
</form>
229
<?php include("fend.inc"); ?>
230
</body>
231
</html>