This commit is contained in:
Squidly271 2022-12-16 22:11:18 -05:00
parent f481131a4e
commit ccfbc19729
6 changed files with 52 additions and 58 deletions

View File

@ -12,6 +12,7 @@ Code="f0db"
# #
###############################################################
$_SESSION['locale'] = $_SESSION['locale'] ?? null;
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: "/usr/local/emhttp";
$plugin = "community.applications";
@ -20,12 +21,6 @@ $cfg['dockerSearch'] = "yes";
$cfg['unRaidVersion'] = $var['version'];
$caSettings = $cfg;
/* UNCOMMENT once the WebGUI is completely PHP8 compliant. Especially dockerMan
if ($caSettings['dev'] == "yes")
error_reporting(E_ALL);
*/
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
require_once "$docroot/plugins/$plugin/include/paths.php";
require_once "$docroot/plugins/$plugin/include/helpers.php";
@ -45,12 +40,15 @@ $diagnosticsFile = htmlspecialchars(str_replace(' ','_',strtolower($var['NAME'])
if ( $cfg['maxPerPage'] < 24 ) $cfg['maxPerPage'] = 24;
if ( ! is_file($caPaths['warningAccepted']) ) {
if ( ! is_file($caPaths['warningAccepted']) )
$firstRun = "true";
}
if ( ! is_file($caPaths['pluginWarning']) ) {
else
$firstRun = "false";
if ( ! is_file($caPaths['pluginWarning']) )
$pluginWarning = "false";
}
else
$pluginWarning = "true";
if ( ! is_file($caPaths['docker_cfg']) ) {
exec("logger -t 'Community Applications' 'Fatal Flash Drive Error: /boot/config/docker.cfg does not exist'");
@ -93,15 +91,18 @@ switch ($theme) {
break;
}
if ( is_file($caPaths['addConverted']) ) {
if ( is_file($caPaths['addConverted']) )
$dockerConvertFlag = "true";
}
else
$dockerConvertFlag = "false";
$date = (date("n/d"));
$startupDisplayed = is_file($caPaths['startupDisplayed']) ? "true" : "false";
if ( $startupDisplayed == "true" && ($_COOKIE['ca_languageSwitch'] ?? false) ) {
if ( $startupDisplayed == "true" && ($_COOKIE['ca_languageSwitch'] ?? false) )
$killCookie = "true";
}
else
$killCookie = "false";
$dockerSearchActive = is_file($caPaths['dockerSearchActive']);
@ -185,7 +186,7 @@ var repoBanner = false;
var repoBannerTimer = false;
var resizeTimer;
var portsInUse = [];
var startupSearch = "<?=$_GET['search']?>";
var startupSearch = "<?=$_GET['search'] ?? ""?>";
var iconHoverTimer;
$(function(){
@ -2239,7 +2240,7 @@ function postNoSpin(options,callback) {
alert("<?tr("You have been logged out")?>");
window.location.reload();
} else {
$("#templates_content").html(sprintf(tr("Something really wrong went on during %s"),options.action)+"<br><?tr("Post the ENTIRE contents of this message in the Community Applications Support Thread")?><br><br>OS: <?=$unRaidSettings['version']?> <?=$md5Error ? "<br>Modified CA" : ""?><br>Browser: <?=$_SERVER['HTTP_USER_AGENT']?><br>Language: <?=($_SESSION['locale'] ?? null)?><br><br>"+retval.escapeHTML());
$("#templates_content").html(sprintf(tr("Something really wrong went on during %s"),options.action)+"<br><?tr("Post the ENTIRE contents of this message in the Community Applications Support Thread")?><br><br>OS: <?=$unRaidSettings['version']?> <?=$md5Error ? "<br>Modified CA" : ""?><br>Browser: <?=$_SERVER['HTTP_USER_AGENT']?><br>Language: <?=$_SESSION['locale']?><br><br>"+retval.escapeHTML());
throw new Error("Something went badly wrong!"+options.action);
}
}
@ -2304,7 +2305,7 @@ function post(options,callback) {
alert("<?tr("You have been logged out")?>");
window.location.reload();
} else {
$("#templates_content").html(sprintf(tr("Something really wrong went on during %s"),options.action)+"<br><?tr("Post the ENTIRE contents of this message in the Community Applications Support Thread")?><br><br>OS: <?=$unRaidSettings['version']?> <?=$md5Error ? "<br>Modified CA" : ""?><br>Browser: <?=$_SERVER['HTTP_USER_AGENT']?><br>Language: <?=($_SESSION['locale'] ?? "")?><br><br>"+retval.escapeHTML());
$("#templates_content").html(sprintf(tr("Something really wrong went on during %s"),options.action)+"<br><?tr("Post the ENTIRE contents of this message in the Community Applications Support Thread")?><br><br>OS: <?=$unRaidSettings['version']?> <?=$md5Error ? "<br>Modified CA" : ""?><br>Browser: <?=$_SERVER['HTTP_USER_AGENT']?><br>Language: <?=$_SESSION['locale']?><br><br>"+retval.escapeHTML());
throw new Error("Something went badly wrong!"+options.action);
}
}
@ -2326,6 +2327,13 @@ function post(options,callback) {
alert("Could not execute Script "+e);
}
}
if (result.globalScript) {
try {
eval(result.globalScript);
} catch(e) {
alert("Could not execute Script "+e);
}
}
postCount--;
if (postCount < 0) postCount = 0;
if ( postCount == 0 && ! options.noSpinner) {
@ -2435,7 +2443,7 @@ function feedWarning(currentServer) {
}
function tr(string) {
<?if ( ! ( ($_SESSION['locale'] ?? "") == "" || ($_SESSION['locale'] ?? "") == "en_US") ) : ?>
<?if ( ! ($_SESSION['locale'] == "" || $_SESSION['locale'] == "en_US") ) : ?>
return _(string);
<?else: ?>
return string;
@ -2481,7 +2489,7 @@ function updateLanguage(language) {
function postUpdateLanguage() {
var languageUpdate = $.cookie("updateLanguage");
var currentLanguage = "<?=($_SESSION['locale'] ?? "")?>";
var currentLanguage = "<?=$_SESSION['locale']?>";
if (languageUpdate == currentLanguage)
window.location.reload();

View File

@ -1,9 +1,9 @@
cfefda874e2de863f14da70bafdf70e4 ./Apps.page
b13bdb01e1ed4ded6df0a012060da930 ./Apps.page
4e55f7483b661af21a25b677179baffe ./CA_notices.page
600469ce287cb1ed78dc6cc11675cfaf ./ca_settings.page
e8d29607ec792ddf9f6832b10ee70fdc ./default.cfg
c506f75e86d9f941f11eb4c949f00424 ./include/exec.php
78d797120193602420951421f8c844ad ./include/helpers.php
4838bc471694a3b5cd0073a7e6a0b086 ./include/exec.php
b0085333575019918bfba13871962526 ./include/helpers.php
8d15446d4edf60a1f4ac4493a494a301 ./include/paths.php
532fffdf939594c143e679da02bd841e ./javascript/libraries.js
71f911a818d88d3d567f8a2898094ee2 ./README.md
@ -22,4 +22,4 @@ da3b4f9b73c5c3bf65be6c42d68b51f9 ./scripts/showStatistics.php
34554a56611dfe625889c82afd5138de ./scripts/updatePluginSupport.php
25bdaed6f62ac73f9ef7c3ce0c125ef7 ./skins/Narrow/css.php
7eb021a105e2f7a15675ec8a14e6f05e ./skins/Narrow/skin.html
f5a56fc6208d45d75069aafe734596f0 ./skins/Narrow/skin.php
925efdb8323bad92d8fbdb632636527f ./skins/Narrow/skin.php

View File

@ -29,9 +29,6 @@ require_once "$docroot/webGui/include/Markdown.php";
$caSettings = parse_plugin_cfg("community.applications");
if ($caSettings['dev'] == "yes")
error_reporting(E_ALL);
$caSettings['dockerSearch'] = "yes";
$caSettings['unRaidVersion'] = $unRaidSettings['version'];
$caSettings['favourite'] = isset($caSettings['favourite']) ? str_replace("*","'",$caSettings['favourite']) : "";
@ -212,7 +209,6 @@ switch ($_POST['action']) {
function DownloadApplicationFeed() {
global $caPaths, $caSettings, $statistics;
$lastUpdated = [];
$info = readJsonFile($caPaths['info']);
exec("rm -rf '{$caPaths['tempFiles']}'");
@mkdir($caPaths['templates-community'],0777,true);
@ -983,9 +979,6 @@ function force_update() {
}
if ( ($latestUpdate['last_updated_timestamp'] ?? 0) != ($lastUpdatedOld['last_updated_timestamp'] ?? 0) ) {
/* if ( $latestUpdate['last_updated_timestamp'] != INF )
copy($caPaths['lastUpdated'],$caPaths['lastUpdated-old']); */
exec("rm -rf '{$caPaths['tempFiles']}'");
$GLOBALS['templates'] = [];
}
@ -2344,9 +2337,7 @@ function enableActionCentre() {
}
# wait til templates are downloaded
for ( $i=0;$i<100;$i++ ) {
$file = readJsonFile($caPaths['community-templates-info']);
if ( ! $file || empty($file) ) {
if ( ! is_file($caPaths['haveTemplates']) ) {
debug("Action Centre sleeping - no templates yet");
sleep(5);
} else {
@ -2359,7 +2350,7 @@ function enableActionCentre() {
postReturn(['status'=>"noaction"]);
return;
}
$file = readJsonFile($caPaths['community-templates-info']);
$extraBlacklist = readJsonFile($caPaths['extraBlacklist']);
$extraDeprecated = readJsonFile($caPaths['extraDeprecated']);

View File

@ -59,20 +59,19 @@ function writeJsonFile($filename,$jsonArray) {
global $caSettings, $caPaths;
debug("Write JSON File $filename");
ca_file_put_contents($filename,json_encode($jsonArray, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
$result = ca_file_put_contents($filename,json_encode($jsonArray, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
debug("Memory Usage:".round(memory_get_usage()/1048576,2)." MB");
}
function ca_file_put_contents($filename,$data,$flags = null) {
function ca_file_put_contents($filename,$data,$flags=0) {
$result = @file_put_contents($filename,$data,$flags);
if ($result === false) {
debug("Unable to write to $filename");
$GLOBALS['script'] = "alert('Error writing to ".htmlentities($filename,ENT_QUOTES)."');";
if ( $result === false ) {
debug("Failed to write to $filename");
$GLOBALS['script'] = "alert('Failed to write to ".htmlentities($filename,ENT_QUOTES)."');";
}
return $result;
}
function download_url($url, $path = "", $bg = false, $timeout = 45) {
global $caSettings, $caPaths;
@ -328,7 +327,7 @@ function versionCheck($template) {
function readXmlFile($xmlfile,$generic=false,$stats=true) {
global $statistics;
if ( ! $xmlfile || ! is_file($xmlfile) ) return false;
if ( $xmlfile && ! is_file($xmlfile) ) return false;
$xml = file_get_contents($xmlfile);
$o = TypeConverter::xmlToArray($xml,TypeConverter::XML_GROUP);
$o = addMissingVars($o);
@ -579,16 +578,12 @@ function formatTags($leadTemplate,$rename="false") {
function postReturn($retArray) {
global $caSettings, $caPaths;
if ( isset($_GLOBALS['script']) ) {
if ( is_array($retArray) ) {
$retArray['script'] = $retArray['script'] ?? null;
$retArray['script'] .= $_GLOBALS['script'];
}
}
if (is_array($retArray))
if (is_array($retArray)) {
if ( isset($GLOBALS['script']) )
$retArray['globalScript'] = $GLOBALS['script'];
echo json_encode($retArray);
else
} else
echo $retArray;
flush();
debug("POST RETURN ({$_POST['action']})\n".var_dump_ret($retArray));
@ -658,7 +653,7 @@ function getAllInfo($force=false) {
$containers = [];
if ( $force ) {
if ( $caSettings['dockerRunning'] ) {
if ( $caSettings['dockerRunning'] ?? false ) {
$info = $DockerTemplates->getAllInfo(false,true,true);
$containers = $DockerClient->getDockerContainers();
foreach ($containers as &$container) {
@ -689,11 +684,11 @@ function debug($str) {
debug("Community Applications Version: $caVersion");
debug("Unraid version: {$caSettings['unRaidVersion']}");
debug("MD5's: \n".shell_exec("cd /usr/local/emhttp/plugins/community.applications && md5sum -c ca.md5"));
$lingo = $_SESSION['locale'] ?: "en_US";
$lingo = $_SESSION['locale'] ?? "en_US";
debug("Language: $lingo");
debug("Settings:\n".print_r($caSettings,true));
}
ca_file_put_contents($caPaths['logging'],date('Y-m-d H:i:s')." $str\n",FILE_APPEND);
@file_put_contents($caPaths['logging'],date('Y-m-d H:i:s')." $str\n",FILE_APPEND); //don't run through CA wrapper as this is non-critical
}
}
########################################

View File

@ -457,6 +457,7 @@ function getPopupDescriptionSkin($appNumber) {
$selected = null;
$pinnedApps = readJsonFile($caPaths['pinnedV2']);
$info = [];
if ( is_file("/var/run/dockerd.pid") && is_dir("/proc/".@file_get_contents("/var/run/dockerd.pid")) ) {
$caSettings['dockerRunning'] = "true";
@ -468,7 +469,6 @@ function getPopupDescriptionSkin($appNumber) {
$dockerUpdateStatus = readJsonFile($caPaths['dockerUpdateStatus']);
} else {
$caSettings['dockerRunning'] = false;
$info = [];
$dockerRunning = [];
$dockerUpdateStatus = [];
}
@ -850,8 +850,8 @@ function getRepoDescriptionSkin($repository) {
$templates = &$GLOBALS['templates'];
$repo = $repositories[$repository];
$repo['icon'] = $repo['icon'] ?: "/plugins/dynamix.docker.manager/images/question.png";
$repo['bio'] = $repo['bio'] ? markdown($repo['bio']) : "<br><center>".tr("No description present");
$repo['icon'] = $repo['icon'] ?? "/plugins/dynamix.docker.manager/images/question.png";
$repo['bio'] = isset($repo['bio']) ? markdown($repo['bio']) : "<br><center>".tr("No description present");
$favRepoClass = ($caSettings['favourite'] == $repository) ? "fav" : "nonfav";
$totalApps = $totalLanguage = $totalPlugins = $totalDocker = $totalDownloads = $downloadDockerCount = 0;