From 6966bc7f3addbf6b39c11fa8cdfe2c4bc622c02a Mon Sep 17 00:00:00 2001 From: Mark Pointing Date: Tue, 15 Dec 2020 13:48:51 +0000 Subject: [PATCH] Changed routing system to use the more common path approach instead of query strings. --- app/js/custom.js | 7 ++-- config/50-raspap-router.conf | 9 +++++ index.php | 61 +++++++++++++++++----------------- installers/common.sh | 47 ++++++++++++++++++++++++++ installers/uninstall.sh | 7 ++++ templates/adblock.php | 2 +- templates/admin.php | 2 +- templates/configure_client.php | 2 +- templates/dashboard.php | 8 ++--- templates/dhcp.php | 2 +- templates/hostapd.php | 2 +- templates/openvpn.php | 2 +- templates/system.php | 2 +- templates/system/advanced.php | 2 +- templates/system/basic.php | 4 +-- templates/system/language.php | 2 +- templates/themes.php | 4 +-- templates/torproxy.php | 2 +- 18 files changed, 117 insertions(+), 50 deletions(-) create mode 100644 config/50-raspap-router.conf diff --git a/app/js/custom.js b/app/js/custom.js index bd067368..e3957ea4 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -145,8 +145,11 @@ function setCSRFTokenHeader(event, xhr, settings) { } function contentLoaded() { - pageCurrent = window.location.href.split("?")[1].split("=")[1]; - pageCurrent = pageCurrent.replace("#",""); + //pageCurrent = window.location.href.split("?")[1].split("=")[1]; + //pageCurrent = pageCurrent.replace("#",""); + + pageCurrent = window.location.href.split("/").pop(); + switch(pageCurrent) { case "network_conf": getAllInterfaces(); diff --git a/config/50-raspap-router.conf b/config/50-raspap-router.conf new file mode 100644 index 00000000..c6ac9a04 --- /dev/null +++ b/config/50-raspap-router.conf @@ -0,0 +1,9 @@ +server.modules += ( + "mod_rewrite", +) + +$HTTP["url"] =~ "^/(?!(dist|app|ajax)).*" { + url.rewrite-once = ( + "^/[^\?]*(\?.*)?" => "/index.php$1" + ) +} diff --git a/index.php b/index.php index ca55c5ce..1efa7733 100755 --- a/index.php +++ b/index.php @@ -48,7 +48,8 @@ require_once 'includes/openvpn.php'; require_once 'includes/torproxy.php'; $output = $return = 0; -$page = $_GET['page']; +//$page = $_GET['page']; +$page = $_SERVER['REQUEST_URI']; $theme_url = getThemeOpt(); $toggleState = getSidebarState(); @@ -107,7 +108,7 @@ $bridgedEnabled = getBridgedState();