Projet

Général

Profil

Télécharger (10,7 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / services_rfc2136_edit.php @ fab1cd2f

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
if (is_numericint($_GET['id']))
41
	$id = $_GET['id'];
42
if (isset($_POST['id']) && is_numericint($_POST['id']))
43
	$id = $_POST['id'];
44

    
45
if (isset($id) && isset($a_rfc2136[$id])) {
46
	$pconfig['enable'] = isset($a_rfc2136[$id]['enable']);
47
	$pconfig['host'] = $a_rfc2136[$id]['host'];
48
	$pconfig['ttl'] = $a_rfc2136[$id]['ttl'];
49
	if (!$pconfig['ttl'])
50
		$pconfig['ttl'] = 60;
51
	$pconfig['keydata'] = $a_rfc2136[$id]['keydata'];
52
	$pconfig['keyname'] = $a_rfc2136[$id]['keyname'];
53
	$pconfig['keytype'] = $a_rfc2136[$id]['keytype'];
54
	if (!$pconfig['keytype'])
55
		$pconfig['keytype'] = "zone";
56
	$pconfig['server'] = $a_rfc2136[$id]['server'];
57
	$pconfig['interface'] = $a_rfc2136[$id]['interface'];
58
	$pconfig['usetcp'] = isset($a_rfc2136[$id]['usetcp']);
59
	$pconfig['usepublicip'] = isset($a_rfc2136[$id]['usepublicip']);
60
	$pconfig['descr'] = $a_rfc2136[$id]['descr'];
61

    
62
}
63

    
64
if ($_POST) {
65

    
66
	unset($input_errors);
67
	$pconfig = $_POST;
68

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

    
75
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
76

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

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

    
98
		if (isset($id) && $a_rfc2136[$id])
99
			$a_rfc2136[$id] = $rfc2136;
100
		else
101
			$a_rfc2136[] = $rfc2136;
102

    
103
		write_config(gettext("New/Edited RFC2136 dnsupdate entry was posted."));
104

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

    
110
		header("Location: services_rfc2136.php");
111
		exit;
112
	}
113
}
114

    
115
$pgtitle = array(gettext("Services"),gettext("RFC 2136 client"), gettext("Edit"));
116
include("head.inc");
117

    
118
?>
119

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