Project

General

Profile

Download (6.3 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();
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
		} else {
58
			$a_dyndns[$_POST['id']]['enable'] = true;
59
		}
60
		write_config();
61
		services_dyndns_configure();
62

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

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

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

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

    
116
			break;
117
		}
118
	}
119

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

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

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

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

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

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

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

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

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

    
224
<?php
225
include("foot.inc");
(124-124/223)