Project

General

Profile

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

    
145
			break;
146
		}
147
	}
148

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

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

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

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

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

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

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

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

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

    
253
<?php
254
include("foot.inc");
(128-128/227)