Project

General

Profile

Download (8.13 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php 
3
/*
4
	services_dyndns.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6
	
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9
	
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12
	
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15
	
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19
	
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31

    
32
require("guiconfig.inc");
33

    
34
$pconfig['username'] = $config['dyndns']['username'];
35
$pconfig['password'] = $config['dyndns']['password'];
36
$pconfig['host'] = $config['dyndns']['host'];
37
$pconfig['mx'] = $config['dyndns']['mx'];
38
$pconfig['type'] = $config['dyndns']['type'];
39
$pconfig['enable'] = isset($config['dyndns']['enable']);
40
$pconfig['wildcard'] = isset($config['dyndns']['wildcard']);
41

    
42
if ($_POST) {
43

    
44
	unset($input_errors);
45
	$pconfig = $_POST;
46

    
47
	/* input validation */
48
	if ($_POST['enable']) {
49
		$reqdfields = explode(" ", "host username password type");
50
		$reqdfieldsn = explode(",", "Hostname,Username,Password,Service type");
51
		
52
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
53
	}
54
	
55
	if (($_POST['host'] && !is_domain($_POST['host']))) {
56
		$input_errors[] = "The host name contains invalid characters.";
57
	}
58
	if (($_POST['mx'] && !is_domain($_POST['mx']))) {
59
		$input_errors[] = "The MX contains invalid characters.";
60
	}
61
	if (($_POST['username'] && !is_dyndns_username($_POST['username']))) {
62
		$input_errors[] = "The username contains invalid characters.";
63
	}
64

    
65
	if (!$input_errors) {
66
		$config['dyndns']['type'] = $_POST['type'];	
67
		$config['dyndns']['username'] = $_POST['username'];
68
		$config['dyndns']['password'] = $_POST['password'];
69
		$config['dyndns']['host'] = $_POST['host'];
70
		$config['dyndns']['mx'] = $_POST['mx'];
71
		$config['dyndns']['wildcard'] = $_POST['wildcard'] ? true : false;
72
		$config['dyndns']['enable'] = $_POST['enable'] ? true : false;
73
			
74
		write_config();
75
		
76
		$retval = 0;
77
		if (!file_exists($d_sysrebootreqd_path)) {
78
			/* nuke the cache file */
79
			config_lock();
80
			services_dyndns_reset();
81
			$retval = services_dyndns_configure();
82
			config_unlock();
83
		}
84
		$savemsg = get_std_save_message($retval);
85
	}
86
}
87
?>
88
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
89
<html>
90
<head>
91
<title><?=gentitle("Services: Dynamic DNS client");?></title>
92
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
93
<link href="gui.css" rel="stylesheet" type="text/css">
94
<script language="JavaScript">
95
<!--
96
function enable_change(enable_change) {
97
	if (document.iform.enable.checked || enable_change) {
98
		document.iform.host.disabled = 0;
99
		document.iform.mx.disabled = 0;
100
		document.iform.type.disabled = 0;
101
		document.iform.wildcard.disabled = 0;
102
		document.iform.username.disabled = 0;
103
		document.iform.password.disabled = 0;
104
	} else {
105
		document.iform.host.disabled = 1;
106
		document.iform.mx.disabled = 1;
107
		document.iform.type.disabled = 1;
108
		document.iform.wildcard.disabled = 1;
109
		document.iform.username.disabled = 1;
110
		document.iform.password.disabled = 1;
111
	}
112
}
113
//-->
114
</script>
115
</head>
116

    
117
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
118
<?php include("fbegin.inc"); ?>
119
<p class="pgtitle">Services: Dynamic DNS client</p>
120
<?php if ($input_errors) print_input_errors($input_errors); ?>
121
<?php if ($savemsg) print_info_box($savemsg); ?>
122
            <form action="services_dyndns.php" method="post" name="iform" id="iform">
123
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
124
                <tr> 
125
                  <td width="22%" valign="top" class="vtable">&nbsp;</td>
126
                  <td width="78%" class="vtable">
127
<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
128
                    <strong>Enable Dynamic DNS client</strong></td>
129
				</tr>
130
                <tr> 
131
                  <td width="22%" valign="top" class="vncellreq">Service type</td>
132
                  <td width="78%" class="vtable">
133
<select name="type" class="formfld" id="type">
134
                      <?php $types = explode(",", "DynDNS,DHS,ODS,DyNS,HN.ORG,ZoneEdit,GNUDip,DynDNS (static),DynDNS (custom),easyDNS,EZ-IP,TZO");
135
					        $vals = explode(" ", "dyndns dhs ods dyns hn zoneedit gnudip dyndns-static dyndns-custom easydns ezip tzo");
136
					  $j = 0; for ($j = 0; $j < count($vals); $j++): ?>
137
                      <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['type']) echo "selected";?>> 
138
                      <?=htmlspecialchars($types[$j]);?>
139
                      </option>
140
                      <?php endfor; ?>
141
                    </select></td>
142
				</tr>
143
                <tr> 
144
                  <td width="22%" valign="top" class="vncellreq">Hostname</td>
145
                  <td width="78%" class="vtable"> 
146
                    <input name="host" type="text" class="formfld" id="host" size="30" value="<?=htmlspecialchars($pconfig['host']);?>"> 
147
                  </td>
148
				</tr>
149
                <tr> 
150
                  <td width="22%" valign="top" class="vncell">MX</td>
151
                  <td width="78%" class="vtable"> 
152
                    <input name="mx" type="text" class="formfld" id="mx" size="30" value="<?=htmlspecialchars($pconfig['mx']);?>"> 
153
                    <br>
154
                    Set this option only if you need a special MX record. Not 
155
                    all services support this.</td>
156
				</tr>
157
                <tr> 
158
                  <td width="22%" valign="top" class="vncellreq">Wildcards</td>
159
                  <td width="78%" class="vtable"> 
160
                    <input name="wildcard" type="checkbox" id="wildcard" value="yes" <?php if ($pconfig['wildcard'] == "yes") echo "checked"; ?>>
161
                    Enable Wildcard</td>
162
				</tr>
163
                <tr> 
164
                  <td width="22%" valign="top" class="vncellreq">Username</td>
165
                  <td width="78%" class="vtable"> 
166
                    <input name="username" type="text" class="formfld" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>"> 
167
                  </td>
168
                </tr>
169
                <tr> 
170
                  <td width="22%" valign="top" class="vncellreq">Password</td>
171
                  <td width="78%" class="vtable"> 
172
                    <input name="password" type="password" class="formfld" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>"> 
173
                  </td>
174
                </tr>
175
                <tr> 
176
                  <td width="22%" valign="top">&nbsp;</td>
177
                  <td width="78%"> 
178
                    <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)"> 
179
                  </td>
180
                </tr>
181
                <tr> 
182
                  <td width="22%" valign="top">&nbsp;</td>
183
                  <td width="78%"><span class="vexpl"><span class="red"><strong>Note:<br>
184
                    </strong></span>You must configure a DNS server in <a href="system.php">System: 
185
                    General setup</a> or allow the DNS server list to be overridden 
186
                    by DHCP/PPP on WAN for the DynDNS client to work.</span></td>
187
                </tr>
188
              </table>
189
</form>
190
<script language="JavaScript">
191
<!--
192
enable_change(false);
193
//-->
194
</script>
195
<?php include("fend.inc"); ?>
196
</body>
197
</html>
(60-60/86)