Project

General

Profile

Download (9.06 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	Copyright (C) 2008 Ermal Lu?i
5
	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
/*
29
	pfSense_MODULE:	dnsupdate
30
*/
31

    
32
require("guiconfig.inc");
33

    
34
if (!is_array($config['dnsupdates']['dnsupdate'])) {
35
	$config['dnsupdates']['dnsupdate'] = array();
36
}
37

    
38
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
39

    
40
$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
	$pconfig['descr'] = $a_rfc2136[$id]['descr'];
59

    
60
}
61

    
62
if ($_POST) {
63

    
64
	unset($input_errors);
65
	$pconfig = $_POST;
66

    
67
	/* input validation */
68
	$reqdfields = array();
69
	$reqdfieldsn = array();
70
	$reqdfields = array_merge($reqdfields, explode(" ", "host ttl keyname keydata"));
71
	$reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Hostname,TTL,Key name,Key"));
72

    
73
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
74

    
75
	if (($_POST['host'] && !is_domain($_POST['host'])))  
76
		$input_errors[] = "The DNS update host name contains invalid characters.";
77
	if (($_POST['ttl'] && !is_numericint($_POST['ttl']))) 
78
		$input_errors[] = "The DNS update TTL must be an integer.";
79
	if (($_POST['keyname'] && !is_domain($_POST['keyname'])))
80
		$input_errors[] = "The DNS update key name contains invalid characters.";
81

    
82
	if (!$input_errors) {
83
		$rfc2136 = array();
84
		$rfc2136['enable'] = $_POST['enable'] ? false : true;
85
		$rfc2136['host'] = $_POST['host'];
86
		$rfc2136['ttl'] = $_POST['ttl'];
87
		$rfc2136['keyname'] = $_POST['keyname'];
88
		$rfc2136['keytype'] = $_POST['keytype'];
89
		$rfc2136['keydata'] = $_POST['keydata'];
90
		$rfc2136['server'] = $_POST['server'];
91
		$rfc2136['usetcp'] = $_POST['usetcp'] ? true : false;
92
		$rfc2136['interface'] = $_POST['interface'];
93
		$rfc2136['descr'] = $_POST['descr'];
94

    
95
		if (isset($id) && $a_rfc2136[$id])
96
			$a_rfc2136[$id] = $rfc2136;
97
		else
98
			$a_rfc2136[] = $rfc2136;
99

    
100
		write_config("New/Edited RFC2136 dnsupdate entry was posted.");
101

    
102
                $retval = services_dnsupdate_process();
103

    
104
		header("Location: services_rfc2136.php");
105
		exit;
106
	}
107
}
108

    
109
$pgtitle = array("Services","RFC 2136 client", "Edit");
110
include("head.inc");
111

    
112
?>
113

    
114
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
115
<?php include("fbegin.inc"); ?>
116
<?php if ($input_errors) print_input_errors($input_errors); ?>
117
<?php if ($savemsg) print_info_box($savemsg); ?>
118
            <form action="services_rfc2136_edit.php" method="post" name="iform" id="iform">
119
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
120
			  	<tr>
121
                  <td colspan="2" valign="top" class="optsect_t">
122
				  <table border="0" cellspacing="0" cellpadding="0" width="100%">
123
				  	<tr><td class="optsect_s"><strong>RFC 2136 client</strong></td></tr>
124
				  </table>
125
				  </td>
126
                </tr>
127
                <tr>
128
                  <td width="22%" valign="top" class="vncellreq">Enable</td>
129
				  <td width="78%" class="vtable">
130
				    <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?>>
131
				  </td>
132
                </tr>
133
				<tr>
134
				   <td width="22%" valign="top" class="vncellreq">Interface to monitor</td>  
135
				   <td width="78%" class="vtable">
136
				   <select name="interface" class="formselect" id="interface">
137
				   <?php $iflist = get_configured_interface_with_descr();
138
				   		foreach ($iflist as $if => $ifdesc):?>
139
							<option value="<?=$if;?>" <?php if ($pconfig['interface'] == $if) echo "selected";?>><?=$ifdesc;?></option>
140
					<?php endforeach; ?>
141
					</select>
142
					</td>
143
					</td>
144
				</tr>	
145
                <tr>
146
                  <td width="22%" valign="top" class="vncellreq">Hostname</td>
147
                  <td width="78%" class="vtable">
148
                    <input name="host" type="text" class="formfld unknown" id="host" size="30" value="<?=htmlspecialchars($pconfig['host']);?>">
149
                  </td>
150
				</tr>
151
                <tr>
152
                  <td valign="top" class="vncellreq">TTL</td>
153
                  <td class="vtable">
154
                    <input name="ttl" type="text" class="formfld unknown" id="ttl" size="6" value="<?=htmlspecialchars($pconfig['ttl']);?>">
155
                  seconds</td>
156
                </tr>
157
                <tr>
158
                  <td valign="top" class="vncellreq">Key name</td>
159
                  <td class="vtable">
160
                    <input name="keyname" type="text" class="formfld unknown" id="keyname" size="30" value="<?=htmlspecialchars($pconfig['keyname']);?>">
161
                    <br>
162
                    This must match the setting on the DNS server.</td>
163
                </tr>
164
                <tr>
165
                  <td valign="top" class="vncellreq">Key type </td>
166
                  <td class="vtable">
167
				  <input name="keytype" type="radio" value="zone" <?php if ($pconfig['keytype'] == "zone") echo "checked"; ?>> Zone &nbsp;
168
                  <input name="keytype" type="radio" value="host" <?php if ($pconfig['keytype'] == "host") echo "checked"; ?>> Host &nbsp;
169
                  <input name="keytype" type="radio" value="user" <?php if ($pconfig['keytype'] == "user") echo "checked"; ?>> User
170
				</tr>
171
                <tr>
172
                  <td valign="top" class="vncellreq">Key</td>
173
                  <td class="vtable">
174
                    <input name="keydata" type="text" class="formfld unknown" id="keydata" size="70" value="<?=htmlspecialchars($pconfig['keydata']);?>">
175
                    <br>
176
                    Paste an HMAC-MD5 key here.</td>
177
				</tr>
178
                <tr>
179
                  <td width="22%" valign="top" class="vncellreq">Server</td>
180
                  <td width="78%" class="vtable">
181
                    <input name="server" type="text" class+"formfld" id="server" size="30" value="<?=htmlspecialchars($pconfig['server'])?>">
182
                  </td>
183
                </tr>
184
                <tr>
185
                  <td width="22%" valign="top" class="vncellreq">Protocol</td>
186
                  <td width="78%" class="vtable">
187
                    <input name="usetcp" type="checkbox" id="usetcp" value="yes" <?php if ($pconfig['usetcp']) echo "checked"; ?>>
188
                    <strong>Use TCP instead of UDP</strong></td>
189
				</tr>
190
                <tr>
191
                  <td width="22%" valign="top" class="vncellreq">Description</td>
192
                  <td width="78%" class="vtable">
193
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="60" value="<?=htmlspecialchars($pconfig['descr']);?>">
194
                  </td>
195
                </tr>
196
                <tr>
197
                  <td width="22%" valign="top">&nbsp;</td>
198
                  <td width="78%">
199
                    <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
200
					<a href="services_rfc2136.php"><input name="Cancel" type="button" class="formbtn" value="Cancel"></a>
201
					<?php if (isset($id) && $a_rfc2136[$id]): ?>
202
						<input name="id" type="hidden" value="<?=$id;?>">
203
					<?php endif; ?>
204
                  </td>
205
                </tr>
206
                <tr>
207
                  <td width="22%" valign="top">&nbsp;</td>
208
                  <td width="78%"><span class="vexpl"><span class="red"><strong>Note:<br>
209
                    </strong></span>You must configure a DNS server in <a href="system.php">System:
210
                    General setup</a> or allow the DNS server list to be overridden
211
                    by DHCP/PPP on WAN for dynamic DNS updates to work.</span></td>
212
                </tr>
213
              </table>
214
</form>
215
<?php include("fend.inc"); ?>
216
</body>
217
</html>
(144-144/221)