Project

General

Profile

Download (6.63 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	services_rfc2136.php
5
*/
6
/* ====================================================================
7
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
8
 *
9
 *	Redistribution and use in source and binary forms, with or without modification,
10
 *	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
 *
55
 */
56
/*
57
	pfSense_MODULE:	dnsupdate
58
*/
59

    
60
##|+PRIV
61
##|*IDENT=page-services-rfc2136clients
62
##|*NAME=Services: RFC 2136 clients page
63
##|*DESCR=Allow access to the 'Services: RFC 2136 clients' page.
64
##|*MATCH=services_rfc2136.php*
65
##|-PRIV
66

    
67
require("guiconfig.inc");
68

    
69
if (!is_array($config['dnsupdates']['dnsupdate'])) {
70
	$config['dnsupdates']['dnsupdate'] = array();
71
}
72

    
73
$a_rfc2136 = &$config['dnsupdates']['dnsupdate'];
74

    
75
if ($_GET['act'] == "del") {
76
	unset($a_rfc2136[$_GET['id']]);
77

    
78
	write_config();
79

    
80
	header("Location: services_rfc2136.php");
81
	exit;
82
}
83
else if ($_GET['act'] == "toggle") {
84
	if ($a_rfc2136[$_GET['id']]) {
85
		if (isset($a_rfc2136[$_GET['id']]['enable'])) {
86
			unset($a_rfc2136[$_GET['id']]['enable']);
87
		} else {
88
			$a_rfc2136[$_GET['id']]['enable'] = true;
89
		}
90
		write_config();
91
				
92
		header("Location: services_rfc2136.php");
93
		exit;
94
	}
95
}
96

    
97
$pgtitle = array(gettext("Services"), gettext("RFC 2136 clients"));
98
include("head.inc");
99

    
100
$tab_array = array();
101
$tab_array[] = array(gettext("DynDns"), false, "services_dyndns.php");
102
$tab_array[] = array(gettext("RFC 2136"), true, "services_rfc2136.php");
103
display_top_tabs($tab_array);
104

    
105
if ($input_errors)
106
    print_input_errors($input_errors);
107
?>
108

    
109
<form action="services_rfc2136.php" method="post" name="iform" id="iform">
110
	<div class="table-responsive">
111
		<table class="table table-striped table-hover table-condensed">
112
			<thead>
113
				<tr>
114
        		    <th><?=gettext("If")?></th>
115
        		    <th><?=gettext("Server")?></th>
116
        		    <th><?=gettext("Hostname")?></th>
117
        		    <th><?=gettext("Cached IP")?></th>
118
        		    <th><?=gettext("Description")?></th>
119
		            <th></th>
120
		        </tr>
121
		    </thead>
122
		    <tbody>
123
<?php
124

    
125

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

    
152
	if (file_exists($filename)) {
153
		print('IPv4: ');
154
		if (isset($rfc2136['usepublicip']))
155
			$ipaddr = dyndnsCheckIP($rfc2136['interface']);
156
		else
157
			$ipaddr = get_interface_ip($rfc2136['interface']);
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('<font color="red">');
164
		else
165
			print('<font color="green">');
166

    
167
		print(tmlspecialchars($cached_ip));
168
		print('</font>');
169
	} else {
170
		print('IPv4: N/A');
171
	}
172

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

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

    
181
		if ($ipaddr != $cached_ip)
182
			print('<font color="red">');
183
		else
184
			print('<font color="green">');
185

    
186
		print(htmlspecialchars($cached_ip));
187
		print('</font>');
188
	} else {
189
		print('IPv6: N/A');
190
	}
191

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

    
214
		    </tbody>
215
        </table>
216
    </div>
217
</form>
218

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

    
226
<?php
227
include("foot.inc");
(148-148/234)