summaryrefslogtreecommitdiffstats
path: root/usr/local/www/services_dyndns_edit.php
diff options
context:
space:
mode:
authorMatt Corallo <matt@bluematt.me>2011-06-03 00:56:39 +0200
committerMatt Corallo <matt@bluematt.me>2012-05-22 23:58:30 +0200
commit37f3e7041f927d692c7381b8df33d48ae1097cf1 (patch)
tree8b73a811e4abca721d74efbe828310dac7a0847f /usr/local/www/services_dyndns_edit.php
parentaec0f2fd54bcd617ad469db67fe34937f339936e (diff)
downloadpfsense-37f3e7041f927d692c7381b8df33d48ae1097cf1.zip
pfsense-37f3e7041f927d692c7381b8df33d48ae1097cf1.tar.gz
Add the option to use a custom Dynamic DNS Provider via an Update URL and Result Match.
Diffstat (limited to 'usr/local/www/services_dyndns_edit.php')
-rw-r--r--usr/local/www/services_dyndns_edit.php139
1 files changed, 114 insertions, 25 deletions
diff --git a/usr/local/www/services_dyndns_edit.php b/usr/local/www/services_dyndns_edit.php
index 70a112a..596dee7 100644
--- a/usr/local/www/services_dyndns_edit.php
+++ b/usr/local/www/services_dyndns_edit.php
@@ -71,6 +71,9 @@ if (isset($id) && isset($a_dyndns[$id])) {
$pconfig['wildcard'] = isset($a_dyndns[$id]['wildcard']);
$pconfig['zoneid'] = $a_dyndns[$id]['zoneid'];
$pconfig['ttl'] = isset($a_dyndns[$id]['ttl']);
+ $pconfig['updateurl'] = $a_dyndns[$id]['updateurl'];
+ $pconfig['resultmatch'] = $a_dyndns[$id]['resultmatch'];
+ $pconfig['requestif'] = $a_dyndns[$id]['requestif'];
$pconfig['descr'] = $a_dyndns[$id]['descr'];
}
@@ -85,15 +88,26 @@ if ($_POST) {
/* input validation */
$reqdfields = array();
$reqdfieldsn = array();
- $reqdfields = array("host", "username", "password", "type");
- $reqdfieldsn = array(gettext("Hostname"),gettext("Username"),gettext("Password"),gettext("Service type"));
+ $reqdfields = array("type");
+ $reqdfieldsn = array(gettext("Service type"));
+ if ($pconfig['type'] != "custom") {
+ $reqdfields[] = "host";
+ $reqdfieldsn[] = gettext("Hostname");
+ $reqdfields[] = "password";
+ $reqdfieldsn[] = gettext("Password");
+ $reqdfields[] = "username";
+ $reqdfieldsn[] = gettext("Username");
+ }else{
+ $reqdfields[] = "updateurl";
+ $reqdfieldsn[] = gettext("Update URL");
+ }
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
if (($_POST['mx'] && !is_domain($_POST['mx'])))
$input_errors[] = gettext("The MX contains invalid characters.");
- if (($_POST['username'] && !is_dyndns_username($_POST['username'])) || (($pconfig['type'] != "namecheap") && ($_POST['username'] == "")))
- $input_errors[] = gettext("The username contains invalid characters.");
+ if ((in_array("username", $reqdfields) && $_POST['username'] && !is_dyndns_username($_POST['username'])) || ((in_array("username", $reqdfields)) && ($_POST['username'] == "")))
+ $input_errors[] = gettext("The username contains invalid characters.");
if (!$input_errors) {
$dyndns = array();
@@ -107,6 +121,10 @@ if ($_POST) {
$dyndns['interface'] = $_POST['interface'];
$dyndns['zoneid'] = $_POST['zoneid'];
$dyndns['ttl'] = $_POST['ttl'];
+ $dyndns['updateurl'] = $_POST['updateurl'];
+ // Trim hard-to-type but sometimes returned characters
+ $dyndns['resultmatch'] = trim($_POST['resultmatch'], "\t\n\r");
+ $dyndns['type'] == "custom" ? $dyndns['requestif'] = $_POST['requestif'] : $dyndns['requestif'] = $_POST['interface'];
$dyndns['descr'] = $_POST['descr'];
$dyndns['force'] = isset($_POST['force']);
@@ -115,8 +133,16 @@ if ($_POST) {
if (isset($id) && $a_dyndns[$id])
$a_dyndns[$id] = $dyndns;
- else
- $a_dyndns[] = $dyndns;
+ else {
+ $a_dyndns[] = $dyndns;
+ $id = count($a_dyndns) - 1;
+ }
+
+ $dyndns['id'] = $id;
+ //Probably overkill, but its better to be safe
+ for($i = 0; $i < count($a_dyndns); $i++) {
+ $a_dyndns[$i]['id'] = $i;
+ }
write_config();
@@ -136,6 +162,41 @@ include("head.inc");
<?php include("fbegin.inc"); ?>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if ($savemsg) print_info_box($savemsg); ?>
+<script type="text/javascript">
+function _onTypeChange(type){
+ switch(type) {
+ case "custom":
+ document.getElementById("_resulttr").style.display = '';
+ document.getElementById("_urltr").style.display = '';
+ document.getElementById("_requestiftr").style.display = '';
+ document.getElementById("_hostnametr").style.display = 'none';
+ document.getElementById("_mxtr").style.display = 'none';
+ document.getElementById("_wildcardtr").style.display = 'none';
+ document.getElementById("r53_zoneid").style.display='none';
+ document.getElementById("r53_ttl").style.display='none';
+ break;
+ case "route53":
+ document.getElementById("_resulttr").style.display = 'none';
+ document.getElementById("_urltr").style.display = 'none';
+ document.getElementById("_requestiftr").style.display = 'none';
+ document.getElementById("_hostnametr").style.display = '';
+ document.getElementById("_mxtr").style.display = '';
+ document.getElementById("_wildcardtr").style.display = '';
+ document.getElementById("r53_zoneid").style.display='';
+ document.getElementById("r53_ttl").style.display='';
+ break;
+ default:
+ document.getElementById("_resulttr").style.display = 'none';
+ document.getElementById("_urltr").style.display = 'none';
+ document.getElementById("_requestiftr").style.display = 'none';
+ document.getElementById("_hostnametr").style.display = '';
+ document.getElementById("_mxtr").style.display = '';
+ document.getElementById("_wildcardtr").style.display = '';
+ document.getElementById("r53_zoneid").style.display='none';
+ document.getElementById("r53_ttl").style.display='none';
+ }
+}
+</script>
<form action="services_dyndns_edit.php" method="post" name="iform" id="iform">
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
@@ -154,10 +215,10 @@ include("head.inc");
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Service type");?></td>
<td width="78%" class="vtable">
- <select name="type" class="formselect" id="type">
+ <select name="type" class="formselect" id="type" onchange="_onTypeChange(this.options[this.selectedIndex].value);">
<?php
- $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");
- $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");
+ $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");
+ $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");
$j = 0; for ($j = 0; $j < count($vals); $j++): ?>
<option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['type']) echo "selected";?>>
<?=htmlspecialchars($types[$j]);?>
@@ -177,7 +238,20 @@ include("head.inc");
</td>
</td>
</tr>
- <tr>
+ <tr id="_requestiftr">
+ <td width="22%" valign="top" class="vncellreq"><?=gettext("Interface to send update from");?></td>
+ <td width="78%" class="vtable">
+ <select name="requestif" class="formselect" id="requestif">
+ <?php $iflist = get_configured_interface_with_descr();
+ foreach ($iflist as $if => $ifdesc):?>
+ <option value="<?=$if;?>" <?php if ($pconfig['requestif'] == $if) echo "selected";?>><?=$ifdesc;?></option>
+ <?php endforeach; ?>
+ </select>
+ <br/><?= gettext("Note: This is almost always the same as the Interface to Monitor.");?>
+ </td>
+ </td>
+ </tr>
+ <tr id="_hostnametr">
<td width="22%" valign="top" class="vncellreq"><?=gettext("Hostname");?></td>
<td width="78%" class="vtable">
<input name="host" type="text" class="formfld unknown" id="host" size="30" value="<?=htmlspecialchars($pconfig['host']);?>">
@@ -190,7 +264,7 @@ include("head.inc");
</span>
</td>
</tr>
- <tr>
+ <tr id="_mxtr">
<td width="22%" valign="top" class="vncell"><?=gettext("MX"); ?></td>
<td width="78%" class="vtable">
<input name="mx" type="text" class="formfld unknown" id="mx" size="30" value="<?=htmlspecialchars($pconfig['mx']);?>">
@@ -200,18 +274,19 @@ include("head.inc");
<?=gettext("Set this option only if you need a special MX record. Not".
" all services support this.");?></td>
</tr>
- <tr>
+ <tr id="_wildcardtr">
<td width="22%" valign="top" class="vncell"><?=gettext("Wildcards"); ?></td>
<td width="78%" class="vtable">
<input name="wildcard" type="checkbox" id="wildcard" value="yes" <?php if ($pconfig['wildcard']) echo "checked"; ?>>
<?=gettext("Enable ");?><?=gettext("Wildcard"); ?></td>
</tr>
- <tr>
+ <tr id="_usernametr">
<td width="22%" valign="top" class="vncellreq"><?=gettext("Username");?></td>
<td width="78%" class="vtable">
<input name="username" type="text" class="formfld user" id="username" size="20" value="<?=htmlspecialchars($pconfig['username']);?>">
- <br/><?= gettext("Username is required for all types except Namecheap and FreeDNS.");?>
+ <br/><?= gettext("Username is required for all types except Namecheap, FreeDNS and Custom Entries.");?>
<br/><?= gettext("Route 53: Enter your Access Key ID.");?>
+ <br/><?= gettext("For Custom Entries, Username and Password represent HTTP Authentication username and passwords.");?>
</td>
</tr>
<tr>
@@ -231,6 +306,30 @@ include("head.inc");
<br/><?= gettext("Enter Zone ID that you received when you created your domain in Route 53.");?>
</td>
</tr>
+ <tr id="_urltr">
+ <td width="22%" valign="top" class="vncell"><?=gettext("Update URL");?></td>
+ <td width="78%" class="vtable">
+ <input name="updateurl" type="text" class="formfld unknown" id="updateurl" size="60" value="<?=htmlspecialchars($pconfig['updateurl']);?>">
+ <br/><?= gettext("This is the only field required by for Custom Dynamic DNS, and is only used by Custom Entries.");?>
+ <br/>
+ <?= gettext("If you need the new IP to be included in the request, put %IP% in its place.");?>
+ </td>
+ </tr>
+ <tr id="_resulttr">
+ <td width="22%" valign="top" class="vncell"><?=gettext("Result Match");?></td>
+ <td width="78%" class="vtable">
+ <textarea name="resultmatch" class="formpre" id="resultmatch" cols="65" rows="7"><?=htmlspecialchars($pconfig['resultmatch']);?></textarea>
+ <br/><?= gettext("This field is only used by Custom Dynamic DNS Entries.");?>
+ <br/>
+ <?= gettext("This field should be identical to what your DDNS Provider will return if the update succeeds, leave it blank to disable checking of returned results.");?>
+ <br/>
+ <?= gettext("If you need the new IP to be included in the request, put %IP% in its place.");?>
+ <br/>
+ <?= gettext("If you need to include multiple possible values, sperate them with a |. If your provider includes a |, escape it with \\|");?>
+ <br/>
+ <?= gettext("Tabs (\\t), newlines (\\n) and carriage returns (\\r) at the beginning or end of the returned results are removed before comparison.");?>
+ </td>
+ </tr>
<tr>
<tr id="r53_ttl" style="display:none">
@@ -272,17 +371,7 @@ include("head.inc");
<?php include("fend.inc"); ?>
<script type="text/javascript">
-var selectmenu=document.getElementById("type")
-selectmenu.onchange=function(){
- var chosenoption=this.options[this.selectedIndex]
- if (chosenoption.value=="route53"){
- document.getElementById("r53_zoneid").style.display="";
- document.getElementById("r53_ttl").style.display="";
- } else if (chosenoption.value !="route53"){
- document.getElementById("r53_zoneid").style.display="none";
- document.getElementById("r53_ttl").style.display="none";
- }
-}
+_onTypeChange("<?php echo $pconfig['type']; ?>");
</script>
</body>
OpenPOWER on IntegriCloud