From 9c12c13069588d2d4df524db6e70819654f7f400 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 24 May 2015 12:38:27 +0545 Subject: Code style services dyndns --- usr/local/www/services_dyndns.php | 257 ++++++++++--------- usr/local/www/services_dyndns_edit.php | 453 +++++++++++++++++---------------- 2 files changed, 379 insertions(+), 331 deletions(-) (limited to 'usr/local/www') diff --git a/usr/local/www/services_dyndns.php b/usr/local/www/services_dyndns.php index 6d2f678..5051f00 100644 --- a/usr/local/www/services_dyndns.php +++ b/usr/local/www/services_dyndns.php @@ -42,8 +42,9 @@ require("guiconfig.inc"); -if (!is_array($config['dyndnses']['dyndns'])) +if (!is_array($config['dyndnses']['dyndns'])) { $config['dyndnses']['dyndns'] = array(); +} $a_dyndns = &$config['dyndnses']['dyndns']; @@ -70,135 +71,157 @@ include("head.inc");
- - + - - - +
+
-
-
- - - - - - - - - - - - + + + - + echo htmlspecialchars($cached_ip); + echo ""; + } else if (file_exists($filename_v6)) { + $ipv6addr = get_interface_ipv6($dyndns['interface']); + $cached_ipv6_s = explode("|", file_get_contents($filename_v6)); + $cached_ipv6 = $cached_ipv6_s[0]; + if ($ipv6addr <> $cached_ipv6) { + echo ""; + } else { + echo ""; + } + echo htmlspecialchars($cached_ipv6); + echo ""; + } else { + echo "N/A"; + } +?> + + + + + + + + + + + + + +
- $ifdesc) { - if ($dyndns['interface'] == $if) { - if (!isset($dyndns['enable'])) - echo "{$ifdesc}"; - else - echo "{$ifdesc}"; - break; +
+
+ + + + + + + + + + + + - + - - + + - - - - - - - - - - - - -
+ $ifdesc) { + if ($dyndns['interface'] == $if) { + if (!isset($dyndns['enable'])) { + echo "{$ifdesc}"; + } else { + echo "{$ifdesc}"; } + break; } - $groupslist = return_gateway_groups_array(); - foreach ($groupslist as $if => $group) { - if ($dyndns['interface'] == $if) { - if (!isset($dyndns['enable'])) - echo "{$if}"; - else - echo "{$if}"; - break; + } + $groupslist = return_gateway_groups_array(); + foreach ($groupslist as $if => $group) { + if ($dyndns['interface'] == $if) { + if (!isset($dyndns['enable'])) { + echo "{$if}"; + } else { + echo "{$if}"; } + break; } - ?> - - " . htmlspecialchars($types[$j]) . ""; - else - echo htmlspecialchars($types[$j]); - break; + } +?> + +" . htmlspecialchars($types[$j]) . ""; + } else { + echo htmlspecialchars($types[$j]); } - ?> - - " . htmlspecialchars($dyndns['host']) . ""; - else - echo htmlspecialchars($dyndns['host']); - ?> - - $cached_ip) - echo ""; - else - echo ""; - echo htmlspecialchars($cached_ip); - echo ""; - } else if (file_exists($filename_v6)) { - $ipv6addr = get_interface_ipv6($dyndns['interface']); - $cached_ipv6_s = explode("|", file_get_contents($filename_v6)); - $cached_ipv6 = $cached_ipv6_s[0]; - if ($ipv6addr <> $cached_ipv6) - echo ""; - else - echo ""; - echo htmlspecialchars($cached_ipv6); - echo ""; + break; + } + } +?> + +" . htmlspecialchars($dyndns['host']) . ""; + } else { + echo htmlspecialchars($dyndns['host']); + } +?> + + $cached_ip) { + echo ""; } else { - echo "N/A"; + echo ""; } - ?> - - ".htmlspecialchars($dyndns['descr']).""; - else - echo htmlspecialchars($dyndns['descr']); - ?> - - edit -  ')">delete -
add

-
-
-
-

-
 
-
-
+".htmlspecialchars($dyndns['descr']).""; + } else { + echo htmlspecialchars($dyndns['descr']); + } +?> + + edit +  ')">delete +
+ add +
+

+ + +
+
+
+
+ +

+
 
+
+
diff --git a/usr/local/www/services_dyndns_edit.php b/usr/local/www/services_dyndns_edit.php index aa2bf43..0387dcf 100644 --- a/usr/local/www/services_dyndns_edit.php +++ b/usr/local/www/services_dyndns_edit.php @@ -42,13 +42,15 @@ /* returns true if $uname is a valid DynDNS username */ function is_dyndns_username($uname) { - if (!is_string($uname)) - return false; - - if (preg_match("/[^a-z0-9\-\+.@_:]/i", $uname)) - return false; - else - return true; + if (!is_string($uname)) { + return false; + } + + if (preg_match("/[^a-z0-9\-\+.@_:]/i", $uname)) { + return false; + } else { + return true; + } } require("guiconfig.inc"); @@ -59,10 +61,12 @@ if (!is_array($config['dyndnses']['dyndns'])) { $a_dyndns = &$config['dyndnses']['dyndns']; -if (is_numericint($_GET['id'])) +if (is_numericint($_GET['id'])) { $id = $_GET['id']; -if (isset($_POST['id']) && is_numericint($_POST['id'])) +} +if (isset($_POST['id']) && is_numericint($_POST['id'])) { $id = $_POST['id']; +} if (isset($id) && isset($a_dyndns[$id])) { $pconfig['username'] = $a_dyndns[$id]['username']; @@ -88,9 +92,10 @@ if ($_POST) { unset($input_errors); $pconfig = $_POST; - - if(($pconfig['type'] == "freedns" || $pconfig['type'] == "namecheap") && $_POST['username'] == "") - $_POST['username'] = "none"; + + if (($pconfig['type'] == "freedns" || $pconfig['type'] == "namecheap") && $_POST['username'] == "") { + $_POST['username'] = "none"; + } /* input validation */ $reqdfields = array(); @@ -102,32 +107,37 @@ if ($_POST) { $reqdfieldsn[] = gettext("Hostname"); $reqdfields[] = "passwordfld"; $reqdfieldsn[] = gettext("Password"); - $reqdfields[] = "username"; - $reqdfieldsn[] = gettext("Username"); - }else{ + $reqdfields[] = "username"; + $reqdfieldsn[] = gettext("Username"); + } else { $reqdfields[] = "updateurl"; $reqdfieldsn[] = gettext("Update URL"); - } + } do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); if (isset($_POST['host']) && in_array("host", $reqdfields)) { /* 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); - else + } else { $host_to_check = $_POST['host']; + } - if ($pconfig['type'] != "custom" && $pconfig['type'] != "custom-v6") - if (!is_domain($host_to_check)) + if ($pconfig['type'] != "custom" && $pconfig['type'] != "custom-v6") { + if (!is_domain($host_to_check)) { $input_errors[] = gettext("The hostname contains invalid characters."); + } + } 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."); - 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 ((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(); @@ -141,10 +151,11 @@ if ($_POST) { $dyndns['curl_ipresolve_v4'] = $_POST['curl_ipresolve_v4'] ? true : false; $dyndns['curl_ssl_verifypeer'] = $_POST['curl_ssl_verifypeer'] ? true : false; /* In this place enable means disabled */ - if ($_POST['enable']) + if ($_POST['enable']) { unset($dyndns['enable']); - else + } else { $dyndns['enable'] = true; + } $dyndns['interface'] = $_POST['interface']; $dyndns['zoneid'] = $_POST['zoneid']; $dyndns['ttl'] = $_POST['ttl']; @@ -154,20 +165,21 @@ if ($_POST) { ($dyndns['type'] == "custom" || $dyndns['type'] == "custom-v6") ? $dyndns['requestif'] = $_POST['requestif'] : $dyndns['requestif'] = $_POST['interface']; $dyndns['descr'] = $_POST['descr']; $dyndns['force'] = isset($_POST['force']); - - if($dyndns['username'] == "none") + + if ($dyndns['username'] == "none") { $dyndns['username'] = ""; + } - if (isset($id) && $a_dyndns[$id]) + 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++) { + for ($i = 0; $i < count($a_dyndns); $i++) { $a_dyndns[$i]['id'] = $i; } @@ -180,7 +192,7 @@ if ($_POST) { } } -$pgtitle = array(gettext("Services"),gettext("Dynamic DNS client")); +$pgtitle = array(gettext("Services"), gettext("Dynamic DNS client")); include("head.inc"); ?> @@ -191,8 +203,8 @@ include("head.inc");
- - - - - - - - - - - + + + + + + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - -
- - -
-
- " /> -
-
+ + + + +
+
+ " /> +
+
- +
+ -
- +
+ -
-
- -
- -
-
+ +
+
+ +
+ + +
+



- -
-
- -
- -
-
- /> -
- /> -
- /> -
- /> - -
- -
-
-
-
-
- -
- -
-
-
-
- -
-
- -
+ +
+ +
+ +
+ /> + +
+ /> + +
+ /> +
+ /> + +
+ +
+
+
+
+
+ +
+ +
+
+
+
+ +
+
+
- -
-
- -
- -
- -
- -
- -
  - " onclick="enable_change(true)" /> - " /> - - - " onclick="enable_change(true)" /> - -
 
-
','');?>
+ + + +
+
+
+
+
+ + + + + + +
+ + + + + + + + + +   + + " onclick="enable_change(true)" /> + " /> + + + " onclick="enable_change(true)" /> + + + + +   + + + + +
+
+
+ ','');?> +
+ + +
-- cgit v1.1