Project

General

Profile

Download (9.14 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
require("guiconfig.inc");
30

    
31
if (!is_array($config['dyndnses']['dyndns'])) {
32
	$config['dyndnses']['dyndns'] = array();
33
}
34

    
35
$a_dyndns = &$config['dyndnses']['dyndns'];
36

    
37
$id = $_GET['id'];
38
if (isset($_POST['id']))
39
	$id = $_POST['id'];
40

    
41
if (isset($id) && isset($a_dyndns[$id])) {
42
	$pconfig['username'] = $a_dyndns[$id]['username'];
43
	$pconfig['password'] = $a_dyndns[$id]['password'];
44
	$pconfig['host'] = $a_dyndns[$id]['host'];
45
	$pconfig['mx'] = $a_dyndns[$id]['mx'];
46
	$pconfig['type'] = $a_dyndns[$id]['type'];
47
	$pconfig['enable'] = isset($a_dyndns[$id]['enable']);
48
	$pconfig['interface'] = $a_dyndns[$id]['interface'];
49
	$pconfig['wildcard'] = isset($a_dyndns[$id]['wildcard']);
50
	$pconfig['descr'] = $a_dyndns[$id]['descr'];
51
}
52

    
53
if ($_POST) {
54

    
55
	unset($input_errors);
56
	$pconfig = $_POST;
57

    
58
	/* input validation */
59
	$reqdfields = array();
60
	$reqdfieldsn = array();
61
	$reqdfields = array_merge($reqdfields, explode(" ", "host username password type"));
62
	$reqdfieldsn = array_merge($reqdfieldsn, explode(",", "Hostname,Username,Password,Service type"));
63

    
64
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
65

    
66
	if (($_POST['mx'] && !is_domain($_POST['mx']))) 
67
		$input_errors[] = "The MX contains invalid characters.";
68
	if (($_POST['username'] && !is_dyndns_username($_POST['username'])) || $_POST['username'] == "") 
69
		$input_errors[] = "The username contains invalid characters.";
70

    
71
	if (!$input_errors) {
72
		$dyndns = array();
73
		$dyndns['type'] = $_POST['type'];
74
		$dyndns['username'] = $_POST['username'];
75
		$dyndns['password'] = $_POST['password'];
76
		$dyndns['host'] = $_POST['host'];
77
		$dyndns['mx'] = $_POST['mx'];
78
		$dyndns['wildcard'] = $_POST['wildcard'] ? true : false;
79
		$dyndns['enable'] = $_POST['enable'] ? false : true;
80
		$dyndns['interface'] = $_POST['interface'];
81
		$dyndns['descr'] = $_POST['descr'];
82

    
83
		if (isset($id) && $a_dyndns[$id])
84
			$a_dyndns[$id] = $dyndns;
85
		else
86
			$a_dyndns[] = $dyndns;
87

    
88
		write_config();
89

    
90
		header("Location: services_dyndns.php");
91
		exit;
92

    
93
		/* XXX: Make this with a touch file */
94
		$retval = 0;
95

    
96
		/* nuke the cache file */
97
		config_lock();
98
		services_dyndns_reset();
99
		$retval = services_dyndns_configure();
100
		config_unlock();
101
		$savemsg = get_std_save_message($retval);
102
	}
103
}
104

    
105
$pgtitle = array("Services","Dynamic DNS client");
106
include("head.inc");
107

    
108
?>
109

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