Project

General

Profile

Download (5.56 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-2019 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();
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
		} else {
48
			$a_rfc2136[$_POST['id']]['enable'] = true;
49
		}
50
		write_config();
51

    
52
		header("Location: services_rfc2136.php");
53
		exit;
54
	}
55
}
56

    
57
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("RFC 2136 Clients"));
58
$pglinks = array("", "services_dyndns.php", "@self");
59
include("head.inc");
60

    
61
$tab_array = array();
62
$tab_array[] = array(gettext("Dynamic DNS Clients"), false, "services_dyndns.php");
63
$tab_array[] = array(gettext("RFC 2136 Clients"), true, "services_rfc2136.php");
64
$tab_array[] = array(gettext("Check IP Services"), false, "services_checkip.php");
65
display_top_tabs($tab_array);
66

    
67
if ($input_errors) {
68
	print_input_errors($input_errors);
69
}
70
?>
71

    
72
<form action="services_rfc2136.php" method="post" name="iform" id="iform">
73
	<div class="panel panel-default">
74
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('RFC2136 Clients')?></h2></div>
75
		<div class="panel-body">
76
			<div class="table-responsive">
77
				<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
78
					<thead>
79
						<tr>
80
							<th><?=gettext("Interface")?></th>
81
							<th><?=gettext("Server")?></th>
82
							<th><?=gettext("Hostname")?></th>
83
							<th><?=gettext("Cached IP")?></th>
84
							<th><?=gettext("Description")?></th>
85
							<th><?=gettext("Actions")?></th>
86
						</tr>
87
					</thead>
88
					<tbody>
89
<?php
90

    
91

    
92
$iflist = get_configured_interface_with_descr();
93
$groupslist = return_gateway_groups_array();
94

    
95
$i = 0;
96
foreach ($a_rfc2136 as $rfc2136):
97
?>
98
						<tr<?=(isset($rfc2136['enable']) ? '' : ' class="disabled"')?>>
99
							<td>
100
<?php
101
	foreach ($iflist as $if => $ifdesc) {
102
		if ($rfc2136['interface'] == $if) {
103
			print($ifdesc);
104
			break;
105
		}
106
	}
107
	foreach ($groupslist as $if => $group) {
108
		if ($rfc2136['interface'] == $if) {
109
			print($if);
110
			break;
111
		}
112
	}
113
?>
114
							</td>
115
							<td>
116
								<?=htmlspecialchars($rfc2136['server'])?>
117
							</td>
118
							<td>
119
								<?=htmlspecialchars($rfc2136['host'])?>
120
							</td>
121
							<td>
122
<?php
123
	$filename = "{$g['conf_path']}/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}.cache";
124
	$filename_v6 = "{$g['conf_path']}/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}_v6.cache";
125
	$if = get_failover_interface($rfc2136['interface']);
126

    
127
	if (file_exists($filename)) {
128
		print('IPv4: ');
129
		if (isset($rfc2136['usepublicip'])) {
130
			$ipaddr = dyndnsCheckIP($if);
131
		} else {
132
			$ipaddr = get_interface_ip($if);
133
		}
134

    
135
		$cached_ip_s = explode("|", file_get_contents($filename));
136
		$cached_ip = $cached_ip_s[0];
137

    
138
		if ($ipaddr != $cached_ip) {
139
			print('<span class="text-danger">');
140
		} else {
141
			print('<span class="text-success">');
142
		}
143

    
144
		print(htmlspecialchars($cached_ip));
145
		print('</span>');
146
	} else {
147
		print('IPv4: N/A');
148
	}
149

    
150
	print('<br />');
151

    
152
	if (file_exists($filename_v6)) {
153
		print('IPv6: ');
154
		$ipaddr = get_interface_ipv6($if);
155
		$cached_ip_s = explode("|", file_get_contents($filename_v6));
156
		$cached_ip = $cached_ip_s[0];
157

    
158
		if ($ipaddr != $cached_ip) {
159
			print('<span class="text-danger">');
160
		} else {
161
			print('<span class="text-success">');
162
		}
163

    
164
		print(htmlspecialchars($cached_ip));
165
		print('</span>');
166
	} else {
167
		print('IPv6: N/A');
168
	}
169

    
170
?>
171
					</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?>" usepost></a>
180
					<?php } else {
181
					?>
182
						<a class="fa fa-check-square-o" title="<?=gettext('Enable client')?>" href="?act=toggle&amp;id=<?=$i?>" usepost></a>
183
					<?php }
184
					?>
185
						<a class="fa fa-trash" title="<?=gettext('Delete client')?>" href="services_rfc2136.php?act=del&amp;id=<?=$i?>" usepost></a>
186
					</td>
187
					</tr>
188
<?php
189
	$i++;
190
endforeach; ?>
191

    
192
					</tbody>
193
				</table>
194
			</div>
195
		</div>
196
	</div>
197
</form>
198

    
199
<nav class="action-buttons">
200
	<a href="services_rfc2136_edit.php" class="btn btn-sm btn-success btn-sm">
201
		<i class="fa fa-plus icon-embed-btn"></i>
202
		<?=gettext('Add')?>
203
	</a>
204
</nav>
205

    
206
<?php
207
include("foot.inc");
(137-137/227)