Project

General

Profile

Download (7.23 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><td>
96
<?php
97
	$tab_array = array();
98
	$tab_array[] = array(gettext("DynDns"), true, "services_dyndns.php");
99
	$tab_array[] = array(gettext("RFC 2136"), false, "services_rfc2136.php");
100
	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
		  <td width="5%"  class="listhdrr"><?=gettext("Interface");?></td>
109
		  <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
                  <td width="10%" class="list"></td>
114
		</tr>
115
		  <?php $i = 0; foreach ($a_dyndns as $dyndns): ?>
116
                <tr  ondblclick="document.location='services_dyndns_edit.php?id=<?=$i;?>'">
117
		  <td class="listlr">
118
		<?php	$iflist = get_configured_interface_with_descr();
119
	  		foreach ($iflist as $if => $ifdesc) {
120
				if ($dyndns['interface'] == $if) {
121
					echo "{$ifdesc}";
122
					$iface = $if;
123
					break;
124
				}
125
			}
126
			$groupslist = return_gateway_groups_array();
127
	  		foreach ($groupslist as $if => $group) {
128
				if ($dyndns['interface'] == $if) {
129
					echo "{$if}";
130
					$iface = $if;
131
					break;
132
				}
133
			}
134
		?>
135
		  </td>
136
                  <td class="listr">
137
				  <?php
138
					$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
					$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
                  </td>
147
                  <td class="listr">
148
					<?=htmlspecialchars($dyndns['host']);?>
149
                  </td>
150
                  <td class="listr">
151
			<?php
152
				$filename = "{$g['conf_path']}/dyndns_{$iface}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
153
				$ipaddr = dyndnsCheckIP($iface);
154
				if(file_exists($filename)) {
155
					$cached_ip_s = explode(":", file_get_contents($filename));
156
					$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
                  <td class="listbg">
169
                    <?=htmlspecialchars($dyndns['descr']);?>&nbsp;
170
                  </td>
171
                  <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
                     &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>
173
				</tr>
174
			  <?php $i++; endforeach; ?>
175
                <tr>
176
                  <td class="list" colspan="5"></td>
177
                  <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
				</tr>
179
				<tr>
180
				<td colspan="3" class="list"><p class="vexpl"><span class="red"><strong>
181
				  <?=gettext("Note:");?><br>
182
				  </strong></span>
183
				  <?=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
				  </td>
186
				<td class="list">&nbsp;</td>
187
				</tr>
188
              </table>
189
	      </div>
190
	</td>
191
	</tr>
192
</table>
193
</form>
194
<?php include("fend.inc"); ?>
195
</body>
196
</html>
(158-158/249)