Project

General

Profile

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

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

    
63
require("guiconfig.inc");
64

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

    
69
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
70

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

    
74
	write_config();
75

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

    
87
		header("Location: services_rfc2136.php");
88
		exit;
89
	}
90
}
91

    
92
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("RFC 2136 Clients"));
93
include("head.inc");
94

    
95
$tab_array = array();
96
$tab_array[] = array(gettext("Dynamic DNS"), false, "services_dyndns.php");
97
$tab_array[] = array(gettext("RFC 2136"), true, "services_rfc2136.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">
111
					<thead>
112
						<tr>
113
							<th><?=gettext("IF")?></th>
114
							<th><?=gettext("Server")?></th>
115
							<th><?=gettext("Hostname")?></th>
116
							<th><?=gettext("Cached IP")?></th>
117
							<th><?=gettext("Description")?></th>
118
							<th></th>
119
						</tr>
120
					</thead>
121
					<tbody>
122
<?php
123

    
124

    
125
$iflist = get_configured_interface_with_descr();
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
?>
140
							</td>
141
							<td>
142
								<?=htmlspecialchars($rfc2136['server'])?>
143
							</td>
144
							<td>
145
								<?=htmlspecialchars($rfc2136['host'])?>
146
							</td>
147
							<td>
148
<?php
149
	$filename = "{$g['conf_path']}/dyndns_{$rfc2136['interface']}_rfc2136_" . escapeshellarg($rfc2136['host']) . "_{$rfc2136['server']}.cache";
150

    
151
	if (file_exists($filename)) {
152
		print('IPv4: ');
153
		if (isset($rfc2136['usepublicip'])) {
154
			$ipaddr = dyndnsCheckIP($rfc2136['interface']);
155
		} else {
156
			$ipaddr = get_interface_ip($rfc2136['interface']);
157
		}
158

    
159
		$cached_ip_s = explode("|", file_get_contents($filename));
160
		$cached_ip = $cached_ip_s[0];
161

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

    
168
		print(htmlspecialchars($cached_ip));
169
		print('</span>');
170
	} else {
171
		print('IPv4: N/A');
172
	}
173

    
174
	print('<br />');
175

    
176
	if (file_exists("{$filename}.ipv6")) {
177
		print('IPv6: ');
178
		$ipaddr = get_interface_ipv6($rfc2136['interface']);
179
		$cached_ip_s = explode("|", file_get_contents("{$filename}.ipv6"));
180
		$cached_ip = $cached_ip_s[0];
181

    
182
		if ($ipaddr != $cached_ip) {
183
			print('<span class="text-danger">');
184
		} else {
185
			print('<span class="text-success">');
186
		}
187

    
188
		print(htmlspecialchars($cached_ip));
189
		print('</span>');
190
	} else {
191
		print('IPv6: N/A');
192
	}
193

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

    
216
					</tbody>
217
				</table>
218
			</div>
219
		</div>
220
	</div>
221
</form>
222

    
223
<nav class="action-buttons">
224
	<a href="services_rfc2136_edit.php" class="btn btn-sm btn-success btn-sm">
225
		<i class="fa fa-plus icon-embed-btn"></i>
226
		<?=gettext('Add')?>
227
	</a>
228
</nav>
229

    
230
<?php
231
include("foot.inc");
(136-136/229)