Project

General

Profile

Download (6.66 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-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2020 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * Licensed under the Apache License, Version 2.0 (the "License");
12
 * you may not use this file except in compliance with the License.
13
 * You may obtain a copy of the License at
14
 *
15
 * http://www.apache.org/licenses/LICENSE-2.0
16
 *
17
 * Unless required by applicable law or agreed to in writing, software
18
 * distributed under the License is distributed on an "AS IS" BASIS,
19
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
 * See the License for the specific language governing permissions and
21
 * limitations under the License.
22
 */
23

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

    
31
require_once("guiconfig.inc");
32

    
33
init_config_arr(array('dyndnses', 'dyndns'));
34
$a_dyndns = &$config['dyndnses']['dyndns'];
35
global $dyndns_split_domain_types;
36

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

    
47
	write_config(gettext("Dynamic DNS client deleted."));
48
	services_dyndns_configure();
49

    
50
	header("Location: services_dyndns.php");
51
	exit;
52
} else if ($_POST['act'] == "toggle") {
53
	if ($a_dyndns[$_POST['id']]) {
54
		if (isset($a_dyndns[$_POST['id']]['enable'])) {
55
			unset($a_dyndns[$_POST['id']]['enable']);
56
			$wc_msg = gettext('Dynamic DNS client disabled.');
57
		} else {
58
			$a_dyndns[$_POST['id']]['enable'] = true;
59
			$wc_msg = gettext('Dynamic DNS client enabled.');
60
		}
61
		write_config($wc_msg);
62
		services_dyndns_configure();
63

    
64
		header("Location: services_dyndns.php");
65
		exit;
66
	}
67
}
68

    
69
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Dynamic DNS Clients"));
70
$pglinks = array("", "@self", "@self");
71
include("head.inc");
72

    
73
if ($input_errors) {
74
	print_input_errors($input_errors);
75
}
76

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

    
117
			break;
118
		}
119
	}
120

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

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

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

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

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

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

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

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

    
221
<div>
222
	<?=sprintf(gettext('IP addresses appearing in %1$sgreen%2$s are up to date with Dynamic DNS provider. '), '<span class="text-success">', '</span>')?>
223
	<?=gettext('An update for an IP address can be forced on the edit page for that service.')?>
224
</div>
225

    
226
<?php
227
include("foot.inc");
(128-128/228)