Fixed: Emergency background notifications weren't working
Fixed: Even if settings didn't allow incompatible / deprecated installs, CA allowed them via the statistics screen
Added: Clearly identify blacklisted / deprecated / incompatible apps installed
This commit is contained in:
Squidly271 2021-12-11 17:03:01 -05:00
parent 49f447d900
commit d496a19261
5 changed files with 58 additions and 39 deletions

Binary file not shown.

View File

@ -14,12 +14,12 @@ b398273cf7daa62ab00d2de2336ca25f ./README.md
524afab04ca930f59117a846f819fb2f ./scripts/installPluginUpdate.sh
92028dcc61f62158cbc7064e6143d287 ./scripts/installUpdate.php
5846421e95b475e1156c3f68164ccc4f ./scripts/languageInstall.sh
729c178196af99c94116246f0c8be7a5 ./scripts/notices.php
c0b2c395a14863960438e4622f20f6ff ./scripts/notices.php
430966e5646376b62905b63a30de7102 ./scripts/PluginAPI.php
9c7608a4a2cf279c8a2af88960e1642d ./scripts/pluginInstall.php
e3dc9ed23036a09d69d5cd5c3111751e ./scripts/showStatistics.php
4425f8fd4ef662a7dc65cee01de3e419 ./scripts/updatePLG.sh
2bd671daecaf01549f8cc0202cb184b3 ./scripts/updatePluginSupport.php
657c9798dbdb95b053127106fb18491e ./skins/Narrow/css.php
b15e910eb0b7d38d5253a99bf0ab7ba8 ./skins/Narrow/css.php
cfa1511913f794c8c5980460dfcdf049 ./skins/Narrow/skin.html
37dc71da8b07799676e29d7a6c6bf484 ./skins/Narrow/skin.php
87ae04cbe1c3745c596ab7ae2ca39c85 ./skins/Narrow/skin.php

View File

@ -44,7 +44,7 @@ if ( is_file("/var/run/dockerd.pid") && is_dir("/proc/".@file_get_contents("/var
} else
$dockerRunning = false;
function debug($message) {
function debug1($message) {
global $debugging;
if ($debugging) echo $message;
@ -54,10 +54,10 @@ function conditionsMet($value) {
global $conditionsMet;
if ($value)
debug(" Passed\n");
debug1(" Passed\n");
else {
$conditionsMet = false;
debug(" Failed\n");
debug1(" Failed\n");
}
}
@ -79,7 +79,7 @@ switch ($action) {
}
if ( $local && ! is_array($notices) ) {
debug("Not a valid local json file");
debug1("Not a valid local json file");
return;
}
@ -89,7 +89,7 @@ switch ($action) {
if ( in_array($notice['ID'],$dismissed) )
continue;
debug("Searching for $app");
debug1("Searching for $app");
$found = false;
$plugin = ( startsWith($app,"https://") || strtolower(pathinfo($app,PATHINFO_EXTENSION)) == "plg");
@ -122,31 +122,31 @@ switch ($action) {
}
}
if ( $found ) {
debug(" Found Looking for conditions\n");
debug1(" Found Looking for conditions\n");
$conditionsMet = true;
if ( $notice['Conditions']['unraid'] ) {
$unraid = parse_ini_file("/etc/unraid-version");
$unraidVersion = $unraid['version'];
foreach ($notice['Conditions']['unraid'] as $condition) {
if ( ! $conditionsMet ) break;
debug("Testing unraid version $unraidVersion {$condition[0]} {$condition[1]}");
debug1("Testing unraid version $unraidVersion {$condition[0]} {$condition[1]}");
conditionsMet(version_compare($unraidVersion,$condition[1],$condition[0]));
}
}
} else {
debug(" Not Found");
debug1(" Not Found");
continue;
}
if ( $plugin && $notice['Conditions']['plugin'] ) {
$pluginVersion = @plugin("version","/var/log/plugins/".basename($app));
if ( ! $pluginVersion ) {
debug("Unable to determine plugin version. Carrying on");
debug1("Unable to determine plugin version. Carrying on");
continue;
}
foreach ($notice['Conditions']['plugin'] as $condition) {
if ( ! $conditionsMet ) break;
debug("Testing plugin version $pluginVersion {$condition[0]} {$condition[1]}");
debug1("Testing plugin version $pluginVersion {$condition[0]} {$condition[1]}");
$cmp = strcmp($pluginVersion,$condition[1]);
// do some operator substitutions
switch($condition[0]) {
@ -208,12 +208,12 @@ switch ($action) {
}
if ( $notice['Conditions']['code'] && $conditionsMet) {
debug("Executing {$notice['Conditions']['code']}");
debug1("Executing {$notice['Conditions']['code']}");
conditionsMet(eval($notice['Conditions']['code']));
}
if ($conditionsMet) {
debug("Conditions Met. Send the notification!\n");
debug1("Conditions Met. Send the notification!\n");
if ( $sendNotification ) {
$command = "/usr/local/emhttp/plugins/dynamix/scripts/notify -b -e 'Community Applications Background Scanning' -s 'Attention Required' -d ".escapeshellarg($notice['email']." Login to your server for more detail. To not receive this notification again, dismiss the banner when logged into your server")." -i 'warning'";
exec($command);
@ -221,9 +221,9 @@ switch ($action) {
$notice['App'] = $app;
$unRaidNotifications[] = $notice;
} else {
debug("Conditions not met. Do nothing!\n");
debug1("Conditions not met. Do nothing!\n");
}
debug("\n");
debug1("\n");
}
echo json_encode($unRaidNotifications ?: [],JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
break;

View File

@ -429,6 +429,7 @@ table {background-color:transparent;}
.unraidIcon{margin-top:4rem;}
.vid{display:inline-block;font-size:8rem;position:relative;top:-0.5rem;color:<?=$sidebarText?>;opacity:70%;padding-right:10px;}
.vid:hover{color:<?=$unRaid66color;?>}
.warningCardBackground{clip-path: polygon(0 0,100% 0, 100% 100%);background-color: #810000;top:0px;height:9rem;width:9rem;position: relative;left:-10rem;margin-right:-9rem;}
#warningNotAccepted{display:none;}
.awesomplete [hidden] {display: none;}

View File

@ -148,7 +148,7 @@ function my_display_apps($file,$pageNumber=1,$selectedApps=false,$startup=false)
}
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>"Install","action"=>"popupInstallXML('".addslashes($template['Path'])."','default','".str_replace(" ","&#32",htmlspecialchars($template['CAComment']))."');");
} else {
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>"Install","action"=>"displayTags('{$template['ID']}');");
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>"Install","action"=>"displayTags('{$template['ID']}',false,'".str_replace(" ","&#32",htmlspecialchars($template['CAComment']))."');");
}
}
}
@ -518,16 +518,18 @@ function getPopupDescriptionSkin($appNumber) {
$actionsContext[] = array("divider"=>true);
$actionsContext[] = array("icon"=>"ca_fa-delete","text"=>"<span class='ca_red'>".tr("Uninstall")."</span>","action"=>"uninstallDocker('".addslashes($info[$name]['template'])."','{$template['Name']}');");
} elseif ( ! $template['Blacklist'] || ! $template['Compatible']) {
} elseif ( ! $template['Blacklist'] ) {
if ( $template['InstallPath'] ) {
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Reinstall"),"action"=>"popupInstallXML('".addslashes($template['InstallPath'])."','user');");
$actionsContext[] = array("divider"=>true);
$actionsContext[] = array("icon"=>"ca_fa-delete","text"=>"<span class='ca_red'>".tr("Remove from Previous Apps")."</span>","action"=>"removeApp('{$template['InstallPath']}','{$template['Name']}');");
} else {
if ( ! $template['BranchID'] ) {
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Install"),"action"=>"popupInstallXML('".addslashes($template['Path'])."','default');");
} else {
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Install"),"action"=>"displayTags('{$template['ID']}');");
if ( $template['Compatible'] || $caSettings['hideIncompatible'] !== "true" ) {
if ( ! $template['BranchID'] ) {
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Install"),"action"=>"popupInstallXML('".addslashes($template['Path'])."','default');");
} else {
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Install"),"action"=>"displayTags('{$template['ID']}');");
}
}
}
}
@ -548,18 +550,17 @@ function getPopupDescriptionSkin($appNumber) {
$actionsContext[] = array("icon"=>"ca_fa-delete","text"=>"<span class='ca_red'>".tr("Uninstall")."</span>","action"=>"uninstallApp('/var/log/plugins/$pluginName','".str_replace(" ","&nbsp;",$template['Name'])."');");
}
} elseif ( ! $template['Blacklist'] || ! $template['Compatible'] ) {
$buttonTitle = $template['InstallPath'] ? tr("Reinstall") : tr("Install");
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>$buttonTitle,"action"=>"installPlugin('{$template['PluginURL']}');");
} elseif ( ! $template['Blacklist'] ) {
if ( $template['Compatible'] || $caSettings['hideIncompatible'] !== "true") {
$buttonTitle = $template['InstallPath'] ? tr("Reinstall") : tr("Install");
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>$buttonTitle,"action"=>"installPlugin('{$template['PluginURL']}');");
}
if ( $template['InstallPath'] ) {
if ( ! empty($actionsContext) )
$actionsContext[] = array("divider"=>true);
$actionsContext[] = array("icon"=>"ca_fa-delete","text"=>"<span class='ca_red'>".tr("Remove from Previous Apps")."</span>","action"=>"removeApp('{$template['InstallPath']}','$pluginName');");
}
/* if ( count($actionsContext) == 1 ) {
$template['newInstallAction'] = "installPlugin('{$template['PluginURL']}')";
unset($actionsContext);
} */
}
}
}
@ -1063,34 +1064,51 @@ function displayCard($template) {
";
}
$card .= "</div>";
if ( $Installed || $Uninstall) {
if ( $Blacklist ) {
$card .= "
<div class='warningCardBackground'>
<div class='betaPopupText ca_center' title='".tr("This application template / has been blacklisted")."'>&nbsp;".tr("Blacklisted")."&nbsp;</div>
</div>
";
} elseif ( ! $Compatible ) {
$card .= "
<div class='warningCardBackground'>
<div class='betaPopupText ca_center' title='".tr("This application is not compatible with your version of Unraid")."'>&nbsp;".tr("Incompatible")."&nbsp;</div>
</div>
";
} elseif ( $Deprecated ) {
$card .= "
<div class='warningCardBackground'>
<div class='betaPopupText ca_center' title='".tr("This application template has been deprecated")."'>&nbsp;".tr("Deprecated")."&nbsp;</div>
</div>
";
} elseif ( $Installed || $Uninstall) {
$card .= "
<div class='installedCardBackground'>
<div class='installedCardText ca_center'>".tr("INSTALLED")."</div>
</div>";
} else if ( $Official ) {
</div>";
} elseif ( $Official ) {
$card .= "
<div class='officialCardBackground'>
<div class='officialPopupText ca_center' title='This is an official container'>".tr("OFFICIAL")."</div>
</div>
";
} else if ( $Beta ) {
} elseif ( $Beta ) {
$card .= "
<div class='betaCardBackground'>
<div class='betaPopupText ca_center'>".tr("BETA")."</div>
</div>
";
} else if ( $RecommendedDate ) {
} elseif ( $RecommendedDate ) {
$card .= "
<div class='spotlightCardBackground'>
<div class='spotlightPopupText' title='".tr("This is a spotlight application")."'></div>
</div>
";
} else if ( $Trusted ) {
} elseif ( $Trusted ) {
$card .= "
<div class='spotlightCardBackground'>
<div class='betaPopupText ca_center' title='This container is digitally signed'>".tr("Digitally Signed")."</div>
<div class='betaPopupText ca_center' title='".tr("This container is digitally signed")."'>".tr("Digitally Signed")."</div>
</div>
";
}
@ -1232,7 +1250,7 @@ function displayPopup($template) {
$card .= "<tr><td class='popupTableLeft'>".tr("DockerHub Stars:")."</td><td class='popupTableRight'>$stars <span class='dockerHubStar'></span></td></tr>";
if ( $Plugin ) {
if ( $Plugin || ! $Compatible) {
if ( $MinVer )
$card .= "<tr><td class='popupTableLeft'>".tr("Min OS")."</td><td class='popupTableRight'>$MinVer</td></tr>";
if ( $MaxVer )