Project

General

Profile

Download (7.24 KB) Statistics
| Branch: | Tag: | Revision:
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
	@unlink("{$g['conf_path']}/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($conf['host']) . "{$conf['id']}.cache");
74
	unset($a_dyndns[$_GET['id']]);
75

    
76
	write_config();
77
	services_dyndns_configure();
78

    
79
	header("Location: services_dyndns.php");
80
	exit;
81
} else if ($_GET['act'] == "toggle") {
82
	if ($a_dyndns[$_GET['id']]) {
83
		if (isset($a_dyndns[$_GET['id']]['enable'])) {
84
			unset($a_dyndns[$_GET['id']]['enable']);
85
		} else {
86
			$a_dyndns[$_GET['id']]['enable'] = true;
87
		}
88
		write_config();
89
		services_dyndns_configure();
90

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

    
98
if ($input_errors) {
99
	print_input_errors($input_errors);
100
}
101

    
102
$tab_array = array();
103
$tab_array[] = array(gettext("Dynamic DNS"), true, "services_dyndns.php");
104
$tab_array[] = array(gettext("RFC 2136"), false, "services_rfc2136.php");
105
display_top_tabs($tab_array);
106
?>
107
<form action="services_dyndns.php" method="post" name="iform" id="iform">
108
	<div class="table-responsive">
109
		<table class="table table-striped table-hover table-condensed">
110
			<thead>
111
				<tr>
112
					<th><?=gettext("Interface")?></th>
113
					<th><?=gettext("Service")?></th>
114
					<th><?=gettext("Hostname")?></th>
115
					<th><?=gettext("Cached IP")?></th>
116
					<th><?=gettext("Description")?></th>
117
					<th><?=gettext("Actions")?></th>
118
				</tr>
119
			</thead>
120
			<tbody>
121
<?php
122
$i = 0;
123
foreach ($a_dyndns as $dyndns):
124
?>
125
				<tr<?=!isset($dyndns['enable'])?' class="disabled""':''?>>
126
					<td>
127
<?php
128
	$iflist = get_configured_interface_with_descr();
129
	foreach ($iflist as $if => $ifdesc) {
130
		if ($dyndns['interface'] == $if) {
131
			print($ifdesc);
132

    
133
			break;
134
		}
135
	}
136

    
137
	$groupslist = return_gateway_groups_array();
138
	foreach ($groupslist as $if => $group) {
139
		if ($dyndns['interface'] == $if) {
140
			print($if);
141
			break;
142
		}
143
	}
144
?>
145
					</td>
146
					<td>
147
<?php
148
	$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS);
149
	$vals = explode(" ", DYNDNS_PROVIDER_VALUES);
150

    
151
	for ($j = 0; $j < count($vals); $j++) {
152
		if ($vals[$j] == $dyndns['type']) {
153
			print(htmlspecialchars($types[$j]));
154

    
155
			break;
156
		}
157
	}
158
?>
159
					</td>
160
					<td>
161
<?php
162
	print(htmlspecialchars($dyndns['host']));
163
?>
164
					</td>
165
					<td>
166
<?php
167
	$filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
168
	$filename_v6 = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}_v6.cache";
169
	if (file_exists($filename)) {
170
		$ipaddr = dyndnsCheckIP($dyndns['interface']);
171
		$cached_ip_s = explode(":", file_get_contents($filename));
172
		$cached_ip = $cached_ip_s[0];
173

    
174
		if ($ipaddr != $cached_ip) {
175
			print('<span class="text-danger">');
176
		} else {
177
			print('<span class="text-success">');
178
		}
179

    
180
		print(htmlspecialchars($cached_ip));
181
		print('</span>');
182
	} else if (file_exists($filename_v6)) {
183
		$ipv6addr = get_interface_ipv6($dyndns['interface']);
184
		$cached_ipv6_s = explode("|", file_get_contents($filename_v6));
185
		$cached_ipv6 = $cached_ipv6_s[0];
186

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

    
193
		print(htmlspecialchars($cached_ipv6));
194
		print('</span>');
195
	} else {
196
		print('N/A');
197
	}
198
?>
199
					</td>
200
					<td>
201
<?php
202
	print(htmlspecialchars($dyndns['descr']));
203
?>
204
					</td>
205
					<td>
206
						<a class="fa fa-pencil"	title="<?=gettext('Edit service')?>" href="services_dyndns_edit.php?id=<?=$i?>"></a>
207
<?php if (isset($dyndns['enable'])) {
208
?>
209
						<a class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
210
<?php } else {
211
?>
212
						<a class="fa fa-check-square-o"	title="<?=gettext('Enable service')?>" href="?act=toggle&amp;id=<?=$i?>" ></a>
213
<?php }
214
?>
215
						<a class="fa fa-trash" title="<?=gettext('Delete service')?>"	href="services_dyndns.php?act=del&amp;id=<?=$i?>"></a>
216
					</td>
217
				</tr>
218
<?php
219
	$i++;
220
	endforeach;
221
?>
222
			</tbody>
223
	  </table>
224
	</div>
225
</form>
226

    
227
<nav class="action-buttons">
228
	<a href="services_dyndns_edit.php" class="btn btn-sm btn-success btn-sm">
229
		<i class="fa fa-plus icon-embed-btn"></i>
230
		<?=gettext('Add')?>
231
	</a>
232
</nav>
233

    
234
<div>
235
	<?=gettext('IP addresses appearing in <span class="text-success">green</span> are up to date with Dynamic DNS provider. ')?>
236
	<?=gettext('You can force an update for an IP address on the edit page for that service.')?>
237
</div>
238

    
239
<?php
240
include("foot.inc");
(127-127/228)