1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
services_dyndns.php
|
5
|
|
6
|
Copyright (C) 2008 Ermal Luçi
|
7
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
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
|
|
20
|
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
|
/*
|
32
|
pfSense_BUILDER_BINARIES: /usr/bin/host
|
33
|
pfSense_MODULE: dyndns
|
34
|
*/
|
35
|
|
36
|
##|+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
|
require("guiconfig.inc");
|
44
|
|
45
|
if (!is_array($config['dyndnses']['dyndns'])) {
|
46
|
$config['dyndnses']['dyndns'] = array();
|
47
|
}
|
48
|
|
49
|
$a_dyndns = &$config['dyndnses']['dyndns'];
|
50
|
|
51
|
if ($_GET['act'] == "del") {
|
52
|
$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
|
|
56
|
write_config();
|
57
|
services_dyndns_configure();
|
58
|
|
59
|
header("Location: services_dyndns.php");
|
60
|
exit;
|
61
|
}
|
62
|
|
63
|
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS clients"));
|
64
|
include("head.inc");
|
65
|
|
66
|
if ($input_errors)
|
67
|
print_input_errors($input_errors);
|
68
|
|
69
|
$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
|
<form action="services_dyndns.php" method="post" name="iform" id="iform">
|
75
|
<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
|
<?php
|
89
|
$i = 0;
|
90
|
foreach ($a_dyndns as $dyndns):
|
91
|
?>
|
92
|
<tr<?=!isset($dyndns['enable'])?' class="disabled""':''?>>
|
93
|
<td>
|
94
|
<?php
|
95
|
$iflist = get_configured_interface_with_descr();
|
96
|
foreach ($iflist as $if => $ifdesc) {
|
97
|
if ($dyndns['interface'] == $if) {
|
98
|
print($ifdesc);
|
99
|
|
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
|
break;
|
109
|
}
|
110
|
}
|
111
|
?>
|
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
|
print(htmlspecialchars($types[$j]));
|
121
|
|
122
|
break;
|
123
|
}
|
124
|
}
|
125
|
?>
|
126
|
</td>
|
127
|
<td>
|
128
|
<?php
|
129
|
print(htmlspecialchars($dyndns['host']));
|
130
|
?>
|
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
|
<td>
|
166
|
<?php
|
167
|
print(htmlspecialchars($dyndns['descr']));
|
168
|
?>
|
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&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
|
</table>
|
181
|
</div>
|
182
|
</form>
|
183
|
|
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
|
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
|
|
193
|
include("foot.inc");
|