diff --git a/src/www/wizard.php b/src/www/wizard.php
index 9ce5affc1..39521448b 100644
--- a/src/www/wizard.php
+++ b/src/www/wizard.php
@@ -210,6 +210,55 @@ function update_config_field($field, $updatetext, $unset, $arraynum, $field_type
eval($text);
}
+function redirect_url()
+{
+ global $config, $title;
+
+ switch($config['system']['webgui']['protocol']) {
+ case "http":
+ $proto = "http";
+ break;
+ case "https":
+ $proto = "https";
+ break;
+ default:
+ $proto = "http";
+ break;
+ }
+ $port = $config['system']['webgui']['port'];
+ if($port != "") {
+ if(($port == "443" and $proto != "https") or ($port == "80" and $proto != "http")) {
+ $urlport = ":" . $port;
+ } elseif ($port != "80" and $port != "443") {
+ $urlport = ":" . $port;
+ } else {
+ $urlport = "";
+ }
+ }
+ $http_host = $_SERVER['SERVER_NAME'];
+ $urlhost = $http_host;
+ // If finishing the setup wizard, check if accessing on a LAN or WAN address that changed
+ if($title == "Reload in progress") {
+ if (is_ipaddr($urlhost)) {
+ $host_if = find_ip_interface($urlhost);
+ if ($host_if) {
+ $host_if = convert_real_interface_to_friendly_interface_name($host_if);
+ if ($host_if && is_ipaddr($config['interfaces'][$host_if]['ipaddr']))
+ $urlhost = $config['interfaces'][$host_if]['ipaddr'];
+ }
+ } else if ($urlhost == $config['system']['hostname']) {
+ $urlhost = $config['wizardtemp']['system']['hostname'];
+ } else if ($urlhost == $config['system']['hostname'] . '.' . $config['system']['domain']) {
+ $urlhost = $config['wizardtemp']['system']['hostname'] . '.' . $config['wizardtemp']['system']['domain'];
+ }
+ }
+ if ($urlhost != $http_host) {
+ file_put_contents('/tmp/setupwizard_lastreferrer', $proto . '://' . $http_host . $urlport . $_SERVER['REQUEST_URI']);
+ }
+
+ return $proto . '://' . $urlhost . $urlport;
+}
+
// handle before form display event.
do {
$oldstepid = $stepid;
@@ -411,7 +460,7 @@ function showchange() {
echo ":\n";
} else if(!$field['dontdisplayname']) {
echo "
\n";
- echo fixup_string(gettext($field['name']));
+ echo gettext($field['name']);
echo ": | \n";
}
if(!$field['dontcombinecells'])
@@ -441,7 +490,7 @@ function showchange() {
echo ":\n";
} else if(!$field['dontdisplayname']) {
echo "\n";
- echo fixup_string(gettext($field['name']));
+ echo gettext($field['name']);
echo ": | \n";
}
if(!$field['dontcombinecells'])
@@ -465,7 +514,7 @@ function showchange() {
$multiple = "";
$name = strtolower($name);
echo "\n";
- echo fixup_string($field['displayname'] ? gettext($field['displayname']) : gettext($field['name'])) . ":\n";
+ echo ($field['displayname'] ? gettext($field['displayname']) : gettext($field['name'])) . ":\n";
echo " | ";
echo "\n";
if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
@@ -516,7 +565,7 @@ function showchange() {
echo ": | \n";
} else if(!$field['dontdisplayname']) {
echo "\n";
- echo fixup_string(gettext($field['name']));
+ echo gettext($field['name']);
echo ": | \n";
}
if(!$field['dontcombinecells'])
@@ -536,7 +585,7 @@ function showchange() {
$multiple = "";
$name = strtolower($name);
echo "\n";
- echo fixup_string($field['displayname'] ? gettext($field['displayname']) : gettext($field['name'])) . ":\n";
+ echo ($field['displayname'] ? gettext($field['displayname']) : gettext($field['name'])) . ":\n";
echo " | ";
echo "\n";
if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
@@ -574,7 +623,7 @@ function showchange() {
$multiple = "";
$name = strtolower($name);
echo " | \n";
- echo fixup_string($field['displayname'] ? gettext($field['displayname']) : gettext($field['name'])) . ":\n";
+ echo ($field['displayname'] ? gettext($field['displayname']) : gettext($field['name'])) . ":\n";
echo " | ";
echo "\n";
if($field['size'] <> "") $size = "size=\"{$field['size']}\"";
@@ -616,7 +665,7 @@ function showchange() {
echo ": | \n";
} else if(!$field['dontdisplayname']) {
echo "\n";
- echo fixup_string(gettext($field['name']));
+ echo gettext($field['name']);
echo ": | \n";
}
if($field['size']) $size = " size='" . $field['size'] . "' ";
@@ -656,7 +705,7 @@ function showchange() {
echo ":\n";
} else if(!$field['dontdisplayname']) {
echo "\n";
- echo fixup_string(gettext($field['name']));
+ echo gettext($field['name']);
echo ": | ";
}
if(!$field['dontcombinecells'])
@@ -694,7 +743,7 @@ function showchange() {
echo ":\n";
} else if(!$field['dontdisplayname']) {
echo "\n";
- echo fixup_string(gettext($field['name']));
+ echo gettext($field['name']);
echo ": | ";
}
if(!$field['dontcombinecells'])
@@ -730,7 +779,7 @@ function showchange() {
echo ":\n";
} else if(!$field['dontdisplayname']) {
echo "\n";
- echo fixup_string(gettext($field['name']));
+ echo gettext($field['name']);
echo ": | ";
}
if(!$field['dontcombinecells'])
@@ -759,7 +808,7 @@ function showchange() {
echo ":\n";
} else if(!$field['dontdisplayname']) {
echo "\n";
- echo fixup_string(gettext($field['name']));
+ echo gettext($field['name']);
echo ": | ";
}
if(!$field['dontcombinecells'])
@@ -833,7 +882,7 @@ function showchange() {
switch ($field['type']) {
case "refresh":
if($field['page'] <> "" && $field['time'] <> "") {
- echo '';
+ echo '';
}
break 2;
}
@@ -975,71 +1024,4 @@ if($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") {
echo "\n\n";
}
-/*
- * HELPER FUNCTIONS
- */
-
-function fixup_string($string)
-{
- global $config, $myurl, $title;
- $newstring = $string;
- // fixup #1: $myurl -> http[s]://ip_address:port/
- switch($config['system']['webgui']['protocol']) {
- case "http":
- $proto = "http";
- break;
- case "https":
- $proto = "https";
- break;
- default:
- $proto = "http";
- break;
- }
- $port = $config['system']['webgui']['port'];
- if($port != "") {
- if(($port == "443" and $proto != "https") or ($port == "80" and $proto != "http")) {
- $urlport = ":" . $port;
- } elseif ($port != "80" and $port != "443") {
- $urlport = ":" . $port;
- } else {
- $urlport = "";
- }
- }
- $http_host = $_SERVER['SERVER_NAME'];
- $urlhost = $http_host;
- // If finishing the setup wizard, check if accessing on a LAN or WAN address that changed
- if($title == "Reload in progress") {
- if (is_ipaddr($urlhost)) {
- $host_if = find_ip_interface($urlhost);
- if ($host_if) {
- $host_if = convert_real_interface_to_friendly_interface_name($host_if);
- if ($host_if && is_ipaddr($config['interfaces'][$host_if]['ipaddr']))
- $urlhost = $config['interfaces'][$host_if]['ipaddr'];
- }
- } else if ($urlhost == $config['system']['hostname'])
- $urlhost = $config['wizardtemp']['system']['hostname'];
- else if ($urlhost == $config['system']['hostname'] . '.' . $config['system']['domain'])
- $urlhost = $config['wizardtemp']['system']['hostname'] . '.' . $config['wizardtemp']['system']['domain'];
- }
- if ($urlhost != $http_host) {
- file_put_contents('/tmp/setupwizard_lastreferrer', $proto . '://' . $http_host . $urlport . $_SERVER['REQUEST_URI']);
- }
- $myurl = $proto . "://" . $urlhost . $urlport . "/";
-
- if (strstr($newstring, "\$myurl"))
- $newstring = str_replace("\$myurl", $myurl, $newstring);
- // fixup #2: $wanip
- if (strstr($newstring, "\$wanip")) {
- $curwanip = get_interface_ip();
- $newstring = str_replace("\$wanip", $curwanip, $newstring);
- }
- // fixup #3: $lanip
- if (strstr($newstring, "\$lanip")) {
- $lanip = get_interface_ip("lan");
- $newstring = str_replace("\$lanip", $lanip, $newstring);
- }
- // fixup #4: fix'r'up here.
- return $newstring;
-}
-
include('foot.inc');