Project

General

Profile

Download (7.25 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	services_dyndns.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_BUILDER_BINARIES:	/usr/bin/host
58
	pfSense_MODULE: dyndns
59
*/
60

    
61
##|+PRIV
62
##|*IDENT=page-services-dynamicdnsclients
63
##|*NAME=Services: Dynamic DNS clients page
64
##|*DESCR=Allow access to the 'Services: Dynamic DNS clients' page.
65
##|*MATCH=services_dyndns.php*
66
##|-PRIV
67

    
68
require("guiconfig.inc");
69

    
70
if (!is_array($config['dyndnses']['dyndns'])) {
71
	$config['dyndnses']['dyndns'] = array();
72
}
73

    
74
$a_dyndns = &$config['dyndnses']['dyndns'];
75

    
76
if ($_GET['act'] == "del") {
77
	$conf = $a_dyndns[$_GET['id']];
78
	@unlink("{$g['conf_path']}/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($conf['host']) . "{$conf['id']}.cache");
79
	unset($a_dyndns[$_GET['id']]);
80

    
81
	write_config();
82
	services_dyndns_configure();
83

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

    
97
		header("Location: services_dyndns.php");
98
		exit;
99
	}
100
}
101
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS clients"));
102
include("head.inc");
103

    
104
if ($input_errors)
105
	print_input_errors($input_errors);
106

    
107
$tab_array = array();
108
$tab_array[] = array(gettext("DynDns"), true, "services_dyndns.php");
109
$tab_array[] = array(gettext("RFC 2136"), false, "services_rfc2136.php");
110
display_top_tabs($tab_array);
111
?>
112
<form action="services_dyndns.php" method="post" name="iform" id="iform">
113
	<div class="table-responsive">
114
		<table class="table table-striped table-hover table-condensed">
115
			<thead>
116
				<tr>
117
					<th><?=gettext("Interface")?></th>
118
					<th><?=gettext("Service")?></th>
119
					<th><?=gettext("Hostname")?></th>
120
					<th><?=gettext("Cached IP")?></th>
121
					<th><?=gettext("Description")?></th>
122
					<th><?=gettext("Actions")?></th>
123
				</tr>
124
			</thead>
125
			<tbody>
126
<?php
127
$i = 0;
128
foreach ($a_dyndns as $dyndns):
129
?>
130
				<tr<?=!isset($dyndns['enable'])?' class="disabled""':''?>>
131
					<td>
132
<?php
133
	$iflist = get_configured_interface_with_descr();
134
	foreach ($iflist as $if => $ifdesc) {
135
		if ($dyndns['interface'] == $if) {
136
			print($ifdesc);
137

    
138
			break;
139
		}
140
	}
141

    
142
	$groupslist = return_gateway_groups_array();
143
	foreach ($groupslist as $if => $group) {
144
		if ($dyndns['interface'] == $if) {
145
			print($if);
146
			break;
147
		}
148
	}
149
?>
150
					</td>
151
					<td>
152
<?php
153
	$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS);
154
	$vals = explode(" ", DYNDNS_PROVIDER_VALUES);
155

    
156
	for ($j = 0; $j < count($vals); $j++) {
157
		if ($vals[$j] == $dyndns['type']) {
158
			print(htmlspecialchars($types[$j]));
159

    
160
			break;
161
		}
162
	}
163
?>
164
					</td>
165
					<td>
166
<?php
167
	print(htmlspecialchars($dyndns['host']));
168
?>
169
					</td>
170
					<td>
171
<?php
172
	$filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
173
	$filename_v6 = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}_v6.cache";
174
	if (file_exists($filename)) {
175
		$ipaddr = dyndnsCheckIP($dyndns['interface']);
176
		$cached_ip_s = explode(":", file_get_contents($filename));
177
		$cached_ip = $cached_ip_s[0];
178

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

    
184
		print(htmlspecialchars($cached_ip));
185
		print('</font>');
186
	} else if (file_exists($filename_v6)) {
187
		$ipv6addr = get_interface_ipv6($dyndns['interface']);
188
		$cached_ipv6_s = explode("|", file_get_contents($filename_v6));
189
		$cached_ipv6 = $cached_ipv6_s[0];
190

    
191
		if ($ipv6addr != $cached_ipv6)
192
			print('<font color="red">');
193
		else
194
			print('<font color="green">');
195

    
196
		print(htmlspecialchars($cached_ipv6));
197
		print('</font>');
198
	} else {
199
		print('N/A');
200
	}
201
?>
202
					</td>
203
					<td>
204
<?php
205
	print(htmlspecialchars($dyndns['descr']));
206
?>
207
					</td>
208
					<td>
209
						<a class="fa fa-pencil"	title="<?=gettext('Edit service')?>" href="services_dyndns_edit.php?id=<?=$i?>"></a>
210
<?php if (isset($dyndns['enable'])) {
211
?>
212
						<a class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
213
<?php } else {
214
?>
215
						<a class="fa fa-check-square-o"	title="<?=gettext('Enable service')?>" href="?act=toggle&amp;id=<?=$i?>" ></a>
216
<?php }
217
?>
218
						<a class="fa fa-trash" title="<?=gettext('Delete service')?>"	href="services_dyndns.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
</form>
229

    
230
<nav class="action-buttons">
231
	<a href="services_dyndns_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
<div>
238
	<?=gettext('IP addresses appearing in <span style="color: green;">green</span> are up to date with Dynamic DNS provider. ')?>
239
	<?=gettext('You can force an update for an IP address on the edit page for that service.')?>
240
</div>
241

    
242
<?php
243
include("foot.inc");
(141-141/234)