Project

General

Profile

Download (7.16 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
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions are met:
11
 *
12
 * 1. Redistributions of source code must retain the above copyright notice,
13
 *    this list of conditions and the following disclaimer.
14
 *
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice, this list of conditions and the following disclaimer in
17
 *    the documentation and/or other materials provided with the
18
 *    distribution.
19
 *
20
 * 3. All advertising materials mentioning features or use of this software
21
 *    must display the following acknowledgment:
22
 *    "This product includes software developed by the pfSense Project
23
 *    for use in the pfSense® software distribution. (http://www.pfsense.org/).
24
 *
25
 * 4. The names "pfSense" and "pfSense Project" must not be used to
26
 *    endorse or promote products derived from this software without
27
 *    prior written permission. For written permission, please contact
28
 *    coreteam@pfsense.org.
29
 *
30
 * 5. Products derived from this software may not be called "pfSense"
31
 *    nor may "pfSense" appear in their names without prior written
32
 *    permission of the Electric Sheep Fencing, LLC.
33
 *
34
 * 6. Redistributions of any form whatsoever must retain the following
35
 *    acknowledgment:
36
 *
37
 * "This product includes software developed by the pfSense Project
38
 * for use in the pfSense software distribution (http://www.pfsense.org/).
39
 *
40
 * THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
41
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
44
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51
 * OF THE POSSIBILITY OF SUCH DAMAGE.
52
 */
53

    
54
##|+PRIV
55
##|*IDENT=page-services-rfc2136clients
56
##|*NAME=Services: RFC 2136 Clients
57
##|*DESCR=Allow access to the 'Services: RFC 2136 Clients' page.
58
##|*MATCH=services_rfc2136.php*
59
##|-PRIV
60

    
61
require_once("guiconfig.inc");
62

    
63
if (!is_array($config['dnsupdates']['dnsupdate'])) {
64
	$config['dnsupdates']['dnsupdate'] = array();
65
}
66

    
67
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
68

    
69
if ($_GET['act'] == "del") {
70
	unset($a_rfc2136[$_GET['id']]);
71

    
72
	write_config();
73

    
74
	header("Location: services_rfc2136.php");
75
	exit;
76
} else if ($_GET['act'] == "toggle") {
77
	if ($a_rfc2136[$_GET['id']]) {
78
		if (isset($a_rfc2136[$_GET['id']]['enable'])) {
79
			unset($a_rfc2136[$_GET['id']]['enable']);
80
		} else {
81
			$a_rfc2136[$_GET['id']]['enable'] = true;
82
		}
83
		write_config();
84

    
85
		header("Location: services_rfc2136.php");
86
		exit;
87
	}
88
}
89

    
90
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("RFC 2136 Clients"));
91
$pglinks = array("", "services_dyndns.php", "@self");
92
include("head.inc");
93

    
94
$tab_array = array();
95
$tab_array[] = array(gettext("Dynamic DNS Clients"), false, "services_dyndns.php");
96
$tab_array[] = array(gettext("RFC 2136 Clients"), true, "services_rfc2136.php");
97
$tab_array[] = array(gettext("Check IP Services"), false, "services_checkip.php");
98
display_top_tabs($tab_array);
99

    
100
if ($input_errors) {
101
	print_input_errors($input_errors);
102
}
103
?>
104

    
105
<form action="services_rfc2136.php" method="post" name="iform" id="iform">
106
	<div class="panel panel-default">
107
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('RFC2136 Clients')?></h2></div>
108
		<div class="panel-body">
109
			<div class="table-responsive">
110
				<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
111
					<thead>
112
						<tr>
113
							<th><?=gettext("Interface")?></th>
114
							<th><?=gettext("Server")?></th>
115
							<th><?=gettext("Hostname")?></th>
116
							<th><?=gettext("Cached IP")?></th>
117
							<th><?=gettext("Description")?></th>
118
							<th><?=gettext("Actions")?></th>
119
						</tr>
120
					</thead>
121
					<tbody>
122
<?php
123

    
124

    
125
$iflist = get_configured_interface_with_descr();
126
$groupslist = return_gateway_groups_array();
127

    
128
$i = 0;
129
foreach ($a_rfc2136 as $rfc2136):
130
?>
131
						<tr<?=(isset($rfc2136['enable']) ? '' : ' class="disabled"')?>>
132
							<td>
133
<?php
134
	foreach ($iflist as $if => $ifdesc) {
135
		if ($rfc2136['interface'] == $if) {
136
			print($ifdesc);
137
			break;
138
		}
139
	}
140
	foreach ($groupslist as $if => $group) {
141
		if ($rfc2136['interface'] == $if) {
142
			print($if);
143
			break;
144
		}
145
	}
146
?>
147
							</td>
148
							<td>
149
								<?=htmlspecialchars($rfc2136['server'])?>
150
							</td>
151
							<td>
152
								<?=htmlspecialchars($rfc2136['host'])?>
153
							</td>
154
							<td>
155
<?php
156
	$filename = "{$g['conf_path']}/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}.cache";
157
	$filename_v6 = "{$g['conf_path']}/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}_v6.cache";
158
	$if = get_failover_interface($rfc2136['interface']);
159

    
160
	if (file_exists($filename)) {
161
		print('IPv4: ');
162
		if (isset($rfc2136['usepublicip'])) {
163
			$ipaddr = dyndnsCheckIP($if);
164
		} else {
165
			$ipaddr = get_interface_ip($if);
166
		}
167

    
168
		$cached_ip_s = explode("|", file_get_contents($filename));
169
		$cached_ip = $cached_ip_s[0];
170

    
171
		if ($ipaddr != $cached_ip) {
172
			print('<span class="text-danger">');
173
		} else {
174
			print('<span class="text-success">');
175
		}
176

    
177
		print(htmlspecialchars($cached_ip));
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?>"></a>
213
					<?php } else {
214
					?>
215
						<a class="fa fa-check-square-o" title="<?=gettext('Enable client')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
216
					<?php }
217
					?>
218
						<a class="fa fa-trash" title="<?=gettext('Delete client')?>" href="services_rfc2136.php?act=del&amp;id=<?=$i?>"></a>
219
					</td>
220
					</tr>
221
<?php
222
	$i++;
223
endforeach; ?>
224

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

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

    
239
<?php
240
include("foot.inc");
(136-136/225)