Commit 45602999 authored by Franco Fichtner's avatar Franco Fichtner

services/dyndns: general sanity and custom* hostname apply fix

parent 9e078f91
...@@ -27,9 +27,6 @@ ...@@ -27,9 +27,6 @@
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
define('DYNDNS_PROVIDER_VALUES', 'dnsomatic dyndns dyndns-static dyndns-custom dhs dyns easydns noip noip-free ods zoneedit loopia freedns dnsexit opendns namecheap he-net he-net-v6 he-net-tunnelbroker selfhost route53 cloudflare custom custom-v6 eurodns gratisdns ovh-dynhost citynetwork');
define('DYNDNS_PROVIDER_DESCRIPTIONS', 'DNS-O-Matic,DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,No-IP (free),ODS.org,ZoneEdit,Loopia,freeDNS,DNSexit,OpenDNS,Namecheap,HE.net,HE.net (v6),HE.net Tunnelbroker,SelfHost,Route 53,CloudFlare,Custom,Custom (v6),Euro Dns,GratisDNS,OVH DynHOST,City Network');
/* implement ipv6 route advertising deamon */ /* implement ipv6 route advertising deamon */
function services_radvd_configure($blacklist = array()) function services_radvd_configure($blacklist = array())
{ {
...@@ -1595,6 +1592,40 @@ function services_dhcrelay6_configure() ...@@ -1595,6 +1592,40 @@ function services_dhcrelay6_configure()
return 0; return 0;
} }
function services_dyndns_list()
{
return array(
'dnsomatic' => 'DNS-O-Matic',
'dyndns' => 'DynDNS (dynamic)',
'dyndns-static' => 'DynDNS (static)',
'dyndns-custom' => 'DynDNS (custom)',
'dhs' => 'DHS',
'dyns' => 'DyNS',
'easydns' => 'easyDNS',
'noip' => 'No-IP',
'noip-free' => 'No-IP (free)',
'ods' => 'ODS.org',
'zoneedit' => 'ZoneEdit',
'loopia' => 'Loopia',
'freedns' => 'freeDNS',
'dnsexit' => 'DNSexit',
'opendns' => 'OpenDNS',
'namecheap' => 'Namecheap',
'he-net' => 'HE.net',
'he-net-v6' => 'HE.net (v6)',
'he-net-tunnelbroker' => 'HE.net Tunnelbroker',
'selfhost' => 'SelfHost',
'route53' => 'Route 53',
'cloudflare' => 'CloudFlare',
'custom' => 'Custom',
'custom-v6' => 'Custom (v6)',
'eurodns' => 'EuroDNS',
'gratisdns' => 'GratisDNS',
'ovh-dynhost' => 'OVH DynHOST',
'citynetwork' => 'City Network'
);
}
function services_dyndns_configure_client($conf) { function services_dyndns_configure_client($conf) {
if (!isset($conf['enable'])) if (!isset($conf['enable']))
......
<?php <?php
/* /*
Copyright (C) 2014-2015 Deciso B.V. Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2008 Ermal Luçi Copyright (C) 2008 Ermal Luçi
...@@ -119,16 +120,14 @@ $main_buttons = array( ...@@ -119,16 +120,14 @@ $main_buttons = array(
</td> </td>
<td class="listr"> <td class="listr">
<?php <?php
$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS); $types = services_dyndns_list();
$vals = explode(" ", DYNDNS_PROVIDER_VALUES); if (isset($types[$dyndns['type']])) {
for ($j = 0; $j < count($vals); $j++) if (!isset($dyndns['enable'])) {
if ($vals[$j] == $dyndns['type']) { echo '<span class="gray">' . htmlspecialchars($types[$dyndns['type']]) . '</span>';
if (!isset($dyndns['enable'])) } else {
echo "<span class=\"gray\">" . htmlspecialchars($types[$j]) . "</span>"; echo htmlspecialchars($types[$dyndns['type']]);
else
echo htmlspecialchars($types[$j]);
break;
} }
}
?> ?>
</td> </td>
<td class="listr"> <td class="listr">
......
<?php <?php
/* /*
Copyright (C) 2014-2015 Deciso B.V. Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2008 Ermal Luçi Copyright (C) 2008 Ermal Luçi
...@@ -83,7 +84,7 @@ if ($_POST) { ...@@ -83,7 +84,7 @@ if ($_POST) {
$reqdfieldsn = array(); $reqdfieldsn = array();
$reqdfields = array("type"); $reqdfields = array("type");
$reqdfieldsn = array(gettext("Service type")); $reqdfieldsn = array(gettext("Service type"));
if ($pconfig['type'] != "custom" && $pconfig['type'] != "custom-v6") { if ($pconfig['type'] != 'custom' && $pconfig['type'] != 'custom-v6') {
$reqdfields[] = "host"; $reqdfields[] = "host";
$reqdfieldsn[] = gettext("Hostname"); $reqdfieldsn[] = gettext("Hostname");
$reqdfields[] = "password"; $reqdfields[] = "password";
...@@ -97,7 +98,7 @@ if ($_POST) { ...@@ -97,7 +98,7 @@ if ($_POST) {
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
if (isset($_POST['host'])) { if (isset($_POST['host']) && in_array('host', $reqdfields)) {
/* Namecheap can have a @. in hostname */ /* Namecheap can have a @. in hostname */
if ($pconfig['type'] == "namecheap" && substr($_POST['host'], 0, 2) == '@.') if ($pconfig['type'] == "namecheap" && substr($_POST['host'], 0, 2) == '@.')
$host_to_check = substr($_POST['host'], 2); $host_to_check = substr($_POST['host'], 2);
...@@ -109,6 +110,7 @@ if ($_POST) { ...@@ -109,6 +110,7 @@ if ($_POST) {
unset($host_to_check); unset($host_to_check);
} }
if (($_POST['mx'] && !is_domain($_POST['mx']))) if (($_POST['mx'] && !is_domain($_POST['mx'])))
$input_errors[] = gettext("The MX contains invalid characters."); $input_errors[] = gettext("The MX contains invalid characters.");
if ((in_array("username", $reqdfields) && $_POST['username'] && !is_dyndns_username($_POST['username'])) || ((in_array("username", $reqdfields)) && ($_POST['username'] == ""))) if ((in_array("username", $reqdfields) && $_POST['username'] && !is_dyndns_username($_POST['username'])) || ((in_array("username", $reqdfields)) && ($_POST['username'] == "")))
...@@ -250,14 +252,14 @@ include("head.inc"); ...@@ -250,14 +252,14 @@ include("head.inc");
<td width="22%" valign="top" class="vncellreq"><?=gettext("Service type");?></td> <td width="22%" valign="top" class="vncellreq"><?=gettext("Service type");?></td>
<td width="78%" class="vtable"> <td width="78%" class="vtable">
<select name="type" class="formselect" id="type" onchange="_onTypeChange(this.options[this.selectedIndex].value);"> <select name="type" class="formselect" id="type" onchange="_onTypeChange(this.options[this.selectedIndex].value);">
<?php <?php
$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS); $types = services_dyndns_list();
$vals = explode(" ", DYNDNS_PROVIDER_VALUES); foreach ($types as $value => $type) {
$j = 0; for ($j = 0; $j < count($vals); $j++): ?> ?>
<option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['type']) echo "selected=\"selected\"";?>> <option value="<?=$value;?>" <?php if ($value == $pconfig['type']) echo 'selected="selected"';?>><?=htmlspecialchars($type);?></option>
<?=htmlspecialchars($types[$j]);?> <?php
</option> }
<?php endfor; ?> ?>
</select></td> </select></td>
</tr> </tr>
<tr> <tr>
......
<?php <?php
/* /*
Copyright (C) 2014 Deciso B.V. Copyright (C) 2014 Deciso B.V.
Copyright (C) 2008 Ermal Luci Copyright (C) 2008 Ermal Luci
Copyright (C) 2013 Stanley P. Miller \ stan-qaz Copyright (C) 2013 Stanley P. Miller \ stan-qaz
All rights reserved. All rights reserved.
...@@ -27,7 +28,6 @@ ...@@ -27,7 +28,6 @@
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
$nocsrf = true; $nocsrf = true;
require_once("guiconfig.inc"); require_once("guiconfig.inc");
...@@ -103,16 +103,14 @@ if($_REQUEST['getdyndnsstatus']) { ...@@ -103,16 +103,14 @@ if($_REQUEST['getdyndnsstatus']) {
</td> </td>
<td class="listr"> <td class="listr">
<?php <?php
$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS); $types = services_dyndns_list();
$vals = explode(" ", DYNDNS_PROVIDER_VALUES); if (isset($types[$dyndns['type']])) {
for ($j = 0; $j < count($vals); $j++) if (!isset($dyndns['enable'])) {
if ($vals[$j] == $dyndns['type']) { echo '<span class="gray">' . htmlspecialchars($types[$dyndns['type']]) . '</span>';
if (!isset($dyndns['enable'])) } else {
echo "<span class=\"gray\">".htmlspecialchars($types[$j])."</span>"; echo htmlspecialchars($types[$dyndns['type']]);
else
echo htmlspecialchars($types[$j]);
break;
} }
}
?> ?>
</td> </td>
<td class="listr"> <td class="listr">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment