Project

General

Profile

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