atomic writes and fix dockerhub searches not supporting proxy
master
Squidly271 2024-03-10 13:03:07 -04:00
parent cfc291b173
commit dc5a188820
4 changed files with 21 additions and 20 deletions

View File

@ -2,8 +2,8 @@ a8912282397fd6ae3351f631ddc2b678 ./Apps.page
2defe45163697e40c813a57ae9a50231 ./CA_notices.page
bce84c6e359376b627561214a730a504 ./ca_settings.page
01ed7990078dee7cecfeda9a4e49377e ./default.cfg
d3af236a9384314bd17eeb62b9c789b8 ./include/exec.php
1d21e20284741127836e4acdafff3cb1 ./include/helpers.php
fefbf5ad8a5ab3a1e40f0ca636fd3ed6 ./include/exec.php
66cebca33e8cf88b513c93939279de91 ./include/helpers.php
590fb8b29aba360a56dd8338b022f9e0 ./include/paths.php
7234caf6800479df03abb222aaedaca5 ./javascript/libraries.js
71f911a818d88d3d567f8a2898094ee2 ./README.md

View File

@ -1088,7 +1088,6 @@ function force_update() {
getConvertedTemplates();
moderateTemplates();
$currentServer = @file_get_contents($caPaths['currentServer']);
$appFeedTime = readJsonFile($caPaths['lastUpdated-old']);
$updateTime = tr(date("F",$appFeedTime['last_updated_timestamp']),0).date(" d, Y @ g:i a",$appFeedTime['last_updated_timestamp']);
@ -1115,7 +1114,6 @@ function force_update() {
postReturn(['status'=>"ok",'script'=> $script]);
}
####################################################################################
# display_content - displays the templates according to view mode, sort order, etc #
####################################################################################
@ -2285,7 +2283,8 @@ function search_dockerhub() {
$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'");
$jsonPage = download_url("https://registry.hub.docker.com/v1/search?q=$filter&page=$pageNumber");
//$jsonPage = shell_exec("curl -s -X GET 'https://registry.hub.docker.com/v1/search?q=$filter&page=$pageNumber'");
$pageresults = json_decode($jsonPage,true);
$num_pages = $pageresults['num_pages'];

View File

@ -65,13 +65,17 @@ function writeJsonFile($filename,$jsonArray) {
}
function ca_file_put_contents($filename,$data,$flags=0) {
$result = @file_put_contents($filename,$data,$flags);
$result = @file_put_contents($filename."~",$data,$flags);
if ( $result === strlen($data) ) {
@rename($filename."~",$filename);
}
if ( $result === false ) {
@unlink($filename."~");
debug("Failed to write to $filename");
$GLOBALS['script'] = "alert('Failed to write to ".htmlentities($filename,ENT_QUOTES)."');";
}
return $result;
return ($result === strlen($data)) ? strlen($data) : false;
}
function download_url($url, $path = "", $bg = false, $timeout = 45) {
global $caSettings, $caPaths;
@ -237,18 +241,16 @@ function fixTemplates($template) {
if ( ($template['DeprecatedMaxVer']??null) && version_compare($caSettings['unRaidVersion'],$template['DeprecatedMaxVer'],">") )
$template['Deprecated'] = true;
if ( version_compare($caSettings['unRaidVersion'],"6.10.0-beta4",">") ) {
if ( $template['Config']??null ) {
if ( $template['Config']['@attributes'] ?? false ) {
if (preg_match("/^(Container Path:|Container Port:|Container Label:|Container Variable:|Container Device:)/",$template['Config']['@attributes']['Description']) ) {
$template['Config']['@attributes']['Description'] = "";
}
} else {
if (is_array($template['Config'])) {
foreach ($template['Config'] as &$config) {
if (preg_match("/^(Container Path:|Container Port:|Container Label:|Container Variable:|Container Device:)/",$config['@attributes']['Description']??"") ) {
$config['@attributes']['Description'] = "";
}
if ( $template['Config']??null ) {
if ( $template['Config']['@attributes'] ?? false ) {
if (preg_match("/^(Container Path:|Container Port:|Container Label:|Container Variable:|Container Device:)/",$template['Config']['@attributes']['Description']) ) {
$template['Config']['@attributes']['Description'] = "";
}
} else {
if (is_array($template['Config'])) {
foreach ($template['Config'] as &$config) {
if (preg_match("/^(Container Path:|Container Port:|Container Label:|Container Variable:|Container Device:)/",$config['@attributes']['Description']??"") ) {
$config['@attributes']['Description'] = "";
}
}
}