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
|
##|+PRIV
|
57
|
##|*IDENT=page-services-dynamicdnsclients
|
58
|
##|*NAME=Services: Dynamic DNS clients
|
59
|
##|*DESCR=Allow access to the 'Services: Dynamic DNS clients' page.
|
60
|
##|*MATCH=services_dyndns.php*
|
61
|
##|-PRIV
|
62
|
|
63
|
require("guiconfig.inc");
|
64
|
|
65
|
if (!is_array($config['dyndnses']['dyndns'])) {
|
66
|
$config['dyndnses']['dyndns'] = array();
|
67
|
}
|
68
|
|
69
|
$a_dyndns = &$config['dyndnses']['dyndns'];
|
70
|
|
71
|
if ($_GET['act'] == "del") {
|
72
|
$conf = $a_dyndns[$_GET['id']];
|
73
|
if ($conf['type'] == "namecheap") {
|
74
|
$hostname = $conf['host'] . "." . $conf['domainname'];
|
75
|
} else {
|
76
|
$hostname = $conf['host'];
|
77
|
}
|
78
|
@unlink("{$g['conf_path']}/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($hostname) . "{$conf['id']}.cache");
|
79
|
unset($a_dyndns[$_GET['id']]);
|
80
|
|
81
|
write_config();
|
82
|
services_dyndns_configure();
|
83
|
|
84
|
header("Location: services_dyndns.php");
|
85
|
exit;
|
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"), gettext("Dynamic DNS Clients"));
|
101
|
include("head.inc");
|
102
|
|
103
|
if ($input_errors) {
|
104
|
print_input_errors($input_errors);
|
105
|
}
|
106
|
|
107
|
$tab_array = array();
|
108
|
$tab_array[] = array(gettext("Dynamic DNS Clients"), true, "services_dyndns.php");
|
109
|
$tab_array[] = array(gettext("RFC 2136 Clients"), false, "services_rfc2136.php");
|
110
|
display_top_tabs($tab_array);
|
111
|
?>
|
112
|
<form action="services_dyndns.php" method="post" name="iform" id="iform">
|
113
|
<div class="panel panel-default">
|
114
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Dynamic DNS Clients')?></h2></div>
|
115
|
<div class="panel-body">
|
116
|
<div class="table-responsive">
|
117
|
<table class="table table-striped table-hover table-condensed">
|
118
|
<thead>
|
119
|
<tr>
|
120
|
<th><?=gettext("Interface")?></th>
|
121
|
<th><?=gettext("Service")?></th>
|
122
|
<th><?=gettext("Hostname")?></th>
|
123
|
<th><?=gettext("Cached IP")?></th>
|
124
|
<th><?=gettext("Description")?></th>
|
125
|
<th><?=gettext("Actions")?></th>
|
126
|
</tr>
|
127
|
</thead>
|
128
|
<tbody>
|
129
|
<?php
|
130
|
$i = 0;
|
131
|
foreach ($a_dyndns as $dyndns):
|
132
|
if ($dyndns['type'] == "namecheap") {
|
133
|
$hostname = $dyndns['host'] . "." . $dyndns['domainname'];
|
134
|
} else {
|
135
|
$hostname = $dyndns['host'];
|
136
|
}
|
137
|
?>
|
138
|
<tr<?=!isset($dyndns['enable'])?' class="disabled"':''?>>
|
139
|
<td>
|
140
|
<?php
|
141
|
$iflist = get_configured_interface_with_descr();
|
142
|
foreach ($iflist as $if => $ifdesc) {
|
143
|
if ($dyndns['interface'] == $if) {
|
144
|
print($ifdesc);
|
145
|
|
146
|
break;
|
147
|
}
|
148
|
}
|
149
|
|
150
|
$groupslist = return_gateway_groups_array();
|
151
|
foreach ($groupslist as $if => $group) {
|
152
|
if ($dyndns['interface'] == $if) {
|
153
|
print($if);
|
154
|
break;
|
155
|
}
|
156
|
}
|
157
|
?>
|
158
|
</td>
|
159
|
<td>
|
160
|
<?php
|
161
|
$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS);
|
162
|
$vals = explode(" ", DYNDNS_PROVIDER_VALUES);
|
163
|
|
164
|
for ($j = 0; $j < count($vals); $j++) {
|
165
|
if ($vals[$j] == $dyndns['type']) {
|
166
|
print(htmlspecialchars($types[$j]));
|
167
|
|
168
|
break;
|
169
|
}
|
170
|
}
|
171
|
?>
|
172
|
</td>
|
173
|
<td>
|
174
|
<?php
|
175
|
print(htmlspecialchars($hostname));
|
176
|
?>
|
177
|
</td>
|
178
|
<td>
|
179
|
<?php
|
180
|
$filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($hostname) . "{$dyndns['id']}.cache";
|
181
|
$filename_v6 = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($hostname) . "{$dyndns['id']}_v6.cache";
|
182
|
if (file_exists($filename)) {
|
183
|
$ipaddr = dyndnsCheckIP($dyndns['interface']);
|
184
|
$cached_ip_s = explode(":", file_get_contents($filename));
|
185
|
$cached_ip = $cached_ip_s[0];
|
186
|
|
187
|
if ($ipaddr != $cached_ip) {
|
188
|
print('<span class="text-danger">');
|
189
|
} else {
|
190
|
print('<span class="text-success">');
|
191
|
}
|
192
|
|
193
|
print(htmlspecialchars($cached_ip));
|
194
|
print('</span>');
|
195
|
} else if (file_exists($filename_v6)) {
|
196
|
$ipv6addr = get_interface_ipv6($dyndns['interface']);
|
197
|
$cached_ipv6_s = explode("|", file_get_contents($filename_v6));
|
198
|
$cached_ipv6 = $cached_ipv6_s[0];
|
199
|
|
200
|
if ($ipv6addr != $cached_ipv6) {
|
201
|
print('<span class="text-danger">');
|
202
|
} else {
|
203
|
print('<span class="text-success">');
|
204
|
}
|
205
|
|
206
|
print(htmlspecialchars($cached_ipv6));
|
207
|
print('</span>');
|
208
|
} else {
|
209
|
print('N/A');
|
210
|
}
|
211
|
?>
|
212
|
</td>
|
213
|
<td>
|
214
|
<?php
|
215
|
print(htmlspecialchars($dyndns['descr']));
|
216
|
?>
|
217
|
</td>
|
218
|
<td>
|
219
|
<a class="fa fa-pencil" title="<?=gettext('Edit service')?>" href="services_dyndns_edit.php?id=<?=$i?>"></a>
|
220
|
<?php if (isset($dyndns['enable'])) {
|
221
|
?>
|
222
|
<a class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&id=<?=$i?>"></a>
|
223
|
<?php } else {
|
224
|
?>
|
225
|
<a class="fa fa-check-square-o" title="<?=gettext('Enable service')?>" href="?act=toggle&id=<?=$i?>"></a>
|
226
|
<?php }
|
227
|
?>
|
228
|
<a class="fa fa-trash" title="<?=gettext('Delete service')?>" href="services_dyndns.php?act=del&id=<?=$i?>"></a>
|
229
|
</td>
|
230
|
</tr>
|
231
|
<?php
|
232
|
$i++;
|
233
|
endforeach;
|
234
|
?>
|
235
|
</tbody>
|
236
|
</table>
|
237
|
</div>
|
238
|
</div>
|
239
|
</div>
|
240
|
</form>
|
241
|
|
242
|
<nav class="action-buttons">
|
243
|
<a href="services_dyndns_edit.php" class="btn btn-sm btn-success btn-sm">
|
244
|
<i class="fa fa-plus icon-embed-btn"></i>
|
245
|
<?=gettext('Add')?>
|
246
|
</a>
|
247
|
</nav>
|
248
|
|
249
|
<div>
|
250
|
<?=gettext('IP addresses appearing in <span class="text-success">green</span> are up to date with Dynamic DNS provider. ')?>
|
251
|
<?=gettext('You can force an update for an IP address on the edit page for that service.')?>
|
252
|
</div>
|
253
|
|
254
|
<?php
|
255
|
include("foot.inc");
|