Project

General

Profile

Download (6.24 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
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12
 *
13
 * http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20
 */
21

    
22
##|+PRIV
23
##|*IDENT=page-services-dynamicdnsclients
24
##|*NAME=Services: Dynamic DNS clients
25
##|*DESCR=Allow access to the 'Services: Dynamic DNS clients' page.
26
##|*MATCH=services_dyndns.php*
27
##|-PRIV
28

    
29
require_once("guiconfig.inc");
30

    
31
if (!is_array($config['dyndnses']['dyndns'])) {
32
	$config['dyndnses']['dyndns'] = array();
33
}
34

    
35
$a_dyndns = &$config['dyndnses']['dyndns'];
36
global $dyndns_split_domain_types;
37

    
38
if ($_GET['act'] == "del") {
39
	$conf = $a_dyndns[$_GET['id']];
40
	if (in_array($conf['type'], $dyndns_split_domain_types)) {
41
		$hostname = $conf['host'] . "." . $conf['domainname'];
42
	} else {
43
		$hostname = $conf['host'];
44
	}
45
	@unlink("{$g['conf_path']}/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($hostname) . "{$conf['id']}.cache");
46
	unset($a_dyndns[$_GET['id']]);
47

    
48
	write_config();
49
	services_dyndns_configure();
50

    
51
	header("Location: services_dyndns.php");
52
	exit;
53
} else if ($_GET['act'] == "toggle") {
54
	if ($a_dyndns[$_GET['id']]) {
55
		if (isset($a_dyndns[$_GET['id']]['enable'])) {
56
			unset($a_dyndns[$_GET['id']]['enable']);
57
		} else {
58
			$a_dyndns[$_GET['id']]['enable'] = true;
59
		}
60
		write_config();
61
		services_dyndns_configure();
62

    
63
		header("Location: services_dyndns.php");
64
		exit;
65
	}
66
}
67
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Dynamic DNS Clients"));
68
$pglinks = array("", "@self", "@self");
69
include("head.inc");
70

    
71
if ($input_errors) {
72
	print_input_errors($input_errors);
73
}
74

    
75
$tab_array = array();
76
$tab_array[] = array(gettext("Dynamic DNS Clients"), true, "services_dyndns.php");
77
$tab_array[] = array(gettext("RFC 2136 Clients"), false, "services_rfc2136.php");
78
$tab_array[] = array(gettext("Check IP Services"), false, "services_checkip.php");
79
display_top_tabs($tab_array);
80
?>
81
<form action="services_dyndns.php" method="post" name="iform" id="iform">
82
	<div class="panel panel-default">
83
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('Dynamic DNS Clients')?></h2></div>
84
		<div class="panel-body">
85
			<div class="table-responsive">
86
				<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
87
					<thead>
88
						<tr>
89
							<th><?=gettext("Interface")?></th>
90
							<th><?=gettext("Service")?></th>
91
							<th><?=gettext("Hostname")?></th>
92
							<th><?=gettext("Cached IP")?></th>
93
							<th><?=gettext("Description")?></th>
94
							<th><?=gettext("Actions")?></th>
95
						</tr>
96
					</thead>
97
					<tbody>
98
<?php
99
$i = 0;
100
foreach ($a_dyndns as $dyndns):
101
	if (in_array($dyndns['type'], $dyndns_split_domain_types)) {
102
		$hostname = $dyndns['host'] . "." . $dyndns['domainname'];
103
	} else {
104
		$hostname = $dyndns['host'];
105
	}
106
?>
107
						<tr<?=!isset($dyndns['enable'])?' class="disabled"':''?>>
108
							<td>
109
<?php
110
	$iflist = get_configured_interface_with_descr();
111
	foreach ($iflist as $if => $ifdesc) {
112
		if ($dyndns['interface'] == $if) {
113
			print($ifdesc);
114

    
115
			break;
116
		}
117
	}
118

    
119
	$groupslist = return_gateway_groups_array();
120
	foreach ($groupslist as $if => $group) {
121
		if ($dyndns['interface'] == $if) {
122
			print($if);
123
			break;
124
		}
125
	}
126
?>
127
							</td>
128
							<td>
129
<?php
130
	$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS);
131
	$vals = explode(" ", DYNDNS_PROVIDER_VALUES);
132

    
133
	for ($j = 0; $j < count($vals); $j++) {
134
		if ($vals[$j] == $dyndns['type']) {
135
			print(htmlspecialchars($types[$j]));
136

    
137
			break;
138
		}
139
	}
140
?>
141
							</td>
142
							<td>
143
<?php
144
	print(htmlspecialchars($hostname));
145
?>
146
							</td>
147
							<td>
148
<?php
149
	$filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($hostname) . "{$dyndns['id']}.cache";
150
	$filename_v6 = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($hostname) . "{$dyndns['id']}_v6.cache";
151
	if (file_exists($filename)) {
152
		$ipaddr = dyndnsCheckIP($dyndns['interface']);
153
		$cached_ip_s = explode(":", file_get_contents($filename));
154
		$cached_ip = $cached_ip_s[0];
155

    
156
		if ($ipaddr != $cached_ip) {
157
			print('<span class="text-danger">');
158
		} else {
159
			print('<span class="text-success">');
160
		}
161

    
162
		print(htmlspecialchars($cached_ip));
163
		print('</span>');
164
	} else if (file_exists($filename_v6)) {
165
		$ipv6addr = get_interface_ipv6($dyndns['interface']);
166
		$cached_ipv6_s = explode("|", file_get_contents($filename_v6));
167
		$cached_ipv6 = $cached_ipv6_s[0];
168

    
169
		if ($ipv6addr != $cached_ipv6) {
170
			print('<span class="text-danger">');
171
		} else {
172
			print('<span class="text-success">');
173
		}
174

    
175
		print(htmlspecialchars($cached_ipv6));
176
		print('</span>');
177
	} else {
178
		print('N/A');
179
	}
180
?>
181
							</td>
182
							<td>
183
<?php
184
	print(htmlspecialchars($dyndns['descr']));
185
?>
186
							</td>
187
							<td>
188
								<a class="fa fa-pencil" title="<?=gettext('Edit service')?>" href="services_dyndns_edit.php?id=<?=$i?>"></a>
189
<?php if (isset($dyndns['enable'])) {
190
?>
191
								<a class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
192
<?php } else {
193
?>
194
								<a class="fa fa-check-square-o" title="<?=gettext('Enable service')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
195
<?php }
196
?>
197
								<a class="fa fa-trash" title="<?=gettext('Delete service')?>"	href="services_dyndns.php?act=del&amp;id=<?=$i?>"></a>
198
							</td>
199
						</tr>
200
<?php
201
	$i++;
202
	endforeach;
203
?>
204
					</tbody>
205
			  </table>
206
			</div>
207
		</div>
208
	</div>
209
</form>
210

    
211
<nav class="action-buttons">
212
	<a href="services_dyndns_edit.php" class="btn btn-sm btn-success btn-sm">
213
		<i class="fa fa-plus icon-embed-btn"></i>
214
		<?=gettext('Add')?>
215
	</a>
216
</nav>
217

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

    
223
<?php
224
include("foot.inc");
(124-124/223)