diff options
author | jim-p <jimp@pfsense.org> | 2016-02-01 12:35:59 -0500 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2016-02-01 12:35:59 -0500 |
commit | 6635aa0f6c7a166a56a92ea2492930a67e825ce1 (patch) | |
tree | 89ef7530c988626b748db3af5946fa553f741443 /src/usr | |
parent | de22e304d4b00a77089c337e1b8ef88097e9308b (diff) | |
download | pfsense-6635aa0f6c7a166a56a92ea2492930a67e825ce1.zip pfsense-6635aa0f6c7a166a56a92ea2492930a67e825ce1.tar.gz |
Change Namecheap dyndns to use split hostname and domain name fields. Upgrade existing entries automatically. Implements #4366
Code should be generic enough that if other DynDNS providers would work better with a separate domain field, they can pick up the feature without too much trouble.
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/local/www/services_dyndns.php | 18 | ||||
-rw-r--r-- | src/usr/local/www/services_dyndns_edit.php | 42 |
2 files changed, 52 insertions, 8 deletions
diff --git a/src/usr/local/www/services_dyndns.php b/src/usr/local/www/services_dyndns.php index c9f24ff..e095cb2 100644 --- a/src/usr/local/www/services_dyndns.php +++ b/src/usr/local/www/services_dyndns.php @@ -70,7 +70,12 @@ $a_dyndns = &$config['dyndnses']['dyndns']; if ($_GET['act'] == "del") { $conf = $a_dyndns[$_GET['id']]; - @unlink("{$g['conf_path']}/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($conf['host']) . "{$conf['id']}.cache"); + if ($conf['type'] == "namecheap") { + $hostname = $conf['host'] . "." . $conf['domainname']; + } else { + $hostname = $conf['host']; + } + @unlink("{$g['conf_path']}/dyndns_{$conf['interface']}{$conf['type']}" . escapeshellarg($hostname) . "{$conf['id']}.cache"); unset($a_dyndns[$_GET['id']]); write_config(); @@ -124,6 +129,11 @@ display_top_tabs($tab_array); <?php $i = 0; foreach ($a_dyndns as $dyndns): + if ($dyndns['type'] == "namecheap") { + $hostname = $dyndns['host'] . "." . $dyndns['domainname']; + } else { + $hostname = $dyndns['host']; + } ?> <tr<?=!isset($dyndns['enable'])?' class="disabled"':''?>> <td> @@ -162,13 +172,13 @@ foreach ($a_dyndns as $dyndns): </td> <td> <?php - print(htmlspecialchars($dyndns['host'])); + print(htmlspecialchars($hostname)); ?> </td> <td> <?php - $filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache"; - $filename_v6 = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}_v6.cache"; + $filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($hostname) . "{$dyndns['id']}.cache"; + $filename_v6 = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($hostname) . "{$dyndns['id']}_v6.cache"; if (file_exists($filename)) { $ipaddr = dyndnsCheckIP($dyndns['interface']); $cached_ip_s = explode(":", file_get_contents($filename)); diff --git a/src/usr/local/www/services_dyndns_edit.php b/src/usr/local/www/services_dyndns_edit.php index e28dc3e..8f69251 100644 --- a/src/usr/local/www/services_dyndns_edit.php +++ b/src/usr/local/www/services_dyndns_edit.php @@ -92,6 +92,7 @@ if (isset($id) && isset($a_dyndns[$id])) { $pconfig['username'] = $a_dyndns[$id]['username']; $pconfig['password'] = $a_dyndns[$id]['password']; $pconfig['host'] = $a_dyndns[$id]['host']; + $pconfig['domainname'] = $a_dyndns[$id]['domainname']; $pconfig['mx'] = $a_dyndns[$id]['mx']; $pconfig['type'] = $a_dyndns[$id]['type']; $pconfig['enable'] = !isset($a_dyndns[$id]['enable']); @@ -129,6 +130,10 @@ if ($_POST) { $reqdfieldsn[] = gettext("Password"); $reqdfields[] = "username"; $reqdfieldsn[] = gettext("Username"); + if ($pconfig['type'] == "namecheap") { + $reqdfields[] = "domainname"; + $reqdfieldsn[] = gettext("Domain Name"); + } } else { $reqdfields[] = "updateurl"; $reqdfieldsn[] = gettext("Update URL"); @@ -173,6 +178,7 @@ if ($_POST) { $dyndns['password'] = $a_dyndns[$id]['password'];; } $dyndns['host'] = $_POST['host']; + $dyndns['domainname'] = $_POST['domainname']; $dyndns['mx'] = $_POST['mx']; $dyndns['wildcard'] = $_POST['wildcard'] ? true : false; $dyndns['verboselog'] = $_POST['verboselog'] ? true : false; @@ -301,15 +307,28 @@ $section->addInput(new Form_Select( $interfacelist ))->setHelp('This is almost always the same as the Interface to Monitor. '); -$section->addInput(new Form_Input( +$group = new Form_Group('Hostname'); + +$group->add(new Form_Input( 'host', 'Hostname', 'text', $pconfig['host'] -))->setHelp('Enter the complete fully qualified domain name. Example: myhost.dyndns.org'. '<br />' . +)); +$group->add(new Form_Input( + 'domainname', + 'Domain Name', + 'text', + $pconfig['domainname'] +)); + +$group->setHelp('Enter the complete fully qualified domain name. Example: myhost.dyndns.org'. '<br />' . 'he.net tunnelbroker: Enter your tunnel ID' . '<br />' . 'GleSYS: Enter your record ID' . '<br />' . - 'DNSimple: Enter only the domain name.'); + 'DNSimple: Enter only the domain name.' . '<br />' . + 'Namecheap: Enter the hostname and the domain separately, with the domain being the domain or subdomain zone being handled by Namecheap.'); + +$section->add($group); $section->addInput(new Form_Input( 'mx', @@ -434,6 +453,7 @@ events.push(function() { switch (service) { case "custom" : case "custom-v6" : + hideGroupInput('domainname', true); hideInput('resultmatch', false); hideInput('updateurl', false); hideInput('requestif', false); @@ -448,6 +468,7 @@ events.push(function() { case "dnsimple": case "route53": + hideGroupInput('domainname', true); hideInput('resultmatch', true); hideInput('updateurl', true); hideInput('requestif', true); @@ -459,8 +480,21 @@ events.push(function() { hideInput('zoneid', false); hideInput('ttl', false); break; - + case "namecheap": + hideGroupInput('domainname', false); + hideInput('resultmatch', true); + hideInput('updateurl', true); + hideInput('requestif', true); + hideCheckbox('curl_ipresolve_v4', true); + hideCheckbox('curl_ssl_verifypeer', true); + hideInput('host', false); + hideInput('mx', false); + hideCheckbox('wildcard', false); + hideInput('zoneid', true); + hideInput('ttl', true); + break; default: + hideGroupInput('domainname', true); hideInput('resultmatch', true); hideInput('updateurl', true); hideInput('requestif', true); |