Project

General

Profile

Download (6.11 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 Electric Sheep Fencing, LLC
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

    
37
if ($_GET['act'] == "del") {
38
	$conf = $a_dyndns[$_GET['id']];
39
	if ($conf['type'] == "namecheap") {
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[$_GET['id']]);
46

    
47
	write_config();
48
	services_dyndns_configure();
49

    
50
	header("Location: services_dyndns.php");
51
	exit;
52
} else if ($_GET['act'] == "toggle") {
53
	if ($a_dyndns[$_GET['id']]) {
54
		if (isset($a_dyndns[$_GET['id']]['enable'])) {
55
			unset($a_dyndns[$_GET['id']]['enable']);
56
		} else {
57
			$a_dyndns[$_GET['id']]['enable'] = true;
58
		}
59
		write_config();
60
		services_dyndns_configure();
61

    
62
		header("Location: services_dyndns.php");
63
		exit;
64
	}
65
}
66
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Dynamic DNS Clients"));
67
include("head.inc");
68

    
69
if ($input_errors) {
70
	print_input_errors($input_errors);
71
}
72

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

    
113
			break;
114
		}
115
	}
116

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

    
131
	for ($j = 0; $j < count($vals); $j++) {
132
		if ($vals[$j] == $dyndns['type']) {
133
			print(htmlspecialchars($types[$j]));
134

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

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

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

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

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

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

    
216
<div>
217
	<?=gettext('IP addresses appearing in <span class="text-success">green</span> are up to date with Dynamic DNS provider. ')?>
218
	<?=gettext('An update for an IP address can be forced on the edit page for that service.')?>
219
</div>
220

    
221
<?php
222
include("foot.inc");
(128-128/227)