Project

General

Profile

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