Project

General

Profile

Download (7.04 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
$a_dyndns = &$config['dyndnses']['dyndns'];
49

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

    
52
	$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

    
56
	write_config();
57
	services_dyndns_configure();
58

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

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

    
66
?>
67

    
68
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
69
<?php include("fbegin.inc"); ?>
70
<form action="services_dyndns.php" method="post" name="iform" id="iform">
71
<?php if ($input_errors) print_input_errors($input_errors); ?>
72
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="dynamic dns">
73
  <tr>
74
	<td>
75
<?php
76
	$tab_array = array();
77
	$tab_array[] = array(gettext("DynDns"), true, "services_dyndns.php");
78
	$tab_array[] = array(gettext("RFC 2136"), false, "services_rfc2136.php");
79
	display_top_tabs($tab_array);
80
?>
81
	</td>
82
  </tr>
83
  <tr>
84
	<td>
85
	  <div id="mainarea">
86
	  <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
87
		<tr>
88
		  <td width="5%"  class="listhdrr"><?=gettext("Interface");?></td>
89
		  <td width="15%" class="listhdrr"><?=gettext("Service");?></td>
90
		  <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
		</tr>
95
		<?php $i = 0; foreach ($a_dyndns as $dyndns): ?>
96
		<tr ondblclick="document.location='services_dyndns_edit.php?id=<?=$i;?>'">
97
		  <td class="listlr">
98
		  <?php	$iflist = get_configured_interface_with_descr();
99
			foreach ($iflist as $if => $ifdesc) {
100
				if ($dyndns['interface'] == $if) {
101
					if (!isset($dyndns['enable']))
102
						echo "<span class=\"gray\">{$ifdesc}</span>";
103
					else
104
						echo "{$ifdesc}";
105
					break;
106
				}
107
			}
108
			$groupslist = return_gateway_groups_array();
109
			foreach ($groupslist as $if => $group) {
110
				if ($dyndns['interface'] == $if) {
111
					if (!isset($dyndns['enable']))
112
						echo "<span class=\"gray\">{$if}</span>";
113
					else
114
						echo "{$if}";
115
					break;
116
				}
117
			}
118
		  ?>
119
		  </td>
120
		  <td class="listr">
121
		  <?php
122
			$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS);
123
			$vals = explode(" ", DYNDNS_PROVIDER_VALUES);
124
			for ($j = 0; $j < count($vals); $j++)
125
				if ($vals[$j] == $dyndns['type']) {
126
					if (!isset($dyndns['enable']))
127
						echo "<span class=\"gray\">" . htmlspecialchars($types[$j]) . "</span>";
128
					else
129
						echo htmlspecialchars($types[$j]);
130
					break;
131
				}
132
		  ?>
133
		  </td>
134
		  <td class="listr">
135
		  <?php
136
			if (!isset($dyndns['enable']))
137
				echo "<span class=\"gray\">" . htmlspecialchars($dyndns['host']) . "</span>";
138
			else
139
				echo htmlspecialchars($dyndns['host']);
140
		  ?>
141
		  </td>
142
		  <td class="listr">
143
		  <?php
144
			$filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
145
			$filename_v6 = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}_v6.cache";
146
			if (file_exists($filename)) {
147
				$ipaddr = dyndnsCheckIP($dyndns['interface']);
148
				$cached_ip_s = explode(":", file_get_contents($filename));
149
				$cached_ip = $cached_ip_s[0];
150
				if ($ipaddr <> $cached_ip)
151
					echo "<font color='red'>";
152
				else
153
					echo "<font color='green'>";
154
				echo htmlspecialchars($cached_ip);
155
				echo "</font>";
156
			} else if (file_exists($filename_v6)) {
157
				$ipv6addr = get_interface_ipv6($dyndns['interface']);
158
				$cached_ipv6_s = explode("|", file_get_contents($filename_v6));
159
				$cached_ipv6 = $cached_ipv6_s[0];
160
				if ($ipv6addr <> $cached_ipv6)
161
					echo "<font color='red'>";
162
				else
163
					echo "<font color='green'>";
164
				echo htmlspecialchars($cached_ipv6);
165
				echo "</font>";
166
			} else {
167
				echo "N/A";
168
			}
169
		  ?>
170
		  </td>
171
		  <td class="listbg">
172
		  <?php
173
			if (!isset($dyndns['enable']))
174
				echo "<span class=\"gray\">".htmlspecialchars($dyndns['descr'])."</span>";
175
			else
176
				echo htmlspecialchars($dyndns['descr']);
177
		  ?>
178
		  </td>
179
		  <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
		  </td>
183
		</tr>
184
		<?php $i++; endforeach; ?>
185
		<tr>
186
		  <td class="list" colspan="5"></td>
187
		  <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
		</tr>
189
		<tr>
190
		  <td colspan="5" class="list"><p class="vexpl"><span class="red"><strong>
191
			<?=gettext("Note:");?><br />
192
			</strong></span>
193
			<?=gettext("IP addresses appearing in green are up to date with Dynamic DNS provider.");?><br />
194
			<?=gettext("You can force an update for an IP address on the edit page for that service.");?></p>
195
		  </td>
196
		  <td class="list">&nbsp;</td>
197
		</tr>
198
	  </table>
199
	  </div>
200
	</td>
201
  </tr>
202
</table>
203
</form>
204
<?php include("fend.inc"); ?>
205
</body>
206
</html>
(156-156/252)