Project

General

Profile

Download (7.14 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	services_dyndns.php
5

    
6
	Copyright (C) 2008 Ermal Luçi
7
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
8
	All rights reserved.
9

    
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

    
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15

    
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19

    
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31
/*
32
	pfSense_BUILDER_BINARIES:	/usr/bin/host
33
	pfSense_MODULE:	dyndns
34
*/
35

    
36
##|+PRIV
37
##|*IDENT=page-services-dynamicdnsclients
38
##|*NAME=Services: Dynamic DNS clients page
39
##|*DESCR=Allow access to the 'Services: Dynamic DNS clients' page.
40
##|*MATCH=services_dyndns.php*
41
##|-PRIV
42

    
43
require("guiconfig.inc");
44

    
45
if (!is_array($config['dyndnses']['dyndns'])) {
46
	$config['dyndnses']['dyndns'] = array();
47
}
48

    
49
$a_dyndns = &$config['dyndnses']['dyndns'];
50

    
51
if ($_GET['act'] == "del") {
52

    
53
	$conf = $a_dyndns[$_GET['id']];
54
	@unlink("{$g['conf_path']}/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($conf['host']) . "{$conf['id']}.cache");
55
	unset($a_dyndns[$_GET['id']]);
56

    
57
	write_config();
58
	services_dyndns_configure();
59

    
60
	header("Location: services_dyndns.php");
61
	exit;
62
}
63

    
64
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS clients"));
65
include("head.inc");
66

    
67
?>
68

    
69
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
70
<?php include("fbegin.inc"); ?>
71
<form action="services_dyndns.php" method="post" name="iform" id="iform">
72
<?php if ($input_errors) print_input_errors($input_errors); ?>
73
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="dynamic dns">
74
	<tr>
75
		<td>
76
<?php
77
	$tab_array = array();
78
	$tab_array[] = array(gettext("DynDns"), true, "services_dyndns.php");
79
	$tab_array[] = array(gettext("RFC 2136"), false, "services_rfc2136.php");
80
	display_top_tabs($tab_array);
81
?>
82
		</td>
83
	</tr>
84
	<tr>
85
		<td>
86
			<div id="mainarea">
87
			<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
88
				<tr>
89
					<td width="5%"  class="listhdrr"><?=gettext("Interface");?></td>
90
					<td width="15%" class="listhdrr"><?=gettext("Service");?></td>
91
					<td width="20%" class="listhdrr"><?=gettext("Hostname");?></td>
92
					<td width="20%" class="listhdrr"><?=gettext("Cached IP");?></td>
93
					<td width="50%" class="listhdr"><?=gettext("Description");?></td>
94
					<td width="10%" class="list"></td>
95
				</tr>
96
<?php
97
	$i = 0;
98
	foreach ($a_dyndns as $dyndns):
99
?>
100
				<tr ondblclick="document.location='services_dyndns_edit.php?id=<?=$i;?>'">
101
					<td class="listlr">
102
<?php
103
		$iflist = get_configured_interface_with_descr();
104
		foreach ($iflist as $if => $ifdesc) {
105
			if ($dyndns['interface'] == $if) {
106
				if (!isset($dyndns['enable'])) {
107
					echo "<span class=\"gray\">{$ifdesc}</span>";
108
				} else {
109
					echo "{$ifdesc}";
110
				}
111
				break;
112
			}
113
		}
114
		$groupslist = return_gateway_groups_array();
115
		foreach ($groupslist as $if => $group) {
116
			if ($dyndns['interface'] == $if) {
117
				if (!isset($dyndns['enable'])) {
118
					echo "<span class=\"gray\">{$if}</span>";
119
				} else {
120
					echo "{$if}";
121
				}
122
				break;
123
			}
124
		}
125
?>
126
					</td>
127
					<td class="listr">
128
<?php
129
		$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS);
130
		$vals = explode(" ", DYNDNS_PROVIDER_VALUES);
131
		for ($j = 0; $j < count($vals); $j++) {
132
			if ($vals[$j] == $dyndns['type']) {
133
				if (!isset($dyndns['enable'])) {
134
					echo "<span class=\"gray\">" . htmlspecialchars($types[$j]) . "</span>";
135
				} else {
136
					echo htmlspecialchars($types[$j]);
137
				}
138
				break;
139
			}
140
		}
141
?>
142
					</td>
143
					<td class="listr">
144
<?php
145
		if (!isset($dyndns['enable'])) {
146
			echo "<span class=\"gray\">" . htmlspecialchars($dyndns['host']) . "</span>";
147
		} else {
148
			echo htmlspecialchars($dyndns['host']);
149
		}
150
?>
151
					</td>
152
					<td class="listr">
153
<?php
154
		$filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
155
		$filename_v6 = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}_v6.cache";
156
		if (file_exists($filename)) {
157
			$ipaddr = dyndnsCheckIP($dyndns['interface']);
158
			$cached_ip_s = explode(":", file_get_contents($filename));
159
			$cached_ip = $cached_ip_s[0];
160
			if ($ipaddr <> $cached_ip) {
161
				echo "<font color='red'>";
162
			} else {
163
				echo "<font color='green'>";
164
			}
165
			echo htmlspecialchars($cached_ip);
166
			echo "</font>";
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
			if ($ipv6addr <> $cached_ipv6) {
172
				echo "<font color='red'>";
173
			} else {
174
				echo "<font color='green'>";
175
			}
176
			echo htmlspecialchars($cached_ipv6);
177
			echo "</font>";
178
		} else {
179
			echo "N/A";
180
		}
181
?>
182
					</td>
183
					<td class="listbg">
184
<?php
185
		if (!isset($dyndns['enable'])) {
186
			echo "<span class=\"gray\">".htmlspecialchars($dyndns['descr'])."</span>";
187
		} else {
188
			echo htmlspecialchars($dyndns['descr']);
189
		}
190
?>
191
					</td>
192
					<td valign="middle" class="list nowrap">
193
						<a href="services_dyndns_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="edit" /></a>
194
						&nbsp;<a href="services_dyndns.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this entry?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete" /></a>
195
					</td>
196
				</tr>
197
<?php
198
		$i++;
199
	endforeach;
200
?>
201
				<tr>
202
					<td class="list" colspan="5"></td>
203
					<td class="list">
204
						<a href="services_dyndns_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" /></a>
205
					</td>
206
				</tr>
207
				<tr>
208
					<td colspan="5" class="list">
209
						<p class="vexpl">
210
							<span class="red">
211
								<strong>
212
									<?=gettext("Note:");?><br />
213
								</strong>
214
							</span>
215
							<?=gettext("IP addresses appearing in green are up to date with Dynamic DNS provider.");?><br />
216
							<?=gettext("You can force an update for an IP address on the edit page for that service.");?>
217
						</p>
218
					</td>
219
					<td class="list">&nbsp;</td>
220
				</tr>
221
			</table>
222
			</div>
223
		</td>
224
	</tr>
225
</table>
226
</form>
227
<?php include("fend.inc"); ?>
228
</body>
229
</html>
(155-155/252)