Project

General

Profile

Download (9.03 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
29
require("guiconfig.inc");
30
31 6626eb26 Ermal Luçi
if (!is_array($config['dnsupdates']['dnsupdate'])) {
32 f1f60c92 Ermal Luçi
	$config['dnsupdates']['dnsupdate'] = array();
33 6626eb26 Ermal Luçi
}
34 f1f60c92 Ermal Luçi
35
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
36
37 6626eb26 Ermal Luçi
$id = $_GET['id'];
38
if (isset($_POST['id']))
39
	$id = $_POST['id'];
40
41
if (isset($id) && isset($a_rfc2136[$id])) {
42
	$pconfig['enable'] = isset($a_rfc2136[$id]['enable']);
43
	$pconfig['host'] = $a_rfc2136[$id]['host'];
44
	$pconfig['ttl'] = $a_rfc2136[$id]['ttl'];
45
	if (!$pconfig['ttl'])
46
		$pconfig['ttl'] = 60;
47
	$pconfig['keydata'] = $a_rfc2136[$id]['keydata'];
48
	$pconfig['keyname'] = $a_rfc2136[$id]['keyname'];
49
	$pconfig['keytype'] = $a_rfc2136[$id]['keytype'];
50
	if (!$pconfig['keytype'])
51
		$pconfig['keytype'] = "zone";
52
	$pconfig['server'] = $a_rfc2136[$id]['server'];
53
	$pconfig['interface'] = $a_rfc2136[$id]['interface'];
54
	$pconfig['usetcp'] = isset($a_rfc2136[$id]['usetcp']);
55
	$pconfig['descr'] = $a_rfc2136[$id]['descr'];
56
57
}
58
59
if ($_POST) {
60
61
	unset($input_errors);
62
	$pconfig = $_POST;
63
64
	/* input validation */
65
	$reqdfields = array();
66
	$reqdfieldsn = array();
67
	$reqdfields = array_merge($reqdfields, explode(" ", "host ttl keyname keydata"));
68
	$reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Hostname,TTL,Key name,Key"));
69
70
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
71
72
	if (($_POST['host'] && !is_domain($_POST['host'])))  
73
		$input_errors[] = "The DNS update host name contains invalid characters.";
74
	if (($_POST['ttl'] && !is_numericint($_POST['ttl']))) 
75
		$input_errors[] = "The DNS update TTL must be an integer.";
76
	if (($_POST['keyname'] && !is_domain($_POST['keyname'])))
77
		$input_errors[] = "The DNS update key name contains invalid characters.";
78 f1f60c92 Ermal Luçi
79 6626eb26 Ermal Luçi
	if (!$input_errors) {
80
		$rfc2136 = array();
81
		$rfc2136['enable'] = $_POST['enable'] ? false : true;
82
		$rfc2136['host'] = $_POST['host'];
83
		$rfc2136['ttl'] = $_POST['ttl'];
84
		$rfc2136['keyname'] = $_POST['keyname'];
85
		$rfc2136['keytype'] = $_POST['keytype'];
86
		$rfc2136['keydata'] = $_POST['keydata'];
87
		$rfc2136['server'] = $_POST['server'];
88
		$rfc2136['usetcp'] = $_POST['usetcp'] ? true : false;
89
		$rfc2136['interface'] = $_POST['interface'];
90
		$rfc2136['descr'] = $_POST['descr'];
91 f1f60c92 Ermal Luçi
92 6626eb26 Ermal Luçi
		if (isset($id) && $a_rfc2136[$id])
93
			$a_rfc2136[$id] = $rfc2136;
94
		else
95
			$a_rfc2136[] = $rfc2136;
96
97
		write_config("New/Edited RFC2136 dnsupdate entry was posted.");
98
99
                $retval = services_dnsupdate_process();
100
101
		header("Location: services_rfc2136.php");
102 f1f60c92 Ermal Luçi
		exit;
103 6626eb26 Ermal Luçi
	}
104 f1f60c92 Ermal Luçi
}
105
106 6626eb26 Ermal Luçi
$pgtitle = array("Services","RFC 2136 client", "Edit");
107 f1f60c92 Ermal Luçi
include("head.inc");
108
109
?>
110
111
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
112
<?php include("fbegin.inc"); ?>
113
<?php if ($input_errors) print_input_errors($input_errors); ?>
114 6626eb26 Ermal Luçi
<?php if ($savemsg) print_info_box($savemsg); ?>
115
            <form action="services_rfc2136_edit.php" method="post" name="iform" id="iform">
116
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
117
			  	<tr>
118
                  <td colspan="2" valign="top" class="optsect_t">
119
				  <table border="0" cellspacing="0" cellpadding="0" width="100%">
120
				  	<tr><td class="optsect_s"><strong>RFC 2136 client</strong></td></tr>
121
				  </table>
122
				  </td>
123
                </tr>
124 f1f60c92 Ermal Luçi
                <tr>
125 6626eb26 Ermal Luçi
                  <td width="22%" valign="top" class="vncellreq">Enable</td>
126
				  <td width="78%" class="vtable">
127
				    <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?>>
128 f1f60c92 Ermal Luçi
				  </td>
129 6626eb26 Ermal Luçi
                </tr>
130
				<tr>
131
				   <td width="22%" valign="top" class="vncellreq">Interface to monitor</td>  
132
				   <td width="78%" class="vtable">
133
				   <select name="interface" class="formselect" id="interface">
134
				   <?php $iflist = get_configured_interface_with_descr();
135
				   		foreach ($iflist as $if => $ifdesc):?>
136
							<option value="<?=$if;?>" <?php if ($pconfig['interface'] == $if) echo "selected";?>><?=$ifdesc;?></option>
137
					<?php endforeach; ?>
138
					</select>
139
					</td>
140
					</td>
141
				</tr>	
142
                <tr>
143
                  <td width="22%" valign="top" class="vncellreq">Hostname</td>
144
                  <td width="78%" class="vtable">
145
                    <input name="host" type="text" class="formfld unknown" id="host" size="30" value="<?=htmlspecialchars($pconfig['host']);?>">
146 f1f60c92 Ermal Luçi
                  </td>
147
				</tr>
148
                <tr>
149 6626eb26 Ermal Luçi
                  <td valign="top" class="vncellreq">TTL</td>
150
                  <td class="vtable">
151
                    <input name="ttl" type="text" class="formfld unknown" id="ttl" size="6" value="<?=htmlspecialchars($pconfig['ttl']);?>">
152
                  seconds</td>
153
                </tr>
154
                <tr>
155
                  <td valign="top" class="vncellreq">Key name</td>
156
                  <td class="vtable">
157
                    <input name="keyname" type="text" class="formfld unknown" id="keyname" size="30" value="<?=htmlspecialchars($pconfig['keyname']);?>">
158
                    <br>
159
                    This must match the setting on the DNS server.</td>
160
                </tr>
161
                <tr>
162
                  <td valign="top" class="vncellreq">Key type </td>
163
                  <td class="vtable">
164
				  <input name="keytype" type="radio" value="zone" <?php if ($pconfig['keytype'] == "zone") echo "checked"; ?>> Zone &nbsp;
165
                  <input name="keytype" type="radio" value="host" <?php if ($pconfig['keytype'] == "host") echo "checked"; ?>> Host &nbsp;
166
                  <input name="keytype" type="radio" value="user" <?php if ($pconfig['keytype'] == "user") echo "checked"; ?>> User
167 f1f60c92 Ermal Luçi
				</tr>
168 6626eb26 Ermal Luçi
                <tr>
169
                  <td valign="top" class="vncellreq">Key</td>
170
                  <td class="vtable">
171
                    <input name="keydata" type="text" class="formfld unknown" id="keydata" size="70" value="<?=htmlspecialchars($pconfig['keydata']);?>">
172
                    <br>
173
                    Paste an HMAC-MD5 key here.</td>
174 f1f60c92 Ermal Luçi
				</tr>
175 6626eb26 Ermal Luçi
                <tr>
176
                  <td width="22%" valign="top" class="vncellreq">Server</td>
177
                  <td width="78%" class="vtable">
178
                    <input name="server" type="text" class+"formfld" id="server" size="30" value="<?=htmlspecialchars($pconfig['server'])?>">
179
                  </td>
180
                </tr>
181
                <tr>
182
                  <td width="22%" valign="top" class="vncellreq">Protocol</td>
183
                  <td width="78%" class="vtable">
184
                    <input name="usetcp" type="checkbox" id="usetcp" value="yes" <?php if ($pconfig['usetcp']) echo "checked"; ?>>
185
                    <strong>Use TCP instead of UDP</strong></td>
186
				</tr>
187
                <tr>
188
                  <td width="22%" valign="top" class="vncellreq">Description</td>
189
                  <td width="78%" class="vtable">
190
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="60" value="<?=htmlspecialchars($pconfig['descr']);?>">
191
                  </td>
192
                </tr>
193
                <tr>
194
                  <td width="22%" valign="top">&nbsp;</td>
195
                  <td width="78%">
196
                    <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
197
					<a href="services_rfc2136.php"><input name="Cancel" type="button" class="formbtn" value="Cancel"></a>
198
					<?php if (isset($id) && $a_rfc2136[$id]): ?>
199
						<input name="id" type="hidden" value="<?=$id;?>">
200
					<?php endif; ?>
201
                  </td>
202
                </tr>
203
                <tr>
204
                  <td width="22%" valign="top">&nbsp;</td>
205
                  <td width="78%"><span class="vexpl"><span class="red"><strong>Note:<br>
206
                    </strong></span>You must configure a DNS server in <a href="system.php">System:
207
                    General setup</a> or allow the DNS server list to be overridden
208
                    by DHCP/PPP on WAN for dynamic DNS updates to work.</span></td>
209
                </tr>
210 f1f60c92 Ermal Luçi
              </table>
211
</form>
212
<?php include("fend.inc"); ?>
213
</body>
214
</html>