mirror of
https://github.com/Squidly271/community.applications.git
synced 2025-06-03 14:52:13 +08:00
Possible fix for a rare race condition
This commit is contained in:
parent
39030c90bc
commit
ebdfbf4db8
Binary file not shown.
@ -1,205 +0,0 @@
|
|||||||
Menu='Buttons'
|
|
||||||
Link='nav-user'
|
|
||||||
---
|
|
||||||
<?
|
|
||||||
###############################################################
|
|
||||||
# #
|
|
||||||
# Community Applications copyright 2015-2021, Andrew Zawadzki #
|
|
||||||
# Licenced under GPLv2 #
|
|
||||||
# #
|
|
||||||
###############################################################
|
|
||||||
|
|
||||||
### Note: This file is only needed on OS versions less than 6.8.3
|
|
||||||
?>
|
|
||||||
|
|
||||||
<? if ( ! file_exists("/usr/local/emhttp/plugins/dynamix.plugin.manager/PluginHelpers.page") ) : ?>
|
|
||||||
<style>
|
|
||||||
.ca_plugin_notice{position:fixed;top:1px;left:0;}
|
|
||||||
.ca_element_notice{padding-right:20px;width:100%;height:40px;line-height:40px;color:#e68a00;background:#feefb3;border-bottom:#e68a00 1px solid;text-align:center;font-size:1.4rem;z-index:900;display:none;}
|
|
||||||
.ca_PluginUpdateDismiss{float:right;margin-right:20px;cursor:pointer;}
|
|
||||||
.ca_pluginUpdateInfo{cursor:pointer;}
|
|
||||||
.ca_PluginUpdateInstall{cursor:pointer;}
|
|
||||||
a.bannerInfo {cursor:pointer;text-decoration:none;}
|
|
||||||
.bannerInfo::before {content:"\f05a";font-family:fontAwesome;color:#e68a00;}
|
|
||||||
</style>
|
|
||||||
<script>
|
|
||||||
var ca_PluginUpdatePLG;
|
|
||||||
var ca_PluginUpdateElement;
|
|
||||||
var ca_WarningItems = [];
|
|
||||||
var currentWarning = 0;
|
|
||||||
warningInterval = false;
|
|
||||||
|
|
||||||
$(function() {
|
|
||||||
$(".upgrade_notice").after("<div class='ca_plugin_notice ca_element_notice'></div>");
|
|
||||||
});
|
|
||||||
|
|
||||||
if ( typeof caPluginUpdateCheck !== "function" ) {
|
|
||||||
function ca_PluginUpdate_openBox(cmd,title,height,width,load,func) {
|
|
||||||
// open shadowbox window (run in foreground)
|
|
||||||
var run = cmd.split('?')[0].substr(-4)=='.php' ? cmd : '/logging.htm?cmd='+cmd+'&csrf_token=<?=$var['csrf_token']?>';
|
|
||||||
var options = load ? {modal:true,onClose:function(){ eval(func); }} : {modal:true};
|
|
||||||
Shadowbox.open({content:run, player:'iframe', title:title, height:height, width:width, options:options});
|
|
||||||
}
|
|
||||||
|
|
||||||
function ca_hidePluginUpdate(version) {
|
|
||||||
$.cookie(ca_PluginUpdatePLG,version);
|
|
||||||
$(ca_PluginUpdateElement).hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
function ca_pluginUpdateInstall(plugin) {
|
|
||||||
ca_PluginUpdate_openBox("/plugins/community.applications/scripts/installPluginUpdate.sh&arg1="+plugin,"Installing Update",600,900,true,"window.location.reload()");
|
|
||||||
}
|
|
||||||
|
|
||||||
function ca_pluginUpdateShowInfo(cmd,title,height,width,load,func,id) {
|
|
||||||
// open shadowbox window (run in foreground)
|
|
||||||
var run = cmd.split('?')[0].substr(-4)=='.php' ? cmd : '/logging.htm?cmd='+cmd+'&csrf_token=<?=$var['csrf_token']?>';
|
|
||||||
var options = load ? (func ? {modal:true,onClose:function(){setTimeout(func+'('+'"'+(id||'')+'")',0);}} : {modal:false,onClose:function(){location=location;}}) : {modal:false};
|
|
||||||
Shadowbox.open({content:run, player:'iframe', title:title, height:Math.min(height,screen.availHeight), width:Math.min(width,screen.availWidth), options:options});
|
|
||||||
}
|
|
||||||
|
|
||||||
function ca_pluginUpdate_evaluateBoolean(str) {
|
|
||||||
regex=/^\s*(true|1|on)\s*$/i
|
|
||||||
return regex.test(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
function caPluginUpdateCheck(plugin,options=[],callback) {
|
|
||||||
ca_PluginUpdatePLG = plugin;
|
|
||||||
pluginFilename = plugin.substr(0, plugin.lastIndexOf("."));
|
|
||||||
console.time("checkPlugin "+plugin);
|
|
||||||
console.log("checkPlugin "+plugin);
|
|
||||||
$.post("/plugins/community.applications/scripts/PluginAPI.php",{action:'checkPlugin',options:{plugin:plugin}},function(caAPIresult) {
|
|
||||||
console.groupCollapsed("Result checkPlugin "+plugin);
|
|
||||||
console.log(caAPIresult);
|
|
||||||
console.timeEnd("checkPlugin "+plugin);
|
|
||||||
console.groupEnd();
|
|
||||||
var result = JSON.parse(caAPIresult);
|
|
||||||
|
|
||||||
if ( options.debug == true ) result.updateAvailable = true;
|
|
||||||
var name = options.name ? options.name : "this plugin ("+plugin+")";
|
|
||||||
if ( ! options.element ) {
|
|
||||||
if ( result.updateAvailable ) {
|
|
||||||
var HTML = "An upgrade to "+name+" is available. Click <a class='ca_PluginUpdateInstall' onclick='ca_pluginUpdateInstall(""+plugin+"");'>here</a> to install version "+result.version+" <a class='bannerInfo fa fa-info-circle' onclick=ca_pluginUpdateShowInfo('/plugins/dynamix.plugin.manager/include/ShowChanges.php?file=%2Ftmp%2Fplugins%2F"+pluginFilename+".txt','Release Notes',600,900); return false;'></a>";
|
|
||||||
addBannerWarning(HTML,false,ca_pluginUpdate_evaluateBoolean(options.noDismiss));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ( $.cookie(plugin) != result.version ) {
|
|
||||||
if ( result.updateAvailable ) {
|
|
||||||
var HTML = "An upgrade to "+name+" is available. Click <a class='ca_PluginUpdateInstall' onclick='ca_pluginUpdateInstall(""+plugin+"");'>here</a> to install version "+result.version+" <i class='ca_pluginUpdateInfo fa fa-info-circle' onclick=ca_pluginUpdateShowInfo('/plugins/dynamix.plugin.manager/include/ShowChanges.php?file=%2Ftmp%2Fplugins%2F"+pluginFilename+".txt','Release Notes',600,900); return false;'></i>";
|
|
||||||
if ( ! ca_pluginUpdate_evaluateBoolean(options.noDismiss) ) {
|
|
||||||
HTML = HTML.concat("<span class='ca_PluginUpdateDismiss'><i class='fa fa-close' onclick='ca_hidePluginUpdate(""+result.version+"");'></i>");
|
|
||||||
}
|
|
||||||
result.HTML = HTML;
|
|
||||||
ca_PluginUpdateElement = options.element ? options.element : ".ca_plugin_notice";
|
|
||||||
|
|
||||||
if ( ! ca_pluginUpdate_evaluateBoolean(options.dontShow) ) {
|
|
||||||
if ( ! options.element ) {
|
|
||||||
$(".ca_element_notice").html(HTML);
|
|
||||||
if (options.priority) {
|
|
||||||
var z_index = $(".upgrade_notice").css("z-index");
|
|
||||||
$(".ca_element_notice").css("z-index",z_index+1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$(ca_PluginUpdateElement).html(HTML);
|
|
||||||
}
|
|
||||||
$(ca_PluginUpdateElement).addClass("ca_element_notice").show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( typeof options === "function" ) {
|
|
||||||
callback = options;
|
|
||||||
}
|
|
||||||
if ( typeof callback === "function" ) {
|
|
||||||
callback(JSON.stringify(result));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( typeof addBannerWarning !== "function" ) {
|
|
||||||
function addBannerWarning(text,warning=true,noDismiss=false) {
|
|
||||||
var cookieText = text.replace(/[^a-z0-9]/gi,'');
|
|
||||||
if ( $.cookie(cookieText) == "true" ) { return false; }
|
|
||||||
|
|
||||||
var z_index = $(".upgrade_notice").css("z-index");
|
|
||||||
$(".ca_element_notice").css("z-index",z_index+1); // Warnings take precendence over unRaid's OS warnings
|
|
||||||
if ( warning ) {
|
|
||||||
text = "<i class='fa fa-warning'></i> "+text;
|
|
||||||
}
|
|
||||||
var arrayEntry = ca_WarningItems.push("placeholder") - 1;
|
|
||||||
if ( ! noDismiss ) {
|
|
||||||
text = text + "<span class='ca_PluginUpdateDismiss'><i class='fa fa-close' onclick='dismissBannerWarning("+arrayEntry+",""+cookieText+"")'></i>";
|
|
||||||
}
|
|
||||||
ca_WarningItems[arrayEntry] = text;
|
|
||||||
if ( ! warningInterval ) {
|
|
||||||
showWarnings();
|
|
||||||
warningInterval = setInterval(function() {
|
|
||||||
showWarnings()
|
|
||||||
},10000);
|
|
||||||
}
|
|
||||||
return arrayEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
function dismissBannerWarning(entry,cookieText) {
|
|
||||||
$.cookie(cookieText,"true");
|
|
||||||
removeBannerWarning(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeBannerWarning(entry) {
|
|
||||||
ca_WarningItems[entry] = false;
|
|
||||||
showWarnings();
|
|
||||||
}
|
|
||||||
|
|
||||||
function filterArray(array) {
|
|
||||||
var newArray = [];
|
|
||||||
array.filter(function(value,index,arr) {
|
|
||||||
if ( value ) {
|
|
||||||
newArray.push(value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return newArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
function showWarnings() {
|
|
||||||
var allWarnings = filterArray(Object.values(ca_WarningItems));
|
|
||||||
if ( allWarnings.length == 0 ) {
|
|
||||||
$(".ca_plugin_notice,.ca_element_notice").hide();
|
|
||||||
clearInterval(warningInterval);
|
|
||||||
warningInterval = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ( currentWarning >= allWarnings.length ) {
|
|
||||||
currentWarning = 0;
|
|
||||||
}
|
|
||||||
$(".upgrade_notice").hide();
|
|
||||||
$(".ca_plugin_notice,.ca_element_notice").show();
|
|
||||||
$(".ca_plugin_notice").html(allWarnings[currentWarning]);
|
|
||||||
currentWarning++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<? endif; ?>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
if ( typeof addRebootNotice !== "function" ) {
|
|
||||||
// add any pre-existing reboot notices
|
|
||||||
$(function() {
|
|
||||||
<?
|
|
||||||
$rebootNotice = @file("/tmp/reboot_notifications") ?: array();
|
|
||||||
foreach ($rebootNotice as $notice):
|
|
||||||
?>
|
|
||||||
var rebootMessage = "<?=trim($notice)?>";
|
|
||||||
if ( rebootMessage ) {
|
|
||||||
addBannerWarning(rebootMessage,true,true);
|
|
||||||
}
|
|
||||||
<?
|
|
||||||
endforeach;
|
|
||||||
?>
|
|
||||||
});
|
|
||||||
|
|
||||||
function addRebootNotice(message="You must reboot for changes to take effect") {
|
|
||||||
addBannerWarning(message,true,true);
|
|
||||||
$.post("/plugins/community.applications/scripts/PluginAPI.php",{action:'addRebootNotice',message:message});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@ -2,11 +2,10 @@
|
|||||||
83b3f89cd42e8601c7c217d5b4889c81 ./CA_notices.page
|
83b3f89cd42e8601c7c217d5b4889c81 ./CA_notices.page
|
||||||
18ded5848ac35ffae0e8e0fc8ed3c512 ./ca_settings.page
|
18ded5848ac35ffae0e8e0fc8ed3c512 ./ca_settings.page
|
||||||
ed2883d6c44c19304c431079596a1731 ./default.cfg
|
ed2883d6c44c19304c431079596a1731 ./default.cfg
|
||||||
7e609a8c3d067f73976f141085aa5688 ./include/exec.php
|
419cd1896bb587653d40a81adbc80fbb ./include/exec.php
|
||||||
b6920c2d8b2ea81a4dabbd935b93895e ./include/helpers.php
|
96ca7bc670ede6df1e170eaff98a7af9 ./include/helpers.php
|
||||||
95709ae0ed53e2889a93849a69b37892 ./include/paths.php
|
95709ae0ed53e2889a93849a69b37892 ./include/paths.php
|
||||||
410c0166bae560754e231486050621f6 ./javascript/libraries.js
|
410c0166bae560754e231486050621f6 ./javascript/libraries.js
|
||||||
8c24d585c7dd3ff9ef961bb2c2705711 ./PluginAPI.page
|
|
||||||
b398273cf7daa62ab00d2de2336ca25f ./README.md
|
b398273cf7daa62ab00d2de2336ca25f ./README.md
|
||||||
717f49d6faabd7e1d7cf0940beb5cd5e ./scripts/checkForUpdates.php
|
717f49d6faabd7e1d7cf0940beb5cd5e ./scripts/checkForUpdates.php
|
||||||
1e2b902321d4bb7efe0d0b78c8130a73 ./scripts/installMulti.php
|
1e2b902321d4bb7efe0d0b78c8130a73 ./scripts/installMulti.php
|
||||||
|
@ -505,7 +505,7 @@ function appOfDay($file) {
|
|||||||
usort($file,"mySort");
|
usort($file,"mySort");
|
||||||
foreach($file as $template) {
|
foreach($file as $template) {
|
||||||
if ($template['RecommendedDate']) {
|
if ($template['RecommendedDate']) {
|
||||||
if ( $caSettings['hideIncompatible'] == "true" && ! versionCheck($template)) continue;
|
if ( ! checkRandomApp($template) ) continue;
|
||||||
|
|
||||||
$appOfDay[] = $template['ID'];
|
$appOfDay[] = $template['ID'];
|
||||||
if ( count($appOfDay) == 7 ) break;
|
if ( count($appOfDay) == 7 ) break;
|
||||||
|
@ -46,7 +46,7 @@ function readJsonFile($filename) {
|
|||||||
debug("Read JSON file $filename");
|
debug("Read JSON file $filename");
|
||||||
|
|
||||||
$json = json_decode(@file_get_contents($filename),true);
|
$json = json_decode(@file_get_contents($filename),true);
|
||||||
if (! $json) {
|
if ( $json === false ) {
|
||||||
if ( ! is_file($filename) )
|
if ( ! is_file($filename) )
|
||||||
debug("$filename not found");
|
debug("$filename not found");
|
||||||
|
|
||||||
@ -387,7 +387,8 @@ function filterMatch($filter,$searchArray,$exact=true) {
|
|||||||
function pluginDupe($templates) {
|
function pluginDupe($templates) {
|
||||||
global $caPaths;
|
global $caPaths;
|
||||||
|
|
||||||
$pluginList = array();
|
$pluginList = [];
|
||||||
|
$dupeList = [];
|
||||||
foreach ($templates as $template) {
|
foreach ($templates as $template) {
|
||||||
if ( $template['Plugin'] )
|
if ( $template['Plugin'] )
|
||||||
$pluginList[basename($template['Repository'])]++;
|
$pluginList[basename($template['Repository'])]++;
|
||||||
@ -583,9 +584,7 @@ function postReturn($retArray) {
|
|||||||
echo json_encode($retArray);
|
echo json_encode($retArray);
|
||||||
else
|
else
|
||||||
echo $retArray;
|
echo $retArray;
|
||||||
ob_flush();
|
|
||||||
flush();
|
flush();
|
||||||
|
|
||||||
debug("POST RETURN ({$_POST['action']})\n".var_dump_ret($retArray));
|
debug("POST RETURN ({$_POST['action']})\n".var_dump_ret($retArray));
|
||||||
}
|
}
|
||||||
####################################
|
####################################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user