Project

General

Profile

Download (9.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
##|+PRIV
30
##|*IDENT=page-services-dynamicdnsclient
31
##|*NAME=Services: Dynamic DNS client page
32
##|*DESCR=Allow access to the 'Services: Dynamic DNS client' page.
33
##|*MATCH=services_dyndns_edit.php*
34
##|-PRIV
35

    
36

    
37
require("guiconfig.inc");
38

    
39
if (!is_array($config['dyndnses']['dyndns'])) {
40
	$config['dyndnses']['dyndns'] = array();
41
}
42

    
43
$a_dyndns = &$config['dyndnses']['dyndns'];
44

    
45
$id = $_GET['id'];
46
if (isset($_POST['id']))
47
	$id = $_POST['id'];
48

    
49
if (isset($id) && isset($a_dyndns[$id])) {
50
	$pconfig['username'] = $a_dyndns[$id]['username'];
51
	$pconfig['password'] = $a_dyndns[$id]['password'];
52
	$pconfig['host'] = $a_dyndns[$id]['host'];
53
	$pconfig['mx'] = $a_dyndns[$id]['mx'];
54
	$pconfig['type'] = $a_dyndns[$id]['type'];
55
	$pconfig['enable'] = !isset($a_dyndns[$id]['enable']);
56
	$pconfig['interface'] = $a_dyndns[$id]['interface'];
57
	$pconfig['wildcard'] = isset($a_dyndns[$id]['wildcard']);
58
	$pconfig['descr'] = $a_dyndns[$id]['descr'];
59
}
60

    
61
if ($_POST) {
62

    
63
	unset($input_errors);
64
	$pconfig = $_POST;
65

    
66
	/* input validation */
67
	$reqdfields = array();
68
	$reqdfieldsn = array();
69
	$reqdfields = array_merge($reqdfields, explode(" ", "host username password type"));
70
	$reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Hostname,Username,Password,Service type"));
71

    
72
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
73

    
74
	if (($_POST['mx'] && !is_domain($_POST['mx']))) 
75
		$input_errors[] = "The MX contains invalid characters.";
76
	if (($_POST['username'] && !is_dyndns_username($_POST['username'])) || $_POST['username'] == "") 
77
		$input_errors[] = "The username contains invalid characters.";
78

    
79
	if (!$input_errors) {
80
		$dyndns = array();
81
		$dyndns['type'] = $_POST['type'];
82
		$dyndns['username'] = $_POST['username'];
83
		$dyndns['password'] = $_POST['password'];
84
		$dyndns['host'] = $_POST['host'];
85
		$dyndns['mx'] = $_POST['mx'];
86
		$dyndns['wildcard'] = $_POST['wildcard'] ? true : false;
87
		$dyndns['enable'] = $_POST['enable'] ? false : true;
88
		$dyndns['interface'] = $_POST['interface'];
89
		$dyndns['descr'] = $_POST['descr'];
90

    
91
		if (isset($id) && $a_dyndns[$id])
92
			$a_dyndns[$id] = $dyndns;
93
		else
94
			$a_dyndns[] = $dyndns;
95

    
96
		write_config();
97

    
98

    
99
		/* XXX: Make this with a touch file */
100
		$retval = 0;
101

    
102
		conf_mount_rw();
103
		mwexec("rm {$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}.cache");
104
		conf_mount_ro();
105

    
106
		config_lock();
107
		$retval = services_dyndns_configure_client($dyndns);
108
		config_unlock();
109

    
110
		header("Location: services_dyndns.php");
111
		exit;
112
	}
113
}
114

    
115
$pgtitle = array("Services","Dynamic DNS client");
116
include("head.inc");
117

    
118
?>
119

    
120
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
121
<?php include("fbegin.inc"); ?>
122
<?php if ($input_errors) print_input_errors($input_errors); ?>
123
<?php if ($savemsg) print_info_box($savemsg); ?>
124
<form action="services_dyndns_edit.php" method="post" name="iform" id="iform">
125
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
126
                <tr>
127
                  <td colspan="2" valign="top" class="optsect_t">
128
				  <table border="0" cellspacing="0" cellpadding="0" width="100%">
129
				  <tr><td class="optsect_s"><strong>Dynamic DNS client</strong></td></tr>
130
				  </table>
131
				  </td>
132
                </tr>
133
                <tr>
134
                  <td width="22%" valign="top" class="vncellreq">Disable</td>
135
				  <td width="78%" class="vtable">
136
				    <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?>>
137
				  </td>
138
                </tr>
139
                <tr>
140
                  <td width="22%" valign="top" class="vncellreq">Service type</td>
141
                  <td width="78%" class="vtable">
142
			<select name="type" class="formselect" id="type">
143
                      <?php
144
						$types = explode(",", "DNS-O-Matic, DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,ODS.org,ZoneEdit,Loopia,freeDNS, DNSexit, OpenDNS");
145
						$vals = explode(" ", "dnsomatic dyndns dyndns-static dyndns-custom dhs dyns easydns noip ods zoneedit loopia freedns dnsexit opendns");
146
						$j = 0; for ($j = 0; $j < count($vals); $j++): ?>
147
                      <option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['type']) echo "selected";?>>
148
                      <?=htmlspecialchars($types[$j]);?>
149
                      </option>
150
                      <?php endfor; ?>
151
                    </select></td>
152
				</tr>
153
				<tr>
154
				   <td width="22%" valign="top" class="vncellreq">Interface to monitor</td>  
155
				   <td width="78%" class="vtable">
156
				   <select name="interface" class="formselect" id="interface">
157
				   <?php $iflist = get_configured_interface_with_descr();
158
				   		foreach ($iflist as $if => $ifdesc):?>
159
							<option value="<?=$if;?>" <?php if ($pconfig['interface'] == $if) echo "selected";?>><?=$ifdesc;?></option>
160
					<?php endforeach; ?>
161
					</select>
162
					</td>
163
					</td>
164
				</tr>	
165
                <tr>
166
                  <td width="22%" valign="top" class="vncellreq">Hostname/Interface</td>
167
                  <td width="78%" class="vtable">
168
                    <input name="host" type="text" class="formfld unknown" id="host" size="30" value="<?=htmlspecialchars($pconfig['host']);?>">
169
                    <br>
170
				    <span class="vexpl">
171
				    <span class="red"><strong>Note:<br></strong>
172
				    </span>
173
					Enter the complete host/domain name.  example:  myhost.dyndns.org
174
				    </span>
175
		          </td>
176
				</tr>
177
                <tr>
178
                  <td width="22%" valign="top" class="vncell">MX</td>
179
                  <td width="78%" class="vtable">
180
                    <input name="mx" type="text" class="formfld unknown" id="mx" size="30" value="<?=htmlspecialchars($pconfig['mx']);?>">
181
                    <br>
182
					Note: With DynDNS service you can only use a hostname, not an IP address.
183
					<br>
184
                    Set this option only if you need a special MX record. Not
185
                    all services support this.</td>
186
				</tr>
187
                <tr>
188
                  <td width="22%" valign="top" class="vncellreq">Wildcards</td>
189
                  <td width="78%" class="vtable">
190
                    <input name="wildcard" type="checkbox" id="wildcard" value="yes" <?php if ($pconfig['wildcard']) echo "checked"; ?>>
191
                    Enable Wildcard</td>
192
				</tr>
193
                <tr>
194
                  <td width="22%" valign="top" class="vncellreq">Username</td>
195
                  <td width="78%" class="vtable">
196
                    <input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
197
                  </td>
198
                </tr>
199
                <tr>
200
                  <td width="22%" valign="top" class="vncellreq">Password</td>
201
                  <td width="78%" class="vtable">
202
                    <input name="password" type="password" class="formfld pwd" id="password" size="20" value="<?=htmlspecialchars($pconfig['password']);?>">
203
                  </td>
204
                </tr>
205
                <tr>
206
                  <td width="22%" valign="top" class="vncellreq">Description</td>
207
                  <td width="78%" class="vtable">
208
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="60" value="<?=htmlspecialchars($pconfig['descr']);?>">
209
                  </td>
210
                </tr>
211
                <tr>
212
                  <td width="22%" valign="top">&nbsp;</td>
213
                  <td width="78%">
214
                    <input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
215
					<a href="services_dyndns.php"><input name="cancel" type="button" class="formbtn" value="Cancel"></a>
216
					<?php if (isset($id) && $a_dyndns[$id]): ?>
217
						<input name="id" type="hidden" value="<?=$id;?>">
218
					<?php endif; ?>
219
                  </td>
220
                </tr>
221
                <tr>
222
                  <td width="22%" valign="top">&nbsp;</td>
223
                  <td width="78%"><span class="vexpl"><span class="red"><strong>Note:<br>
224
                    </strong></span>You must configure a DNS server in <a href="system.php">System:
225
                    General setup</a> or allow the DNS server list to be overridden
226
                    by DHCP/PPP on WAN for dynamic DNS updates to work.</span></td>
227
                </tr>
228
              </table>
229
</form>
230
<?php include("fend.inc"); ?>
231
</body>
232
</html>
(128-128/206)