Project

General

Profile

Download (7.78 KB) Statistics
| Branch: | Tag: | Revision:
1 d03efa9c Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3 aaec5634 Renato Botelho
 * services_dyndns.php
4 df4957e4 Stephen Beaver
 *
5 aaec5634 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2016 Electric Sheep Fencing, LLC
7
 * All rights reserved.
8 df4957e4 Stephen Beaver
 *
9 aaec5634 Renato Botelho
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions are met:
11 df4957e4 Stephen Beaver
 *
12 aaec5634 Renato Botelho
 * 1. Redistributions of source code must retain the above copyright notice,
13
 *    this list of conditions and the following disclaimer.
14 df4957e4 Stephen Beaver
 *
15 aaec5634 Renato Botelho
 * 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 df4957e4 Stephen Beaver
 *
20 aaec5634 Renato Botelho
 * 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 df4957e4 Stephen Beaver
 *
25 aaec5634 Renato Botelho
 * 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 df4957e4 Stephen Beaver
 *
30 aaec5634 Renato Botelho
 * 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 df4957e4 Stephen Beaver
 *
34 aaec5634 Renato Botelho
 * 6. Redistributions of any form whatsoever must retain the following
35
 *    acknowledgment:
36 df4957e4 Stephen Beaver
 *
37 aaec5634 Renato Botelho
 * "This product includes software developed by the pfSense Project
38
 * for use in the pfSense software distribution (http://www.pfsense.org/).
39 df4957e4 Stephen Beaver
 *
40 aaec5634 Renato Botelho
 * 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 df4957e4 Stephen Beaver
 */
53 5b237745 Scott Ullrich
54 6b07c15a Matthew Grooms
##|+PRIV
55
##|*IDENT=page-services-dynamicdnsclients
56 5230f468 jim-p
##|*NAME=Services: Dynamic DNS clients
57 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Services: Dynamic DNS clients' page.
58
##|*MATCH=services_dyndns.php*
59
##|-PRIV
60
61 aceaf18c Phil Davis
require_once("guiconfig.inc");
62 5b237745 Scott Ullrich
63 9c12c130 Phil Davis
if (!is_array($config['dyndnses']['dyndns'])) {
64 f1f60c92 Ermal Luçi
	$config['dyndnses']['dyndns'] = array();
65 9c12c130 Phil Davis
}
66 5b237745 Scott Ullrich
67 f1f60c92 Ermal Luçi
$a_dyndns = &$config['dyndnses']['dyndns'];
68 d03efa9c Scott Ullrich
69 f1f60c92 Ermal Luçi
if ($_GET['act'] == "del") {
70 f42193a4 Ermal
	$conf = $a_dyndns[$_GET['id']];
71 6635aa0f jim-p
	if ($conf['type'] == "namecheap") {
72
		$hostname = $conf['host'] . "." . $conf['domainname'];
73
	} else {
74
		$hostname = $conf['host'];
75
	}
76
	@unlink("{$g['conf_path']}/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($hostname) . "{$conf['id']}.cache");
77 f42193a4 Ermal
	unset($a_dyndns[$_GET['id']]);
78 37f3e704 Matt Corallo
79 5a39eb2b bcyrill
	write_config();
80
	services_dyndns_configure();
81 37f3e704 Matt Corallo
82 5a39eb2b bcyrill
	header("Location: services_dyndns.php");
83
	exit;
84 6e3488e9 Phil Davis
} else if ($_GET['act'] == "toggle") {
85 e5e89876 heper
	if ($a_dyndns[$_GET['id']]) {
86
		if (isset($a_dyndns[$_GET['id']]['enable'])) {
87
			unset($a_dyndns[$_GET['id']]['enable']);
88
		} else {
89
			$a_dyndns[$_GET['id']]['enable'] = true;
90
		}
91
		write_config();
92
		services_dyndns_configure();
93 c9679d8c Stephen Beaver
94 e5e89876 heper
		header("Location: services_dyndns.php");
95
		exit;
96
	}
97
}
98 c8f6b745 k-paulius
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Dynamic DNS Clients"));
99 4df96eff Scott Ullrich
include("head.inc");
100
101 6e3488e9 Phil Davis
if ($input_errors) {
102 f5606ded sbeaver
	print_input_errors($input_errors);
103 6e3488e9 Phil Davis
}
104 4df96eff Scott Ullrich
105 f5606ded sbeaver
$tab_array = array();
106 c8f6b745 k-paulius
$tab_array[] = array(gettext("Dynamic DNS Clients"), true, "services_dyndns.php");
107
$tab_array[] = array(gettext("RFC 2136 Clients"), false, "services_rfc2136.php");
108 b89bc607 Phil Davis
$tab_array[] = array(gettext("Check IP Services"), false, "services_checkip.php");
109 f5606ded sbeaver
display_top_tabs($tab_array);
110
?>
111 f1f60c92 Ermal Luçi
<form action="services_dyndns.php" method="post" name="iform" id="iform">
112 060ed238 Stephen Beaver
	<div class="panel panel-default">
113 f0efd690 Phil Davis
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('Dynamic DNS Clients')?></h2></div>
114 060ed238 Stephen Beaver
		<div class="panel-body">
115
			<div class="table-responsive">
116 91677170 PiBa-NL
				<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
117 060ed238 Stephen Beaver
					<thead>
118
						<tr>
119
							<th><?=gettext("Interface")?></th>
120
							<th><?=gettext("Service")?></th>
121
							<th><?=gettext("Hostname")?></th>
122
							<th><?=gettext("Cached IP")?></th>
123
							<th><?=gettext("Description")?></th>
124
							<th><?=gettext("Actions")?></th>
125
						</tr>
126
					</thead>
127
					<tbody>
128 f1f60c92 Ermal Luçi
<?php
129 f5606ded sbeaver
$i = 0;
130
foreach ($a_dyndns as $dyndns):
131 6635aa0f jim-p
	if ($dyndns['type'] == "namecheap") {
132
		$hostname = $dyndns['host'] . "." . $dyndns['domainname'];
133
	} else {
134
		$hostname = $dyndns['host'];
135
	}
136 f1f60c92 Ermal Luçi
?>
137 060ed238 Stephen Beaver
						<tr<?=!isset($dyndns['enable'])?' class="disabled"':''?>>
138
							<td>
139 f5606ded sbeaver
<?php
140
	$iflist = get_configured_interface_with_descr();
141
	foreach ($iflist as $if => $ifdesc) {
142
		if ($dyndns['interface'] == $if) {
143 71dbcc11 Sjon Hortensius
			print($ifdesc);
144 f5606ded sbeaver
145
			break;
146
		}
147
	}
148
149
	$groupslist = return_gateway_groups_array();
150
	foreach ($groupslist as $if => $group) {
151
		if ($dyndns['interface'] == $if) {
152
			print($if);
153 71dbcc11 Sjon Hortensius
			break;
154 f5606ded sbeaver
		}
155 71dbcc11 Sjon Hortensius
	}
156 f5606ded sbeaver
?>
157 060ed238 Stephen Beaver
							</td>
158
							<td>
159 f5606ded sbeaver
<?php
160
	$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS);
161
	$vals = explode(" ", DYNDNS_PROVIDER_VALUES);
162
163
	for ($j = 0; $j < count($vals); $j++) {
164
		if ($vals[$j] == $dyndns['type']) {
165 71dbcc11 Sjon Hortensius
			print(htmlspecialchars($types[$j]));
166 f5606ded sbeaver
167
			break;
168
		}
169
	}
170
?>
171 060ed238 Stephen Beaver
							</td>
172
							<td>
173 f5606ded sbeaver
<?php
174 6635aa0f jim-p
	print(htmlspecialchars($hostname));
175 f5606ded sbeaver
?>
176 060ed238 Stephen Beaver
							</td>
177
							<td>
178 f5606ded sbeaver
<?php
179 6635aa0f jim-p
	$filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($hostname) . "{$dyndns['id']}.cache";
180
	$filename_v6 = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($hostname) . "{$dyndns['id']}_v6.cache";
181 f5606ded sbeaver
	if (file_exists($filename)) {
182
		$ipaddr = dyndnsCheckIP($dyndns['interface']);
183
		$cached_ip_s = explode(":", file_get_contents($filename));
184
		$cached_ip = $cached_ip_s[0];
185
186 6e3488e9 Phil Davis
		if ($ipaddr != $cached_ip) {
187 9c9617a5 Jared Dillard
			print('<span class="text-danger">');
188 6e3488e9 Phil Davis
		} else {
189 9c9617a5 Jared Dillard
			print('<span class="text-success">');
190 6e3488e9 Phil Davis
		}
191 f5606ded sbeaver
192
		print(htmlspecialchars($cached_ip));
193 9c9617a5 Jared Dillard
		print('</span>');
194 f5606ded sbeaver
	} else if (file_exists($filename_v6)) {
195
		$ipv6addr = get_interface_ipv6($dyndns['interface']);
196
		$cached_ipv6_s = explode("|", file_get_contents($filename_v6));
197
		$cached_ipv6 = $cached_ipv6_s[0];
198
199 6e3488e9 Phil Davis
		if ($ipv6addr != $cached_ipv6) {
200 9c9617a5 Jared Dillard
			print('<span class="text-danger">');
201 6e3488e9 Phil Davis
		} else {
202 9c9617a5 Jared Dillard
			print('<span class="text-success">');
203 6e3488e9 Phil Davis
		}
204 f5606ded sbeaver
205
		print(htmlspecialchars($cached_ipv6));
206 9c9617a5 Jared Dillard
		print('</span>');
207 f5606ded sbeaver
	} else {
208
		print('N/A');
209
	}
210
?>
211 060ed238 Stephen Beaver
							</td>
212
							<td>
213 f5606ded sbeaver
<?php
214 71dbcc11 Sjon Hortensius
	print(htmlspecialchars($dyndns['descr']));
215 f5606ded sbeaver
?>
216 060ed238 Stephen Beaver
							</td>
217
							<td>
218
								<a class="fa fa-pencil" title="<?=gettext('Edit service')?>" href="services_dyndns_edit.php?id=<?=$i?>"></a>
219 c9679d8c Stephen Beaver
<?php if (isset($dyndns['enable'])) {
220
?>
221 060ed238 Stephen Beaver
								<a class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
222 c9679d8c Stephen Beaver
<?php } else {
223
?>
224 060ed238 Stephen Beaver
								<a class="fa fa-check-square-o" title="<?=gettext('Enable service')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
225 c9679d8c Stephen Beaver
<?php }
226
?>
227 060ed238 Stephen Beaver
								<a class="fa fa-trash" title="<?=gettext('Delete service')?>"	href="services_dyndns.php?act=del&amp;id=<?=$i?>"></a>
228
							</td>
229
						</tr>
230 f5606ded sbeaver
<?php
231
	$i++;
232
	endforeach;
233
?>
234 060ed238 Stephen Beaver
					</tbody>
235
			  </table>
236
			</div>
237
		</div>
238 f5606ded sbeaver
	</div>
239 5b237745 Scott Ullrich
</form>
240 f5606ded sbeaver
241
<nav class="action-buttons">
242 c9679d8c Stephen Beaver
	<a href="services_dyndns_edit.php" class="btn btn-sm btn-success btn-sm">
243 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
244 c9679d8c Stephen Beaver
		<?=gettext('Add')?>
245
	</a>
246 f5606ded sbeaver
</nav>
247
248 df4957e4 Stephen Beaver
<div>
249 9c9617a5 Jared Dillard
	<?=gettext('IP addresses appearing in <span class="text-success">green</span> are up to date with Dynamic DNS provider. ')?>
250 7194b250 Stephen Beaver
	<?=gettext('An update for an IP address can be forced on the edit page for that service.')?>
251 df4957e4 Stephen Beaver
</div>
252 f5606ded sbeaver
253 df4957e4 Stephen Beaver
<?php
254 e5e89876 heper
include("foot.inc");