Project

General

Profile

Download (6.97 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / services_dyndns.php @ a1b66bec

1
<?php
2
/* $Id$ */
3
/*
4
	Copyright (C) 2008 Ermal Luçi
5
	All rights reserved.
6

    
7
	Redistribution and use in source and binary forms, with or without
8
	modification, are permitted provided that the following conditions are met:
9

    
10
	1. Redistributions of source code must retain the above copyright notice,
11
	   this list of conditions and the following disclaimer.
12

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

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

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

    
40
require("guiconfig.inc");
41

    
42
if (!is_array($config['dyndnses']['dyndns']))
43
	$config['dyndnses']['dyndns'] = array();
44

    
45
$a_dyndns = &$config['dyndnses']['dyndns'];
46

    
47
if ($_GET['act'] == "del") {
48

    
49
	$conf = $a_dyndns[$_GET['id']];
50
	@unlink("{$g['conf_path']}/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($conf['host']) . "{$conf['id']}.cache");
51
	unset($a_dyndns[$_GET['id']]);
52

    
53
	write_config();
54
	services_dyndns_configure();
55

    
56
	header("Location: services_dyndns.php");
57
	exit;
58
}
59

    
60
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS clients"));
61
include("head.inc");
62

    
63
?>
64

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