Project

General

Profile

Download (7.47 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("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="panel panel-default">
109
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('Dynamic DNS Clients')?></h2></div>
110
		<div class="panel-body">
111
			<div class="table-responsive">
112
				<table class="table table-striped table-hover table-condensed">
113
					<thead>
114
						<tr>
115
							<th><?=gettext("Interface")?></th>
116
							<th><?=gettext("Service")?></th>
117
							<th><?=gettext("Hostname")?></th>
118
							<th><?=gettext("Cached IP")?></th>
119
							<th><?=gettext("Description")?></th>
120
							<th><?=gettext("Actions")?></th>
121
						</tr>
122
					</thead>
123
					<tbody>
124
<?php
125
$i = 0;
126
foreach ($a_dyndns as $dyndns):
127
?>
128
						<tr<?=!isset($dyndns['enable'])?' class="disabled"':''?>>
129
							<td>
130
<?php
131
	$iflist = get_configured_interface_with_descr();
132
	foreach ($iflist as $if => $ifdesc) {
133
		if ($dyndns['interface'] == $if) {
134
			print($ifdesc);
135

    
136
			break;
137
		}
138
	}
139

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

    
154
	for ($j = 0; $j < count($vals); $j++) {
155
		if ($vals[$j] == $dyndns['type']) {
156
			print(htmlspecialchars($types[$j]));
157

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

    
177
		if ($ipaddr != $cached_ip) {
178
			print('<span class="text-danger">');
179
		} else {
180
			print('<span class="text-success">');
181
		}
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

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

    
232
<nav class="action-buttons">
233
	<a href="services_dyndns_edit.php" class="btn btn-sm btn-success btn-sm">
234
		<i class="fa fa-plus icon-embed-btn"></i>
235
		<?=gettext('Add')?>
236
	</a>
237
</nav>
238

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

    
244
<?php
245
include("foot.inc");
(127-127/229)