Project

General

Profile

Download (6.97 KB) Statistics
| Branch: | Tag: | Revision:
1 f1f60c92 Ermal Luçi
<?php
2
/*
3 aaec5634 Renato Botelho
 * services_rfc2136.php
4 33f0b0d5 Stephen Beaver
 *
5 aaec5634 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 2a2396a6 Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 aaec5634 Renato Botelho
 * All rights reserved.
8 33f0b0d5 Stephen Beaver
 *
9 aaec5634 Renato Botelho
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions are met:
11 33f0b0d5 Stephen Beaver
 *
12 aaec5634 Renato Botelho
 * 1. Redistributions of source code must retain the above copyright notice,
13
 *    this list of conditions and the following disclaimer.
14 33f0b0d5 Stephen Beaver
 *
15 aaec5634 Renato Botelho
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice, this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19 33f0b0d5 Stephen Beaver
 *
20 aaec5634 Renato Botelho
 * 3. All advertising materials mentioning features or use of this software
21
 *    must display the following acknowledgment:
22
 *    "This product includes software developed by the pfSense Project
23
 *    for use in the pfSense® software distribution. (http://www.pfsense.org/).
24 33f0b0d5 Stephen Beaver
 *
25 aaec5634 Renato Botelho
 * 4. The names "pfSense" and "pfSense Project" must not be used to
26
 *    endorse or promote products derived from this software without
27
 *    prior written permission. For written permission, please contact
28
 *    coreteam@pfsense.org.
29 33f0b0d5 Stephen Beaver
 *
30 aaec5634 Renato Botelho
 * 5. Products derived from this software may not be called "pfSense"
31
 *    nor may "pfSense" appear in their names without prior written
32
 *    permission of the Electric Sheep Fencing, LLC.
33 33f0b0d5 Stephen Beaver
 *
34 aaec5634 Renato Botelho
 * 6. Redistributions of any form whatsoever must retain the following
35
 *    acknowledgment:
36 33f0b0d5 Stephen Beaver
 *
37 aaec5634 Renato Botelho
 * "This product includes software developed by the pfSense Project
38
 * for use in the pfSense software distribution (http://www.pfsense.org/).
39 33f0b0d5 Stephen Beaver
 *
40 aaec5634 Renato Botelho
 * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
41
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
44
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51
 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 33f0b0d5 Stephen Beaver
 */
53 f1f60c92 Ermal Luçi
54 6b07c15a Matthew Grooms
##|+PRIV
55
##|*IDENT=page-services-rfc2136clients
56 5230f468 jim-p
##|*NAME=Services: RFC 2136 Clients
57 a57d9fa2 jim-p
##|*DESCR=Allow access to the 'Services: RFC 2136 Clients' page.
58 6b07c15a Matthew Grooms
##|*MATCH=services_rfc2136.php*
59
##|-PRIV
60
61 aceaf18c Phil Davis
require_once("guiconfig.inc");
62 f1f60c92 Ermal Luçi
63 efdf8358 Phil Davis
if (!is_array($config['dnsupdates']['dnsupdate'])) {
64 f1f60c92 Ermal Luçi
	$config['dnsupdates']['dnsupdate'] = array();
65 efdf8358 Phil Davis
}
66 f1f60c92 Ermal Luçi
67
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
68
69
if ($_GET['act'] == "del") {
70 e766bd84 bcyrill
	unset($a_rfc2136[$_GET['id']]);
71 f1f60c92 Ermal Luçi
72 e766bd84 bcyrill
	write_config();
73 f1f60c92 Ermal Luçi
74 e766bd84 bcyrill
	header("Location: services_rfc2136.php");
75
	exit;
76 20db3e1a Phil Davis
} else if ($_GET['act'] == "toggle") {
77 c5d81fdf heper
	if ($a_rfc2136[$_GET['id']]) {
78
		if (isset($a_rfc2136[$_GET['id']]['enable'])) {
79
			unset($a_rfc2136[$_GET['id']]['enable']);
80
		} else {
81
			$a_rfc2136[$_GET['id']]['enable'] = true;
82
		}
83
		write_config();
84 919d91f9 Phil Davis
85 c5d81fdf heper
		header("Location: services_rfc2136.php");
86
		exit;
87
	}
88
}
89 f1f60c92 Ermal Luçi
90 bf40071d Phil Davis
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("RFC 2136 Clients"));
91 f1f60c92 Ermal Luçi
include("head.inc");
92 a5d5b1f7 sbeaver
93
$tab_array = array();
94 c8f6b745 k-paulius
$tab_array[] = array(gettext("Dynamic DNS Clients"), false, "services_dyndns.php");
95
$tab_array[] = array(gettext("RFC 2136 Clients"), true, "services_rfc2136.php");
96 b89bc607 Phil Davis
$tab_array[] = array(gettext("Check IP Services"), false, "services_checkip.php");
97 a5d5b1f7 sbeaver
display_top_tabs($tab_array);
98
99 20db3e1a Phil Davis
if ($input_errors) {
100 060ed238 Stephen Beaver
	print_input_errors($input_errors);
101 20db3e1a Phil Davis
}
102 f1f60c92 Ermal Luçi
?>
103
104
<form action="services_rfc2136.php" method="post" name="iform" id="iform">
105 060ed238 Stephen Beaver
	<div class="panel panel-default">
106 f0efd690 Phil Davis
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('RFC2136 Clients')?></h2></div>
107 060ed238 Stephen Beaver
		<div class="panel-body">
108
			<div class="table-responsive">
109 91677170 PiBa-NL
				<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
110 060ed238 Stephen Beaver
					<thead>
111
						<tr>
112 f0efd690 Phil Davis
							<th><?=gettext("Interface")?></th>
113 060ed238 Stephen Beaver
							<th><?=gettext("Server")?></th>
114
							<th><?=gettext("Hostname")?></th>
115
							<th><?=gettext("Cached IP")?></th>
116
							<th><?=gettext("Description")?></th>
117 f0efd690 Phil Davis
							<th><?=gettext("Actions")?></th>
118 060ed238 Stephen Beaver
						</tr>
119
					</thead>
120
					<tbody>
121 f1f60c92 Ermal Luçi
<?php
122 30a40ca8 sbeaver
123
124
$iflist = get_configured_interface_with_descr();
125 c7127a13 jim-p
$groupslist = return_gateway_groups_array();
126 30a40ca8 sbeaver
127 a5d5b1f7 sbeaver
$i = 0;
128
foreach ($a_rfc2136 as $rfc2136):
129 f1f60c92 Ermal Luçi
?>
130 060ed238 Stephen Beaver
						<tr<?=(isset($rfc2136['enable']) ? '' : ' class="disabled"')?>>
131
							<td>
132 a5d5b1f7 sbeaver
<?php
133
	foreach ($iflist as $if => $ifdesc) {
134 060ed238 Stephen Beaver
		if ($rfc2136['interface'] == $if) {
135
			print($ifdesc);
136 a5d5b1f7 sbeaver
			break;
137 060ed238 Stephen Beaver
		}
138 a5d5b1f7 sbeaver
	}
139 c7127a13 jim-p
	foreach ($groupslist as $if => $group) {
140
		if ($rfc2136['interface'] == $if) {
141
			print($if);
142
			break;
143
		}
144
	}
145 a5d5b1f7 sbeaver
?>
146 060ed238 Stephen Beaver
							</td>
147
							<td>
148
								<?=htmlspecialchars($rfc2136['server'])?>
149
							</td>
150
							<td>
151
								<?=htmlspecialchars($rfc2136['host'])?>
152
							</td>
153
							<td>
154 a5d5b1f7 sbeaver
<?php
155
	$filename = "{$g['conf_path']}/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}.cache";
156 c7127a13 jim-p
	$if = get_failover_interface($rfc2136['interface']);
157 a5d5b1f7 sbeaver
158
	if (file_exists($filename)) {
159
		print('IPv4: ');
160 20db3e1a Phil Davis
		if (isset($rfc2136['usepublicip'])) {
161 c7127a13 jim-p
			$ipaddr = dyndnsCheckIP($if);
162 20db3e1a Phil Davis
		} else {
163 c7127a13 jim-p
			$ipaddr = get_interface_ip($if);
164 20db3e1a Phil Davis
		}
165 a5d5b1f7 sbeaver
166
		$cached_ip_s = explode("|", file_get_contents($filename));
167
		$cached_ip = $cached_ip_s[0];
168
169 20db3e1a Phil Davis
		if ($ipaddr != $cached_ip) {
170 9c9617a5 Jared Dillard
			print('<span class="text-danger">');
171 20db3e1a Phil Davis
		} else {
172 9c9617a5 Jared Dillard
			print('<span class="text-success">');
173 20db3e1a Phil Davis
		}
174 a5d5b1f7 sbeaver
175 67e58c2c Luiz Otavio O Souza
		print(htmlspecialchars($cached_ip));
176 9c9617a5 Jared Dillard
		print('</span>');
177 a5d5b1f7 sbeaver
	} else {
178
		print('IPv4: N/A');
179
	}
180
181
	print('<br />');
182
183
	if (file_exists("{$filename}.ipv6")) {
184
		print('IPv6: ');
185 c7127a13 jim-p
		$ipaddr = get_interface_ipv6($if);
186 a5d5b1f7 sbeaver
		$cached_ip_s = explode("|", file_get_contents("{$filename}.ipv6"));
187
		$cached_ip = $cached_ip_s[0];
188
189 20db3e1a Phil Davis
		if ($ipaddr != $cached_ip) {
190 9c9617a5 Jared Dillard
			print('<span class="text-danger">');
191 20db3e1a Phil Davis
		} else {
192 9c9617a5 Jared Dillard
			print('<span class="text-success">');
193 20db3e1a Phil Davis
		}
194 a5d5b1f7 sbeaver
195
		print(htmlspecialchars($cached_ip));
196 9c9617a5 Jared Dillard
		print('</span>');
197 a5d5b1f7 sbeaver
	} else {
198
		print('IPv6: N/A');
199
	}
200
201
?>
202 060ed238 Stephen Beaver
					</td>
203
					<td>
204
						<?=htmlspecialchars($rfc2136['descr'])?>
205
					</td>
206
					<td>
207
						<a class="fa fa-pencil" title="<?=gettext('Edit client')?>" href="services_rfc2136_edit.php?id=<?=$i?>"></a>
208
					<?php if (isset($rfc2136['enable'])) {
209
					?>
210
						<a	class="fa fa-ban" title="<?=gettext('Disable client')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
211
					<?php } else {
212
					?>
213
						<a class="fa fa-check-square-o" title="<?=gettext('Enable client')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
214
					<?php }
215
					?>
216
						<a class="fa fa-trash" title="<?=gettext('Delete client')?>" href="services_rfc2136.php?act=del&amp;id=<?=$i?>"></a>
217
					</td>
218
					</tr>
219 a5d5b1f7 sbeaver
<?php
220 060ed238 Stephen Beaver
	$i++;
221 a5d5b1f7 sbeaver
endforeach; ?>
222
223 060ed238 Stephen Beaver
					</tbody>
224
				</table>
225
			</div>
226
		</div>
227
	</div>
228 f1f60c92 Ermal Luçi
</form>
229 a5d5b1f7 sbeaver
230 c10cb196 Stephen Beaver
<nav class="action-buttons">
231 782922c2 Stephen Beaver
	<a href="services_rfc2136_edit.php" class="btn btn-sm btn-success btn-sm">
232 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
233 782922c2 Stephen Beaver
		<?=gettext('Add')?>
234
	</a>
235 a5d5b1f7 sbeaver
</nav>
236
237
<?php
238 c5d81fdf heper
include("foot.inc");