Project

General

Profile

Download (7.03 KB) Statistics
| Branch: | Tag: | Revision:
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-2023 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
	if (!is_array($rfc2136) || empty($rfc2136)) {
101
		continue;
102
	}
103
	$filename = "{$g['conf_path']}/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}.cache";
104
	$filename_v6 = "{$g['conf_path']}/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}_v6.cache";
105
	$if = get_failover_interface($rfc2136['interface']);
106

    
107
	if (file_exists($filename)) {
108
		if (isset($rfc2136['usepublicip'])) {
109
			$ipaddr = dyndnsCheckIP($if);
110
		} else {
111
			$ipaddr = get_interface_ip($if);
112
		}
113

    
114
		$cached_ip_s = explode("|", file_get_contents($filename));
115
		$cached_ip = $cached_ip_s[0];
116

    
117
		if ($ipaddr == $cached_ip) {
118
			$icon_class = "fa fa-check-circle";
119
			$text_class = "text-success";
120
			$icon_title = "Updated";
121
		} else {
122
			$icon_class = "fa fa-times-circle";
123
			$text_class = "text-danger";
124
			$icon_title = "Failed";
125
		}
126
	} elseif (file_exists($filename_v6)) {
127
		$ipv6addr = get_interface_ipv6($if);
128
		$cached_ipv6_s = explode("|", file_get_contents($filename_v6));
129
		$cached_ipv6 = $cached_ip_s[0];
130

    
131
		if ($ipv6addr == $cached_ipv6) {
132
			$icon_class = "fa fa-check-circle";
133
			$text_class = "text-success";
134
			$icon_title = "Updated";
135
		} else {
136
			$icon_class = "fa fa-times-circle";
137
			$text_class = "text-danger";
138
			$icon_title = "Failed";
139
		}
140
	}
141
?>
142
						<tr<?=(isset($rfc2136['enable']) ? '' : ' class="disabled"')?>>
143
							<td>
144
							<i class="<?=$icon_class?> <?=$text_class?>" title="<?=$icon_title?>"></i>
145
							</td>
146
							<td>
147
<?php
148
	foreach ($iflist as $if => $ifdesc) {
149
		if ($rfc2136['interface'] == $if) {
150
			print($ifdesc);
151
			break;
152
		}
153
	}
154
	foreach ($groupslist as $if => $group) {
155
		if ($rfc2136['interface'] == $if) {
156
			print($if);
157
			break;
158
		}
159
	}
160
?>
161
							</td>
162
							<td>
163
								<?=htmlspecialchars($rfc2136['server'])?>
164
							</td>
165
							<td>
166
								<?=htmlspecialchars($rfc2136['host'])?>
167
							</td>
168
							<td>
169
<?php
170
	if (file_exists($filename)) {
171
		print('IPv4: ');
172
		print("<span class='{$text_class}'>");
173
		print(htmlspecialchars($cached_ip));
174
		print('</span>');
175
	} elseif (file_exists($filename_v6)) {
176
		print("<span class='{$text_class}'>");
177
		print(htmlspecialchars($cached_ipv6));
178
		print('</span>');
179
	} else {
180
		print('IPv4: N/A');
181
	}
182

    
183
	print('<br />');
184

    
185
	if (file_exists($filename_v6)) {
186
		print('IPv6: ');
187
		$ipaddr = get_interface_ipv6($if);
188
		$cached_ip_s = explode("|", file_get_contents($filename_v6));
189
		$cached_ip = $cached_ip_s[0];
190

    
191
		if ($ipaddr != $cached_ip) {
192
			print('<span class="text-danger">');
193
		} else {
194
			print('<span class="text-success">');
195
		}
196

    
197
		print(htmlspecialchars($cached_ip));
198
		print('</span>');
199
	} else {
200
		print('IPv6: N/A');
201
	}
202

    
203
?>
204
					</td>
205
					<td>
206
						<?=htmlspecialchars($rfc2136['descr'])?>
207
					</td>
208
					<td>
209
						<a class="fa fa-pencil" title="<?=gettext('Edit client')?>" href="services_rfc2136_edit.php?id=<?=$i?>"></a>
210
					<?php if (isset($rfc2136['enable'])) {
211
					?>
212
						<a	class="fa fa-ban" title="<?=gettext('Disable client')?>" href="?act=toggle&amp;id=<?=$i?>" usepost></a>
213
					<?php } else {
214
					?>
215
						<a class="fa fa-check-square-o" title="<?=gettext('Enable client')?>" href="?act=toggle&amp;id=<?=$i?>" usepost></a>
216
					<?php }
217
					?>
218
						<a class="fa fa-clone" title="<?=gettext('Copy client')?>" href="services_rfc2136_edit.php?dup=<?=$i?>"></a>
219
						<a class="fa fa-trash" title="<?=gettext('Delete client')?>" href="services_rfc2136.php?act=del&amp;id=<?=$i?>" usepost></a>
220
					</td>
221
					</tr>
222
<?php
223
	$i++;
224
endforeach; ?>
225

    
226
					</tbody>
227
				</table>
228
			</div>
229
		</div>
230
	</div>
231
</form>
232

    
233
<nav class="action-buttons">
234
	<a href="services_rfc2136_edit.php" class="btn btn-sm btn-success btn-sm">
235
		<i class="fa fa-plus icon-embed-btn"></i>
236
		<?=gettext('Add')?>
237
	</a>
238
</nav>
239

    
240
<div>
241
	<?=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>')?>
242
	<?=gettext('An update can be forced on the edit page for an entry.')?>
243
</div>
244

    
245
<?php
246
include("foot.inc");
(137-137/228)