Project

General

Profile

Download (10.7 KB) Statistics
| Branch: | Tag: | Revision:
1 f1f60c92 Ermal Luçi
<?php
2
/* $Id$ */
3
/*
4 6317d31d Phil Davis
	services_rfc2136_edit.php
5
6 1d7ba683 ayvis
	Copyright (C) 2008 Ermal Luçi
7 6317d31d Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
8 f1f60c92 Ermal Luçi
	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 1d333258 Scott Ullrich
/*
32
	pfSense_MODULE:	dnsupdate
33
*/
34 f1f60c92 Ermal Luçi
35
require("guiconfig.inc");
36
37 6626eb26 Ermal Luçi
if (!is_array($config['dnsupdates']['dnsupdate'])) {
38 f1f60c92 Ermal Luçi
	$config['dnsupdates']['dnsupdate'] = array();
39 6626eb26 Ermal Luçi
}
40 f1f60c92 Ermal Luçi
41
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
42
43 e41ec584 Renato Botelho
if (is_numericint($_GET['id']))
44
	$id = $_GET['id'];
45
if (isset($_POST['id']) && is_numericint($_POST['id']))
46 6626eb26 Ermal Luçi
	$id = $_POST['id'];
47
48
if (isset($id) && isset($a_rfc2136[$id])) {
49
	$pconfig['enable'] = isset($a_rfc2136[$id]['enable']);
50
	$pconfig['host'] = $a_rfc2136[$id]['host'];
51
	$pconfig['ttl'] = $a_rfc2136[$id]['ttl'];
52
	if (!$pconfig['ttl'])
53
		$pconfig['ttl'] = 60;
54
	$pconfig['keydata'] = $a_rfc2136[$id]['keydata'];
55
	$pconfig['keyname'] = $a_rfc2136[$id]['keyname'];
56
	$pconfig['keytype'] = $a_rfc2136[$id]['keytype'];
57
	if (!$pconfig['keytype'])
58
		$pconfig['keytype'] = "zone";
59
	$pconfig['server'] = $a_rfc2136[$id]['server'];
60
	$pconfig['interface'] = $a_rfc2136[$id]['interface'];
61
	$pconfig['usetcp'] = isset($a_rfc2136[$id]['usetcp']);
62 6d8dd98b jim-p
	$pconfig['usepublicip'] = isset($a_rfc2136[$id]['usepublicip']);
63 6626eb26 Ermal Luçi
	$pconfig['descr'] = $a_rfc2136[$id]['descr'];
64
65
}
66
67
if ($_POST) {
68
69
	unset($input_errors);
70
	$pconfig = $_POST;
71
72
	/* input validation */
73
	$reqdfields = array();
74
	$reqdfieldsn = array();
75
	$reqdfields = array_merge($reqdfields, explode(" ", "host ttl keyname keydata"));
76 c37eeb93 Carlos Eduardo Ramos
	$reqdfieldsn = array_merge($reqdfieldsn, array(gettext("Hostname"), gettext("TTL"), gettext("Key name"), gettext("Key")));
77 6626eb26 Ermal Luçi
78 1e9b4611 Renato Botelho
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
79 6626eb26 Ermal Luçi
80
	if (($_POST['host'] && !is_domain($_POST['host'])))  
81 bd758833 Rafael Lucas
		$input_errors[] = gettext("The DNS update host name contains invalid characters.");
82 6626eb26 Ermal Luçi
	if (($_POST['ttl'] && !is_numericint($_POST['ttl']))) 
83 bd758833 Rafael Lucas
		$input_errors[] = gettext("The DNS update TTL must be an integer.");
84 6626eb26 Ermal Luçi
	if (($_POST['keyname'] && !is_domain($_POST['keyname'])))
85 bd758833 Rafael Lucas
		$input_errors[] = gettext("The DNS update key name contains invalid characters.");
86 f1f60c92 Ermal Luçi
87 6626eb26 Ermal Luçi
	if (!$input_errors) {
88
		$rfc2136 = array();
89 d2ff48a0 Ermal
		$rfc2136['enable'] = $_POST['enable'] ? true : false;
90 6626eb26 Ermal Luçi
		$rfc2136['host'] = $_POST['host'];
91
		$rfc2136['ttl'] = $_POST['ttl'];
92
		$rfc2136['keyname'] = $_POST['keyname'];
93
		$rfc2136['keytype'] = $_POST['keytype'];
94
		$rfc2136['keydata'] = $_POST['keydata'];
95
		$rfc2136['server'] = $_POST['server'];
96
		$rfc2136['usetcp'] = $_POST['usetcp'] ? true : false;
97 6d8dd98b jim-p
		$rfc2136['usepublicip'] = $_POST['usepublicip'] ? true : false;
98 6626eb26 Ermal Luçi
		$rfc2136['interface'] = $_POST['interface'];
99
		$rfc2136['descr'] = $_POST['descr'];
100 f1f60c92 Ermal Luçi
101 6626eb26 Ermal Luçi
		if (isset($id) && $a_rfc2136[$id])
102
			$a_rfc2136[$id] = $rfc2136;
103
		else
104
			$a_rfc2136[] = $rfc2136;
105
106 bd758833 Rafael Lucas
		write_config(gettext("New/Edited RFC2136 dnsupdate entry was posted."));
107 6626eb26 Ermal Luçi
108 7c9da7be jim-p
		if ($_POST['Submit'] == gettext("Save & Force Update"))
109
			$retval = services_dnsupdate_process("", $rfc2136['host'], true);
110
		else
111
			$retval = services_dnsupdate_process();
112 6626eb26 Ermal Luçi
113
		header("Location: services_rfc2136.php");
114 f1f60c92 Ermal Luçi
		exit;
115 6626eb26 Ermal Luçi
	}
116 f1f60c92 Ermal Luçi
}
117
118 bd758833 Rafael Lucas
$pgtitle = array(gettext("Services"),gettext("RFC 2136 client"), gettext("Edit"));
119 f1f60c92 Ermal Luçi
include("head.inc");
120
121
?>
122
123
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
124
<?php include("fbegin.inc"); ?>
125
<?php if ($input_errors) print_input_errors($input_errors); ?>
126 6626eb26 Ermal Luçi
<?php if ($savemsg) print_info_box($savemsg); ?>
127
            <form action="services_rfc2136_edit.php" method="post" name="iform" id="iform">
128 d3c90ddd Colin Fleming
              <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="rfs2136 edit">
129 6626eb26 Ermal Luçi
			  	<tr>
130
                  <td colspan="2" valign="top" class="optsect_t">
131 d3c90ddd Colin Fleming
				  <table border="0" cellspacing="0" cellpadding="0" width="100%" summary="title">
132 bd758833 Rafael Lucas
				  	<tr><td class="optsect_s"><strong><?=gettext("RFC 2136 client");?></strong></td></tr>
133 6626eb26 Ermal Luçi
				  </table>
134
				  </td>
135
                </tr>
136 f1f60c92 Ermal Luçi
                <tr>
137 bd758833 Rafael Lucas
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Enable");?></td>
138 6626eb26 Ermal Luçi
				  <td width="78%" class="vtable">
139 d3c90ddd Colin Fleming
				    <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> />
140 f1f60c92 Ermal Luçi
				  </td>
141 6626eb26 Ermal Luçi
                </tr>
142
				<tr>
143 bd758833 Rafael Lucas
				   <td width="22%" valign="top" class="vncellreq"><?=gettext("Interface to monitor");?></td>  
144 6626eb26 Ermal Luçi
				   <td width="78%" class="vtable">
145
				   <select name="interface" class="formselect" id="interface">
146
				   <?php $iflist = get_configured_interface_with_descr();
147
				   		foreach ($iflist as $if => $ifdesc):?>
148 d3c90ddd Colin Fleming
							<option value="<?=$if;?>" <?php if ($pconfig['interface'] == $if) echo "selected=\"selected\"";?>><?=$ifdesc;?></option>
149 6626eb26 Ermal Luçi
					<?php endforeach; ?>
150
					</select>
151
					</td>
152
				</tr>	
153
                <tr>
154 bd758833 Rafael Lucas
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Hostname");?></td>
155 6626eb26 Ermal Luçi
                  <td width="78%" class="vtable">
156 d3c90ddd Colin Fleming
                    <input name="host" type="text" class="formfld unknown" id="host" size="30" value="<?=htmlspecialchars($pconfig['host']);?>" />
157 1d7ba683 ayvis
			<br /><span>Fully qualified hostname of the host to be updated</span>
158 f1f60c92 Ermal Luçi
                  </td>
159
				</tr>
160
                <tr>
161 3b0b4ea7 Carlos Eduardo Ramos
                  <td valign="top" class="vncellreq"><?=gettext("TTL"); ?></td>
162 6626eb26 Ermal Luçi
                  <td class="vtable">
163 d3c90ddd Colin Fleming
                    <input name="ttl" type="text" class="formfld unknown" id="ttl" size="6" value="<?=htmlspecialchars($pconfig['ttl']);?>" />
164 bd758833 Rafael Lucas
                  <?=gettext("seconds");?></td>
165 6626eb26 Ermal Luçi
                </tr>
166
                <tr>
167 bd758833 Rafael Lucas
                  <td valign="top" class="vncellreq"><?=gettext("Key name");?></td>
168 6626eb26 Ermal Luçi
                  <td class="vtable">
169 d3c90ddd Colin Fleming
                    <input name="keyname" type="text" class="formfld unknown" id="keyname" size="30" value="<?=htmlspecialchars($pconfig['keyname']);?>" />
170 1d7ba683 ayvis
                    <br />
171 bd758833 Rafael Lucas
                    <?=gettext("This must match the setting on the DNS server.");?></td>
172 6626eb26 Ermal Luçi
                </tr>
173
                <tr>
174 3b0b4ea7 Carlos Eduardo Ramos
                  <td valign="top" class="vncellreq"><?=gettext("Key type");?> </td>
175 6626eb26 Ermal Luçi
                  <td class="vtable">
176 d3c90ddd Colin Fleming
				  <input name="keytype" type="radio" value="zone" <?php if ($pconfig['keytype'] == "zone") echo "checked=\"checked\""; ?> /> <?=gettext("Zone");?> &nbsp;
177
                  <input name="keytype" type="radio" value="host" <?php if ($pconfig['keytype'] == "host") echo "checked=\"checked\""; ?> /> <?=gettext("Host");?> &nbsp;
178
                  <input name="keytype" type="radio" value="user" <?php if ($pconfig['keytype'] == "user") echo "checked=\"checked\""; ?> /><?=gettext(" User");?>
179
				</td>
180
                </tr>
181 6626eb26 Ermal Luçi
                <tr>
182 bd758833 Rafael Lucas
                  <td valign="top" class="vncellreq"><?=gettext("Key");?></td>
183 6626eb26 Ermal Luçi
                  <td class="vtable">
184 d3c90ddd Colin Fleming
                    <input name="keydata" type="text" class="formfld unknown" id="keydata" size="70" value="<?=htmlspecialchars($pconfig['keydata']);?>" />
185 1d7ba683 ayvis
                    <br />
186 bd758833 Rafael Lucas
                    <?=gettext("Paste an HMAC-MD5 key here.");?></td>
187 f1f60c92 Ermal Luçi
				</tr>
188 6626eb26 Ermal Luçi
                <tr>
189 bd758833 Rafael Lucas
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Server");?></td>
190 6626eb26 Ermal Luçi
                  <td width="78%" class="vtable">
191 90c39f4e Phil Davis
                    <input name="server" type="text" class="formfld unknown" id="server" size="30" value="<?=htmlspecialchars($pconfig['server'])?>" />
192 6626eb26 Ermal Luçi
                  </td>
193
                </tr>
194
                <tr>
195 bd758833 Rafael Lucas
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
196 6626eb26 Ermal Luçi
                  <td width="78%" class="vtable">
197 d3c90ddd Colin Fleming
                    <input name="usetcp" type="checkbox" id="usetcp" value="<?=gettext("yes");?>" <?php if ($pconfig['usetcp']) echo "checked=\"checked\""; ?> />
198 bd758833 Rafael Lucas
                    <strong><?=gettext("Use TCP instead of UDP");?></strong></td>
199 6626eb26 Ermal Luçi
				</tr>
200 6d8dd98b jim-p
		<tr>
201
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Use Public IP");?></td>
202
			<td width="78%" class="vtable">
203 d3c90ddd Colin Fleming
				<input name="usepublicip" type="checkbox" id="usepublicip" value="<?=gettext("yes");?>" <?php if ($pconfig['usepublicip']) echo "checked=\"checked\""; ?> />
204 6d8dd98b jim-p
				<strong><?=gettext("If the interface IP is private, attempt to fetch and use the public IP instead.");?></strong>
205
			</td>
206
		</tr>
207 6626eb26 Ermal Luçi
                <tr>
208 bd758833 Rafael Lucas
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Description");?></td>
209 6626eb26 Ermal Luçi
                  <td width="78%" class="vtable">
210 d3c90ddd Colin Fleming
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="60" value="<?=htmlspecialchars($pconfig['descr']);?>" />
211 6626eb26 Ermal Luçi
                  </td>
212
                </tr>
213
                <tr>
214
                  <td width="22%" valign="top">&nbsp;</td>
215
                  <td width="78%">
216 d3c90ddd Colin Fleming
					<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)" />
217
					<a href="services_rfc2136.php"><input name="Cancel" type="button" class="formbtn" value="<?=gettext("Cancel");?>" /></a>
218
					<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save &amp; Force Update");?>" onclick="enable_change(true)" />
219 6626eb26 Ermal Luçi
					<?php if (isset($id) && $a_rfc2136[$id]): ?>
220 d3c90ddd Colin Fleming
						<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
221 6626eb26 Ermal Luçi
					<?php endif; ?>
222
                  </td>
223
                </tr>
224
                <tr>
225
                  <td width="22%" valign="top">&nbsp;</td>
226 1d7ba683 ayvis
                  <td width="78%"><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br />
227 3b0b4ea7 Carlos Eduardo Ramos
                    </strong></span><?php printf(gettext("You must configure a DNS server in %sSystem: " .
228
                    "General setup %sor allow the DNS server list to be overridden " .
229
                    "by DHCP/PPP on WAN for dynamic DNS updates to work."),'<a href="system.php">', '</a>');?></span></td>
230 6626eb26 Ermal Luçi
                </tr>
231 f1f60c92 Ermal Luçi
              </table>
232
</form>
233
<?php include("fend.inc"); ?>
234
</body>
235
</html>