Project

General

Profile

Download (5.38 KB) Statistics
| Branch: | Tag: | Revision:
1 d03efa9c Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4 ce77a9c4 Phil Davis
	services_dyndns.php
5
6 14aee2f4 Phil Davis
	Copyright (C) 2008 Ermal Luçi
7 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
8 5b237745 Scott Ullrich
	All rights reserved.
9 d03efa9c Scott Ullrich
10 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12 d03efa9c Scott Ullrich
13 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15 d03efa9c Scott Ullrich
16 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19 d03efa9c Scott Ullrich
20 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31 1d333258 Scott Ullrich
/*
32 0abc8f4a Charlie Marshall
	pfSense_BUILDER_BINARIES:	/usr/bin/host
33 f5606ded sbeaver
	pfSense_MODULE: dyndns
34 1d333258 Scott Ullrich
*/
35 5b237745 Scott Ullrich
36 6b07c15a Matthew Grooms
##|+PRIV
37
##|*IDENT=page-services-dynamicdnsclients
38
##|*NAME=Services: Dynamic DNS clients page
39
##|*DESCR=Allow access to the 'Services: Dynamic DNS clients' page.
40
##|*MATCH=services_dyndns.php*
41
##|-PRIV
42
43 5b237745 Scott Ullrich
require("guiconfig.inc");
44
45 9c12c130 Phil Davis
if (!is_array($config['dyndnses']['dyndns'])) {
46 f1f60c92 Ermal Luçi
	$config['dyndnses']['dyndns'] = array();
47 9c12c130 Phil Davis
}
48 5b237745 Scott Ullrich
49 f1f60c92 Ermal Luçi
$a_dyndns = &$config['dyndnses']['dyndns'];
50 d03efa9c Scott Ullrich
51 f1f60c92 Ermal Luçi
if ($_GET['act'] == "del") {
52 f42193a4 Ermal
	$conf = $a_dyndns[$_GET['id']];
53
	@unlink("{$g['conf_path']}/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($conf['host']) . "{$conf['id']}.cache");
54
	unset($a_dyndns[$_GET['id']]);
55 37f3e704 Matt Corallo
56 5a39eb2b bcyrill
	write_config();
57
	services_dyndns_configure();
58 37f3e704 Matt Corallo
59 5a39eb2b bcyrill
	header("Location: services_dyndns.php");
60
	exit;
61 5b237745 Scott Ullrich
}
62 4df96eff Scott Ullrich
63 c55f0507 Rafael Lucas
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS clients"));
64 4df96eff Scott Ullrich
include("head.inc");
65
66 f5606ded sbeaver
if ($input_errors)
67
	print_input_errors($input_errors);
68 4df96eff Scott Ullrich
69 f5606ded sbeaver
$tab_array = array();
70
$tab_array[] = array(gettext("DynDns"), true, "services_dyndns.php");
71
$tab_array[] = array(gettext("RFC 2136"), false, "services_rfc2136.php");
72
display_top_tabs($tab_array);
73
?>
74 f1f60c92 Ermal Luçi
<form action="services_dyndns.php" method="post" name="iform" id="iform">
75 f5606ded sbeaver
	<div class="table-responsive">
76
		<table class="table table-striped table-hover table-condensed">
77
			<thead>
78
				<tr>
79
					<th><?=gettext("Interface")?></th>
80
					<th><?=gettext("Service")?></th>
81
					<th><?=gettext("Hostname")?></th>
82
					<th><?=gettext("Cached IP")?></th>
83
					<th><?=gettext("Description")?></th>
84
					<th></th>
85
				</tr>
86
			</thead>
87
			<tbody>
88 f1f60c92 Ermal Luçi
<?php
89 f5606ded sbeaver
$i = 0;
90
foreach ($a_dyndns as $dyndns):
91 f1f60c92 Ermal Luçi
?>
92 71dbcc11 Sjon Hortensius
				<tr<?=!isset($dyndns['enable'])?' class="disabled""':''?>>
93 f5606ded sbeaver
					<td>
94
<?php
95
	$iflist = get_configured_interface_with_descr();
96
	foreach ($iflist as $if => $ifdesc) {
97
		if ($dyndns['interface'] == $if) {
98 71dbcc11 Sjon Hortensius
			print($ifdesc);
99 f5606ded sbeaver
100
			break;
101
		}
102
	}
103
104
	$groupslist = return_gateway_groups_array();
105
	foreach ($groupslist as $if => $group) {
106
		if ($dyndns['interface'] == $if) {
107
			print($if);
108 71dbcc11 Sjon Hortensius
			break;
109 f5606ded sbeaver
		}
110 71dbcc11 Sjon Hortensius
	}
111 f5606ded sbeaver
?>
112
					</td>
113
					<td>
114
<?php
115
	$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS);
116
	$vals = explode(" ", DYNDNS_PROVIDER_VALUES);
117
118
	for ($j = 0; $j < count($vals); $j++) {
119
		if ($vals[$j] == $dyndns['type']) {
120 71dbcc11 Sjon Hortensius
			print(htmlspecialchars($types[$j]));
121 f5606ded sbeaver
122
			break;
123
		}
124
	}
125
?>
126
					</td>
127
					<td>
128
<?php
129 71dbcc11 Sjon Hortensius
	print(htmlspecialchars($dyndns['host']));
130 f5606ded sbeaver
?>
131
					</td>
132
					<td>
133
<?php
134
	$filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
135
	$filename_v6 = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}_v6.cache";
136
	if (file_exists($filename)) {
137
		$ipaddr = dyndnsCheckIP($dyndns['interface']);
138
		$cached_ip_s = explode(":", file_get_contents($filename));
139
		$cached_ip = $cached_ip_s[0];
140
141
		if ($ipaddr != $cached_ip)
142
			print('<font color="red">');
143
		else
144
			print('<font color="green">');
145
146
		print(htmlspecialchars($cached_ip));
147
		print('</font>');
148
	} else if (file_exists($filename_v6)) {
149
		$ipv6addr = get_interface_ipv6($dyndns['interface']);
150
		$cached_ipv6_s = explode("|", file_get_contents($filename_v6));
151
		$cached_ipv6 = $cached_ipv6_s[0];
152
153
		if ($ipv6addr != $cached_ipv6)
154
			print('<font color="red">');
155
		else
156
			print('<font color="green">');
157
158
		print(htmlspecialchars($cached_ipv6));
159
		print('</font>');
160
	} else {
161
		print('N/A');
162
	}
163
?>
164
					</td>
165 71dbcc11 Sjon Hortensius
					<td>
166 f5606ded sbeaver
<?php
167 71dbcc11 Sjon Hortensius
	print(htmlspecialchars($dyndns['descr']));
168 f5606ded sbeaver
?>
169
					</td>
170
					<td>
171
						<a href="services_dyndns_edit.php?id=<?=$i?>" class="btn btn-xs btn-info"><?=gettext('Edit')?></a>
172
						<a href="services_dyndns.php?act=del&amp;id=<?=$i?>" class="btn btn-xs btn-danger"><?=gettext("Delete")?></a>
173
					</td>
174
				</tr>
175
<?php
176
	$i++;
177
	endforeach;
178
?>
179
			</tbody>
180 5a39eb2b bcyrill
	  </table>
181 f5606ded sbeaver
	</div>
182 5b237745 Scott Ullrich
</form>
183 f5606ded sbeaver
184
<nav class="action-buttons">
185
	<a href="services_dyndns_edit.php" class="btn btn-sm btn-success"><?=gettext('Add')?></a>
186
</nav>
187
188
<?php
189
190 f1cef2a2 sbeaver
print_info_box(gettext("IP addresses appearing in green are up to date with Dynamic DNS provider. " .
191
			           "You can force an update for an IP address on the edit page for that service."));
192 f5606ded sbeaver
193
include("foot.inc");