Project

General

Profile

Download (7.7 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * services_dyndns.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2016 Electric Sheep Fencing, LLC
7
 * All rights reserved.
8
 *
9
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions are met:
11
 *
12
 * 1. Redistributions of source code must retain the above copyright notice,
13
 *    this list of conditions and the following disclaimer.
14
 *
15
 * 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
 *
20
 * 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
 *
25
 * 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
 *
30
 * 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
 *
34
 * 6. Redistributions of any form whatsoever must retain the following
35
 *    acknowledgment:
36
 *
37
 * "This product includes software developed by the pfSense Project
38
 * for use in the pfSense software distribution (http://www.pfsense.org/).
39
 *
40
 * 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
 */
53

    
54
##|+PRIV
55
##|*IDENT=page-services-dynamicdnsclients
56
##|*NAME=Services: Dynamic DNS clients
57
##|*DESCR=Allow access to the 'Services: Dynamic DNS clients' page.
58
##|*MATCH=services_dyndns.php*
59
##|-PRIV
60

    
61
require_once("guiconfig.inc");
62

    
63
if (!is_array($config['dyndnses']['dyndns'])) {
64
	$config['dyndnses']['dyndns'] = array();
65
}
66

    
67
$a_dyndns = &$config['dyndnses']['dyndns'];
68

    
69
if ($_GET['act'] == "del") {
70
	$conf = $a_dyndns[$_GET['id']];
71
	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
	unset($a_dyndns[$_GET['id']]);
78

    
79
	write_config();
80
	services_dyndns_configure();
81

    
82
	header("Location: services_dyndns.php");
83
	exit;
84
} else if ($_GET['act'] == "toggle") {
85
	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

    
94
		header("Location: services_dyndns.php");
95
		exit;
96
	}
97
}
98
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Dynamic DNS Clients"));
99
include("head.inc");
100

    
101
if ($input_errors) {
102
	print_input_errors($input_errors);
103
}
104

    
105
$tab_array = array();
106
$tab_array[] = array(gettext("Dynamic DNS Clients"), true, "services_dyndns.php");
107
$tab_array[] = array(gettext("RFC 2136 Clients"), false, "services_rfc2136.php");
108
display_top_tabs($tab_array);
109
?>
110
<form action="services_dyndns.php" method="post" name="iform" id="iform">
111
	<div class="panel panel-default">
112
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('Dynamic DNS Clients')?></h2></div>
113
		<div class="panel-body">
114
			<div class="table-responsive">
115
				<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
116
					<thead>
117
						<tr>
118
							<th><?=gettext("Interface")?></th>
119
							<th><?=gettext("Service")?></th>
120
							<th><?=gettext("Hostname")?></th>
121
							<th><?=gettext("Cached IP")?></th>
122
							<th><?=gettext("Description")?></th>
123
							<th><?=gettext("Actions")?></th>
124
						</tr>
125
					</thead>
126
					<tbody>
127
<?php
128
$i = 0;
129
foreach ($a_dyndns as $dyndns):
130
	if ($dyndns['type'] == "namecheap") {
131
		$hostname = $dyndns['host'] . "." . $dyndns['domainname'];
132
	} else {
133
		$hostname = $dyndns['host'];
134
	}
135
?>
136
						<tr<?=!isset($dyndns['enable'])?' class="disabled"':''?>>
137
							<td>
138
<?php
139
	$iflist = get_configured_interface_with_descr();
140
	foreach ($iflist as $if => $ifdesc) {
141
		if ($dyndns['interface'] == $if) {
142
			print($ifdesc);
143

    
144
			break;
145
		}
146
	}
147

    
148
	$groupslist = return_gateway_groups_array();
149
	foreach ($groupslist as $if => $group) {
150
		if ($dyndns['interface'] == $if) {
151
			print($if);
152
			break;
153
		}
154
	}
155
?>
156
							</td>
157
							<td>
158
<?php
159
	$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS);
160
	$vals = explode(" ", DYNDNS_PROVIDER_VALUES);
161

    
162
	for ($j = 0; $j < count($vals); $j++) {
163
		if ($vals[$j] == $dyndns['type']) {
164
			print(htmlspecialchars($types[$j]));
165

    
166
			break;
167
		}
168
	}
169
?>
170
							</td>
171
							<td>
172
<?php
173
	print(htmlspecialchars($hostname));
174
?>
175
							</td>
176
							<td>
177
<?php
178
	$filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($hostname) . "{$dyndns['id']}.cache";
179
	$filename_v6 = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($hostname) . "{$dyndns['id']}_v6.cache";
180
	if (file_exists($filename)) {
181
		$ipaddr = dyndnsCheckIP($dyndns['interface']);
182
		$cached_ip_s = explode(":", file_get_contents($filename));
183
		$cached_ip = $cached_ip_s[0];
184

    
185
		if ($ipaddr != $cached_ip) {
186
			print('<span class="text-danger">');
187
		} else {
188
			print('<span class="text-success">');
189
		}
190

    
191
		print(htmlspecialchars($cached_ip));
192
		print('</span>');
193
	} else if (file_exists($filename_v6)) {
194
		$ipv6addr = get_interface_ipv6($dyndns['interface']);
195
		$cached_ipv6_s = explode("|", file_get_contents($filename_v6));
196
		$cached_ipv6 = $cached_ipv6_s[0];
197

    
198
		if ($ipv6addr != $cached_ipv6) {
199
			print('<span class="text-danger">');
200
		} else {
201
			print('<span class="text-success">');
202
		}
203

    
204
		print(htmlspecialchars($cached_ipv6));
205
		print('</span>');
206
	} else {
207
		print('N/A');
208
	}
209
?>
210
							</td>
211
							<td>
212
<?php
213
	print(htmlspecialchars($dyndns['descr']));
214
?>
215
							</td>
216
							<td>
217
								<a class="fa fa-pencil" title="<?=gettext('Edit service')?>" href="services_dyndns_edit.php?id=<?=$i?>"></a>
218
<?php if (isset($dyndns['enable'])) {
219
?>
220
								<a class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
221
<?php } else {
222
?>
223
								<a class="fa fa-check-square-o" title="<?=gettext('Enable service')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
224
<?php }
225
?>
226
								<a class="fa fa-trash" title="<?=gettext('Delete service')?>"	href="services_dyndns.php?act=del&amp;id=<?=$i?>"></a>
227
							</td>
228
						</tr>
229
<?php
230
	$i++;
231
	endforeach;
232
?>
233
					</tbody>
234
			  </table>
235
			</div>
236
		</div>
237
	</div>
238
</form>
239

    
240
<nav class="action-buttons">
241
	<a href="services_dyndns_edit.php" class="btn btn-sm btn-success btn-sm">
242
		<i class="fa fa-plus icon-embed-btn"></i>
243
		<?=gettext('Add')?>
244
	</a>
245
</nav>
246

    
247
<div>
248
	<?=gettext('IP addresses appearing in <span class="text-success">green</span> are up to date with Dynamic DNS provider. ')?>
249
	<?=gettext('An update for an IP address can be forced on the edit page for that service.')?>
250
</div>
251

    
252
<?php
253
include("foot.inc");
(126-126/225)