Project

General

Profile

Download (6.48 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 ($_POST['act'] == "del") {
39
	$conf = $a_dyndns[$_POST['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[$_POST['id']]);
47

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

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

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

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

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

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

    
118
			break;
119
		}
120
	}
121

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

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

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

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

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

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

    
178
		print(htmlspecialchars($cached_ipv6));
179
		print('</span>');
180
	} else {
181
		print('N/A');
182
	}
183
?>
184
							</td>
185
							<td>
186
<?php
187
	print(htmlspecialchars($dyndns['descr']));
188
?>
189
							</td>
190
							<td>
191
								<a class="fa fa-pencil" title="<?=gettext('Edit service')?>" href="services_dyndns_edit.php?id=<?=$i?>"></a>
192
<?php if (isset($dyndns['enable'])) {
193
?>
194
								<a class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&amp;id=<?=$i?>" usepost></a>
195
<?php } else {
196
?>
197
								<a class="fa fa-check-square-o" title="<?=gettext('Enable service')?>" href="?act=toggle&amp;id=<?=$i?>" usepost></a>
198
<?php }
199
?>
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");
(130-130/229)