1
|
<?php
|
2
|
/*
|
3
|
services_dyndns.php
|
4
|
*/
|
5
|
/* ====================================================================
|
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
|
/*
|
56
|
pfSense_BUILDER_BINARIES: /usr/bin/host
|
57
|
pfSense_MODULE: dyndns
|
58
|
*/
|
59
|
|
60
|
##|+PRIV
|
61
|
##|*IDENT=page-services-dynamicdnsclients
|
62
|
##|*NAME=Services: Dynamic DNS clients
|
63
|
##|*DESCR=Allow access to the 'Services: Dynamic DNS clients' page.
|
64
|
##|*MATCH=services_dyndns.php*
|
65
|
##|-PRIV
|
66
|
|
67
|
require("guiconfig.inc");
|
68
|
|
69
|
if (!is_array($config['dyndnses']['dyndns'])) {
|
70
|
$config['dyndnses']['dyndns'] = array();
|
71
|
}
|
72
|
|
73
|
$a_dyndns = &$config['dyndnses']['dyndns'];
|
74
|
|
75
|
if ($_GET['act'] == "del") {
|
76
|
$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
|
|
80
|
write_config();
|
81
|
services_dyndns_configure();
|
82
|
|
83
|
header("Location: services_dyndns.php");
|
84
|
exit;
|
85
|
}
|
86
|
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
|
|
96
|
header("Location: services_dyndns.php");
|
97
|
exit;
|
98
|
}
|
99
|
}
|
100
|
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS clients"));
|
101
|
include("head.inc");
|
102
|
|
103
|
if ($input_errors)
|
104
|
print_input_errors($input_errors);
|
105
|
|
106
|
$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
|
<form action="services_dyndns.php" method="post" name="iform" id="iform">
|
112
|
<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
|
<th><?=gettext("Actions")?></th>
|
122
|
</tr>
|
123
|
</thead>
|
124
|
<tbody>
|
125
|
<?php
|
126
|
$i = 0;
|
127
|
foreach ($a_dyndns as $dyndns):
|
128
|
?>
|
129
|
<tr<?=!isset($dyndns['enable'])?' class="disabled""':''?>>
|
130
|
<td>
|
131
|
<?php
|
132
|
$iflist = get_configured_interface_with_descr();
|
133
|
foreach ($iflist as $if => $ifdesc) {
|
134
|
if ($dyndns['interface'] == $if) {
|
135
|
print($ifdesc);
|
136
|
|
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
|
break;
|
146
|
}
|
147
|
}
|
148
|
?>
|
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
|
print(htmlspecialchars($types[$j]));
|
158
|
|
159
|
break;
|
160
|
}
|
161
|
}
|
162
|
?>
|
163
|
</td>
|
164
|
<td>
|
165
|
<?php
|
166
|
print(htmlspecialchars($dyndns['host']));
|
167
|
?>
|
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
|
print('<span class="text-danger">');
|
180
|
else
|
181
|
print('<span class="text-success">');
|
182
|
|
183
|
print(htmlspecialchars($cached_ip));
|
184
|
print('</span>');
|
185
|
} 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
|
print('<span class="text-danger">');
|
192
|
else
|
193
|
print('<span class="text-success">');
|
194
|
|
195
|
print(htmlspecialchars($cached_ipv6));
|
196
|
print('</span>');
|
197
|
} else {
|
198
|
print('N/A');
|
199
|
}
|
200
|
?>
|
201
|
</td>
|
202
|
<td>
|
203
|
<?php
|
204
|
print(htmlspecialchars($dyndns['descr']));
|
205
|
?>
|
206
|
</td>
|
207
|
<td>
|
208
|
<a class="fa fa-pencil" title="<?=gettext('Edit service')?>" href="services_dyndns_edit.php?id=<?=$i?>"></a>
|
209
|
<?php if (isset($dyndns['enable'])) {
|
210
|
?>
|
211
|
<a class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&id=<?=$i?>"></a>
|
212
|
<?php } else {
|
213
|
?>
|
214
|
<a class="fa fa-check-square-o" title="<?=gettext('Enable service')?>" href="?act=toggle&id=<?=$i?>" ></a>
|
215
|
<?php }
|
216
|
?>
|
217
|
<a class="fa fa-trash" title="<?=gettext('Delete service')?>" href="services_dyndns.php?act=del&id=<?=$i?>"></a>
|
218
|
</td>
|
219
|
</tr>
|
220
|
<?php
|
221
|
$i++;
|
222
|
endforeach;
|
223
|
?>
|
224
|
</tbody>
|
225
|
</table>
|
226
|
</div>
|
227
|
</form>
|
228
|
|
229
|
<nav class="action-buttons">
|
230
|
<a href="services_dyndns_edit.php" class="btn btn-sm btn-success btn-sm">
|
231
|
<i class="fa fa-plus icon-embed-btn"></i>
|
232
|
<?=gettext('Add')?>
|
233
|
</a>
|
234
|
</nav>
|
235
|
|
236
|
<div>
|
237
|
<?=gettext('IP addresses appearing in <span class="text-success">green</span> are up to date with Dynamic DNS provider. ')?>
|
238
|
<?=gettext('You can force an update for an IP address on the edit page for that service.')?>
|
239
|
</div>
|
240
|
|
241
|
<?php
|
242
|
include("foot.inc");
|