From bb3f795488c91a056adb917065229e46fdf3e7a0 Mon Sep 17 00:00:00 2001
From: SofianeLasri <alasri250@gmail.com>
Date: Sat, 16 Oct 2021 10:59:12 +0200
Subject: [PATCH] mutliples bugfixes related to connector

---
 vbcms-core/defaultPages/404.php    | 10 +++++++---
 vbcms-core/defaultPages/ext404.php | 10 +++++++---
 vbcms-core/defaultPages/index.php  | 10 +++++++---
 vbcms-core/functions.php           |  1 +
 vbcms-core/variables.php           |  7 +++++--
 5 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/vbcms-core/defaultPages/404.php b/vbcms-core/defaultPages/404.php
index f2997d1..6d8138a 100644
--- a/vbcms-core/defaultPages/404.php
+++ b/vbcms-core/defaultPages/404.php
@@ -1,7 +1,11 @@
 <?php
-if(isset($_SERVER['HTTPS'])) $http = "https"; else $http = "http";
-$url = parse_url("$http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
-$websiteUrl = $url["scheme"]."://".$url["host"]."/";
+if(isset($bdd)){
+    $websiteUrl = VBcmsGetSetting("websiteUrl");
+}else{
+    if(isset($_SERVER['HTTPS'])) $http = "https"; else $http = "http";
+    $url = parse_url("$http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
+    $websiteUrl = $url["scheme"]."://".$url["host"]."/";
+}
 ?>
 <!DOCTYPE html>
 <html lang="fr">
diff --git a/vbcms-core/defaultPages/ext404.php b/vbcms-core/defaultPages/ext404.php
index a47864d..5177c02 100644
--- a/vbcms-core/defaultPages/ext404.php
+++ b/vbcms-core/defaultPages/ext404.php
@@ -1,7 +1,11 @@
 <?php
-if(isset($_SERVER['HTTPS'])) $http = "https"; else $http = "http";
-$url = parse_url("$http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
-$websiteUrl = $url["scheme"]."://".$url["host"]."/";
+if(isset($bdd)){
+    $websiteUrl = VBcmsGetSetting("websiteUrl");
+}else{
+    if(isset($_SERVER['HTTPS'])) $http = "https"; else $http = "http";
+    $url = parse_url("$http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
+    $websiteUrl = $url["scheme"]."://".$url["host"]."/";
+}
 ?>
 <!DOCTYPE html>
 <html lang="fr">
diff --git a/vbcms-core/defaultPages/index.php b/vbcms-core/defaultPages/index.php
index 4f424c7..33a814f 100644
--- a/vbcms-core/defaultPages/index.php
+++ b/vbcms-core/defaultPages/index.php
@@ -1,7 +1,11 @@
 <?php
-if(isset($_SERVER['HTTPS'])) $http = "https"; else $http = "http";
-$url = parse_url("$http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
-$websiteUrl = $url["scheme"]."://".$url["host"]."/";
+if(isset($bdd)){
+    $websiteUrl = VBcmsGetSetting("websiteUrl");
+}else{
+    if(isset($_SERVER['HTTPS'])) $http = "https"; else $http = "http";
+    $url = parse_url("$http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
+    $websiteUrl = $url["scheme"]."://".$url["host"]."/";
+}
 ?>
 <!DOCTYPE html>
 <html lang="fr">
diff --git a/vbcms-core/functions.php b/vbcms-core/functions.php
index 2ccbc67..931dfc1 100644
--- a/vbcms-core/functions.php
+++ b/vbcms-core/functions.php
@@ -152,6 +152,7 @@ function show404($type){
 	if ($type=="client") {
 		// Affiche la page 404 du site client
         // A savoir que les pages 404 des modules sont gérées par ces derniers
+        global $bdd;
 		include $GLOBALS['vbcmsRootPath'].'/vbcms-core/defaultPages/404.php';
         
 	} elseif($type=="admin") {
diff --git a/vbcms-core/variables.php b/vbcms-core/variables.php
index f245a1a..8ab73ed 100644
--- a/vbcms-core/variables.php
+++ b/vbcms-core/variables.php
@@ -14,5 +14,8 @@ if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
 if(isset($_SERVER['HTTPS'])) $http = "https"; else $http = "http";
 
 // Variables permettant la gestion des pages à afficher
-$url = parse_url("$http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");	
-$urlPath = explode("/", $url["path"]);
+$url = parse_url("$http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
+if(!isset($urlPath)){
+    $urlPath = explode("/", $url["path"]);
+}
+
-- 
GitLab