From c6fdebf3c259af02abc36e63181291f84104507a Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Fri, 31 Aug 2018 16:49:56 +0100
Subject: [PATCH] Ensure correct path is preserved

---
 webadmin/backuprestore.php | 14 ++++++++++++--
 webadmin/systemmonitor.php |  7 ++++++-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/webadmin/backuprestore.php b/webadmin/backuprestore.php
index 3fd514f34..a52e4c77c 100755
--- a/webadmin/backuprestore.php
+++ b/webadmin/backuprestore.php
@@ -21,7 +21,12 @@ if (isset($_POST['submitbackuppassword'])) {
                 exec('cp backup_progress_template.html backup_progress.html');
                 $host  = $_SERVER['HTTP_HOST'];
                 $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
-                header("Location: http://$host$uri/admin/backup_progress.html");
+                if (endsWith($uri, 'admin')) {
+                    header("Location: http://$host$uri/backup_progress.html");
+                }
+                else {
+                    header("Location: http://$host$uri/admin/backup_progress.html");
+                }
                 $output_filename = "backup_progress.html";
             }
             else {
@@ -51,7 +56,12 @@ if (isset($_POST['submitrestorepassword'])) {
             exec('cp restore_progress_template.html restore_progress.html');
             $host  = $_SERVER['HTTP_HOST'];
             $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
-            header("Location: http://$host$uri/admin/restore_progress.html");
+            if (endsWith($uri, 'admin')) {
+                header("Location: http://$host$uri/restore_progress.html");
+            }
+            else {
+                header("Location: http://$host$uri/admin/restore_progress.html");
+            }
             $output_filename = "restore_progress.html";
         }
         else {
diff --git a/webadmin/systemmonitor.php b/webadmin/systemmonitor.php
index 8273de224..f154e03c9 100755
--- a/webadmin/systemmonitor.php
+++ b/webadmin/systemmonitor.php
@@ -12,7 +12,12 @@ if (isset($_POST['submitsystemmonitor'])) {
     # remain on this screen after clicking update
     $host  = $_SERVER['HTTP_HOST'];
     $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
-    header("Location: http://$host$uri/system_monitor.html");
+    if (endsWith($uri, 'admin')) {
+        header("Location: http://$host$uri/system_monitor.html");
+    }
+    else {
+        header("Location: http://$host$uri/admin/system_monitor.html");
+    }
 
     sleep(3);
 
-- 
GitLab