Revision 6626eb26
Added by Ermal Luçi almost 17 years ago
usr/local/www/services_rfc2136_edit.php | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
/* $Id$ */ |
3 | 3 |
/* |
4 |
Copyright (C) 2008 Ermal Lu?i
|
|
4 |
Copyright (C) 2008 Ermal Luci
|
|
5 | 5 |
All rights reserved. |
6 | 6 |
|
7 | 7 |
Redistribution and use in source and binary forms, with or without |
... | ... | |
28 | 28 |
|
29 | 29 |
require("guiconfig.inc"); |
30 | 30 |
|
31 |
if (!is_array($config['dnsupdates']['dnsupdate'])) |
|
31 |
if (!is_array($config['dnsupdates']['dnsupdate'])) {
|
|
32 | 32 |
$config['dnsupdates']['dnsupdate'] = array(); |
33 |
} |
|
33 | 34 |
|
34 | 35 |
$a_rfc2136 = &$config['dnsupdates']['dnsupdate']; |
35 | 36 |
|
36 |
if ($_GET['act'] == "del") { |
|
37 |
unset($a_rfc2136[$_GET['id']]); |
|
37 |
$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."; |
|
38 | 78 |
|
39 |
write_config(); |
|
79 |
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']; |
|
40 | 91 |
|
41 |
header("Location: services_dyndns.php"); |
|
92 |
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 |
config_lock(); |
|
100 |
/* nuke the cache file */ |
|
101 |
services_rfc2136_reset(); |
|
102 |
$retval = services_dnsupdate_process(); |
|
103 |
config_unlock(); |
|
104 |
|
|
105 |
header("Location: services_rfc2136.php"); |
|
42 | 106 |
exit; |
107 |
} |
|
43 | 108 |
} |
44 | 109 |
|
45 |
$pgtitle = array("Services", "RFC 2136 clients");
|
|
110 |
$pgtitle = array("Services","RFC 2136 client", "Edit");
|
|
46 | 111 |
include("head.inc"); |
47 | 112 |
|
48 | 113 |
?> |
49 | 114 |
|
50 | 115 |
<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> |
51 | 116 |
<?php include("fbegin.inc"); ?> |
52 |
<form action="services_rfc2136.php" method="post" name="iform" id="iform"> |
|
53 | 117 |
<?php if ($input_errors) print_input_errors($input_errors); ?> |
54 |
<table width="100%" border="0" cellpadding="0" cellspacing="0"> |
|
55 |
<tr><td> |
|
56 |
<?php |
|
57 |
$tab_array = array(); |
|
58 |
$tab_array[] = array("DynDns", false, "services_dyndns.php"); |
|
59 |
$tab_array[] = array("RFC 2136", true, "services_rfc2136.php"); |
|
60 |
display_top_tabs($tab_array); |
|
61 |
?> |
|
62 |
</td></tr> |
|
63 |
<tr> |
|
64 |
<td> |
|
65 |
<div id="mainarea"> |
|
66 |
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> |
|
67 |
<tr> |
|
68 |
<td width="5%" class="listhdrr"></td> |
|
69 |
<td width="25%" class="listhdrr">Hostname</td> |
|
70 |
<td width="60%" class="listhdr">Description</td> |
|
71 |
<td width="10%" class="list"></td> |
|
72 |
</tr> |
|
73 |
<?php $i = 0; foreach ($a_rfc2136 as $rfc2136): ?> |
|
118 |
<?php if ($savemsg) print_info_box($savemsg); ?> |
|
119 |
<form action="services_rfc2136_edit.php" method="post" name="iform" id="iform"> |
|
120 |
<table width="100%" border="0" cellpadding="6" cellspacing="0"> |
|
121 |
<tr> |
|
122 |
<td colspan="2" valign="top" class="optsect_t"> |
|
123 |
<table border="0" cellspacing="0" cellpadding="0" width="100%"> |
|
124 |
<tr><td class="optsect_s"><strong>RFC 2136 client</strong></td></tr> |
|
125 |
</table> |
|
126 |
</td> |
|
127 |
</tr> |
|
74 | 128 |
<tr> |
75 |
<td class="listlr"> |
|
76 |
<?php $iflist = get_configured_interface_with_descr(); |
|
77 |
foreach ($iflist as $if => $ifdesc): |
|
78 |
if ($rfc2136['interface'] == $if): ?> |
|
79 |
<?=$ifdesc; break;?> |
|
80 |
<?php endif; endforeach; ?> |
|
129 |
<td width="22%" valign="top" class="vncellreq">Enable</td> |
|
130 |
<td width="78%" class="vtable"> |
|
131 |
<input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?>> |
|
81 | 132 |
</td> |
82 |
<td class="listr"> |
|
83 |
<?=htmlspecialchars($rfc2136['host']);?> |
|
84 |
</td> |
|
85 |
<td class="listbg"> |
|
86 |
<?=htmlspecialchars($rfc2136['descr']);?> |
|
133 |
</tr> |
|
134 |
<tr> |
|
135 |
<td width="22%" valign="top" class="vncellreq">Interface to monitor</td> |
|
136 |
<td width="78%" class="vtable"> |
|
137 |
<select name="interface" class="formselect" id="interface"> |
|
138 |
<?php $iflist = get_configured_interface_with_descr(); |
|
139 |
foreach ($iflist as $if => $ifdesc):?> |
|
140 |
<option value="<?=$if;?>" <?php if ($pconfig['interface'] == $if) echo "selected";?>><?=$ifdesc;?></option> |
|
141 |
<?php endforeach; ?> |
|
142 |
</select> |
|
143 |
</td> |
|
144 |
</td> |
|
145 |
</tr> |
|
146 |
<tr> |
|
147 |
<td width="22%" valign="top" class="vncellreq">Hostname</td> |
|
148 |
<td width="78%" class="vtable"> |
|
149 |
<input name="host" type="text" class="formfld unknown" id="host" size="30" value="<?=htmlspecialchars($pconfig['host']);?>"> |
|
87 | 150 |
</td> |
88 |
<td valign="middle" nowrap class="list"> <a href="services_rfc2136_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a> |
|
89 |
<a href="services_rfc2136.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this client?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td> |
|
90 | 151 |
</tr> |
91 |
<?php $i++; endforeach; ?> |
|
92 | 152 |
<tr> |
93 |
<td class="list" colspan="3"> </td> |
|
94 |
<td class="list"> <a href="services_rfc2136_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td> |
|
153 |
<td valign="top" class="vncellreq">TTL</td> |
|
154 |
<td class="vtable"> |
|
155 |
<input name="ttl" type="text" class="formfld unknown" id="ttl" size="6" value="<?=htmlspecialchars($pconfig['ttl']);?>"> |
|
156 |
seconds</td> |
|
157 |
</tr> |
|
158 |
<tr> |
|
159 |
<td valign="top" class="vncellreq">Key name</td> |
|
160 |
<td class="vtable"> |
|
161 |
<input name="keyname" type="text" class="formfld unknown" id="keyname" size="30" value="<?=htmlspecialchars($pconfig['keyname']);?>"> |
|
162 |
<br> |
|
163 |
This must match the setting on the DNS server.</td> |
|
164 |
</tr> |
|
165 |
<tr> |
|
166 |
<td valign="top" class="vncellreq">Key type </td> |
|
167 |
<td class="vtable"> |
|
168 |
<input name="keytype" type="radio" value="zone" <?php if ($pconfig['keytype'] == "zone") echo "checked"; ?>> Zone |
|
169 |
<input name="keytype" type="radio" value="host" <?php if ($pconfig['keytype'] == "host") echo "checked"; ?>> Host |
|
170 |
<input name="keytype" type="radio" value="user" <?php if ($pconfig['keytype'] == "user") echo "checked"; ?>> User |
|
95 | 171 |
</tr> |
96 |
<tr> |
|
97 |
<td colspan="3" class="list"><p class="vexpl"><span class="red"><strong> |
|
98 |
Note:<br> |
|
99 |
</strong></span> |
|
100 |
Add something meaningful here. |
|
101 |
</td> |
|
102 |
<td class="list"> </td> |
|
172 |
<tr> |
|
173 |
<td valign="top" class="vncellreq">Key</td> |
|
174 |
<td class="vtable"> |
|
175 |
<input name="keydata" type="text" class="formfld unknown" id="keydata" size="70" value="<?=htmlspecialchars($pconfig['keydata']);?>"> |
|
176 |
<br> |
|
177 |
Paste an HMAC-MD5 key here.</td> |
|
103 | 178 |
</tr> |
179 |
<tr> |
|
180 |
<td width="22%" valign="top" class="vncellreq">Server</td> |
|
181 |
<td width="78%" class="vtable"> |
|
182 |
<input name="server" type="text" class+"formfld" id="server" size="30" value="<?=htmlspecialchars($pconfig['server'])?>"> |
|
183 |
</td> |
|
184 |
</tr> |
|
185 |
<tr> |
|
186 |
<td width="22%" valign="top" class="vncellreq">Protocol</td> |
|
187 |
<td width="78%" class="vtable"> |
|
188 |
<input name="usetcp" type="checkbox" id="usetcp" value="yes" <?php if ($pconfig['usetcp']) echo "checked"; ?>> |
|
189 |
<strong>Use TCP instead of UDP</strong></td> |
|
190 |
</tr> |
|
191 |
<tr> |
|
192 |
<td width="22%" valign="top" class="vncellreq">Description</td> |
|
193 |
<td width="78%" class="vtable"> |
|
194 |
<input name="descr" type="text" class="formfld unknown" id="descr" size="60" value="<?=htmlspecialchars($pconfig['descr']);?>"> |
|
195 |
</td> |
|
196 |
</tr> |
|
197 |
<tr> |
|
198 |
<td width="22%" valign="top"> </td> |
|
199 |
<td width="78%"> |
|
200 |
<input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)"> |
|
201 |
<a href="services_rfc2136.php"><input name="Cancel" type="button" class="formbtn" value="Cancel"></a> |
|
202 |
<?php if (isset($id) && $a_rfc2136[$id]): ?> |
|
203 |
<input name="id" type="hidden" value="<?=$id;?>"> |
|
204 |
<?php endif; ?> |
|
205 |
</td> |
|
206 |
</tr> |
|
207 |
<tr> |
|
208 |
<td width="22%" valign="top"> </td> |
|
209 |
<td width="78%"><span class="vexpl"><span class="red"><strong>Note:<br> |
|
210 |
</strong></span>You must configure a DNS server in <a href="system.php">System: |
|
211 |
General setup</a> or allow the DNS server list to be overridden |
|
212 |
by DHCP/PPP on WAN for dynamic DNS updates to work.</span></td> |
|
213 |
</tr> |
|
104 | 214 |
</table> |
105 |
</div> |
|
106 |
</td> |
|
107 |
</tr> |
|
108 |
</table> |
|
109 | 215 |
</form> |
110 | 216 |
<?php include("fend.inc"); ?> |
111 | 217 |
</body> |
Also available in: Unified diff
Oops, seems i have commited the wrong file for this service! Bring in the right one.