1
|
<?php
|
2
|
/*
|
3
|
* services_rfc2136.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8
|
* Copyright (c) 2014-2021 Rubicon Communications, LLC (Netgate)
|
9
|
* All rights reserved.
|
10
|
*
|
11
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
12
|
* you may not use this file except in compliance with the License.
|
13
|
* You may obtain a copy of the License at
|
14
|
*
|
15
|
* http://www.apache.org/licenses/LICENSE-2.0
|
16
|
*
|
17
|
* Unless required by applicable law or agreed to in writing, software
|
18
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
19
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
20
|
* See the License for the specific language governing permissions and
|
21
|
* limitations under the License.
|
22
|
*/
|
23
|
|
24
|
##|+PRIV
|
25
|
##|*IDENT=page-services-rfc2136clients
|
26
|
##|*NAME=Services: RFC 2136 Clients
|
27
|
##|*DESCR=Allow access to the 'Services: RFC 2136 Clients' page.
|
28
|
##|*MATCH=services_rfc2136.php*
|
29
|
##|-PRIV
|
30
|
|
31
|
require_once("guiconfig.inc");
|
32
|
|
33
|
init_config_arr(array('dnsupdates', 'dnsupdate'));
|
34
|
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
|
35
|
|
36
|
if ($_POST['act'] == "del") {
|
37
|
unset($a_rfc2136[$_POST['id']]);
|
38
|
|
39
|
write_config("RFC 2136 client deleted");
|
40
|
|
41
|
header("Location: services_rfc2136.php");
|
42
|
exit;
|
43
|
} else if ($_POST['act'] == "toggle") {
|
44
|
if ($a_rfc2136[$_POST['id']]) {
|
45
|
if (isset($a_rfc2136[$_POST['id']]['enable'])) {
|
46
|
unset($a_rfc2136[$_POST['id']]['enable']);
|
47
|
$action = "disabled";
|
48
|
} else {
|
49
|
$a_rfc2136[$_POST['id']]['enable'] = true;
|
50
|
$action = "enabled";
|
51
|
}
|
52
|
write_config("RFC 2136 {$action}");
|
53
|
|
54
|
header("Location: services_rfc2136.php");
|
55
|
exit;
|
56
|
}
|
57
|
}
|
58
|
|
59
|
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("RFC 2136 Clients"));
|
60
|
$pglinks = array("", "services_dyndns.php", "@self");
|
61
|
include("head.inc");
|
62
|
|
63
|
$tab_array = array();
|
64
|
$tab_array[] = array(gettext("Dynamic DNS Clients"), false, "services_dyndns.php");
|
65
|
$tab_array[] = array(gettext("RFC 2136 Clients"), true, "services_rfc2136.php");
|
66
|
$tab_array[] = array(gettext("Check IP Services"), false, "services_checkip.php");
|
67
|
display_top_tabs($tab_array);
|
68
|
|
69
|
if ($input_errors) {
|
70
|
print_input_errors($input_errors);
|
71
|
}
|
72
|
?>
|
73
|
|
74
|
<form action="services_rfc2136.php" method="post" name="iform" id="iform">
|
75
|
<div class="panel panel-default">
|
76
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('RFC2136 Clients')?></h2></div>
|
77
|
<div class="panel-body">
|
78
|
<div class="table-responsive">
|
79
|
<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
|
80
|
<thead>
|
81
|
<tr>
|
82
|
<th><?=gettext("Status")?></th>
|
83
|
<th><?=gettext("Interface")?></th>
|
84
|
<th><?=gettext("Server")?></th>
|
85
|
<th><?=gettext("Hostname")?></th>
|
86
|
<th><?=gettext("Cached IP")?></th>
|
87
|
<th><?=gettext("Description")?></th>
|
88
|
<th><?=gettext("Actions")?></th>
|
89
|
</tr>
|
90
|
</thead>
|
91
|
<tbody>
|
92
|
<?php
|
93
|
|
94
|
|
95
|
$iflist = get_configured_interface_with_descr();
|
96
|
$groupslist = return_gateway_groups_array();
|
97
|
|
98
|
$i = 0;
|
99
|
foreach ($a_rfc2136 as $rfc2136):
|
100
|
$filename = "{$g['conf_path']}/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}.cache";
|
101
|
$filename_v6 = "{$g['conf_path']}/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}_v6.cache";
|
102
|
$if = get_failover_interface($rfc2136['interface']);
|
103
|
|
104
|
if (file_exists($filename)) {
|
105
|
if (isset($rfc2136['usepublicip'])) {
|
106
|
$ipaddr = dyndnsCheckIP($if);
|
107
|
} else {
|
108
|
$ipaddr = get_interface_ip($if);
|
109
|
}
|
110
|
|
111
|
$cached_ip_s = explode("|", file_get_contents($filename));
|
112
|
$cached_ip = $cached_ip_s[0];
|
113
|
|
114
|
if ($ipaddr == $cached_ip) {
|
115
|
$icon_class = "fa fa-check-circle";
|
116
|
$text_class = "text-success";
|
117
|
$icon_title = "Updated";
|
118
|
} else {
|
119
|
$icon_class = "fa fa-times-circle";
|
120
|
$text_class = "text-danger";
|
121
|
$icon_title = "Failed";
|
122
|
}
|
123
|
} elseif (file_exists($filename_v6)) {
|
124
|
$ipv6addr = get_interface_ipv6($if);
|
125
|
$cached_ipv6_s = explode("|", file_get_contents($filename_v6));
|
126
|
$cached_ipv6 = $cached_ip_s[0];
|
127
|
|
128
|
if ($ipv6addr == $cached_ipv6) {
|
129
|
$icon_class = "fa fa-check-circle";
|
130
|
$text_class = "text-success";
|
131
|
$icon_title = "Updated";
|
132
|
} else {
|
133
|
$icon_class = "fa fa-times-circle";
|
134
|
$text_class = "text-danger";
|
135
|
$icon_title = "Failed";
|
136
|
}
|
137
|
}
|
138
|
?>
|
139
|
<tr<?=(isset($rfc2136['enable']) ? '' : ' class="disabled"')?>>
|
140
|
<td>
|
141
|
<i class="<?=$icon_class?> <?=$text_class?>" title="<?=$icon_title?>"></i>
|
142
|
</td>
|
143
|
<td>
|
144
|
<?php
|
145
|
foreach ($iflist as $if => $ifdesc) {
|
146
|
if ($rfc2136['interface'] == $if) {
|
147
|
print($ifdesc);
|
148
|
break;
|
149
|
}
|
150
|
}
|
151
|
foreach ($groupslist as $if => $group) {
|
152
|
if ($rfc2136['interface'] == $if) {
|
153
|
print($if);
|
154
|
break;
|
155
|
}
|
156
|
}
|
157
|
?>
|
158
|
</td>
|
159
|
<td>
|
160
|
<?=htmlspecialchars($rfc2136['server'])?>
|
161
|
</td>
|
162
|
<td>
|
163
|
<?=htmlspecialchars($rfc2136['host'])?>
|
164
|
</td>
|
165
|
<td>
|
166
|
<?php
|
167
|
if (file_exists($filename)) {
|
168
|
print('IPv4: ');
|
169
|
print("<span class='{$text_class}'>");
|
170
|
print(htmlspecialchars($cached_ip));
|
171
|
print('</span>');
|
172
|
} elseif (file_exists($filename_v6)) {
|
173
|
print("<span class='{$text_class}'>");
|
174
|
print(htmlspecialchars($cached_ipv6));
|
175
|
print('</span>');
|
176
|
} else {
|
177
|
print('IPv4: N/A');
|
178
|
}
|
179
|
|
180
|
print('<br />');
|
181
|
|
182
|
if (file_exists($filename_v6)) {
|
183
|
print('IPv6: ');
|
184
|
$ipaddr = get_interface_ipv6($if);
|
185
|
$cached_ip_s = explode("|", file_get_contents($filename_v6));
|
186
|
$cached_ip = $cached_ip_s[0];
|
187
|
|
188
|
if ($ipaddr != $cached_ip) {
|
189
|
print('<span class="text-danger">');
|
190
|
} else {
|
191
|
print('<span class="text-success">');
|
192
|
}
|
193
|
|
194
|
print(htmlspecialchars($cached_ip));
|
195
|
print('</span>');
|
196
|
} else {
|
197
|
print('IPv6: N/A');
|
198
|
}
|
199
|
|
200
|
?>
|
201
|
</td>
|
202
|
<td>
|
203
|
<?=htmlspecialchars($rfc2136['descr'])?>
|
204
|
</td>
|
205
|
<td>
|
206
|
<a class="fa fa-pencil" title="<?=gettext('Edit client')?>" href="services_rfc2136_edit.php?id=<?=$i?>"></a>
|
207
|
<?php if (isset($rfc2136['enable'])) {
|
208
|
?>
|
209
|
<a class="fa fa-ban" title="<?=gettext('Disable client')?>" href="?act=toggle&id=<?=$i?>" usepost></a>
|
210
|
<?php } else {
|
211
|
?>
|
212
|
<a class="fa fa-check-square-o" title="<?=gettext('Enable client')?>" href="?act=toggle&id=<?=$i?>" usepost></a>
|
213
|
<?php }
|
214
|
?>
|
215
|
<a class="fa fa-clone" title="<?=gettext('Copy client')?>" href="services_rfc2136_edit.php?dup=<?=$i?>"></a>
|
216
|
<a class="fa fa-trash" title="<?=gettext('Delete client')?>" href="services_rfc2136.php?act=del&id=<?=$i?>" usepost></a>
|
217
|
</td>
|
218
|
</tr>
|
219
|
<?php
|
220
|
$i++;
|
221
|
endforeach; ?>
|
222
|
|
223
|
</tbody>
|
224
|
</table>
|
225
|
</div>
|
226
|
</div>
|
227
|
</div>
|
228
|
</form>
|
229
|
|
230
|
<nav class="action-buttons">
|
231
|
<a href="services_rfc2136_edit.php" class="btn btn-sm btn-success btn-sm">
|
232
|
<i class="fa fa-plus icon-embed-btn"></i>
|
233
|
<?=gettext('Add')?>
|
234
|
</a>
|
235
|
</nav>
|
236
|
|
237
|
<div>
|
238
|
<?=sprintf(gettext('Entries with a %3$s status column icon and IP address appearing in %1$sgreen%2$s are up to date with Dynamic DNS provider. '), '<span class="text-success">', '</span>', '<i class="fa fa-check-circle text-success"></i>')?>
|
239
|
<?=gettext('An update can be forced on the edit page for an entry.')?>
|
240
|
</div>
|
241
|
|
242
|
<?php
|
243
|
include("foot.inc");
|