master
Squidly271 2024-11-29 11:04:30 -05:00
parent de86d94bf0
commit 101b4e4075
4 changed files with 71 additions and 80 deletions

View File

@ -2,8 +2,8 @@
<!DOCTYPE PLUGIN [
<!ENTITY name "community.applications">
<!ENTITY author "Andrew Zawadzki">
<!ENTITY version "2024.11.27">
<!ENTITY md5 "4525f48c9a7dd43f0e5abcb028c26c95">
<!ENTITY version "2024.11.29">
<!ENTITY md5 "d41d6a0ef89fa2c234a8d9171d275971">
<!ENTITY launch "Apps">
<!ENTITY plugdir "/usr/local/emhttp/plugins/&name;">
<!ENTITY github "Squidly271/community.applications">
@ -13,6 +13,10 @@
<PLUGIN name="&name;" author="&author;" version="&version;" launch="&launch;" pluginURL="&pluginURL;" min="6.12.0" support="https://forums.unraid.net/topic/38582-plug-in-community-applications" icon="users">
<CHANGES>
###2924,11,29
- Fixed: Attempting to visit the support forum (or project) where there was only the single option (ie: Card said "Support Forum" instead of "Support" with a dropdown would fail
- Added: Ability to "whitelist" 3rd party external links
###2024.11.27
- Fixed: Code unnecessary with Unraid 7.x was being executed

View File

@ -190,59 +190,73 @@ var wheelActive = false;
var ca_done_override = false;
// handle 3rd party links on older versions of OS
<? if ( version_compare($unRaidSettings['version'],"6.12.999","<") ):?>
<? if ( version_compare($unRaidSettings['version'],"7.0.0-rc1","<") ):?>
var gui_pages_available = [];
<?
$gui_pages = glob("/usr/local/emhttp/plugins/*/*.page");
array_walk($gui_pages,function($value,$key){ ?>
gui_pages_available.push('<?=basename($value,".page")?>'); <?
});
?>
<?
$gui_pages = glob("/usr/local/emhttp/plugins/*/*.page");
array_walk($gui_pages,function($value,$key){ ?>
gui_pages_available.push('<?=basename($value,".page")?>'); <?
});
?>
function isValidURL(url) {
try {
new URL(url);
return true;
} catch (err) {
return false;
}
function isValidURL(url) {
try {
var ret = new URL(url);
return ret;
} catch (err) {
return false;
}
function checkURL(href,target="") {
if ( href ) {
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 true;
}
}
if (href !== "#" && href.indexOf("javascript") !== 0) {
if ( ! isValidURL(href) ) {
if ( href.indexOf("/") == 0 ) { // all internal links start with "/"
return true;
}
var baseURLpage = href.split("/");
if ( gui_pages_available.includes(baseURLpage[0]) ) {
return true;
}
}
if ( $(this).hasClass("localURL") ) {
return true;
}
return false;
}
}
return true;
}
$('body').on("click","a", function(e) {
$('body').on("click","a,.ca_href", function(e) {
if ($(this).hasClass("ca_href") ) {
var ca_href = true;
var href=$(this).attr("data-href");
var target=$(this).attr("data-target");
} else {
var ca_href = false;
var href = $(this).attr("href");
var target = $(this).attr("target");
if ( !href )
return;
}
if ( href ) {
href = href.trim();
if ( ! checkURL(href,target) ) {
if ( href.match('https?://[^\.]*.(my)?unraid.net/') || href.indexOf("https://unraid.net/") == 0 || href == "https://unraid.net" || href.indexOf("http://lime-technology.com") == 0) {
if ( ca_href ) {
window.open(href,target);
}
return;
}
if (href !== "#" && href.indexOf("javascript") !== 0) {
var dom = isValidURL(href);
if ( dom == false ) {
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;
}
try {
var domainsAllowed = JSON.parse($.cookie("allowedDomains"));
} catch(e) {
var domainsAllowed = new Object();
}
$.cookie("allowedDomains",JSON.stringify(domainsAllowed),{expires:3650}); // rewrite cookie to further extend expiration by 400 days
if ( domainsAllowed[dom.hostname] ) {
return;
}
e.preventDefault();
swal({
title: "<?=_('External Link')?>",
text: "<span title='"+href+"'><?=_('Clicking OK will take you to a 3rd party website not associated with Limetech')?><br><br><b>"+href+"</span>",
text: "<span title='"+href+"'><?=_('Clicking OK will take you to a 3rd party website not associated with Limetech')?><br><br><b>"+href+"<br><br><input id='Link_Always_Allow' type='checkbox'></input><?=_('Always Allow')?> "+dom.hostname+"</span>",
html: true,
type: 'warning',
showCancelButton: true,
@ -251,6 +265,10 @@ var ca_done_override = false;
confirmButtonText: "<?=_('OK')?>"
},function(isConfirm) {
if (isConfirm) {
if ( $("#Link_Always_Allow").is(":checked") ) {
domainsAllowed[dom.hostname] = true;
$.cookie("allowedDomains",JSON.stringify(domainsAllowed),{expires:3650});
}
var popupOpen = window.open(href,target);
if ( !popupOpen || popupOpen.closed || typeof popupOpen == "undefined" ) {
var popupWarning = addBannerWarning("<?=_('Popup Blocked.');?>");
@ -260,8 +278,9 @@ var ca_done_override = false;
}
}
});
} else return;
});
}
}
});
<?endif;?>
$(function(){
@ -420,38 +439,6 @@ $(function(){
});
});
$('.mainArea').on("click",".ca_href",function(e) {
var href = $(this).attr("data-href");
var target = $(this).attr("data-target");
if ( ! target ) target = "_blank";
if ( checkURL(href,target) ) {
window.open(href,target);
} else {
e.preventDefault();
swal({
title: "<?=_('External Link')?>",
text: "<span title='"+href+"'><?=_('Clicking OK will take you to a 3rd party website not associated with Limetech')?><br><br><b>"+href+"</span>",
html: true,
type: 'warning',
showCancelButton: true,
showConfirmButton: true,
cancelButtonText: "<?=_('Cancel')?>",
confirmButtonText: "<?=_('OK')?>"
},function(isConfirm) {
if (isConfirm) {
var popupOpen = window.open(href,target);
if ( !popupOpen || popupOpen.closed || typeof popupOpen == "undefined" ) {
var popupWarning = addBannerWarning("<?=_('Popup Blocked.');?>");
setTimeout(function() {
removeBannerWarning(popupWarning);}
,10000);
}
}
});
}
});
$('body').on("click",".dockerUpdate",function() {
var container = $(this).attr("data-name");
updateDocker(container);

View File

@ -1,4 +1,4 @@
6e475bfc6d951a441e6b31403fa1a241 ./Apps.page
61eb082eb073f58ec1d750af5b7ab9d1 ./Apps.page
2defe45163697e40c813a57ae9a50231 ./CA_notices.page
c12622d8281346d37398e96cbb6b8b69 ./ca_settings.page
01ed7990078dee7cecfeda9a4e49377e ./default.cfg