Project

General

Profile

Download (6.55 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-2018 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'])){
32
	$config['dyndnses'] = array();
33
}
34

    
35
if (!is_array($config['dyndnses']['dyndns'])) {
36
	$config['dyndnses']['dyndns'] = array();
37
}
38

    
39
$a_dyndns = &$config['dyndnses']['dyndns'];
40
global $dyndns_split_domain_types;
41

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

    
52
	write_config(gettext("Dynamic DNS client deleted."));
53
	services_dyndns_configure();
54

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

    
69
		header("Location: services_dyndns.php");
70
		exit;
71
	}
72
}
73

    
74
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Dynamic DNS Clients"));
75
$pglinks = array("", "@self", "@self");
76
include("head.inc");
77

    
78
if ($input_errors) {
79
	print_input_errors($input_errors);
80
}
81

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

    
122
			break;
123
		}
124
	}
125

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

    
140
	for ($j = 0; $j < count($vals); $j++) {
141
		if ($vals[$j] == $dyndns['type']) {
142
			print(htmlspecialchars($types[$j]));
143

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

    
163
		if ($ipaddr != $cached_ip) {
164
			print('<span class="text-danger">');
165
		} else {
166
			print('<span class="text-success">');
167
		}
168

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

    
176
		if ($ipv6addr != $cached_ipv6) {
177
			print('<span class="text-danger">');
178
		} else {
179
			print('<span class="text-success">');
180
		}
181

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

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

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

    
230
<?php
231
include("foot.inc");
(133-133/234)