Prevent excess memory usage by using $GLOBAL
This commit is contained in:
parent
c39e25e5d8
commit
e70902c6ad
BIN
archive/community.applications-2022.11.13-x86_64-1.txz
Normal file
BIN
archive/community.applications-2022.11.13-x86_64-1.txz
Normal file
Binary file not shown.
@ -2,8 +2,8 @@
|
||||
4e55f7483b661af21a25b677179baffe ./CA_notices.page
|
||||
4c5d4598e1bafa46bd90c27cbe302122 ./ca_settings.page
|
||||
e8d29607ec792ddf9f6832b10ee70fdc ./default.cfg
|
||||
d0845b8038d064fde29c5a0ca7873bce ./include/exec.php
|
||||
f25b1ed0b1cddfb4ff95a10ced212a0d ./include/helpers.php
|
||||
aed8d4eda97f849fff5b0a4d054b6637 ./include/exec.php
|
||||
58943e7d6c7ded15b71f160bd4493f1d ./include/helpers.php
|
||||
116042a918060278e77379b0dd73482c ./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
|
||||
0e60030b86d25fd60e8b416bf0929558 ./skins/Narrow/skin.php
|
||||
23217bd2953036a0f400f6892692effa ./skins/Narrow/skin.php
|
||||
|
@ -73,6 +73,9 @@ if ( ! $sortOrder ) {
|
||||
$sortOrder['sortDir'] = "Up";
|
||||
writeJsonFile($caPaths['sortOrder'],$sortOrder);
|
||||
}
|
||||
|
||||
$GLOBALS['templates'] = readJsonFile($caPaths['community-templates-info']);
|
||||
|
||||
############################################
|
||||
## ##
|
||||
## BEGIN MAIN ROUTINES CALLED BY THE HTML ##
|
||||
@ -390,6 +393,7 @@ function DownloadApplicationFeed() {
|
||||
@unlink($caPaths['invalidXML_txt']);
|
||||
|
||||
writeJsonFile($caPaths['community-templates-info'],$myTemplates);
|
||||
$GLOBALS['templates'] = $myTemplates;
|
||||
writeJsonFile($caPaths['categoryList'],$ApplicationFeed['categories']);
|
||||
|
||||
foreach ($ApplicationFeed['repositories'] as &$repo) {
|
||||
@ -444,7 +448,8 @@ function getConvertedTemplates() {
|
||||
global $caPaths, $caSettings, $statistics;
|
||||
|
||||
# Start by removing any pre-existing private (converted templates)
|
||||
$templates = readJsonFile($caPaths['community-templates-info']);
|
||||
// $templates = readJsonFile($caPaths['community-templates-info']);
|
||||
$templates = &$GLOBALS['templates'];
|
||||
|
||||
if ( empty($templates) ) return false;
|
||||
|
||||
@ -458,6 +463,8 @@ function getConvertedTemplates() {
|
||||
|
||||
if ( ! is_dir($caPaths['convertedTemplates']) ) {
|
||||
writeJsonFile($caPaths['community-templates-info'],$myTemplates);
|
||||
$GLOBALS['templates'] = $myTemplates;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -480,6 +487,7 @@ function getConvertedTemplates() {
|
||||
$i = ++$i;
|
||||
}
|
||||
writeJsonFile($caPaths['community-templates-info'],$myTemplates);
|
||||
$GLOBALS['templates'] = $myTemplates;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -622,7 +630,8 @@ function displayRepositories() {
|
||||
$templates = $temp['community'];
|
||||
}
|
||||
if ( is_file($caPaths['startupDisplayed']) ) {
|
||||
$templates = readJsonFile($caPaths['community-templates-info']);
|
||||
// $templates = readJsonFile($caPaths['community-templates-info']);
|
||||
$templates = &$GLOBALS['templates'];
|
||||
}
|
||||
$templates = $templates ?: array();
|
||||
$allRepos = array();
|
||||
@ -709,7 +718,8 @@ function get_content() {
|
||||
$disp = readJsonFile($caPaths['community-templates-allSearchResults']);
|
||||
$file = $disp['community'];
|
||||
} else {
|
||||
$file = readJsonFile($caPaths['community-templates-info']);
|
||||
// $file = readJsonFile($caPaths['community-templates-info']);
|
||||
$file = &$GLOBALS['templates'];
|
||||
}
|
||||
if ( empty($file)) return;
|
||||
|
||||
@ -966,11 +976,13 @@ function force_update() {
|
||||
if ( $latestUpdate['last_updated_timestamp'] != INF )
|
||||
copy($caPaths['lastUpdated'],$caPaths['lastUpdated-old']);
|
||||
|
||||
if ( ! $badDownload )
|
||||
if ( ! $badDownload ) {
|
||||
@unlink($caPaths['community-templates-info']);
|
||||
$GLOBALS['templates'] = [];
|
||||
}
|
||||
}
|
||||
|
||||
if (!file_exists($caPaths['community-templates-info']) || !readJsonFile($caPaths['community-templates-info'])) {
|
||||
if (!file_exists($caPaths['community-templates-info']) || ! $$GLOBALS['templates']) {
|
||||
$updatedSyncFlag = true;
|
||||
if (! DownloadApplicationFeed() ) {
|
||||
$o['script'] = "$('.onlyShowWithFeed').hide();";
|
||||
@ -987,6 +999,7 @@ function force_update() {
|
||||
$o['data'] .= "</div>";
|
||||
@unlink($caPaths['appFeedDownloadError']);
|
||||
@unlink($caPaths['community-templates-info']);
|
||||
$GLOBALS['templates'] = [];
|
||||
postReturn($o);
|
||||
return;
|
||||
}
|
||||
@ -1054,7 +1067,8 @@ function previous_apps() {
|
||||
@unlink($caPaths['startupDisplayed']);
|
||||
@unlink($caPaths['dockerSearchActive']);
|
||||
|
||||
$file = readJsonFile($caPaths['community-templates-info']);
|
||||
// $file = readJsonFile($caPaths['community-templates-info']);
|
||||
$file = &$GLOBALS['templates'];
|
||||
$extraBlacklist = readJsonFile($caPaths['extraBlacklist']);
|
||||
$extraDeprecated = readJsonFile($caPaths['extraDeprecated']);
|
||||
|
||||
@ -1381,7 +1395,8 @@ function pinnedApps() {
|
||||
global $caPaths, $caSettings;
|
||||
|
||||
$pinnedApps = readJsonFile($caPaths['pinnedV2']);
|
||||
$file = readJsonFile($caPaths['community-templates-info']);
|
||||
// $file = readJsonFile($caPaths['community-templates-info']);
|
||||
$file = &$GLOBALS['templates'];
|
||||
@unlink($caPaths['community-templates-allSearchResults']);
|
||||
@unlink($caPaths['community-templates-catSearchResults']);
|
||||
@unlink($caPaths['repositoriesDisplayed']);
|
||||
@ -1450,7 +1465,8 @@ function statistics() {
|
||||
download_json($caPaths['moderationURL'],$caPaths['moderation']);
|
||||
$statistics['totalModeration'] = count(readJsonFile($caPaths['moderation']));
|
||||
$repositories = readJsonFile($caPaths['repositoryList']);
|
||||
$templates = readJsonFile($caPaths['community-templates-info']);
|
||||
// $templates = readJsonFile($caPaths['community-templates-info']);
|
||||
$templates = &$GLOBALS['templates'];
|
||||
pluginDupe($templates);
|
||||
$invalidXML = readJsonFile($caPaths['invalidXML_txt']);
|
||||
$statistics['private'] = 0;
|
||||
@ -1655,7 +1671,9 @@ function removePrivateApp() {
|
||||
postReturn(["error"=>"Path not contained within /boot/config/community.applications"]);
|
||||
return;
|
||||
}
|
||||
$templates = readJsonFile($caPaths['community-templates-info']);
|
||||
// $templates = readJsonFile($caPaths['community-templates-info']);
|
||||
$templates = &$$GLOBALS['templates'];
|
||||
|
||||
$displayed = readJsonFile($caPaths['community-templates-displayed']);
|
||||
foreach ( $displayed as &$displayType ) {
|
||||
if ( is_array($displayType) ) {
|
||||
@ -1682,7 +1700,8 @@ function populateAutoComplete() {
|
||||
global $caPaths, $caSettings;
|
||||
|
||||
while ( ! $templates ) {
|
||||
$templates = readJsonFile($caPaths['community-templates-info']);
|
||||
// $templates = readJsonFile($caPaths['community-templates-info']);
|
||||
$templates = &$GLOBALS['templates'];
|
||||
if ( ! $templates )
|
||||
sleep(1);
|
||||
}
|
||||
@ -1774,7 +1793,8 @@ function get_categories() {
|
||||
$cat .= "</ul>";
|
||||
}
|
||||
}
|
||||
$templates = readJsonFile($caPaths['community-templates-info']);
|
||||
// $templates = readJsonFile($caPaths['community-templates-info']);
|
||||
$templates = &$GLOBALS['templates'];
|
||||
foreach ($templates as $template) {
|
||||
if ($template['Private'] == true && ! $template['Blacklist']) {
|
||||
$cat .= "<li class='categoryMenu caMenuItem nonDockerSearch' data-category='PRIVATE'>".tr("Private Apps")."</li>";
|
||||
@ -1813,7 +1833,8 @@ function createXML() {
|
||||
postReturn(["error"=>"CreateXML: XML file was missing"]);
|
||||
return;
|
||||
}
|
||||
$templates = readJsonFile($caPaths['community-templates-info']);
|
||||
// $templates = readJsonFile($caPaths['community-templates-info']);
|
||||
$templates = &$GLOBALS['templates'];
|
||||
if ( ! $templates ) {
|
||||
postReturn(["error"=>"Create XML: templates file missing or empty"]);
|
||||
return;
|
||||
@ -2169,7 +2190,8 @@ function search_dockerhub() {
|
||||
$filter = getPost("filter","");
|
||||
$pageNumber = getPost("page","1");
|
||||
|
||||
$communityTemplates = readJsonFile($caPaths['community-templates-info']);
|
||||
// $communityTemplates = readJsonFile($caPaths['community-templates-info']);
|
||||
$communityTemplates = &$GLOBALS['templates'];
|
||||
$filter = str_replace(" ","%20",$filter);
|
||||
$filter = str_replace("/","%20",$filter);
|
||||
$jsonPage = shell_exec("curl -s -X GET 'https://registry.hub.docker.com/v1/search?q=$filter&page=$pageNumber'");
|
||||
@ -2227,7 +2249,8 @@ function getLastUpdate($ID) {
|
||||
|
||||
$count = 0;
|
||||
while ( $count < 5 ) {
|
||||
$templates = readJsonFile($caPaths['community-templates-info']);
|
||||
// $templates = readJsonFile($caPaths['community-templates-info']);
|
||||
$templates = &$GLOBALS['templates'];
|
||||
if ( $templates ) break;
|
||||
sleep(1); # keep trying in case of a collision between reading and writing
|
||||
}
|
||||
@ -2304,7 +2327,8 @@ function enableActionCentre() {
|
||||
|
||||
# wait til templates are downloaded
|
||||
for ( ;; ) {
|
||||
$file = readJsonFile($caPaths['community-templates-info']);
|
||||
// $file = readJsonFile($caPaths['community-templates-info']);
|
||||
$file = &$GLOBALS['templates'];
|
||||
if ( ! $file ) {
|
||||
debug("Action Centre sleeping - no templates yet");
|
||||
sleep(5);
|
||||
|
@ -360,7 +360,8 @@ function readXmlFile($xmlfile,$generic=false,$stats=true) {
|
||||
function moderateTemplates() {
|
||||
global $caPaths,$caSettings;
|
||||
|
||||
$templates = readJsonFile($caPaths['community-templates-info']);
|
||||
// $templates = readJsonFile($caPaths['community-templates-info']);
|
||||
$templates = &$GLOBALS['templates'];
|
||||
|
||||
if ( ! $templates ) return;
|
||||
foreach ($templates as $template) {
|
||||
@ -372,6 +373,7 @@ function moderateTemplates() {
|
||||
$o[] = $template;
|
||||
}
|
||||
writeJsonFile($caPaths['community-templates-info'],$o);
|
||||
$GLOBALS['templates'] = $o;
|
||||
pluginDupe($o);
|
||||
}
|
||||
#######################################################
|
||||
@ -535,7 +537,10 @@ function formatTags($leadTemplate,$rename="false") {
|
||||
global $caPaths;
|
||||
|
||||
$type = $rename == "true" ? "second" : "default";
|
||||
$file = readJsonFile($caPaths['community-templates-info']);
|
||||
|
||||
// $file = readJsonFile($caPaths['community-templates-info']);
|
||||
$file = &$GLOBALS['templates'];
|
||||
|
||||
$template = $file[$leadTemplate];
|
||||
$childTemplates = $file[$leadTemplate]['BranchID'];
|
||||
if ( ! is_array($childTemplates) )
|
||||
|
@ -500,7 +500,8 @@ function getPopupDescriptionSkin($appNumber) {
|
||||
|
||||
# handle case where the app being asked to display isn't on the most recent displayed list (ie: multiple browser tabs open)
|
||||
if ( ! $template ) {
|
||||
$file = readJsonFile($caPaths['community-templates-info']);
|
||||
// $file = readJsonFile($caPaths['community-templates-info']);
|
||||
$file = &$GLOBALS['templates'];
|
||||
$index = searchArray($file,"Path",$appNumber);
|
||||
if ( $index === false ) {
|
||||
echo json_encode(array("description"=>tr("Something really wrong happened. Reloading the Apps tab will probably fix the problem")));
|
||||
@ -560,7 +561,8 @@ function getPopupDescriptionSkin($appNumber) {
|
||||
$pluginName = basename($template['PluginURL']);
|
||||
|
||||
if ( $template['trending'] ) {
|
||||
$allApps = readJsonFile($caPaths['community-templates-info']);
|
||||
// $allApps = readJsonFile($caPaths['community-templates-info']);
|
||||
$allApps = &$GLOBALS['templates'];
|
||||
|
||||
$allTrends = array_unique(array_column($allApps,"trending"));
|
||||
rsort($allTrends);
|
||||
@ -843,7 +845,8 @@ function getRepoDescriptionSkin($repository) {
|
||||
|
||||
$dockerVars = parse_ini_file($caPaths['docker_cfg']);
|
||||
$repositories = readJsonFile($caPaths['repositoryList']);
|
||||
$templates = readJsonFile($caPaths['community-templates-info']);
|
||||
// $templates = readJsonFile($caPaths['community-templates-info']);
|
||||
$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");
|
||||
@ -1001,7 +1004,8 @@ function displaySearchResults($pageNumber) {
|
||||
$tempFile = readJsonFile($caPaths['dockerSearchResults']);
|
||||
$num_pages = $tempFile['num_pages'];
|
||||
$file = $tempFile['results'];
|
||||
$templates = readJsonFile($caPaths['community-templates-info']);
|
||||
// $templates = readJsonFile($caPaths['community-templates-info']);
|
||||
$templates = &$GLOBALS['templates'];
|
||||
|
||||
$ct = "<div>".tr("NOTE You must visit the dockerHub page to gather the information required to install correctly")."<span class='templateSearch' style='float:right'>Show CA templates</span></div><br><br>";
|
||||
$ct .= "<div class='ca_templatesDisplay'>";
|
||||
|
Loading…
x
Reference in New Issue
Block a user