Project

General

Profile

Download (7.94 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 Rubicon Communications, LLC (Netgate)
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
global $dyndns_split_domain_types;
69

    
70
if ($_GET['act'] == "del") {
71
	$conf = $a_dyndns[$_GET['id']];
72
	if (in_array($conf['type'], $dyndns_split_domain_types)) {
73
		$hostname = $conf['host'] . "." . $conf['domainname'];
74
	} else {
75
		$hostname = $conf['host'];
76
	}
77
	@unlink("{$g['conf_path']}/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($hostname) . "{$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
} else if ($_GET['act'] == "toggle") {
86
	if ($a_dyndns[$_GET['id']]) {
87
		if (isset($a_dyndns[$_GET['id']]['enable'])) {
88
			unset($a_dyndns[$_GET['id']]['enable']);
89
		} else {
90
			$a_dyndns[$_GET['id']]['enable'] = true;
91
		}
92
		write_config();
93
		services_dyndns_configure();
94

    
95
		header("Location: services_dyndns.php");
96
		exit;
97
	}
98
}
99
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Dynamic DNS Clients"));
100
$pglinks = array("", "@self", "@self");
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
$tab_array[] = array(gettext("Check IP Services"), false, "services_checkip.php");
111
display_top_tabs($tab_array);
112
?>
113
<form action="services_dyndns.php" method="post" name="iform" id="iform">
114
	<div class="panel panel-default">
115
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('Dynamic DNS Clients')?></h2></div>
116
		<div class="panel-body">
117
			<div class="table-responsive">
118
				<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
119
					<thead>
120
						<tr>
121
							<th><?=gettext("Interface")?></th>
122
							<th><?=gettext("Service")?></th>
123
							<th><?=gettext("Hostname")?></th>
124
							<th><?=gettext("Cached IP")?></th>
125
							<th><?=gettext("Description")?></th>
126
							<th><?=gettext("Actions")?></th>
127
						</tr>
128
					</thead>
129
					<tbody>
130
<?php
131
$i = 0;
132
foreach ($a_dyndns as $dyndns):
133
	if (in_array($dyndns['type'], $dyndns_split_domain_types)) {
134
		$hostname = $dyndns['host'] . "." . $dyndns['domainname'];
135
	} else {
136
		$hostname = $dyndns['host'];
137
	}
138
?>
139
						<tr<?=!isset($dyndns['enable'])?' class="disabled"':''?>>
140
							<td>
141
<?php
142
	$iflist = get_configured_interface_with_descr();
143
	foreach ($iflist as $if => $ifdesc) {
144
		if ($dyndns['interface'] == $if) {
145
			print($ifdesc);
146

    
147
			break;
148
		}
149
	}
150

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

    
165
	for ($j = 0; $j < count($vals); $j++) {
166
		if ($vals[$j] == $dyndns['type']) {
167
			print(htmlspecialchars($types[$j]));
168

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

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

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

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

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

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

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

    
255
<?php
256
include("foot.inc");
(126-126/225)