Project

General

Profile

Download (7.26 KB) Statistics
| Branch: | Tag: | Revision:
1 d03efa9c Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3 ce77a9c4 Phil Davis
	services_dyndns.php
4 5b237745 Scott Ullrich
*/
5 df4957e4 Stephen Beaver
/* ====================================================================
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 1d333258 Scott Ullrich
/*
56 0abc8f4a Charlie Marshall
	pfSense_BUILDER_BINARIES:	/usr/bin/host
57 f5606ded sbeaver
	pfSense_MODULE: dyndns
58 1d333258 Scott Ullrich
*/
59 5b237745 Scott Ullrich
60 6b07c15a Matthew Grooms
##|+PRIV
61
##|*IDENT=page-services-dynamicdnsclients
62 5230f468 jim-p
##|*NAME=Services: Dynamic DNS clients
63 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Services: Dynamic DNS clients' page.
64
##|*MATCH=services_dyndns.php*
65
##|-PRIV
66
67 5b237745 Scott Ullrich
require("guiconfig.inc");
68
69 9c12c130 Phil Davis
if (!is_array($config['dyndnses']['dyndns'])) {
70 f1f60c92 Ermal Luçi
	$config['dyndnses']['dyndns'] = array();
71 9c12c130 Phil Davis
}
72 5b237745 Scott Ullrich
73 f1f60c92 Ermal Luçi
$a_dyndns = &$config['dyndnses']['dyndns'];
74 d03efa9c Scott Ullrich
75 f1f60c92 Ermal Luçi
if ($_GET['act'] == "del") {
76 f42193a4 Ermal
	$conf = $a_dyndns[$_GET['id']];
77
	@unlink("{$g['conf_path']}/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($conf['host']) . "{$conf['id']}.cache");
78
	unset($a_dyndns[$_GET['id']]);
79 37f3e704 Matt Corallo
80 5a39eb2b bcyrill
	write_config();
81
	services_dyndns_configure();
82 37f3e704 Matt Corallo
83 5a39eb2b bcyrill
	header("Location: services_dyndns.php");
84
	exit;
85 5b237745 Scott Ullrich
}
86 e5e89876 heper
else if ($_GET['act'] == "toggle") {
87
	if ($a_dyndns[$_GET['id']]) {
88
		if (isset($a_dyndns[$_GET['id']]['enable'])) {
89
			unset($a_dyndns[$_GET['id']]['enable']);
90
		} else {
91
			$a_dyndns[$_GET['id']]['enable'] = true;
92
		}
93
		write_config();
94
		services_dyndns_configure();
95 c9679d8c Stephen Beaver
96 e5e89876 heper
		header("Location: services_dyndns.php");
97
		exit;
98
	}
99
}
100 c55f0507 Rafael Lucas
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS clients"));
101 4df96eff Scott Ullrich
include("head.inc");
102
103 f5606ded sbeaver
if ($input_errors)
104
	print_input_errors($input_errors);
105 4df96eff Scott Ullrich
106 f5606ded sbeaver
$tab_array = array();
107
$tab_array[] = array(gettext("DynDns"), true, "services_dyndns.php");
108
$tab_array[] = array(gettext("RFC 2136"), false, "services_rfc2136.php");
109
display_top_tabs($tab_array);
110
?>
111 f1f60c92 Ermal Luçi
<form action="services_dyndns.php" method="post" name="iform" id="iform">
112 f5606ded sbeaver
	<div class="table-responsive">
113
		<table class="table table-striped table-hover table-condensed">
114
			<thead>
115
				<tr>
116
					<th><?=gettext("Interface")?></th>
117
					<th><?=gettext("Service")?></th>
118
					<th><?=gettext("Hostname")?></th>
119
					<th><?=gettext("Cached IP")?></th>
120
					<th><?=gettext("Description")?></th>
121 c9679d8c Stephen Beaver
					<th><?=gettext("Actions")?></th>
122 f5606ded sbeaver
				</tr>
123
			</thead>
124
			<tbody>
125 f1f60c92 Ermal Luçi
<?php
126 f5606ded sbeaver
$i = 0;
127
foreach ($a_dyndns as $dyndns):
128 f1f60c92 Ermal Luçi
?>
129 71dbcc11 Sjon Hortensius
				<tr<?=!isset($dyndns['enable'])?' class="disabled""':''?>>
130 f5606ded sbeaver
					<td>
131
<?php
132
	$iflist = get_configured_interface_with_descr();
133
	foreach ($iflist as $if => $ifdesc) {
134
		if ($dyndns['interface'] == $if) {
135 71dbcc11 Sjon Hortensius
			print($ifdesc);
136 f5606ded sbeaver
137
			break;
138
		}
139
	}
140
141
	$groupslist = return_gateway_groups_array();
142
	foreach ($groupslist as $if => $group) {
143
		if ($dyndns['interface'] == $if) {
144
			print($if);
145 71dbcc11 Sjon Hortensius
			break;
146 f5606ded sbeaver
		}
147 71dbcc11 Sjon Hortensius
	}
148 f5606ded sbeaver
?>
149
					</td>
150
					<td>
151
<?php
152
	$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS);
153
	$vals = explode(" ", DYNDNS_PROVIDER_VALUES);
154
155
	for ($j = 0; $j < count($vals); $j++) {
156
		if ($vals[$j] == $dyndns['type']) {
157 71dbcc11 Sjon Hortensius
			print(htmlspecialchars($types[$j]));
158 f5606ded sbeaver
159
			break;
160
		}
161
	}
162
?>
163
					</td>
164
					<td>
165
<?php
166 71dbcc11 Sjon Hortensius
	print(htmlspecialchars($dyndns['host']));
167 f5606ded sbeaver
?>
168
					</td>
169
					<td>
170
<?php
171
	$filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
172
	$filename_v6 = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}_v6.cache";
173
	if (file_exists($filename)) {
174
		$ipaddr = dyndnsCheckIP($dyndns['interface']);
175
		$cached_ip_s = explode(":", file_get_contents($filename));
176
		$cached_ip = $cached_ip_s[0];
177
178
		if ($ipaddr != $cached_ip)
179 9c9617a5 Jared Dillard
			print('<span class="text-danger">');
180 f5606ded sbeaver
		else
181 9c9617a5 Jared Dillard
			print('<span class="text-success">');
182 f5606ded sbeaver
183
		print(htmlspecialchars($cached_ip));
184 9c9617a5 Jared Dillard
		print('</span>');
185 f5606ded sbeaver
	} else if (file_exists($filename_v6)) {
186
		$ipv6addr = get_interface_ipv6($dyndns['interface']);
187
		$cached_ipv6_s = explode("|", file_get_contents($filename_v6));
188
		$cached_ipv6 = $cached_ipv6_s[0];
189
190
		if ($ipv6addr != $cached_ipv6)
191 9c9617a5 Jared Dillard
			print('<span class="text-danger">');
192 f5606ded sbeaver
		else
193 9c9617a5 Jared Dillard
			print('<span class="text-success">');
194 f5606ded sbeaver
195
		print(htmlspecialchars($cached_ipv6));
196 9c9617a5 Jared Dillard
		print('</span>');
197 f5606ded sbeaver
	} else {
198
		print('N/A');
199
	}
200
?>
201
					</td>
202 71dbcc11 Sjon Hortensius
					<td>
203 f5606ded sbeaver
<?php
204 71dbcc11 Sjon Hortensius
	print(htmlspecialchars($dyndns['descr']));
205 f5606ded sbeaver
?>
206
					</td>
207
					<td>
208 33f0b0d5 Stephen Beaver
						<a class="fa fa-pencil"	title="<?=gettext('Edit service')?>" href="services_dyndns_edit.php?id=<?=$i?>"></a>
209 c9679d8c Stephen Beaver
<?php if (isset($dyndns['enable'])) {
210
?>
211 33f0b0d5 Stephen Beaver
						<a class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
212 c9679d8c Stephen Beaver
<?php } else {
213
?>
214 e5e89876 heper
						<a class="fa fa-check-square-o"	title="<?=gettext('Enable service')?>" href="?act=toggle&amp;id=<?=$i?>" ></a>
215 c9679d8c Stephen Beaver
<?php }
216
?>
217 33f0b0d5 Stephen Beaver
						<a class="fa fa-trash" title="<?=gettext('Delete service')?>"	href="services_dyndns.php?act=del&amp;id=<?=$i?>"></a>
218 f5606ded sbeaver
					</td>
219
				</tr>
220
<?php
221
	$i++;
222
	endforeach;
223
?>
224
			</tbody>
225 5a39eb2b bcyrill
	  </table>
226 f5606ded sbeaver
	</div>
227 5b237745 Scott Ullrich
</form>
228 f5606ded sbeaver
229
<nav class="action-buttons">
230 c9679d8c Stephen Beaver
	<a href="services_dyndns_edit.php" class="btn btn-sm btn-success btn-sm">
231 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
232 c9679d8c Stephen Beaver
		<?=gettext('Add')?>
233
	</a>
234 f5606ded sbeaver
</nav>
235
236 df4957e4 Stephen Beaver
<div>
237 9c9617a5 Jared Dillard
	<?=gettext('IP addresses appearing in <span class="text-success">green</span> are up to date with Dynamic DNS provider. ')?>
238 df4957e4 Stephen Beaver
	<?=gettext('You can force an update for an IP address on the edit page for that service.')?>
239
</div>
240 f5606ded sbeaver
241 df4957e4 Stephen Beaver
<?php
242 e5e89876 heper
include("foot.inc");