Project

General

Profile

Download (5.47 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 4a762cf0 Steve Beaver
 * Copyright (c) 2004-2019 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 ea0dd417 jim-p
init_config_arr(array('dnsupdates', 'dnsupdate'));
32 f1f60c92 Ermal Luçi
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
33
34 13541a81 Steve Beaver
if ($_POST['act'] == "del") {
35
	unset($a_rfc2136[$_POST['id']]);
36 f1f60c92 Ermal Luçi
37 e766bd84 bcyrill
	write_config();
38 f1f60c92 Ermal Luçi
39 e766bd84 bcyrill
	header("Location: services_rfc2136.php");
40
	exit;
41 13541a81 Steve Beaver
} else if ($_POST['act'] == "toggle") {
42
	if ($a_rfc2136[$_POST['id']]) {
43
		if (isset($a_rfc2136[$_POST['id']]['enable'])) {
44
			unset($a_rfc2136[$_POST['id']]['enable']);
45 c5d81fdf heper
		} else {
46 13541a81 Steve Beaver
			$a_rfc2136[$_POST['id']]['enable'] = true;
47 c5d81fdf heper
		}
48
		write_config();
49 919d91f9 Phil Davis
50 c5d81fdf heper
		header("Location: services_rfc2136.php");
51
		exit;
52
	}
53
}
54 f1f60c92 Ermal Luçi
55 bf40071d Phil Davis
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("RFC 2136 Clients"));
56 edcd7535 Phil Davis
$pglinks = array("", "services_dyndns.php", "@self");
57 f1f60c92 Ermal Luçi
include("head.inc");
58 a5d5b1f7 sbeaver
59
$tab_array = array();
60 c8f6b745 k-paulius
$tab_array[] = array(gettext("Dynamic DNS Clients"), false, "services_dyndns.php");
61
$tab_array[] = array(gettext("RFC 2136 Clients"), true, "services_rfc2136.php");
62 39d2f39d NOYB
$tab_array[] = array(gettext("Check IP Services"), false, "services_checkip.php");
63 a5d5b1f7 sbeaver
display_top_tabs($tab_array);
64
65 20db3e1a Phil Davis
if ($input_errors) {
66 060ed238 Stephen Beaver
	print_input_errors($input_errors);
67 20db3e1a Phil Davis
}
68 f1f60c92 Ermal Luçi
?>
69
70
<form action="services_rfc2136.php" method="post" name="iform" id="iform">
71 060ed238 Stephen Beaver
	<div class="panel panel-default">
72 f0efd690 Phil Davis
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('RFC2136 Clients')?></h2></div>
73 060ed238 Stephen Beaver
		<div class="panel-body">
74
			<div class="table-responsive">
75 1c10ce97 PiBa-NL
				<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
76 060ed238 Stephen Beaver
					<thead>
77
						<tr>
78 f0efd690 Phil Davis
							<th><?=gettext("Interface")?></th>
79 060ed238 Stephen Beaver
							<th><?=gettext("Server")?></th>
80
							<th><?=gettext("Hostname")?></th>
81
							<th><?=gettext("Cached IP")?></th>
82
							<th><?=gettext("Description")?></th>
83 f0efd690 Phil Davis
							<th><?=gettext("Actions")?></th>
84 060ed238 Stephen Beaver
						</tr>
85
					</thead>
86
					<tbody>
87 f1f60c92 Ermal Luçi
<?php
88 30a40ca8 sbeaver
89
90
$iflist = get_configured_interface_with_descr();
91 c7127a13 jim-p
$groupslist = return_gateway_groups_array();
92 30a40ca8 sbeaver
93 a5d5b1f7 sbeaver
$i = 0;
94
foreach ($a_rfc2136 as $rfc2136):
95 f1f60c92 Ermal Luçi
?>
96 060ed238 Stephen Beaver
						<tr<?=(isset($rfc2136['enable']) ? '' : ' class="disabled"')?>>
97
							<td>
98 a5d5b1f7 sbeaver
<?php
99
	foreach ($iflist as $if => $ifdesc) {
100 060ed238 Stephen Beaver
		if ($rfc2136['interface'] == $if) {
101
			print($ifdesc);
102 a5d5b1f7 sbeaver
			break;
103 060ed238 Stephen Beaver
		}
104 a5d5b1f7 sbeaver
	}
105 c7127a13 jim-p
	foreach ($groupslist as $if => $group) {
106
		if ($rfc2136['interface'] == $if) {
107
			print($if);
108
			break;
109
		}
110
	}
111 a5d5b1f7 sbeaver
?>
112 060ed238 Stephen Beaver
							</td>
113
							<td>
114
								<?=htmlspecialchars($rfc2136['server'])?>
115
							</td>
116
							<td>
117
								<?=htmlspecialchars($rfc2136['host'])?>
118
							</td>
119
							<td>
120 a5d5b1f7 sbeaver
<?php
121
	$filename = "{$g['conf_path']}/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}.cache";
122 474def89 Renato Botelho
	$filename_v6 = "{$g['conf_path']}/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}_v6.cache";
123 c7127a13 jim-p
	$if = get_failover_interface($rfc2136['interface']);
124 a5d5b1f7 sbeaver
125
	if (file_exists($filename)) {
126
		print('IPv4: ');
127 20db3e1a Phil Davis
		if (isset($rfc2136['usepublicip'])) {
128 c7127a13 jim-p
			$ipaddr = dyndnsCheckIP($if);
129 20db3e1a Phil Davis
		} else {
130 c7127a13 jim-p
			$ipaddr = get_interface_ip($if);
131 20db3e1a Phil Davis
		}
132 a5d5b1f7 sbeaver
133
		$cached_ip_s = explode("|", file_get_contents($filename));
134
		$cached_ip = $cached_ip_s[0];
135
136 20db3e1a Phil Davis
		if ($ipaddr != $cached_ip) {
137 9c9617a5 Jared Dillard
			print('<span class="text-danger">');
138 20db3e1a Phil Davis
		} else {
139 9c9617a5 Jared Dillard
			print('<span class="text-success">');
140 20db3e1a Phil Davis
		}
141 a5d5b1f7 sbeaver
142 67e58c2c Luiz Otavio O Souza
		print(htmlspecialchars($cached_ip));
143 9c9617a5 Jared Dillard
		print('</span>');
144 a5d5b1f7 sbeaver
	} else {
145
		print('IPv4: N/A');
146
	}
147
148
	print('<br />');
149
150 474def89 Renato Botelho
	if (file_exists($filename_v6)) {
151 a5d5b1f7 sbeaver
		print('IPv6: ');
152 c7127a13 jim-p
		$ipaddr = get_interface_ipv6($if);
153 474def89 Renato Botelho
		$cached_ip_s = explode("|", file_get_contents($filename_v6));
154 a5d5b1f7 sbeaver
		$cached_ip = $cached_ip_s[0];
155
156 20db3e1a Phil Davis
		if ($ipaddr != $cached_ip) {
157 9c9617a5 Jared Dillard
			print('<span class="text-danger">');
158 20db3e1a Phil Davis
		} else {
159 9c9617a5 Jared Dillard
			print('<span class="text-success">');
160 20db3e1a Phil Davis
		}
161 a5d5b1f7 sbeaver
162
		print(htmlspecialchars($cached_ip));
163 9c9617a5 Jared Dillard
		print('</span>');
164 a5d5b1f7 sbeaver
	} else {
165
		print('IPv6: N/A');
166
	}
167
168
?>
169 060ed238 Stephen Beaver
					</td>
170
					<td>
171
						<?=htmlspecialchars($rfc2136['descr'])?>
172
					</td>
173
					<td>
174
						<a class="fa fa-pencil" title="<?=gettext('Edit client')?>" href="services_rfc2136_edit.php?id=<?=$i?>"></a>
175
					<?php if (isset($rfc2136['enable'])) {
176
					?>
177 13541a81 Steve Beaver
						<a	class="fa fa-ban" title="<?=gettext('Disable client')?>" href="?act=toggle&amp;id=<?=$i?>" usepost></a>
178 060ed238 Stephen Beaver
					<?php } else {
179
					?>
180 13541a81 Steve Beaver
						<a class="fa fa-check-square-o" title="<?=gettext('Enable client')?>" href="?act=toggle&amp;id=<?=$i?>" usepost></a>
181 060ed238 Stephen Beaver
					<?php }
182
					?>
183 13541a81 Steve Beaver
						<a class="fa fa-trash" title="<?=gettext('Delete client')?>" href="services_rfc2136.php?act=del&amp;id=<?=$i?>" usepost></a>
184 060ed238 Stephen Beaver
					</td>
185
					</tr>
186 a5d5b1f7 sbeaver
<?php
187 060ed238 Stephen Beaver
	$i++;
188 a5d5b1f7 sbeaver
endforeach; ?>
189
190 060ed238 Stephen Beaver
					</tbody>
191
				</table>
192
			</div>
193
		</div>
194
	</div>
195 f1f60c92 Ermal Luçi
</form>
196 a5d5b1f7 sbeaver
197 c10cb196 Stephen Beaver
<nav class="action-buttons">
198 782922c2 Stephen Beaver
	<a href="services_rfc2136_edit.php" class="btn btn-sm btn-success btn-sm">
199 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
200 782922c2 Stephen Beaver
		<?=gettext('Add')?>
201
	</a>
202 a5d5b1f7 sbeaver
</nav>
203
204
<?php
205 c5d81fdf heper
include("foot.inc");