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 @@
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 */
function services_radvd_configure($blacklist = array())
{
......@@ -1595,6 +1592,40 @@ function services_dhcrelay6_configure()
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) {
if (!isset($conf['enable']))
......
<?php
/*
Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2008 Ermal Luçi
......@@ -119,16 +120,14 @@ $main_buttons = array(
</td>
<td class="listr">
<?php
$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS);
$vals = explode(" ", DYNDNS_PROVIDER_VALUES);
for ($j = 0; $j < count($vals); $j++)
if ($vals[$j] == $dyndns['type']) {
if (!isset($dyndns['enable']))
echo "<span class=\"gray\">" . htmlspecialchars($types[$j]) . "</span>";
else
echo htmlspecialchars($types[$j]);
break;
$types = services_dyndns_list();
if (isset($types[$dyndns['type']])) {
if (!isset($dyndns['enable'])) {
echo '<span class="gray">' . htmlspecialchars($types[$dyndns['type']]) . '</span>';
} else {
echo htmlspecialchars($types[$dyndns['type']]);
}
}
?>
</td>
<td class="listr">
......
<?php
/*
Copyright (C) 2014-2015 Deciso B.V.
Copyright (C) 2008 Ermal Luçi
......@@ -83,7 +84,7 @@ if ($_POST) {
$reqdfieldsn = array();
$reqdfields = array("type");
$reqdfieldsn = array(gettext("Service type"));
if ($pconfig['type'] != "custom" && $pconfig['type'] != "custom-v6") {
if ($pconfig['type'] != 'custom' && $pconfig['type'] != 'custom-v6') {
$reqdfields[] = "host";
$reqdfieldsn[] = gettext("Hostname");
$reqdfields[] = "password";
......@@ -97,7 +98,7 @@ if ($_POST) {
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 */
if ($pconfig['type'] == "namecheap" && substr($_POST['host'], 0, 2) == '@.')
$host_to_check = substr($_POST['host'], 2);
......@@ -109,6 +110,7 @@ if ($_POST) {
unset($host_to_check);
}
if (($_POST['mx'] && !is_domain($_POST['mx'])))
$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'] == "")))
......@@ -250,14 +252,14 @@ include("head.inc");
<td width="22%" valign="top" class="vncellreq"><?=gettext("Service type");?></td>
<td width="78%" class="vtable">
<select name="type" class="formselect" id="type" onchange="_onTypeChange(this.options[this.selectedIndex].value);">
<?php
$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS);
$vals = explode(" ", DYNDNS_PROVIDER_VALUES);
$j = 0; for ($j = 0; $j < count($vals); $j++): ?>
<option value="<?=$vals[$j];?>" <?php if ($vals[$j] == $pconfig['type']) echo "selected=\"selected\"";?>>
<?=htmlspecialchars($types[$j]);?>
</option>
<?php endfor; ?>
<?php
$types = services_dyndns_list();
foreach ($types as $value => $type) {
?>
<option value="<?=$value;?>" <?php if ($value == $pconfig['type']) echo 'selected="selected"';?>><?=htmlspecialchars($type);?></option>
<?php
}
?>
</select></td>
</tr>
<tr>
......
<?php
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2008 Ermal Luci
Copyright (C) 2013 Stanley P. Miller \ stan-qaz
All rights reserved.
......@@ -27,7 +28,6 @@
POSSIBILITY OF SUCH DAMAGE.
*/
$nocsrf = true;
require_once("guiconfig.inc");
......@@ -103,16 +103,14 @@ if($_REQUEST['getdyndnsstatus']) {
</td>
<td class="listr">
<?php
$types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS);
$vals = explode(" ", DYNDNS_PROVIDER_VALUES);
for ($j = 0; $j < count($vals); $j++)
if ($vals[$j] == $dyndns['type']) {
if (!isset($dyndns['enable']))
echo "<span class=\"gray\">".htmlspecialchars($types[$j])."</span>";
else
echo htmlspecialchars($types[$j]);
break;
$types = services_dyndns_list();
if (isset($types[$dyndns['type']])) {
if (!isset($dyndns['enable'])) {
echo '<span class="gray">' . htmlspecialchars($types[$dyndns['type']]) . '</span>';
} else {
echo htmlspecialchars($types[$dyndns['type']]);
}
}
?>
</td>
<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