Project

General

Profile

Download (6.48 KB) Statistics
| Branch: | Tag: | Revision:
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 5b237745 Scott Ullrich
		write_config();
51 d03efa9c Scott Ullrich
52 f1f60c92 Ermal Luçi
		header("Location: services_dyndns.php");
53
		exit;
54 5b237745 Scott Ullrich
}
55 4df96eff Scott Ullrich
56 23e69ae8 Ermal Lu?i
function dyndnsCheckIP($int) {
57
58
	$ip_address = get_interface_ip($int);
59
	if (is_private_ip($ip_address)) {
60
		$hosttocheck = "checkip.dyndns.org";
61
		$checkip = gethostbyname($hosttocheck);
62
		$ip_ch = curl_init("http://{$checkip}");
63
		curl_setopt($ip_ch, CURLOPT_RETURNTRANSFER, 1);
64
		curl_setopt($ip_ch, CURLOPT_SSL_VERIFYPEER, FALSE);
65
		curl_setopt($ip_ch, CURLOPT_INTERFACE, $ip_address);
66
		$ip_result_page = curl_exec($ip_ch);
67
		curl_close($ip_ch);
68
		$ip_result_decoded = urldecode($ip_result_page);
69
		preg_match('=Current IP Address: (.*)</body>=siU', $ip_result_decoded, $matches);
70
		$ip_address = trim($matches[1]);
71
	}
72
73
	return $ip_address;
74
}
75
76 c55f0507 Rafael Lucas
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS clients"));
77 4df96eff Scott Ullrich
include("head.inc");
78
79 5b237745 Scott Ullrich
?>
80 4df96eff Scott Ullrich
81 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
82
<?php include("fbegin.inc"); ?>
83 f1f60c92 Ermal Luçi
<form action="services_dyndns.php" method="post" name="iform" id="iform">
84 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
85 f1f60c92 Ermal Luçi
<table width="100%" border="0" cellpadding="0" cellspacing="0">
86
  <tr><td>
87
<?php
88
	$tab_array = array();
89 9a8d5eaf Carlos Eduardo Ramos
	$tab_array[] = array(gettext("DynDns"), true, "services_dyndns.php");
90
	$tab_array[] = array(gettext("RFC 2136"), false, "services_rfc2136.php");
91 f1f60c92 Ermal Luçi
	display_top_tabs($tab_array);
92
?>
93
  </td></tr>
94
  <tr>
95
    <td>
96
	<div id="mainarea">
97
	<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
98
                <tr>
99 23e69ae8 Ermal Lu?i
		  <td width="5%"  class="listhdrr"></td>
100 c55f0507 Rafael Lucas
		  <td width="15%" class="listhdrr"><?=gettext("Service");?></td>
101
                  <td width="20%" class="listhdrr"><?=gettext("Hostname");?></td>
102
                  <td width="20%" class="listhdrr"><?=gettext("Cached IP");?></td>
103
                  <td width="50%" class="listhdr"><?=gettext("Description");?></td>
104 f1f60c92 Ermal Luçi
                  <td width="10%" class="list"></td>
105 23e69ae8 Ermal Lu?i
		</tr>
106
		  <?php $i = 0; foreach ($a_dyndns as $dyndns): ?>
107 fd22be34 Ermal Lu?i
                <tr  ondblclick="document.location='services_dyndns_edit.php?id=<?=$i;?>'">
108 23e69ae8 Ermal Lu?i
		  <td class="listlr">
109
		  <?php $iflist = get_configured_interface_with_descr();
110
	  		foreach ($iflist as $if => $ifdesc):
111
				if ($dyndns['interface'] == $if): ?>
112
					<?=$ifdesc; break;?>
113
		  <?php endif; endforeach; ?>
114
		  </td>
115 f1f60c92 Ermal Luçi
                  <td class="listlr">
116
				  <?php
117 37c8e07d Ermal
					$types = explode(",", "DNS-O-Matic, DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,ODS.org,ZoneEdit,Loopia,freeDNS, DNSexit, OpenDNS, Namecheap");
118
					$vals = explode(" ", "dnsomatic dyndns dyndns-static dyndns-custom dhs dyns easydns noip ods zoneedit loopia freedns dnsexit opendns namecheap");
119
					$j = 0; for ($j = 0; $j < count($vals); $j++) 
120
                      			if ($vals[$j] == $dyndns['type']) { 
121
                      				echo htmlspecialchars($types[$j]);
122
							break;
123
					}
124
				?>
125 5b237745 Scott Ullrich
                  </td>
126 f1f60c92 Ermal Luçi
                  <td class="listr">
127
					<?=htmlspecialchars($dyndns['host']);?>
128 5b237745 Scott Ullrich
                  </td>
129 9abce230 Scott Ullrich
                  <td class="listlr">
130 23e69ae8 Ermal Lu?i
			<?php
131 37c8e07d Ermal
				$filename = "{$g['conf_path']}/dyndns_{$if}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . ".cache";
132 23e69ae8 Ermal Lu?i
				$ipaddr = dyndnsCheckIP($if);
133
				if(file_exists($filename)) {
134
					$cached_ip_s = split(":", file_get_contents($filename));
135
					$cached_ip = $cached_ip_s[0];
136
					if($ipaddr <> $cached_ip) 
137
						echo "<font color='red'>";
138
					else 
139
						echo "<font color='green'>";
140
						echo htmlspecialchars($cached_ip);
141
						echo "</font>";
142
				} else {
143
					echo "N/A";
144
				}
145
			?>
146
		  </td>
147 f1f60c92 Ermal Luçi
                  <td class="listbg">
148
                    <?=htmlspecialchars($dyndns['descr']);?>&nbsp;
149 07bd3f83 Scott Ullrich
                  </td>
150 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>
151 c55f0507 Rafael Lucas
                     &nbsp;<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>
152 07bd3f83 Scott Ullrich
				</tr>
153 f1f60c92 Ermal Luçi
			  <?php $i++; endforeach; ?>
154 07bd3f83 Scott Ullrich
                <tr>
155 9abce230 Scott Ullrich
                  <td class="list" colspan="5"></td>
156 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>
157 07bd3f83 Scott Ullrich
				</tr>
158 f1f60c92 Ermal Luçi
				<tr>
159
				<td colspan="3" class="list"><p class="vexpl"><span class="red"><strong>
160 16457bdd Renato Botelho
				  <?=gettext("Note:");?><br>
161 f1f60c92 Ermal Luçi
				  </strong></span>
162 c55f0507 Rafael Lucas
				  <?=gettext("IP addresses appearing in green are up to date with Dynamic DNS provider.");?>
163 f1f60c92 Ermal Luçi
				  </td>
164
				<td class="list">&nbsp;</td>
165 07bd3f83 Scott Ullrich
				</tr>
166 5b237745 Scott Ullrich
              </table>
167 f1f60c92 Ermal Luçi
	      </div>
168
	</td>
169
	</tr>
170
</table>
171 5b237745 Scott Ullrich
</form>
172
<?php include("fend.inc"); ?>
173
</body>
174
</html>