Project

General

Profile

Download (7.04 KB) Statistics
| Branch: | Tag: | Revision:
1 d03efa9c Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4 ce77a9c4 Phil Davis
	services_dyndns.php
5
6 14aee2f4 Phil Davis
	Copyright (C) 2008 Ermal Luçi
7 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
8 5b237745 Scott Ullrich
	All rights reserved.
9 d03efa9c Scott Ullrich
10 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12 d03efa9c Scott Ullrich
13 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15 d03efa9c Scott Ullrich
16 5b237745 Scott Ullrich
	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 d03efa9c Scott Ullrich
20 5b237745 Scott Ullrich
	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 1d333258 Scott Ullrich
/*
32 0abc8f4a Charlie Marshall
	pfSense_BUILDER_BINARIES:	/usr/bin/host
33 1d333258 Scott Ullrich
	pfSense_MODULE:	dyndns
34
*/
35 5b237745 Scott Ullrich
36 6b07c15a Matthew Grooms
##|+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 5b237745 Scott Ullrich
require("guiconfig.inc");
44
45 f1f60c92 Ermal Luçi
if (!is_array($config['dyndnses']['dyndns']))
46
	$config['dyndnses']['dyndns'] = array();
47 5b237745 Scott Ullrich
48 f1f60c92 Ermal Luçi
$a_dyndns = &$config['dyndnses']['dyndns'];
49 d03efa9c Scott Ullrich
50 f1f60c92 Ermal Luçi
if ($_GET['act'] == "del") {
51 37f3e704 Matt Corallo
52 f42193a4 Ermal
	$conf = $a_dyndns[$_GET['id']];
53
	@unlink("{$g['conf_path']}/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($conf['host']) . "{$conf['id']}.cache");
54
	unset($a_dyndns[$_GET['id']]);
55 37f3e704 Matt Corallo
56 5a39eb2b bcyrill
	write_config();
57
	services_dyndns_configure();
58 37f3e704 Matt Corallo
59 5a39eb2b bcyrill
	header("Location: services_dyndns.php");
60
	exit;
61 5b237745 Scott Ullrich
}
62 4df96eff Scott Ullrich
63 c55f0507 Rafael Lucas
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS clients"));
64 4df96eff Scott Ullrich
include("head.inc");
65
66 5b237745 Scott Ullrich
?>
67 4df96eff Scott Ullrich
68 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
69
<?php include("fbegin.inc"); ?>
70 f1f60c92 Ermal Luçi
<form action="services_dyndns.php" method="post" name="iform" id="iform">
71 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
72 f9f467e2 Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="dynamic dns">
73 5a39eb2b bcyrill
  <tr>
74
	<td>
75 f1f60c92 Ermal Luçi
<?php
76
	$tab_array = array();
77 9a8d5eaf Carlos Eduardo Ramos
	$tab_array[] = array(gettext("DynDns"), true, "services_dyndns.php");
78
	$tab_array[] = array(gettext("RFC 2136"), false, "services_rfc2136.php");
79 f1f60c92 Ermal Luçi
	display_top_tabs($tab_array);
80
?>
81 5a39eb2b bcyrill
	</td>
82
  </tr>
83 f1f60c92 Ermal Luçi
  <tr>
84 5a39eb2b bcyrill
	<td>
85
	  <div id="mainarea">
86 f9f467e2 Colin Fleming
	  <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
87 5a39eb2b bcyrill
		<tr>
88 3e1eec58 smos
		  <td width="5%"  class="listhdrr"><?=gettext("Interface");?></td>
89 c55f0507 Rafael Lucas
		  <td width="15%" class="listhdrr"><?=gettext("Service");?></td>
90 5a39eb2b bcyrill
		  <td width="20%" class="listhdrr"><?=gettext("Hostname");?></td>
91
		  <td width="20%" class="listhdrr"><?=gettext("Cached IP");?></td>
92
		  <td width="50%" class="listhdr"><?=gettext("Description");?></td>
93
		  <td width="10%" class="list"></td>
94 23e69ae8 Ermal Lu?i
		</tr>
95 5a39eb2b bcyrill
		<?php $i = 0; foreach ($a_dyndns as $dyndns): ?>
96
		<tr ondblclick="document.location='services_dyndns_edit.php?id=<?=$i;?>'">
97 23e69ae8 Ermal Lu?i
		  <td class="listlr">
98 5a39eb2b bcyrill
		  <?php	$iflist = get_configured_interface_with_descr();
99
			foreach ($iflist as $if => $ifdesc) {
100 3e1eec58 smos
				if ($dyndns['interface'] == $if) {
101 51ce2ea7 bcyrill
					if (!isset($dyndns['enable']))
102
						echo "<span class=\"gray\">{$ifdesc}</span>";
103
					else
104
						echo "{$ifdesc}";
105 3e1eec58 smos
					break;
106
				}
107
			}
108
			$groupslist = return_gateway_groups_array();
109 ab4ce295 bcyrill
			foreach ($groupslist as $if => $group) {
110 bf001dec smos
				if ($dyndns['interface'] == $if) {
111 51ce2ea7 bcyrill
					if (!isset($dyndns['enable']))
112
						echo "<span class=\"gray\">{$if}</span>";
113
					else
114
						echo "{$if}";
115 3e1eec58 smos
					break;
116
				}
117
			}
118 5a39eb2b bcyrill
		  ?>
119 23e69ae8 Ermal Lu?i
		  </td>
120 5a39eb2b bcyrill
		  <td class="listr">
121
		  <?php
122 14aee2f4 Phil Davis
			$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS);
123
			$vals = explode(" ", DYNDNS_PROVIDER_VALUES);
124 0abc8f4a Charlie Marshall
			for ($j = 0; $j < count($vals); $j++)
125 51ce2ea7 bcyrill
				if ($vals[$j] == $dyndns['type']) {
126
					if (!isset($dyndns['enable']))
127 f9f467e2 Colin Fleming
						echo "<span class=\"gray\">" . htmlspecialchars($types[$j]) . "</span>";
128 51ce2ea7 bcyrill
					else
129
						echo htmlspecialchars($types[$j]);
130 5a39eb2b bcyrill
					break;
131 23e69ae8 Ermal Lu?i
				}
132 5a39eb2b bcyrill
		  ?>
133
		  </td>
134
		  <td class="listr">
135 51ce2ea7 bcyrill
		  <?php
136
			if (!isset($dyndns['enable']))
137 f9f467e2 Colin Fleming
				echo "<span class=\"gray\">" . htmlspecialchars($dyndns['host']) . "</span>";
138 51ce2ea7 bcyrill
			else
139
				echo htmlspecialchars($dyndns['host']);
140
		  ?>
141 5a39eb2b bcyrill
		  </td>
142
		  <td class="listr">
143
		  <?php
144 ab4ce295 bcyrill
			$filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
145 ebfe7d20 Daniel Becker
			$filename_v6 = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}_v6.cache";
146 5a39eb2b bcyrill
			if (file_exists($filename)) {
147 ab4ce295 bcyrill
				$ipaddr = dyndnsCheckIP($dyndns['interface']);
148 5a39eb2b bcyrill
				$cached_ip_s = explode(":", file_get_contents($filename));
149
				$cached_ip = $cached_ip_s[0];
150 0abc8f4a Charlie Marshall
				if ($ipaddr <> $cached_ip)
151 5a39eb2b bcyrill
					echo "<font color='red'>";
152 0abc8f4a Charlie Marshall
				else
153 5a39eb2b bcyrill
					echo "<font color='green'>";
154
				echo htmlspecialchars($cached_ip);
155
				echo "</font>";
156 ebfe7d20 Daniel Becker
			} else if (file_exists($filename_v6)) {
157
				$ipv6addr = get_interface_ipv6($dyndns['interface']);
158 b4319c50 Daniel Becker
				$cached_ipv6_s = explode("|", file_get_contents($filename_v6));
159 ebfe7d20 Daniel Becker
				$cached_ipv6 = $cached_ipv6_s[0];
160 0abc8f4a Charlie Marshall
				if ($ipv6addr <> $cached_ipv6)
161 ebfe7d20 Daniel Becker
					echo "<font color='red'>";
162 0abc8f4a Charlie Marshall
				else
163 ebfe7d20 Daniel Becker
					echo "<font color='green'>";
164
				echo htmlspecialchars($cached_ipv6);
165
				echo "</font>";
166 5a39eb2b bcyrill
			} else {
167
				echo "N/A";
168
			}
169
		  ?>
170 23e69ae8 Ermal Lu?i
		  </td>
171 5a39eb2b bcyrill
		  <td class="listbg">
172 51ce2ea7 bcyrill
		  <?php
173
			if (!isset($dyndns['enable']))
174
				echo "<span class=\"gray\">".htmlspecialchars($dyndns['descr'])."</span>";
175
			else
176
				echo htmlspecialchars($dyndns['descr']);
177
		  ?>
178 5a39eb2b bcyrill
		  </td>
179 f9f467e2 Colin Fleming
		  <td valign="middle" class="list nowrap">
180
			<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>
181
			&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>
182 5a39eb2b bcyrill
		  </td>
183
		</tr>
184
		<?php $i++; endforeach; ?>
185
		<tr>
186
		  <td class="list" colspan="5"></td>
187 f9f467e2 Colin Fleming
		  <td class="list"><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></td>
188 5a39eb2b bcyrill
		</tr>
189
		<tr>
190 f5da0849 Charlie Marshall
		  <td colspan="5" class="list"><p class="vexpl"><span class="red"><strong>
191 8cd558b6 ayvis
			<?=gettext("Note:");?><br />
192 5a39eb2b bcyrill
			</strong></span>
193 8cd558b6 ayvis
			<?=gettext("IP addresses appearing in green are up to date with Dynamic DNS provider.");?><br />
194 f9f467e2 Colin Fleming
			<?=gettext("You can force an update for an IP address on the edit page for that service.");?></p>
195 5a39eb2b bcyrill
		  </td>
196
		  <td class="list">&nbsp;</td>
197
		</tr>
198
	  </table>
199
	  </div>
200 f1f60c92 Ermal Luçi
	</td>
201 5a39eb2b bcyrill
  </tr>
202 f1f60c92 Ermal Luçi
</table>
203 5b237745 Scott Ullrich
</form>
204
<?php include("fend.inc"); ?>
205
</body>
206
</html>