parent
8dcbf1d462
commit
8b404c89d9
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -2,9 +2,9 @@
|
|||
4e55f7483b661af21a25b677179baffe ./CA_notices.page
|
||||
600469ce287cb1ed78dc6cc11675cfaf ./ca_settings.page
|
||||
e8d29607ec792ddf9f6832b10ee70fdc ./default.cfg
|
||||
9ffd40aedffad25c998e947faf169ad3 ./include/exec.php
|
||||
3a1e5abf962bd5700e286a48c941b2c9 ./include/helpers.php
|
||||
8d15446d4edf60a1f4ac4493a494a301 ./include/paths.php
|
||||
29f110f50c87f9e8285aca289bce6e57 ./include/exec.php
|
||||
8cb18002feb91c9eb07811a75aabb7b5 ./include/helpers.php
|
||||
116042a918060278e77379b0dd73482c ./include/paths.php
|
||||
532fffdf939594c143e679da02bd841e ./javascript/libraries.js
|
||||
71f911a818d88d3d567f8a2898094ee2 ./README.md
|
||||
ebb6450725d05c53116c3c996b6abac1 ./scripts/checkForUpdates.php
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
# #
|
||||
###############################################################
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('log_errors',TRUE);
|
||||
ini_set('error_log',"/tmp/php");
|
||||
ini_set('memory_limit','256M'); // REQUIRED LINE
|
||||
|
@ -211,7 +212,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);
|
||||
|
@ -227,10 +227,10 @@ function DownloadApplicationFeed() {
|
|||
@unlink($downloadURL);
|
||||
if ( ! is_array($ApplicationFeed['applist']) ) {
|
||||
@unlink($caPaths['currentServer']);
|
||||
ca_file_put_contents($caPaths['appFeedDownloadError'],$downloadURL);
|
||||
file_put_contents($caPaths['appFeedDownloadError'],$downloadURL);
|
||||
return false;
|
||||
}
|
||||
ca_file_put_contents($caPaths['currentServer'],$currentFeed);
|
||||
file_put_contents($caPaths['currentServer'],$currentFeed);
|
||||
$i = 0;
|
||||
$lastUpdated['last_updated_timestamp'] = $ApplicationFeed['last_updated_timestamp'];
|
||||
writeJsonFile($caPaths['lastUpdated-old'],$lastUpdated);
|
||||
|
@ -406,7 +406,6 @@ function DownloadApplicationFeed() {
|
|||
writeJsonFile($caPaths['extraDeprecated'],$ApplicationFeed['deprecated']);
|
||||
|
||||
updatePluginSupport($myTemplates);
|
||||
touch($caPaths['haveTemplates']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -438,7 +437,7 @@ function updatePluginSupport($templates) {
|
|||
$dom->preserveWhiteSpace = false;
|
||||
$dom->formatOutput = true;
|
||||
$dom->loadXML($xml->asXML());
|
||||
ca_file_put_contents($plugin, $dom->saveXML());
|
||||
file_put_contents($plugin, $dom->saveXML());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -734,7 +733,7 @@ function get_content() {
|
|||
if ( !$filter && $category === "/NONE/i" ) {
|
||||
getConvertedTemplates(); // Only scan for private XMLs when going HOME
|
||||
|
||||
ca_file_put_contents($caPaths['startupDisplayed'],"startup");
|
||||
file_put_contents($caPaths['startupDisplayed'],"startup");
|
||||
$displayApplications = [];
|
||||
$displayApplications['community'] = [];
|
||||
if ( count($file) > 200) {
|
||||
|
@ -969,24 +968,28 @@ function force_update() {
|
|||
global $caPaths;
|
||||
|
||||
$lastUpdatedOld = readJsonFile($caPaths['lastUpdated-old']);
|
||||
debug("old feed timestamp: {$lastUpdatedOld['last_updated_timestamp']}");
|
||||
|
||||
@unlink($caPaths['lastUpdated']);
|
||||
$latestUpdate = download_json($caPaths['application-feed-last-updated'],$caPaths['lastUpdated'],"",5);
|
||||
if ( ! $latestUpdate['last_updated_timestamp'] )
|
||||
$latestUpdate = download_json($caPaths['application-feed-last-updatedBackup'],$caPaths['lastUpdated'],"",5);
|
||||
debug("new appfeed timestamp: {$latestUpdate['last_updated_timestamp']}");
|
||||
|
||||
if ( ! isset($latestUpdate['last_updated_timestamp']) ) {
|
||||
$latestUpdate['last_updated_timestamp'] = INF;
|
||||
$badDownload = true;
|
||||
@unlink($caPaths['lastUpdated']);
|
||||
}
|
||||
|
||||
if ( ($latestUpdate['last_updated_timestamp'] ?? 0) != ($lastUpdatedOld['last_updated_timestamp'] ?? 0) ) {
|
||||
/* if ( $latestUpdate['last_updated_timestamp'] != INF )
|
||||
copy($caPaths['lastUpdated'],$caPaths['lastUpdated-old']); */
|
||||
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'] = [];
|
||||
if (isset($badDownload)) {
|
||||
if ( ! $badDownload ) {
|
||||
@unlink($caPaths['community-templates-info']);
|
||||
$GLOBALS['templates'] = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!file_exists($caPaths['community-templates-info']) || ! $GLOBALS['templates']) {
|
||||
|
@ -1048,13 +1051,13 @@ function display_content() {
|
|||
function dismiss_warning() {
|
||||
global $caPaths;
|
||||
|
||||
ca_file_put_contents($caPaths['warningAccepted'],"warning dismissed");
|
||||
file_put_contents($caPaths['warningAccepted'],"warning dismissed");
|
||||
postReturn(['status'=>"warning dismissed"]);
|
||||
}
|
||||
function dismiss_plugin_warning() {
|
||||
global $caPaths;
|
||||
|
||||
ca_file_put_contents($caPaths['pluginWarning'],"disclaimer ok");
|
||||
file_put_contents($caPaths['pluginWarning'],"disclaimer ok");
|
||||
postReturn(['status'=>"disclaimed"]);
|
||||
}
|
||||
|
||||
|
@ -1984,7 +1987,7 @@ function createXML() {
|
|||
}
|
||||
$xml = makeXML($template);
|
||||
@mkdir(dirname($xmlFile));
|
||||
ca_file_put_contents($xmlFile,$xml);
|
||||
file_put_contents($xmlFile,$xml);
|
||||
}
|
||||
postReturn(["status"=>"ok","cache"=>$cacheVolume ?? ""]);
|
||||
}
|
||||
|
@ -2188,7 +2191,7 @@ function convert_docker() {
|
|||
|
||||
$dockerXML = makeXML($dockerfile);
|
||||
|
||||
ca_file_put_contents($caPaths['dockerSearchInstall'],$dockerXML);
|
||||
file_put_contents($caPaths['dockerSearchInstall'],$dockerXML);
|
||||
postReturn(['xml'=>$caPaths['dockerSearchInstall']]);
|
||||
}
|
||||
|
||||
|
@ -2328,7 +2331,7 @@ function enableActionCentre() {
|
|||
global $caPaths, $caSettings, $DockerClient;
|
||||
|
||||
# wait til check for updates is finished
|
||||
for ( $i=0;$i<100;$i++ ) {
|
||||
for ( ;; ) {
|
||||
if ( is_file($caPaths['updateRunning']) && file_exists("/proc/".@file_get_contents($caPaths['updateRunning'])) ) {
|
||||
debug("Action Centre sleeping -> update running");
|
||||
sleep(5);
|
||||
|
@ -2336,15 +2339,10 @@ function enableActionCentre() {
|
|||
}
|
||||
else break;
|
||||
}
|
||||
if ( $i >= 100 ) {
|
||||
debug("Something went wrong. EnableActionCentre ran longer than 500 seconds");
|
||||
postReturn(['status'=>"noaction"]);
|
||||
return;
|
||||
}
|
||||
# wait til templates are downloaded
|
||||
for ( $i=0;$i<100;$i++ ) {
|
||||
$file = readJsonFile($caPaths['community-templates-info']);
|
||||
|
||||
# wait til templates are downloaded
|
||||
for ( ;; ) {
|
||||
$file = &$GLOBALS['templates'];
|
||||
if ( ! $file || empty($file) ) {
|
||||
debug("Action Centre sleeping - no templates yet");
|
||||
sleep(5);
|
||||
|
@ -2353,12 +2351,6 @@ function enableActionCentre() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if ( $i >= 100 ) {
|
||||
debug("Something went wrong. EnableActionCentre ran longer than 500 seconds");
|
||||
postReturn(['status'=>"noaction"]);
|
||||
return;
|
||||
}
|
||||
|
||||
$extraBlacklist = readJsonFile($caPaths['extraBlacklist']);
|
||||
$extraDeprecated = readJsonFile($caPaths['extraDeprecated']);
|
||||
|
||||
|
|
|
@ -60,17 +60,12 @@ function writeJsonFile($filename,$jsonArray) {
|
|||
|
||||
debug("Write JSON File $filename");
|
||||
|
||||
ca_file_put_contents($filename,json_encode($jsonArray, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
|
||||
$result = 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) {
|
||||
$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 )
|
||||
debug("Write error $filename");
|
||||
}
|
||||
|
||||
function download_url($url, $path = "", $bg = false, $timeout = 45) {
|
||||
|
@ -99,7 +94,7 @@ function download_url($url, $path = "", $bg = false, $timeout = 45) {
|
|||
$out = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ( $path )
|
||||
ca_file_put_contents($path,$out);
|
||||
file_put_contents($path,$out);
|
||||
|
||||
$totalTime = time() - $startTime;
|
||||
debug("DOWNLOAD $url Time: $totalTime RESULT:\n".var_dump_ret($out));
|
||||
|
@ -328,7 +323,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);
|
||||
|
@ -439,7 +434,6 @@ function pluginDupe() {
|
|||
function checkInstalledPlugin($template) {
|
||||
global $caPaths;
|
||||
|
||||
debug("checkInstalledPlugin $template");
|
||||
$pluginName = basename($template['PluginURL']);
|
||||
if ( ! file_exists("/var/log/plugins/$pluginName") ) return false;
|
||||
$dupeList = readJsonFile($caPaths['pluginDupes']);
|
||||
|
@ -580,13 +574,6 @@ 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))
|
||||
echo json_encode($retArray);
|
||||
else
|
||||
|
@ -649,7 +636,7 @@ function write_ini_file($file,$array) {
|
|||
else
|
||||
$res[] = $key.'="'.$val.'"';
|
||||
}
|
||||
ca_file_put_contents($file,implode("\r\n", $res),LOCK_EX);
|
||||
file_put_contents($file,implode("\r\n", $res),LOCK_EX);
|
||||
}
|
||||
###################################################
|
||||
# Gets all the information about what's installed #
|
||||
|
@ -659,7 +646,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) {
|
||||
|
@ -694,7 +681,7 @@ function debug($str) {
|
|||
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);
|
||||
}
|
||||
}
|
||||
########################################
|
||||
|
|
|
@ -14,7 +14,6 @@ $caPaths['templates-community'] = $caPaths['tempFiles']."/templa
|
|||
$caPaths['community-templates-url'] = "https://raw.githubusercontent.com/Squidly271/Community-Applications-Moderators/master/Repositories.json";
|
||||
$caPaths['PublicServiceAnnouncement'] = "https://raw.githubusercontent.com/Squidly271/Community-Applications-Moderators/master/PublicServiceAnnouncement.txt";
|
||||
$caPaths['community-templates-info'] = $caPaths['tempFiles']."/templates.json"; /* json file containing all of the templates */
|
||||
$caPaths['haveTemplates'] = $caPaths['tempFiles']."/haveTemplates";
|
||||
$caPaths['community-templates-displayed'] = $caPaths['tempFiles']."/displayed.json"; /* json file containing all of the templates currently displayed */
|
||||
$caPaths['community-templates-allSearchResults']= $caPaths['tempFiles']."/allSearchResults.json";
|
||||
$caPaths['community-templates-catSearchResults']= $caPaths['tempFiles']."/catSearchResults.json";
|
||||
|
|
Loading…
Reference in New Issue