Project

General

Profile

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