Project

General

Profile

Download (6.2 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
include("head.inc");
69

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

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

    
114
			break;
115
		}
116
	}
117

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

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

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

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

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

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

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

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

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

    
222
<?php
223
include("foot.inc");
(126-126/225)