Project

General

Profile

Download (5.52 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-2016 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
if (!is_array($config['dnsupdates']['dnsupdate'])) {
32
	$config['dnsupdates']['dnsupdate'] = array();
33
}
34

    
35
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
36

    
37
if ($_POST['act'] == "del") {
38
	unset($a_rfc2136[$_POST['id']]);
39

    
40
	write_config();
41

    
42
	header("Location: services_rfc2136.php");
43
	exit;
44
} else if ($_POST['act'] == "toggle") {
45
	if ($a_rfc2136[$_POST['id']]) {
46
		if (isset($a_rfc2136[$_POST['id']]['enable'])) {
47
			unset($a_rfc2136[$_POST['id']]['enable']);
48
		} else {
49
			$a_rfc2136[$_POST['id']]['enable'] = true;
50
		}
51
		write_config();
52

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

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

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

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

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

    
92

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

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

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

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

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

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

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

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

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

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

    
171
?>
172
					</td>
173
					<td>
174
						<?=htmlspecialchars($rfc2136['descr'])?>
175
					</td>
176
					<td>
177
						<a class="fa fa-pencil" title="<?=gettext('Edit client')?>" href="services_rfc2136_edit.php?id=<?=$i?>"></a>
178
					<?php if (isset($rfc2136['enable'])) {
179
					?>
180
						<a	class="fa fa-ban" title="<?=gettext('Disable client')?>" href="?act=toggle&amp;id=<?=$i?>" usepost></a>
181
					<?php } else {
182
					?>
183
						<a class="fa fa-check-square-o" title="<?=gettext('Enable client')?>" href="?act=toggle&amp;id=<?=$i?>" usepost></a>
184
					<?php }
185
					?>
186
						<a class="fa fa-trash" title="<?=gettext('Delete client')?>" href="services_rfc2136.php?act=del&amp;id=<?=$i?>" usepost></a>
187
					</td>
188
					</tr>
189
<?php
190
	$i++;
191
endforeach; ?>
192

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

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

    
207
<?php
208
include("foot.inc");
(139-139/228)