Project

General

Profile

Download (5.36 KB) Statistics
| Branch: | Tag: | Revision:
1 f1f60c92 Ermal Luçi
<?php
2
/*
3 c5d81585 Renato Botelho
 * services_rfc2136.php
4 33f0b0d5 Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 81299b5c Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 c5d81585 Renato Botelho
 * All rights reserved.
8 33f0b0d5 Stephen Beaver
 *
9 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12 33f0b0d5 Stephen Beaver
 *
13 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
14 33f0b0d5 Stephen Beaver
 *
15 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20 33f0b0d5 Stephen Beaver
 */
21 f1f60c92 Ermal Luçi
22 6b07c15a Matthew Grooms
##|+PRIV
23
##|*IDENT=page-services-rfc2136clients
24 5230f468 jim-p
##|*NAME=Services: RFC 2136 Clients
25 a57d9fa2 jim-p
##|*DESCR=Allow access to the 'Services: RFC 2136 Clients' page.
26 6b07c15a Matthew Grooms
##|*MATCH=services_rfc2136.php*
27
##|-PRIV
28
29 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
30 f1f60c92 Ermal Luçi
31 efdf8358 Phil Davis
if (!is_array($config['dnsupdates']['dnsupdate'])) {
32 f1f60c92 Ermal Luçi
	$config['dnsupdates']['dnsupdate'] = array();
33 efdf8358 Phil Davis
}
34 f1f60c92 Ermal Luçi
35
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
36
37
if ($_GET['act'] == "del") {
38 e766bd84 bcyrill
	unset($a_rfc2136[$_GET['id']]);
39 f1f60c92 Ermal Luçi
40 e766bd84 bcyrill
	write_config();
41 f1f60c92 Ermal Luçi
42 e766bd84 bcyrill
	header("Location: services_rfc2136.php");
43
	exit;
44 20db3e1a Phil Davis
} else if ($_GET['act'] == "toggle") {
45 c5d81fdf heper
	if ($a_rfc2136[$_GET['id']]) {
46
		if (isset($a_rfc2136[$_GET['id']]['enable'])) {
47
			unset($a_rfc2136[$_GET['id']]['enable']);
48
		} else {
49
			$a_rfc2136[$_GET['id']]['enable'] = true;
50
		}
51
		write_config();
52 919d91f9 Phil Davis
53 c5d81fdf heper
		header("Location: services_rfc2136.php");
54
		exit;
55
	}
56
}
57 f1f60c92 Ermal Luçi
58 bf40071d Phil Davis
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("RFC 2136 Clients"));
59 edcd7535 Phil Davis
$pglinks = array("", "services_dyndns.php", "@self");
60 f1f60c92 Ermal Luçi
include("head.inc");
61 a5d5b1f7 sbeaver
62
$tab_array = array();
63 c8f6b745 k-paulius
$tab_array[] = array(gettext("Dynamic DNS Clients"), false, "services_dyndns.php");
64
$tab_array[] = array(gettext("RFC 2136 Clients"), true, "services_rfc2136.php");
65 39d2f39d NOYB
$tab_array[] = array(gettext("Check IP Services"), false, "services_checkip.php");
66 a5d5b1f7 sbeaver
display_top_tabs($tab_array);
67
68 20db3e1a Phil Davis
if ($input_errors) {
69 060ed238 Stephen Beaver
	print_input_errors($input_errors);
70 20db3e1a Phil Davis
}
71 f1f60c92 Ermal Luçi
?>
72
73
<form action="services_rfc2136.php" method="post" name="iform" id="iform">
74 060ed238 Stephen Beaver
	<div class="panel panel-default">
75 f0efd690 Phil Davis
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('RFC2136 Clients')?></h2></div>
76 060ed238 Stephen Beaver
		<div class="panel-body">
77
			<div class="table-responsive">
78 1c10ce97 PiBa-NL
				<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
79 060ed238 Stephen Beaver
					<thead>
80
						<tr>
81 f0efd690 Phil Davis
							<th><?=gettext("Interface")?></th>
82 060ed238 Stephen Beaver
							<th><?=gettext("Server")?></th>
83
							<th><?=gettext("Hostname")?></th>
84
							<th><?=gettext("Cached IP")?></th>
85
							<th><?=gettext("Description")?></th>
86 f0efd690 Phil Davis
							<th><?=gettext("Actions")?></th>
87 060ed238 Stephen Beaver
						</tr>
88
					</thead>
89
					<tbody>
90 f1f60c92 Ermal Luçi
<?php
91 30a40ca8 sbeaver
92
93
$iflist = get_configured_interface_with_descr();
94 c7127a13 jim-p
$groupslist = return_gateway_groups_array();
95 30a40ca8 sbeaver
96 a5d5b1f7 sbeaver
$i = 0;
97
foreach ($a_rfc2136 as $rfc2136):
98 f1f60c92 Ermal Luçi
?>
99 060ed238 Stephen Beaver
						<tr<?=(isset($rfc2136['enable']) ? '' : ' class="disabled"')?>>
100
							<td>
101 a5d5b1f7 sbeaver
<?php
102
	foreach ($iflist as $if => $ifdesc) {
103 060ed238 Stephen Beaver
		if ($rfc2136['interface'] == $if) {
104
			print($ifdesc);
105 a5d5b1f7 sbeaver
			break;
106 060ed238 Stephen Beaver
		}
107 a5d5b1f7 sbeaver
	}
108 c7127a13 jim-p
	foreach ($groupslist as $if => $group) {
109
		if ($rfc2136['interface'] == $if) {
110
			print($if);
111
			break;
112
		}
113
	}
114 a5d5b1f7 sbeaver
?>
115 060ed238 Stephen Beaver
							</td>
116
							<td>
117
								<?=htmlspecialchars($rfc2136['server'])?>
118
							</td>
119
							<td>
120
								<?=htmlspecialchars($rfc2136['host'])?>
121
							</td>
122
							<td>
123 a5d5b1f7 sbeaver
<?php
124
	$filename = "{$g['conf_path']}/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}.cache";
125 c7127a13 jim-p
	$if = get_failover_interface($rfc2136['interface']);
126 a5d5b1f7 sbeaver
127
	if (file_exists($filename)) {
128
		print('IPv4: ');
129 20db3e1a Phil Davis
		if (isset($rfc2136['usepublicip'])) {
130 c7127a13 jim-p
			$ipaddr = dyndnsCheckIP($if);
131 20db3e1a Phil Davis
		} else {
132 c7127a13 jim-p
			$ipaddr = get_interface_ip($if);
133 20db3e1a Phil Davis
		}
134 a5d5b1f7 sbeaver
135
		$cached_ip_s = explode("|", file_get_contents($filename));
136
		$cached_ip = $cached_ip_s[0];
137
138 20db3e1a Phil Davis
		if ($ipaddr != $cached_ip) {
139 9c9617a5 Jared Dillard
			print('<span class="text-danger">');
140 20db3e1a Phil Davis
		} else {
141 9c9617a5 Jared Dillard
			print('<span class="text-success">');
142 20db3e1a Phil Davis
		}
143 a5d5b1f7 sbeaver
144 67e58c2c Luiz Otavio O Souza
		print(htmlspecialchars($cached_ip));
145 9c9617a5 Jared Dillard
		print('</span>');
146 a5d5b1f7 sbeaver
	} else {
147
		print('IPv4: N/A');
148
	}
149
150
	print('<br />');
151
152
	if (file_exists("{$filename}.ipv6")) {
153
		print('IPv6: ');
154 c7127a13 jim-p
		$ipaddr = get_interface_ipv6($if);
155 a5d5b1f7 sbeaver
		$cached_ip_s = explode("|", file_get_contents("{$filename}.ipv6"));
156
		$cached_ip = $cached_ip_s[0];
157
158 20db3e1a Phil Davis
		if ($ipaddr != $cached_ip) {
159 9c9617a5 Jared Dillard
			print('<span class="text-danger">');
160 20db3e1a Phil Davis
		} else {
161 9c9617a5 Jared Dillard
			print('<span class="text-success">');
162 20db3e1a Phil Davis
		}
163 a5d5b1f7 sbeaver
164
		print(htmlspecialchars($cached_ip));
165 9c9617a5 Jared Dillard
		print('</span>');
166 a5d5b1f7 sbeaver
	} else {
167
		print('IPv6: N/A');
168
	}
169
170
?>
171 060ed238 Stephen Beaver
					</td>
172
					<td>
173
						<?=htmlspecialchars($rfc2136['descr'])?>
174
					</td>
175
					<td>
176
						<a class="fa fa-pencil" title="<?=gettext('Edit client')?>" href="services_rfc2136_edit.php?id=<?=$i?>"></a>
177
					<?php if (isset($rfc2136['enable'])) {
178
					?>
179
						<a	class="fa fa-ban" title="<?=gettext('Disable client')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
180
					<?php } else {
181
					?>
182
						<a class="fa fa-check-square-o" title="<?=gettext('Enable client')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
183
					<?php }
184
					?>
185
						<a class="fa fa-trash" title="<?=gettext('Delete client')?>" href="services_rfc2136.php?act=del&amp;id=<?=$i?>"></a>
186
					</td>
187
					</tr>
188 a5d5b1f7 sbeaver
<?php
189 060ed238 Stephen Beaver
	$i++;
190 a5d5b1f7 sbeaver
endforeach; ?>
191
192 060ed238 Stephen Beaver
					</tbody>
193
				</table>
194
			</div>
195
		</div>
196
	</div>
197 f1f60c92 Ermal Luçi
</form>
198 a5d5b1f7 sbeaver
199 c10cb196 Stephen Beaver
<nav class="action-buttons">
200 782922c2 Stephen Beaver
	<a href="services_rfc2136_edit.php" class="btn btn-sm btn-success btn-sm">
201 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
202 782922c2 Stephen Beaver
		<?=gettext('Add')?>
203
	</a>
204 a5d5b1f7 sbeaver
</nav>
205
206
<?php
207 c5d81fdf heper
include("foot.inc");