Project

General

Profile

Download (10.7 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	services_rfc2136_edit.php
5

    
6
	Copyright (C) 2008 Ermal Luçi
7
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
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
	pfSense_MODULE:	dnsupdate
33
*/
34

    
35
require("guiconfig.inc");
36

    
37
if (!is_array($config['dnsupdates']['dnsupdate'])) {
38
	$config['dnsupdates']['dnsupdate'] = array();
39
}
40

    
41
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
42

    
43
if (is_numericint($_GET['id']))
44
	$id = $_GET['id'];
45
if (isset($_POST['id']) && is_numericint($_POST['id']))
46
	$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
	$pconfig['usepublicip'] = isset($a_rfc2136[$id]['usepublicip']);
63
	$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
	$reqdfieldsn = array_merge($reqdfieldsn, array(gettext("Hostname"), gettext("TTL"), gettext("Key name"), gettext("Key")));
77

    
78
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
79

    
80
	if (($_POST['host'] && !is_domain($_POST['host'])))  
81
		$input_errors[] = gettext("The DNS update host name contains invalid characters.");
82
	if (($_POST['ttl'] && !is_numericint($_POST['ttl']))) 
83
		$input_errors[] = gettext("The DNS update TTL must be an integer.");
84
	if (($_POST['keyname'] && !is_domain($_POST['keyname'])))
85
		$input_errors[] = gettext("The DNS update key name contains invalid characters.");
86

    
87
	if (!$input_errors) {
88
		$rfc2136 = array();
89
		$rfc2136['enable'] = $_POST['enable'] ? true : false;
90
		$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
		$rfc2136['usepublicip'] = $_POST['usepublicip'] ? true : false;
98
		$rfc2136['interface'] = $_POST['interface'];
99
		$rfc2136['descr'] = $_POST['descr'];
100

    
101
		if (isset($id) && $a_rfc2136[$id])
102
			$a_rfc2136[$id] = $rfc2136;
103
		else
104
			$a_rfc2136[] = $rfc2136;
105

    
106
		write_config(gettext("New/Edited RFC2136 dnsupdate entry was posted."));
107

    
108
		if ($_POST['Submit'] == gettext("Save & Force Update"))
109
			$retval = services_dnsupdate_process("", $rfc2136['host'], true);
110
		else
111
			$retval = services_dnsupdate_process();
112

    
113
		header("Location: services_rfc2136.php");
114
		exit;
115
	}
116
}
117

    
118
$pgtitle = array(gettext("Services"),gettext("RFC 2136 client"), gettext("Edit"));
119
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
<?php if ($savemsg) print_info_box($savemsg); ?>
127
            <form action="services_rfc2136_edit.php" method="post" name="iform" id="iform">
128
              <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="rfs2136 edit">
129
			  	<tr>
130
                  <td colspan="2" valign="top" class="optsect_t">
131
				  <table border="0" cellspacing="0" cellpadding="0" width="100%" summary="title">
132
				  	<tr><td class="optsect_s"><strong><?=gettext("RFC 2136 client");?></strong></td></tr>
133
				  </table>
134
				  </td>
135
                </tr>
136
                <tr>
137
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Enable");?></td>
138
				  <td width="78%" class="vtable">
139
				    <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\""; ?> />
140
				  </td>
141
                </tr>
142
				<tr>
143
				   <td width="22%" valign="top" class="vncellreq"><?=gettext("Interface to monitor");?></td>  
144
				   <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
							<option value="<?=$if;?>" <?php if ($pconfig['interface'] == $if) echo "selected=\"selected\"";?>><?=$ifdesc;?></option>
149
					<?php endforeach; ?>
150
					</select>
151
					</td>
152
				</tr>	
153
                <tr>
154
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Hostname");?></td>
155
                  <td width="78%" class="vtable">
156
                    <input name="host" type="text" class="formfld unknown" id="host" size="30" value="<?=htmlspecialchars($pconfig['host']);?>" />
157
			<br /><span>Fully qualified hostname of the host to be updated</span>
158
                  </td>
159
				</tr>
160
                <tr>
161
                  <td valign="top" class="vncellreq"><?=gettext("TTL"); ?></td>
162
                  <td class="vtable">
163
                    <input name="ttl" type="text" class="formfld unknown" id="ttl" size="6" value="<?=htmlspecialchars($pconfig['ttl']);?>" />
164
                  <?=gettext("seconds");?></td>
165
                </tr>
166
                <tr>
167
                  <td valign="top" class="vncellreq"><?=gettext("Key name");?></td>
168
                  <td class="vtable">
169
                    <input name="keyname" type="text" class="formfld unknown" id="keyname" size="30" value="<?=htmlspecialchars($pconfig['keyname']);?>" />
170
                    <br />
171
                    <?=gettext("This must match the setting on the DNS server.");?></td>
172
                </tr>
173
                <tr>
174
                  <td valign="top" class="vncellreq"><?=gettext("Key type");?> </td>
175
                  <td class="vtable">
176
				  <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
                <tr>
182
                  <td valign="top" class="vncellreq"><?=gettext("Key");?></td>
183
                  <td class="vtable">
184
                    <input name="keydata" type="text" class="formfld unknown" id="keydata" size="70" value="<?=htmlspecialchars($pconfig['keydata']);?>" />
185
                    <br />
186
                    <?=gettext("Paste an HMAC-MD5 key here.");?></td>
187
				</tr>
188
                <tr>
189
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Server");?></td>
190
                  <td width="78%" class="vtable">
191
                    <input name="server" type="text" class="formfld unknown" id="server" size="30" value="<?=htmlspecialchars($pconfig['server'])?>" />
192
                  </td>
193
                </tr>
194
                <tr>
195
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
196
                  <td width="78%" class="vtable">
197
                    <input name="usetcp" type="checkbox" id="usetcp" value="<?=gettext("yes");?>" <?php if ($pconfig['usetcp']) echo "checked=\"checked\""; ?> />
198
                    <strong><?=gettext("Use TCP instead of UDP");?></strong></td>
199
				</tr>
200
		<tr>
201
			<td width="22%" valign="top" class="vncellreq"><?=gettext("Use Public IP");?></td>
202
			<td width="78%" class="vtable">
203
				<input name="usepublicip" type="checkbox" id="usepublicip" value="<?=gettext("yes");?>" <?php if ($pconfig['usepublicip']) echo "checked=\"checked\""; ?> />
204
				<strong><?=gettext("If the interface IP is private, attempt to fetch and use the public IP instead.");?></strong>
205
			</td>
206
		</tr>
207
                <tr>
208
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Description");?></td>
209
                  <td width="78%" class="vtable">
210
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="60" value="<?=htmlspecialchars($pconfig['descr']);?>" />
211
                  </td>
212
                </tr>
213
                <tr>
214
                  <td width="22%" valign="top">&nbsp;</td>
215
                  <td width="78%">
216
					<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
					<?php if (isset($id) && $a_rfc2136[$id]): ?>
220
						<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
221
					<?php endif; ?>
222
                  </td>
223
                </tr>
224
                <tr>
225
                  <td width="22%" valign="top">&nbsp;</td>
226
                  <td width="78%"><span class="vexpl"><span class="red"><strong><?=gettext("Note:");?><br />
227
                    </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
                </tr>
231
              </table>
232
</form>
233
<?php include("fend.inc"); ?>
234
</body>
235
</html>
(167-167/256)