Project

General

Profile

Download (5.47 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-2019 Rubicon Communications, LLC (Netgate)
7
 * All rights reserved.
8
 *
9
 * 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
 *
13
 * http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * 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
 */
21

    
22
##|+PRIV
23
##|*IDENT=page-services-rfc2136clients
24
##|*NAME=Services: RFC 2136 Clients
25
##|*DESCR=Allow access to the 'Services: RFC 2136 Clients' page.
26
##|*MATCH=services_rfc2136.php*
27
##|-PRIV
28

    
29
require_once("guiconfig.inc");
30

    
31
init_config_arr(array('dnsupdates', 'dnsupdate'));
32
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
33

    
34
if ($_POST['act'] == "del") {
35
	unset($a_rfc2136[$_POST['id']]);
36

    
37
	write_config();
38

    
39
	header("Location: services_rfc2136.php");
40
	exit;
41
} 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
		} else {
46
			$a_rfc2136[$_POST['id']]['enable'] = true;
47
		}
48
		write_config();
49

    
50
		header("Location: services_rfc2136.php");
51
		exit;
52
	}
53
}
54

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

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

    
65
if ($input_errors) {
66
	print_input_errors($input_errors);
67
}
68
?>
69

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

    
89

    
90
$iflist = get_configured_interface_with_descr();
91
$groupslist = return_gateway_groups_array();
92

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

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

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

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

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

    
148
	print('<br />');
149

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

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

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

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

    
190
					</tbody>
191
				</table>
192
			</div>
193
		</div>
194
	</div>
195
</form>
196

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

    
204
<?php
205
include("foot.inc");
(144-144/235)