1 |
d03efa9c
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
f1f60c92
|
Ermal Luçi
|
Copyright (C) 2008 Ermal Lu?i
|
5 |
5b237745
|
Scott Ullrich
|
All rights reserved.
|
6 |
d03efa9c
|
Scott Ullrich
|
|
7 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
8 |
|
|
modification, are permitted provided that the following conditions are met:
|
9 |
d03efa9c
|
Scott Ullrich
|
|
10 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
11 |
|
|
this list of conditions and the following disclaimer.
|
12 |
d03efa9c
|
Scott Ullrich
|
|
13 |
5b237745
|
Scott Ullrich
|
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 |
d03efa9c
|
Scott Ullrich
|
|
17 |
5b237745
|
Scott Ullrich
|
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 |
1d333258
|
Scott Ullrich
|
/*
|
29 |
|
|
pfSense_BUILDER_BINARIES: /usr/bin/host
|
30 |
|
|
pfSense_MODULE: dyndns
|
31 |
|
|
*/
|
32 |
5b237745
|
Scott Ullrich
|
|
33 |
6b07c15a
|
Matthew Grooms
|
##|+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 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
41 |
|
|
|
42 |
f1f60c92
|
Ermal Luçi
|
if (!is_array($config['dyndnses']['dyndns']))
|
43 |
|
|
$config['dyndnses']['dyndns'] = array();
|
44 |
5b237745
|
Scott Ullrich
|
|
45 |
f1f60c92
|
Ermal Luçi
|
$a_dyndns = &$config['dyndnses']['dyndns'];
|
46 |
d03efa9c
|
Scott Ullrich
|
|
47 |
f1f60c92
|
Ermal Luçi
|
if ($_GET['act'] == "del") {
|
48 |
|
|
unset($a_dyndns[$_GET['id']]);
|
49 |
d03efa9c
|
Scott Ullrich
|
|
50 |
37f3e704
|
Matt Corallo
|
for($i = 0; $i < count($a_dyndns); $i++) {
|
51 |
|
|
$a_dyndns[$i]['id'] = $i;
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
//FIXME: Instead of rechecking all interfaces and removing the cache files, gracefully move all cache files to the appropriate ID number.
|
55 |
|
|
mwexec("/bin/rm {$g['conf_path']}/dyndns_*.cache");
|
56 |
|
|
|
57 |
5b237745
|
Scott Ullrich
|
write_config();
|
58 |
d03efa9c
|
Scott Ullrich
|
|
59 |
37f3e704
|
Matt Corallo
|
services_dyndns_configure();
|
60 |
|
|
|
61 |
f1f60c92
|
Ermal Luçi
|
header("Location: services_dyndns.php");
|
62 |
|
|
exit;
|
63 |
5b237745
|
Scott Ullrich
|
}
|
64 |
4df96eff
|
Scott Ullrich
|
|
65 |
23e69ae8
|
Ermal Lu?i
|
function dyndnsCheckIP($int) {
|
66 |
|
|
|
67 |
|
|
$ip_address = get_interface_ip($int);
|
68 |
|
|
if (is_private_ip($ip_address)) {
|
69 |
|
|
$hosttocheck = "checkip.dyndns.org";
|
70 |
|
|
$checkip = gethostbyname($hosttocheck);
|
71 |
|
|
$ip_ch = curl_init("http://{$checkip}");
|
72 |
|
|
curl_setopt($ip_ch, CURLOPT_RETURNTRANSFER, 1);
|
73 |
|
|
curl_setopt($ip_ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
74 |
|
|
curl_setopt($ip_ch, CURLOPT_INTERFACE, $ip_address);
|
75 |
|
|
$ip_result_page = curl_exec($ip_ch);
|
76 |
|
|
curl_close($ip_ch);
|
77 |
|
|
$ip_result_decoded = urldecode($ip_result_page);
|
78 |
|
|
preg_match('=Current IP Address: (.*)</body>=siU', $ip_result_decoded, $matches);
|
79 |
|
|
$ip_address = trim($matches[1]);
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
return $ip_address;
|
83 |
|
|
}
|
84 |
|
|
|
85 |
c55f0507
|
Rafael Lucas
|
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS clients"));
|
86 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
87 |
|
|
|
88 |
5b237745
|
Scott Ullrich
|
?>
|
89 |
4df96eff
|
Scott Ullrich
|
|
90 |
5b237745
|
Scott Ullrich
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
91 |
|
|
<?php include("fbegin.inc"); ?>
|
92 |
f1f60c92
|
Ermal Luçi
|
<form action="services_dyndns.php" method="post" name="iform" id="iform">
|
93 |
5b237745
|
Scott Ullrich
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
94 |
f1f60c92
|
Ermal Luçi
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
95 |
|
|
<tr><td>
|
96 |
|
|
<?php
|
97 |
|
|
$tab_array = array();
|
98 |
9a8d5eaf
|
Carlos Eduardo Ramos
|
$tab_array[] = array(gettext("DynDns"), true, "services_dyndns.php");
|
99 |
|
|
$tab_array[] = array(gettext("RFC 2136"), false, "services_rfc2136.php");
|
100 |
f1f60c92
|
Ermal Luçi
|
display_top_tabs($tab_array);
|
101 |
|
|
?>
|
102 |
|
|
</td></tr>
|
103 |
|
|
<tr>
|
104 |
|
|
<td>
|
105 |
|
|
<div id="mainarea">
|
106 |
|
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
107 |
|
|
<tr>
|
108 |
3e1eec58
|
smos
|
<td width="5%" class="listhdrr"><?=gettext("Interface");?></td>
|
109 |
c55f0507
|
Rafael Lucas
|
<td width="15%" class="listhdrr"><?=gettext("Service");?></td>
|
110 |
|
|
<td width="20%" class="listhdrr"><?=gettext("Hostname");?></td>
|
111 |
|
|
<td width="20%" class="listhdrr"><?=gettext("Cached IP");?></td>
|
112 |
|
|
<td width="50%" class="listhdr"><?=gettext("Description");?></td>
|
113 |
f1f60c92
|
Ermal Luçi
|
<td width="10%" class="list"></td>
|
114 |
23e69ae8
|
Ermal Lu?i
|
</tr>
|
115 |
|
|
<?php $i = 0; foreach ($a_dyndns as $dyndns): ?>
|
116 |
fd22be34
|
Ermal Lu?i
|
<tr ondblclick="document.location='services_dyndns_edit.php?id=<?=$i;?>'">
|
117 |
23e69ae8
|
Ermal Lu?i
|
<td class="listlr">
|
118 |
3e1eec58
|
smos
|
<?php $iflist = get_configured_interface_with_descr();
|
119 |
|
|
foreach ($iflist as $if => $ifdesc) {
|
120 |
|
|
if ($dyndns['interface'] == $if) {
|
121 |
|
|
echo "{$ifdesc}";
|
122 |
bf001dec
|
smos
|
$iface = $if;
|
123 |
3e1eec58
|
smos
|
break;
|
124 |
|
|
}
|
125 |
|
|
}
|
126 |
|
|
$groupslist = return_gateway_groups_array();
|
127 |
bf001dec
|
smos
|
foreach ($groupslist as $if => $group) {
|
128 |
|
|
if ($dyndns['interface'] == $if) {
|
129 |
|
|
echo "{$if}";
|
130 |
|
|
$iface = $if;
|
131 |
3e1eec58
|
smos
|
break;
|
132 |
|
|
}
|
133 |
|
|
}
|
134 |
|
|
?>
|
135 |
23e69ae8
|
Ermal Lu?i
|
</td>
|
136 |
3e1eec58
|
smos
|
<td class="listr">
|
137 |
f1f60c92
|
Ermal Luçi
|
<?php
|
138 |
37f3e704
|
Matt Corallo
|
$types = explode(",", "DNS-O-Matic, DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,ODS.org,ZoneEdit,Loopia,freeDNS, DNSexit, OpenDNS, Namecheap, HE.net, HE.net Tunnelbroker, SelfHost, Route 53, Custom");
|
139 |
|
|
$vals = explode(" ", "dnsomatic dyndns dyndns-static dyndns-custom dhs dyns easydns noip ods zoneedit loopia freedns dnsexit opendns namecheap he-net he-net-tunnelbroker selfhost route53 custom");
|
140 |
37c8e07d
|
Ermal
|
$j = 0; for ($j = 0; $j < count($vals); $j++)
|
141 |
|
|
if ($vals[$j] == $dyndns['type']) {
|
142 |
|
|
echo htmlspecialchars($types[$j]);
|
143 |
|
|
break;
|
144 |
|
|
}
|
145 |
|
|
?>
|
146 |
5b237745
|
Scott Ullrich
|
</td>
|
147 |
f1f60c92
|
Ermal Luçi
|
<td class="listr">
|
148 |
|
|
<?=htmlspecialchars($dyndns['host']);?>
|
149 |
5b237745
|
Scott Ullrich
|
</td>
|
150 |
3e1eec58
|
smos
|
<td class="listr">
|
151 |
23e69ae8
|
Ermal Lu?i
|
<?php
|
152 |
bf001dec
|
smos
|
$filename = "{$g['conf_path']}/dyndns_{$iface}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
|
153 |
|
|
$ipaddr = dyndnsCheckIP($iface);
|
154 |
23e69ae8
|
Ermal Lu?i
|
if(file_exists($filename)) {
|
155 |
cfbfd941
|
smos
|
$cached_ip_s = explode(":", file_get_contents($filename));
|
156 |
23e69ae8
|
Ermal Lu?i
|
$cached_ip = $cached_ip_s[0];
|
157 |
|
|
if($ipaddr <> $cached_ip)
|
158 |
|
|
echo "<font color='red'>";
|
159 |
|
|
else
|
160 |
|
|
echo "<font color='green'>";
|
161 |
|
|
echo htmlspecialchars($cached_ip);
|
162 |
|
|
echo "</font>";
|
163 |
|
|
} else {
|
164 |
|
|
echo "N/A";
|
165 |
|
|
}
|
166 |
|
|
?>
|
167 |
|
|
</td>
|
168 |
f1f60c92
|
Ermal Luçi
|
<td class="listbg">
|
169 |
|
|
<?=htmlspecialchars($dyndns['descr']);?>
|
170 |
07bd3f83
|
Scott Ullrich
|
</td>
|
171 |
f1f60c92
|
Ermal Luçi
|
<td valign="middle" nowrap class="list"> <a href="services_dyndns_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
|
172 |
c55f0507
|
Rafael Lucas
|
<a href="services_dyndns.php?act=del&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"></a></td>
|
173 |
07bd3f83
|
Scott Ullrich
|
</tr>
|
174 |
f1f60c92
|
Ermal Luçi
|
<?php $i++; endforeach; ?>
|
175 |
07bd3f83
|
Scott Ullrich
|
<tr>
|
176 |
9abce230
|
Scott Ullrich
|
<td class="list" colspan="5"></td>
|
177 |
f1f60c92
|
Ermal Luçi
|
<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"></a></td>
|
178 |
07bd3f83
|
Scott Ullrich
|
</tr>
|
179 |
f1f60c92
|
Ermal Luçi
|
<tr>
|
180 |
|
|
<td colspan="3" class="list"><p class="vexpl"><span class="red"><strong>
|
181 |
16457bdd
|
Renato Botelho
|
<?=gettext("Note:");?><br>
|
182 |
f1f60c92
|
Ermal Luçi
|
</strong></span>
|
183 |
f3b2b2a4
|
Yehuda Katz
|
<?=gettext("IP addresses appearing in green are up to date with Dynamic DNS provider.");?><br>
|
184 |
|
|
<?=gettext("You can force an update for an IP address on the edit page for that service.");?>
|
185 |
f1f60c92
|
Ermal Luçi
|
</td>
|
186 |
|
|
<td class="list"> </td>
|
187 |
07bd3f83
|
Scott Ullrich
|
</tr>
|
188 |
5b237745
|
Scott Ullrich
|
</table>
|
189 |
f1f60c92
|
Ermal Luçi
|
</div>
|
190 |
|
|
</td>
|
191 |
|
|
</tr>
|
192 |
|
|
</table>
|
193 |
5b237745
|
Scott Ullrich
|
</form>
|
194 |
|
|
<?php include("fend.inc"); ?>
|
195 |
|
|
</body>
|
196 |
|
|
</html>
|