From ca85424b7a22a49b6cf1ae5c7dc75c362ac5ddd2 Mon Sep 17 00:00:00 2001 From: Squidly271 Date: Sat, 2 Nov 2024 12:07:34 -0400 Subject: [PATCH] Update DefaultPageLayout.php --- .../dynamix/include/DefaultPageLayout.php | 81 ++++++++++++------- 1 file changed, 53 insertions(+), 28 deletions(-) diff --git a/emhttp/plugins/dynamix/include/DefaultPageLayout.php b/emhttp/plugins/dynamix/include/DefaultPageLayout.php index de7a79f3e..24bd8d870 100644 --- a/emhttp/plugins/dynamix/include/DefaultPageLayout.php +++ b/emhttp/plugins/dynamix/include/DefaultPageLayout.php @@ -1112,40 +1112,65 @@ $(function() { $('form').append($('').attr({type:'hidden', name:'csrf_token', value:csrf_token})); }); +var gui_pages_available = []; + + gui_pages_available.push(''); + +function isValidURL(url) { + try { + new URL(url); + return true; + } catch (err) { + return false; + } +} + $('body').on("click","a", function(e) { href = $(this).attr("href").trim(); target = $(this).attr("target"); - if ( href ) { - if ( href.indexOf("/") == 0 ) { // all internal links start with "/" + if ( href.match('https://[^\.]*.(my)?unraid.net/') || href.indexOf("https://unraid.net/") == 0 || href == "https://unraid.net" || href.indexOf("http://lime-technology.com") == 0) { return; - } - if ( href.match('https://[^\.]*.(my)?unraid.net/') || href.indexOf("https://unraid.net/") == 0 || href == "https://unraid.net" || href.indexOf("http://lime-technology.com/") == 0) { - return; - } else { - if (href !== "#" && href.indexOf("javascript") !== 0) { - e.preventDefault(); - swal({ - title: "", - text: "

"+href, - html: true, - type: 'warning', - showCancelButton: true, - showConfirmButton: true, - cancelButtonText: "", - confirmButtonText: "" - },function(isConfirm) { - if (isConfirm) { - var popupOpen = window.open(href,target); - if ( !popupOpen || popupOpen.closed || typeof popupOpen == "undefined" ) { - var popupWarning = addBannerWarning(""); - setTimeout(function() { - removeBannerWarning(popupWarning);} - ,10000); - } - } - }); + } + + if (href !== "#" && href.indexOf("javascript") !== 0) { + if ( ! isValidURL(href) ) { + if ( href.indexOf("/") == 0 ) { // all internal links start with "/" + return; } + var baseURLpage = href.split("/"); + if ( gui_pages_available.includes(baseURLpage[0]) ) { + return; + } + } + if ( $(this).hasClass("localURL") ) { + return; + } + e.preventDefault(); + swal({ + title: "", + text: "

"+href+"
", + html: true, + type: 'warning', + showCancelButton: true, + showConfirmButton: true, + cancelButtonText: "", + confirmButtonText: "" + },function(isConfirm) { + if (isConfirm) { + var popupOpen = window.open(href,target); + if ( !popupOpen || popupOpen.closed || typeof popupOpen == "undefined" ) { + var popupWarning = addBannerWarning(""); + setTimeout(function() { + removeBannerWarning(popupWarning);} + ,10000); + } + } + }); } } });