Project

General

Profile

Download (6.96 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 Electric Sheep Fencing, LLC
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
include("head.inc");
92

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

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

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

    
123

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

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

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

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

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

    
175
		print(htmlspecialchars($cached_ip));
176
		print('</span>');
177
	} else {
178
		print('IPv4: N/A');
179
	}
180

    
181
	print('<br />');
182

    
183
	if (file_exists("{$filename}.ipv6")) {
184
		print('IPv6: ');
185
		$ipaddr = get_interface_ipv6($if);
186
		$cached_ip_s = explode("|", file_get_contents("{$filename}.ipv6"));
187
		$cached_ip = $cached_ip_s[0];
188

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

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

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

    
223
					</tbody>
224
				</table>
225
			</div>
226
		</div>
227
	</div>
228
</form>
229

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

    
237
<?php
238
include("foot.inc");
(138-138/227)