Project

General

Profile

Download (7.43 KB) Statistics
| Branch: | Tag: | Revision:
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
	unset($a_dyndns[$_GET['id']]);
49

    
50
	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
	write_config();
58

    
59
	services_dyndns_configure();
60

    
61
	header("Location: services_dyndns.php");
62
	exit;
63
}
64

    
65
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
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS clients"));
86
include("head.inc");
87

    
88
?>
89

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