Project

General

Profile

Download (6.48 KB) Statistics
| Branch: | Tag: | Revision:
1 d03efa9c Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3 c5d81585 Renato Botelho
 * services_dyndns.php
4 df4957e4 Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 81299b5c Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 c5d81585 Renato Botelho
 * All rights reserved.
8 df4957e4 Stephen Beaver
 *
9 b12ea3fb Renato Botelho
 * 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 df4957e4 Stephen Beaver
 *
13 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
14 df4957e4 Stephen Beaver
 *
15 b12ea3fb Renato Botelho
 * 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 df4957e4 Stephen Beaver
 */
21 5b237745 Scott Ullrich
22 6b07c15a Matthew Grooms
##|+PRIV
23
##|*IDENT=page-services-dynamicdnsclients
24 5230f468 jim-p
##|*NAME=Services: Dynamic DNS clients
25 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Services: Dynamic DNS clients' page.
26
##|*MATCH=services_dyndns.php*
27
##|-PRIV
28
29 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
30 5b237745 Scott Ullrich
31 9c12c130 Phil Davis
if (!is_array($config['dyndnses']['dyndns'])) {
32 f1f60c92 Ermal Luçi
	$config['dyndnses']['dyndns'] = array();
33 9c12c130 Phil Davis
}
34 5b237745 Scott Ullrich
35 f1f60c92 Ermal Luçi
$a_dyndns = &$config['dyndnses']['dyndns'];
36 2446fffa jim-p
global $dyndns_split_domain_types;
37 d03efa9c Scott Ullrich
38 13541a81 Steve Beaver
if ($_POST['act'] == "del") {
39
	$conf = $a_dyndns[$_POST['id']];
40 2446fffa jim-p
	if (in_array($conf['type'], $dyndns_split_domain_types)) {
41 6635aa0f jim-p
		$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 13541a81 Steve Beaver
	unset($a_dyndns[$_POST['id']]);
47 37f3e704 Matt Corallo
48 830cafe8 doktornotor
	write_config(gettext("Dynamic DNS client deleted."));
49 5a39eb2b bcyrill
	services_dyndns_configure();
50 37f3e704 Matt Corallo
51 5a39eb2b bcyrill
	header("Location: services_dyndns.php");
52
	exit;
53 13541a81 Steve Beaver
} 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 830cafe8 doktornotor
			$wc_msg = gettext('Dynamic DNS client disabled.');
58 e5e89876 heper
		} else {
59 13541a81 Steve Beaver
			$a_dyndns[$_POST['id']]['enable'] = true;
60 830cafe8 doktornotor
			$wc_msg = gettext('Dynamic DNS client enabled.');
61 e5e89876 heper
		}
62 830cafe8 doktornotor
		write_config($wc_msg);
63 e5e89876 heper
		services_dyndns_configure();
64 c9679d8c Stephen Beaver
65 e5e89876 heper
		header("Location: services_dyndns.php");
66
		exit;
67
	}
68
}
69 13541a81 Steve Beaver
70 c8f6b745 k-paulius
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Dynamic DNS Clients"));
71 edcd7535 Phil Davis
$pglinks = array("", "@self", "@self");
72 4df96eff Scott Ullrich
include("head.inc");
73
74 6e3488e9 Phil Davis
if ($input_errors) {
75 f5606ded sbeaver
	print_input_errors($input_errors);
76 6e3488e9 Phil Davis
}
77 4df96eff Scott Ullrich
78 f5606ded sbeaver
$tab_array = array();
79 c8f6b745 k-paulius
$tab_array[] = array(gettext("Dynamic DNS Clients"), true, "services_dyndns.php");
80
$tab_array[] = array(gettext("RFC 2136 Clients"), false, "services_rfc2136.php");
81 39d2f39d NOYB
$tab_array[] = array(gettext("Check IP Services"), false, "services_checkip.php");
82 f5606ded sbeaver
display_top_tabs($tab_array);
83
?>
84 f1f60c92 Ermal Luçi
<form action="services_dyndns.php" method="post" name="iform" id="iform">
85 060ed238 Stephen Beaver
	<div class="panel panel-default">
86 f0efd690 Phil Davis
		<div class="panel-heading"><h2 class="panel-title"><?=gettext('Dynamic DNS Clients')?></h2></div>
87 060ed238 Stephen Beaver
		<div class="panel-body">
88
			<div class="table-responsive">
89 1c10ce97 PiBa-NL
				<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
90 060ed238 Stephen Beaver
					<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 f1f60c92 Ermal Luçi
<?php
102 f5606ded sbeaver
$i = 0;
103
foreach ($a_dyndns as $dyndns):
104 2446fffa jim-p
	if (in_array($dyndns['type'], $dyndns_split_domain_types)) {
105 6635aa0f jim-p
		$hostname = $dyndns['host'] . "." . $dyndns['domainname'];
106
	} else {
107
		$hostname = $dyndns['host'];
108
	}
109 f1f60c92 Ermal Luçi
?>
110 060ed238 Stephen Beaver
						<tr<?=!isset($dyndns['enable'])?' class="disabled"':''?>>
111
							<td>
112 f5606ded sbeaver
<?php
113
	$iflist = get_configured_interface_with_descr();
114
	foreach ($iflist as $if => $ifdesc) {
115
		if ($dyndns['interface'] == $if) {
116 71dbcc11 Sjon Hortensius
			print($ifdesc);
117 f5606ded sbeaver
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 71dbcc11 Sjon Hortensius
			break;
127 f5606ded sbeaver
		}
128 71dbcc11 Sjon Hortensius
	}
129 f5606ded sbeaver
?>
130 060ed238 Stephen Beaver
							</td>
131
							<td>
132 f5606ded sbeaver
<?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 71dbcc11 Sjon Hortensius
			print(htmlspecialchars($types[$j]));
139 f5606ded sbeaver
140
			break;
141
		}
142
	}
143
?>
144 060ed238 Stephen Beaver
							</td>
145
							<td>
146 f5606ded sbeaver
<?php
147 138e79d4 Phil Davis
	print(insert_word_breaks_in_domain_name(htmlspecialchars($hostname)));
148 f5606ded sbeaver
?>
149 060ed238 Stephen Beaver
							</td>
150
							<td>
151 f5606ded sbeaver
<?php
152 6635aa0f jim-p
	$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 f5606ded sbeaver
	if (file_exists($filename)) {
155
		$ipaddr = dyndnsCheckIP($dyndns['interface']);
156 d51cdd48 Renato Botelho
		$cached_ip_s = explode("|", file_get_contents($filename));
157 f5606ded sbeaver
		$cached_ip = $cached_ip_s[0];
158
159 6e3488e9 Phil Davis
		if ($ipaddr != $cached_ip) {
160 9c9617a5 Jared Dillard
			print('<span class="text-danger">');
161 6e3488e9 Phil Davis
		} else {
162 9c9617a5 Jared Dillard
			print('<span class="text-success">');
163 6e3488e9 Phil Davis
		}
164 f5606ded sbeaver
165
		print(htmlspecialchars($cached_ip));
166 9c9617a5 Jared Dillard
		print('</span>');
167 f5606ded sbeaver
	} 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 6e3488e9 Phil Davis
		if ($ipv6addr != $cached_ipv6) {
173 9c9617a5 Jared Dillard
			print('<span class="text-danger">');
174 6e3488e9 Phil Davis
		} else {
175 9c9617a5 Jared Dillard
			print('<span class="text-success">');
176 6e3488e9 Phil Davis
		}
177 f5606ded sbeaver
178
		print(htmlspecialchars($cached_ipv6));
179 9c9617a5 Jared Dillard
		print('</span>');
180 f5606ded sbeaver
	} else {
181
		print('N/A');
182
	}
183
?>
184 060ed238 Stephen Beaver
							</td>
185
							<td>
186 f5606ded sbeaver
<?php
187 71dbcc11 Sjon Hortensius
	print(htmlspecialchars($dyndns['descr']));
188 f5606ded sbeaver
?>
189 060ed238 Stephen Beaver
							</td>
190
							<td>
191
								<a class="fa fa-pencil" title="<?=gettext('Edit service')?>" href="services_dyndns_edit.php?id=<?=$i?>"></a>
192 c9679d8c Stephen Beaver
<?php if (isset($dyndns['enable'])) {
193
?>
194 13541a81 Steve Beaver
								<a class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&amp;id=<?=$i?>" usepost></a>
195 c9679d8c Stephen Beaver
<?php } else {
196
?>
197 13541a81 Steve Beaver
								<a class="fa fa-check-square-o" title="<?=gettext('Enable service')?>" href="?act=toggle&amp;id=<?=$i?>" usepost></a>
198 c9679d8c Stephen Beaver
<?php }
199
?>
200 13541a81 Steve Beaver
								<a class="fa fa-trash" title="<?=gettext('Delete service')?>"	href="services_dyndns.php?act=del&amp;id=<?=$i?>" usepost></a>
201 060ed238 Stephen Beaver
							</td>
202
						</tr>
203 f5606ded sbeaver
<?php
204
	$i++;
205
	endforeach;
206
?>
207 060ed238 Stephen Beaver
					</tbody>
208
			  </table>
209
			</div>
210
		</div>
211 f5606ded sbeaver
	</div>
212 5b237745 Scott Ullrich
</form>
213 f5606ded sbeaver
214
<nav class="action-buttons">
215 c9679d8c Stephen Beaver
	<a href="services_dyndns_edit.php" class="btn btn-sm btn-success btn-sm">
216 9d5a20cf heper
		<i class="fa fa-plus icon-embed-btn"></i>
217 c9679d8c Stephen Beaver
		<?=gettext('Add')?>
218
	</a>
219 f5606ded sbeaver
</nav>
220
221 df4957e4 Stephen Beaver
<div>
222 3fd41815 Phil Davis
	<?=sprintf(gettext('IP addresses appearing in %1$sgreen%2$s are up to date with Dynamic DNS provider. '), '<span class="text-success">', '</span>')?>
223 f6800641 NOYB
	<?=gettext('An update for an IP address can be forced on the edit page for that service.')?>
224 df4957e4 Stephen Beaver
</div>
225 f5606ded sbeaver
226 df4957e4 Stephen Beaver
<?php
227 e5e89876 heper
include("foot.inc");