Project

General

Profile

Download (9.69 KB) Statistics
| Branch: | Tag: | Revision:
1 f1f60c92 Ermal Luçi
<?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 1d333258 Scott Ullrich
/*
29
	pfSense_BUILDER_BINARIES:	/bin/rm
30
	pfSense_MODULE:	dyndns
31
*/
32 f1f60c92 Ermal Luçi
33 6b07c15a Matthew Grooms
##|+PRIV
34
##|*IDENT=page-services-dynamicdnsclient
35
##|*NAME=Services: Dynamic DNS client page
36
##|*DESCR=Allow access to the 'Services: Dynamic DNS client' page.
37
##|*MATCH=services_dyndns_edit.php*
38
##|-PRIV
39
40 ee2db55f Ermal Lu?i
/* returns true if $uname is a valid DynDNS username */
41
function is_dyndns_username($uname) {
42
        if (!is_string($uname))
43
                return false;
44
        
45
        if (preg_match("/[^a-z0-9\-.@_:]/i", $uname))
46
                return false;
47
        else
48
                return true;
49
}
50
51 f1f60c92 Ermal Luçi
require("guiconfig.inc");
52
53
if (!is_array($config['dyndnses']['dyndns'])) {
54
	$config['dyndnses']['dyndns'] = array();
55
}
56
57
$a_dyndns = &$config['dyndnses']['dyndns'];
58
59
$id = $_GET['id'];
60
if (isset($_POST['id']))
61
	$id = $_POST['id'];
62
63
if (isset($id) && isset($a_dyndns[$id])) {
64
	$pconfig['username'] = $a_dyndns[$id]['username'];
65
	$pconfig['password'] = $a_dyndns[$id]['password'];
66
	$pconfig['host'] = $a_dyndns[$id]['host'];
67
	$pconfig['mx'] = $a_dyndns[$id]['mx'];
68
	$pconfig['type'] = $a_dyndns[$id]['type'];
69 acdfc164 Ermal Luçi
	$pconfig['enable'] = !isset($a_dyndns[$id]['enable']);
70 f1f60c92 Ermal Luçi
	$pconfig['interface'] = $a_dyndns[$id]['interface'];
71
	$pconfig['wildcard'] = isset($a_dyndns[$id]['wildcard']);
72
	$pconfig['descr'] = $a_dyndns[$id]['descr'];
73
}
74
75
if ($_POST) {
76
77
	unset($input_errors);
78
	$pconfig = $_POST;
79
80
	/* input validation */
81
	$reqdfields = array();
82
	$reqdfieldsn = array();
83
	$reqdfields = array_merge($reqdfields, explode(" ", "host username password type"));
84
	$reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Hostname,Username,Password,Service type"));
85
86
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
87
88
	if (($_POST['mx'] && !is_domain($_POST['mx']))) 
89
		$input_errors[] = "The MX contains invalid characters.";
90
	if (($_POST['username'] && !is_dyndns_username($_POST['username'])) || $_POST['username'] == "") 
91
		$input_errors[] = "The username contains invalid characters.";
92
93
	if (!$input_errors) {
94
		$dyndns = array();
95
		$dyndns['type'] = $_POST['type'];
96
		$dyndns['username'] = $_POST['username'];
97
		$dyndns['password'] = $_POST['password'];
98
		$dyndns['host'] = $_POST['host'];
99
		$dyndns['mx'] = $_POST['mx'];
100
		$dyndns['wildcard'] = $_POST['wildcard'] ? true : false;
101
		$dyndns['enable'] = $_POST['enable'] ? false : true;
102
		$dyndns['interface'] = $_POST['interface'];
103
		$dyndns['descr'] = $_POST['descr'];
104
105
		if (isset($id) && $a_dyndns[$id])
106
			$a_dyndns[$id] = $dyndns;
107
		else
108
			$a_dyndns[] = $dyndns;
109
110
		write_config();
111
112
		$retval = 0;
113
114 91e55d73 Ermal Luçi
		conf_mount_rw();
115 9c38bcea sullrich
116 1d333258 Scott Ullrich
		mwexec("/bin/rm {$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}.cache");
117 91e55d73 Ermal Luçi
118 789af363 Ermal Luçi
		$retval = services_dyndns_configure_client($dyndns);
119
120 9c38bcea sullrich
		conf_mount_ro();
121
122 07cdb9a2 Ermal Luçi
		header("Location: services_dyndns.php");
123
		exit;
124 f1f60c92 Ermal Luçi
	}
125
}
126
127
$pgtitle = array("Services","Dynamic DNS client");
128
include("head.inc");
129
130
?>
131
132
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
133
<?php include("fbegin.inc"); ?>
134
<?php if ($input_errors) print_input_errors($input_errors); ?>
135
<?php if ($savemsg) print_info_box($savemsg); ?>
136
<form action="services_dyndns_edit.php" method="post" name="iform" id="iform">
137
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
138
                <tr>
139
                  <td colspan="2" valign="top" class="optsect_t">
140
				  <table border="0" cellspacing="0" cellpadding="0" width="100%">
141
				  <tr><td class="optsect_s"><strong>Dynamic DNS client</strong></td></tr>
142
				  </table>
143
				  </td>
144
                </tr>
145
                <tr>
146 2248a940 Ermal Lu?i
                  <td width="22%" valign="top" class="vncell">Disable</td>
147 f1f60c92 Ermal Luçi
				  <td width="78%" class="vtable">
148 acdfc164 Ermal Luçi
				    <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?>>
149 f1f60c92 Ermal Luçi
				  </td>
150
                </tr>
151
                <tr>
152
                  <td width="22%" valign="top" class="vncellreq">Service type</td>
153
                  <td width="78%" class="vtable">
154
			<select name="type" class="formselect" id="type">
155
                      <?php
156 7d9dca1c Ermal Luçi
						$types = explode(",", "DNS-O-Matic, DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,ODS.org,ZoneEdit,Loopia,freeDNS, DNSexit, OpenDNS");
157
						$vals = explode(" ", "dnsomatic dyndns dyndns-static dyndns-custom dhs dyns easydns noip ods zoneedit loopia freedns dnsexit opendns");
158 f1f60c92 Ermal Luçi
						$j = 0; for ($j = 0; $j < count($vals); $j++): ?>
159
                      <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['type']) echo "selected";?>>
160
                      <?=htmlspecialchars($types[$j]);?>
161
                      </option>
162
                      <?php endfor; ?>
163
                    </select></td>
164
				</tr>
165
				<tr>
166
				   <td width="22%" valign="top" class="vncellreq">Interface to monitor</td>  
167
				   <td width="78%" class="vtable">
168
				   <select name="interface" class="formselect" id="interface">
169
				   <?php $iflist = get_configured_interface_with_descr();
170
				   		foreach ($iflist as $if => $ifdesc):?>
171
							<option value="<?=$if;?>" <?php if ($pconfig['interface'] == $if) echo "selected";?>><?=$ifdesc;?></option>
172
					<?php endforeach; ?>
173
					</select>
174
					</td>
175
					</td>
176
				</tr>	
177
                <tr>
178 d31e9455 Chris Buechler
                  <td width="22%" valign="top" class="vncellreq">Hostname</td>
179 f1f60c92 Ermal Luçi
                  <td width="78%" class="vtable">
180
                    <input name="host" type="text" class="formfld unknown" id="host" size="30" value="<?=htmlspecialchars($pconfig['host']);?>">
181
                    <br>
182
				    <span class="vexpl">
183
				    <span class="red"><strong>Note:<br></strong>
184
				    </span>
185
					Enter the complete host/domain name.  example:  myhost.dyndns.org
186
				    </span>
187
		          </td>
188
				</tr>
189
                <tr>
190
                  <td width="22%" valign="top" class="vncell">MX</td>
191
                  <td width="78%" class="vtable">
192
                    <input name="mx" type="text" class="formfld unknown" id="mx" size="30" value="<?=htmlspecialchars($pconfig['mx']);?>">
193
                    <br>
194
					Note: With DynDNS service you can only use a hostname, not an IP address.
195
					<br>
196
                    Set this option only if you need a special MX record. Not
197
                    all services support this.</td>
198
				</tr>
199
                <tr>
200 2248a940 Ermal Lu?i
                  <td width="22%" valign="top" class="vncell">Wildcards</td>
201 f1f60c92 Ermal Luçi
                  <td width="78%" class="vtable">
202
                    <input name="wildcard" type="checkbox" id="wildcard" value="yes" <?php if ($pconfig['wildcard']) echo "checked"; ?>>
203
                    Enable Wildcard</td>
204
				</tr>
205
                <tr>
206
                  <td width="22%" valign="top" class="vncellreq">Username</td>
207
                  <td width="78%" class="vtable">
208
                    <input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
209
                  </td>
210
                </tr>
211
                <tr>
212
                  <td width="22%" valign="top" class="vncellreq">Password</td>
213
                  <td width="78%" class="vtable">
214
                    <input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
215
                  </td>
216
                </tr>
217
                <tr>
218 2248a940 Ermal Lu?i
                  <td width="22%" valign="top" class="vncell">Description</td>
219 f1f60c92 Ermal Luçi
                  <td width="78%" class="vtable">
220
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="60" value="<?=htmlspecialchars($pconfig['descr']);?>">
221
                  </td>
222
                </tr>
223
                <tr>
224
                  <td width="22%" valign="top">&nbsp;</td>
225
                  <td width="78%">
226
                    <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
227
					<a href="services_dyndns.php"><input name="cancel" type="button" class="formbtn" value="Cancel"></a>
228
					<?php if (isset($id) && $a_dyndns[$id]): ?>
229
						<input name="id" type="hidden" value="<?=$id;?>">
230
					<?php endif; ?>
231
                  </td>
232
                </tr>
233
                <tr>
234
                  <td width="22%" valign="top">&nbsp;</td>
235
                  <td width="78%"><span class="vexpl"><span class="red"><strong>Note:<br>
236
                    </strong></span>You must configure a DNS server in <a href="system.php">System:
237
                    General setup</a> or allow the DNS server list to be overridden
238
                    by DHCP/PPP on WAN for dynamic DNS updates to work.</span></td>
239
                </tr>
240
              </table>
241
</form>
242 9e9b596f Ermal Luçi
<?php include("fend.inc"); ?>
243 f1f60c92 Ermal Luçi
</body>
244
</html>