";
- postReturn(['statistics'=>$o]);
+ postReturn(['statistics'=>$o]);
}
####################################################
# Creates the entries for autocomplete on searches #
####################################################
function populateAutoComplete() {
- global $caPaths, $caSettings;
+ global $caPaths, $caSettings;
- $templates = null;
- while ( ! $templates ) {
- $templates = &$GLOBALS['templates'];
- if ( ! $templates )
- sleep(1);
- }
- $autoComplete = array_map(function($x){return str_replace(":","",tr($x['Cat']));},readJsonFile($caPaths['categoryList']));
- foreach ($templates as $template) {
- if ( $template['RepoTemplate'] )
- continue;
- if ( ! $template['Blacklist'] && ! ($template['Deprecated'] && $caSettings['hideDeprecated'] == "true") && ($template['Compatible'] || $caSettings['hideIncompatible'] != "true") || ($template['Featured']??false) ) {
- if ( $template['Language'] && $template['LanguageLocal'] ) {
- $autoComplete[strtolower($template['Language'])] = $template['Language'];
- $autoComplete[strtolower($template['LanguageLocal'])] = $template['LanguageLocal'];
- } else {
- if ( isset($template['Repo']) )
- $autoComplete[$template['Repo']] = $template['Repo'];
- }
- $name = trim(strtolower($template['SortName']));
+ $templates = null;
+ while ( ! $templates ) {
+ $templates = &$GLOBALS['templates'];
+ if ( ! $templates )
+ sleep(1);
+ }
+ $autoComplete = array_map(function($x){return str_replace(":","",tr($x['Cat']));},readJsonFile($caPaths['categoryList']));
+ foreach ($templates as $template) {
+ if ( $template['RepoTemplate'] )
+ continue;
+ if ( ! $template['Blacklist'] && ! ($template['Deprecated'] && $caSettings['hideDeprecated'] == "true") && ($template['Compatible'] || $caSettings['hideIncompatible'] != "true") || ($template['Featured']??false) ) {
+ if ( $template['Language'] && $template['LanguageLocal'] ) {
+ $autoComplete[strtolower($template['Language'])] = $template['Language'];
+ $autoComplete[strtolower($template['LanguageLocal'])] = $template['LanguageLocal'];
+ } else {
+ if ( isset($template['Repo']) )
+ $autoComplete[$template['Repo']] = $template['Repo'];
+ }
+ $name = trim(strtolower($template['SortName']));
- $autoComplete[$name] = $name;
- if ( startsWith($autoComplete[$name],"dynamix ") )
- $autoComplete[$name] = str_replace("dynamix ","",$autoComplete[$name]);
- if ( startsWith($autoComplete[$name],"ca ") )
- $autoComplete[$name] = str_replace("ca ","",$autoComplete[$name]);
- if ( startsWith($autoComplete[$name],"binhex ") )
- $autoComplete[$name] = str_replace("binhex ","",$autoComplete[$name]);
- if ( startsWith($autoComplete[$name],"activ ") )
- $autoComplete[$name] = str_replace("activ ","",$autoComplete[$name]);
+ $autoComplete[$name] = $name;
+ if ( startsWith($autoComplete[$name],"dynamix ") )
+ $autoComplete[$name] = str_replace("dynamix ","",$autoComplete[$name]);
+ if ( startsWith($autoComplete[$name],"ca ") )
+ $autoComplete[$name] = str_replace("ca ","",$autoComplete[$name]);
+ if ( startsWith($autoComplete[$name],"binhex ") )
+ $autoComplete[$name] = str_replace("binhex ","",$autoComplete[$name]);
+ if ( startsWith($autoComplete[$name],"activ ") )
+ $autoComplete[$name] = str_replace("activ ","",$autoComplete[$name]);
- if ( ! isset($autoComplete[strtolower($template['Author'])."'s Repository"]) && ! isset($autoComplete[strtolower($template['Author']."' Repository")])) {
- $autoComplete[strtolower($template['Author'])] = $template['Author'];
- }
+ if ( ! isset($autoComplete[strtolower($template['Author'])."'s Repository"]) && ! isset($autoComplete[strtolower($template['Author']."' Repository")])) {
+ $autoComplete[strtolower($template['Author'])] = $template['Author'];
+ }
- if ( $template['ExtraSearchTerms'] ) {
- foreach (explode(" ",$template['ExtraSearchTerms']) as $searchTerm) {
- $searchTerm = str_replace("%20"," ",$searchTerm);
- $autoComplete[strtolower($searchTerm)] = strtolower($searchTerm);
- }
- }
- }
- }
- $autoComplete[tr("language")] = tr("Language");
+ if ( $template['ExtraSearchTerms'] ) {
+ foreach (explode(" ",$template['ExtraSearchTerms']) as $searchTerm) {
+ $searchTerm = str_replace("%20"," ",$searchTerm);
+ $autoComplete[strtolower($searchTerm)] = strtolower($searchTerm);
+ }
+ }
+ }
+ }
+ $autoComplete[tr("language")] = tr("Language");
- postReturn(['autocomplete'=>array_values(array_filter(array_unique($autoComplete)))]);
+ postReturn(['autocomplete'=>array_values(array_filter(array_unique($autoComplete)))]);
}
##########################
# Displays the changelog #
##########################
function caChangeLog() {
- $o = "
";
- $o .= "
".tr("Community Applications Changelog")."
";
- postReturn(["changelog"=>$o.Markdown(plugin("changes","/var/log/plugins/community.applications.plg"))."
"]);
+ $o = "
";
+ $o .= "
".tr("Community Applications Changelog")."
";
+ postReturn(["changelog"=>$o.Markdown(plugin("changes","/var/log/plugins/community.applications.plg"))."
"]);
}
###############################
# Populates the category list #
###############################
function get_categories() {
- global $caPaths, $sortOrder, $caSettings, $DockerClient, $DockerTemplates;
- $categories = readJsonFile($caPaths['categoryList']);
- if ( ! is_array($categories) || empty($categories) ) {
- $cat = "Category list N/A
";
- postReturn(['categories'=>$cat]);
- return;
- } else {
- $categories[] = ["Des"=>"Language","Cat"=>"Language:"];
+ global $caPaths, $sortOrder, $caSettings, $DockerClient, $DockerTemplates;
+ $categories = readJsonFile($caPaths['categoryList']);
+ if ( ! is_array($categories) || empty($categories) ) {
+ $cat = "Category list N/A
";
+ postReturn(['categories'=>$cat]);
+ return;
+ } else {
+ $categories[] = ["Des"=>"Language","Cat"=>"Language:"];
- foreach ($categories as $category) {
- $category['Des'] = tr($category['Des']);
- if ( isset($category['Sub']) && is_array($category['Sub']) ) {
- unset($subCat);
- foreach ($category['Sub'] as $subcategory) {
- $subcategory['Des'] = tr($subcategory['Des']);
- $subCat[] = $subcategory;
- }
- $category['Sub'] = $subCat;
- }
- $newCat[] = $category;
- }
- $sortOrder['sortBy'] = "Des";
- $sortOrder['sortDir'] = "Up";
- usort($newCat,"mySort"); // Sort it alphabetically according to the language. May not work right in non-roman charsets
+ foreach ($categories as $category) {
+ $category['Des'] = tr($category['Des']);
+ if ( isset($category['Sub']) && is_array($category['Sub']) ) {
+ unset($subCat);
+ foreach ($category['Sub'] as $subcategory) {
+ $subcategory['Des'] = tr($subcategory['Des']);
+ $subCat[] = $subcategory;
+ }
+ $category['Sub'] = $subCat;
+ }
+ $newCat[] = $category;
+ }
+ $sortOrder['sortBy'] = "Des";
+ $sortOrder['sortDir'] = "Up";
+ usort($newCat,"mySort"); // Sort it alphabetically according to the language. May not work right in non-roman charsets
- $cat = "";
- foreach ($newCat as $category) {
- $cat .= "";
- if (isset($category['Sub']) && is_array($category['Sub'])) {
- $cat .= "
";
- foreach($category['Sub'] as $subcategory) {
- $cat .= "";
- }
- $cat .= "
";
- }
- }
- $templates = &$GLOBALS['templates'];
- foreach ($templates as $template) {
- if ($template['Private'] == true && ! $template['Blacklist']) {
- $cat .= "";
- break;
- }
- }
- }
- postReturn(["categories"=>$cat]);
+ $cat = "";
+ foreach ($newCat as $category) {
+ $cat .= "";
+ if (isset($category['Sub']) && is_array($category['Sub'])) {
+ $cat .= "
";
+ foreach($category['Sub'] as $subcategory) {
+ $cat .= "";
+ }
+ $cat .= "
";
+ }
+ }
+ $templates = &$GLOBALS['templates'];
+ foreach ($templates as $template) {
+ if ($template['Private'] == true && ! $template['Blacklist']) {
+ $cat .= "";
+ break;
+ }
+ }
+ }
+ postReturn(["categories"=>$cat]);
}
##############################
# Get the html for the popup #
##############################
function getPopupDescription() {
- $appNumber = getPost("appPath","");
- postReturn(getPopupDescriptionSkin($appNumber));
+ $appNumber = getPost("appPath","");
+ postReturn(getPopupDescriptionSkin($appNumber));
}
#################################
# Get the html for a repo popup #
#################################
function getRepoDescription() {
- $repository = html_entity_decode(getPost("repository",""),ENT_QUOTES);
- postReturn(getRepoDescriptionSkin($repository));
+ $repository = html_entity_decode(getPost("repository",""),ENT_QUOTES);
+ postReturn(getRepoDescriptionSkin($repository));
}
###########################################
# Creates the XML for a container install #
###########################################
function createXML() {
- global $caPaths, $caSettings;
+ global $caPaths, $caSettings;
- $xmlFile = getPost("xml","");
- $type = getPost("type","");
- if ( ! $xmlFile ) {
- postReturn(["error"=>"CreateXML: XML file was missing"]);
- return;
- }
- $templates = &$GLOBALS['templates'];
- if ( ! $templates ) {
- postReturn(["error"=>"Create XML: templates file missing or empty"]);
- return;
- }
- if ( !startsWith($xmlFile,"/boot/") ) {
- $index = searchArray($templates,"Path",$xmlFile);
- if ( $index === false ) {
- postReturn(["error"=>"Create XML: couldn't find template with path of $xmlFile"]);
- return;
- }
- $template = $templates[$index];
- if ( $template['OriginalOverview'] )
- $template['Overview'] = $template['OriginalOverview'];
- if ( $template['OriginalDescription'] )
- $template['Description'] = $template['OriginalDescription'];
- $template['Icon'] = $template["Icon-{$caSettings['dynamixTheme']}"] ?? $template['Icon'];
-
+ $xmlFile = getPost("xml","");
+ $type = getPost("type","");
+ if ( ! $xmlFile ) {
+ postReturn(["error"=>"CreateXML: XML file was missing"]);
+ return;
+ }
+ $templates = &$GLOBALS['templates'];
+ if ( ! $templates ) {
+ postReturn(["error"=>"Create XML: templates file missing or empty"]);
+ return;
+ }
+ if ( !startsWith($xmlFile,"/boot/") ) {
+ $index = searchArray($templates,"Path",$xmlFile);
+ if ( $index === false ) {
+ postReturn(["error"=>"Create XML: couldn't find template with path of $xmlFile"]);
+ return;
+ }
+ $template = $templates[$index];
+ if ( $template['OriginalOverview'] )
+ $template['Overview'] = $template['OriginalOverview'];
+ if ( $template['OriginalDescription'] )
+ $template['Description'] = $template['OriginalDescription'];
+ $template['Icon'] = $template["Icon-{$caSettings['dynamixTheme']}"] ?? $template['Icon'];
+
// Handle paths directly referencing disks / poola that aren't present in the user's system, and replace the path with the first disk present
- $unRaidDisks = parse_ini_file($caPaths['disksINI'],true);
+ $unRaidDisks = parse_ini_file($caPaths['disksINI'],true);
- $disksPresent = array_keys(array_filter($unRaidDisks, function($k) {
- return ($k['status'] !== "DISK_NP" && ! preg_match("/(parity|parity2|disks|diskP|diskQ)/",$k['name']));
- }));
+ $disksPresent = array_keys(array_filter($unRaidDisks, function($k) {
+ return ($k['status'] !== "DISK_NP" && ! preg_match("/(parity|parity2|disks|diskP|diskQ)/",$k['name']));
+ }));
- $unRaidVersion = parse_ini_file($caPaths['unRaidVersion']);
- $cachePools = array_filter($unRaidDisks, function($k) {
- return ! preg_match("/disk\d(\d|$)|(parity|parity2|disks|flash|diskP|diskQ)/",$k['name']);
- });
- $cachePools = array_keys(array_filter($cachePools, function($k) {
- return $k['status'] !== "DISK_NP";
- }));
+ $unRaidVersion = parse_ini_file($caPaths['unRaidVersion']);
+ $cachePools = array_filter($unRaidDisks, function($k) {
+ return ! preg_match("/disk\d(\d|$)|(parity|parity2|disks|flash|diskP|diskQ)/",$k['name']);
+ });
+ $cachePools = array_keys(array_filter($cachePools, function($k) {
+ return $k['status'] !== "DISK_NP";
+ }));
- // always prefer the default cache pool
- if ( in_array("cache",$cachePools) )
- array_unshift($cachePools,"cache"); // This will be a duplicate, but it doesn't matter as we only reference item0
+ // always prefer the default cache pool
+ if ( in_array("cache",$cachePools) )
+ array_unshift($cachePools,"cache"); // This will be a duplicate, but it doesn't matter as we only reference item0
- // Prefer cache pools over disks
- $disksPresent = array_merge($cachePools,$disksPresent,["disks"]);
+ // Prefer cache pools over disks
+ $disksPresent = array_merge($cachePools,$disksPresent,["disks"]);
- // check to see if user shares enabled
- $unRaidVars = parse_ini_file($caPaths['unRaidVars']);
- if ( $unRaidVars['shareUser'] == "e" )
- $disksPresent[] = "user";
- if ( @is_array($template['Data']['Volume']) ) {
- $testarray = $template['Data']['Volume'];
- if ( ( ! isset($testarray[0]) ) || ( ! is_array($testarray[0]) ) ) $testarray = [$testarray];
- foreach ($testarray as &$volume) {
- $diskReferenced = array_values(array_filter(explode("/",$volume['HostDir'])));
- if ( $diskReferenced[0] == "mnt" && $diskReferenced[1] && ! in_array($diskReferenced[1],$disksPresent) ) {
- $volume['HostDir'] = str_replace("/mnt/{$diskReferenced[1]}/","/mnt/{$disksPresent[0]}/",$volume['HostDir']);
- }
- }
- $template['Data']['Volume'] = $testarray;
- }
+ // check to see if user shares enabled
+ $unRaidVars = parse_ini_file($caPaths['unRaidVars']);
+ if ( $unRaidVars['shareUser'] == "e" )
+ $disksPresent[] = "user";
+ if ( @is_array($template['Data']['Volume']) ) {
+ $testarray = $template['Data']['Volume'];
+ if ( ( ! isset($testarray[0]) ) || ( ! is_array($testarray[0]) ) ) $testarray = [$testarray];
+ foreach ($testarray as &$volume) {
+ $diskReferenced = array_values(array_filter(explode("/",$volume['HostDir'])));
+ if ( $diskReferenced[0] == "mnt" && $diskReferenced[1] && ! in_array($diskReferenced[1],$disksPresent) ) {
+ $volume['HostDir'] = str_replace("/mnt/{$diskReferenced[1]}/","/mnt/{$disksPresent[0]}/",$volume['HostDir']);
+ }
+ }
+ $template['Data']['Volume'] = $testarray;
+ }
- if ( $template['Config'] ) {
- $testarray = $template['Config'] ?: [];
- if (!($testarray[0]??false)) $testarray = [$testarray];
+ if ( $template['Config'] ) {
+ $testarray = $template['Config'] ?: [];
+ if (!($testarray[0]??false)) $testarray = [$testarray];
- foreach ($testarray as &$config) {
- if ( is_array($config['@attributes']) ) {
- if ( $config['@attributes']['Type'] == "Path" ) {
- $defaultReferenced = array_values(array_filter(explode("/",$config['@attributes']['Default'])));
+ foreach ($testarray as &$config) {
+ if ( is_array($config['@attributes']) ) {
+ if ( $config['@attributes']['Type'] == "Path" ) {
+ $defaultReferenced = array_values(array_filter(explode("/",$config['@attributes']['Default'])));
- if ( isset($defaultReferenced[0]) && isset($defaultReferenced[1]) ) {
- if ( $defaultReferenced[0] == "mnt" && $defaultReferenced[1] && ! in_array($defaultReferenced[1],$disksPresent) )
- $config['@attributes']['Default'] = str_replace("/mnt/{$defaultReferenced[1]}/","/mnt/{$disksPresent[0]}/",$config['@attributes']['Default']);
- }
+ if ( isset($defaultReferenced[0]) && isset($defaultReferenced[1]) ) {
+ if ( $defaultReferenced[0] == "mnt" && $defaultReferenced[1] && ! in_array($defaultReferenced[1],$disksPresent) )
+ $config['@attributes']['Default'] = str_replace("/mnt/{$defaultReferenced[1]}/","/mnt/{$disksPresent[0]}/",$config['@attributes']['Default']);
+ }
- $valueReferenced = array_values(array_filter(explode("/",$config['value'])));
- if ( isset($valueReferenced[0]) && isset($valueReferenced[1]) ) {
- if ( $valueReferenced[0] == "mnt" && $valueReferenced[1] && ! in_array($valueReferenced[1],$disksPresent) )
- $config['value'] = str_replace("/mnt/{$valueReferenced[1]}/","/mnt/{$disksPresent[0]}/",$config['value']);
- }
+ $valueReferenced = array_values(array_filter(explode("/",$config['value'])));
+ if ( isset($valueReferenced[0]) && isset($valueReferenced[1]) ) {
+ if ( $valueReferenced[0] == "mnt" && $valueReferenced[1] && ! in_array($valueReferenced[1],$disksPresent) )
+ $config['value'] = str_replace("/mnt/{$valueReferenced[1]}/","/mnt/{$disksPresent[0]}/",$config['value']);
+ }
- // Check for pre-existing folders only differing by "case" and adjust accordingly
+ // Check for pre-existing folders only differing by "case" and adjust accordingly
- // Default path
- if ( ! $config['value'] ) { // Don't override default if value exists
- $configPath = explode("/",$config['@attributes']['Default']);
- $testPath = "/";
- foreach ($configPath as &$entry) {
- $directories = @scandir($testPath);
- if ( ! $directories ) {
- break;
- }
- foreach ($directories as $testDir) {
- if ( strtolower($testDir) == strtolower($entry) ) {
- if ( $testDir == $entry )
- break;
+ // Default path
+ if ( ! $config['value'] ) { // Don't override default if value exists
+ $configPath = explode("/",$config['@attributes']['Default']);
+ $testPath = "/";
+ foreach ($configPath as &$entry) {
+ $directories = @scandir($testPath);
+ if ( ! $directories ) {
+ break;
+ }
+ foreach ($directories as $testDir) {
+ if ( strtolower($testDir) == strtolower($entry) ) {
+ if ( $testDir == $entry )
+ break;
- $entry = $testDir;
- }
- }
- $testPath .= $entry."/";
- }
- $config['@attributes']['Default'] = implode("/",$configPath);
- }
+ $entry = $testDir;
+ }
+ }
+ $testPath .= $entry."/";
+ }
+ $config['@attributes']['Default'] = implode("/",$configPath);
+ }
- // entered path
- if ( $config['value'] ) {
- $configPath = explode("/",$config['value']);
- $testPath = "/";
- foreach ($configPath as &$entry) {
- $directories = @scandir($testPath);
- if ( ! $directories ) {
- break;
- }
- foreach ($directories as $testDir) {
- if ( strtolower($testDir) == strtolower($entry) ) {
- if ( $testDir == $entry )
- break;
+ // entered path
+ if ( $config['value'] ) {
+ $configPath = explode("/",$config['value']);
+ $testPath = "/";
+ foreach ($configPath as &$entry) {
+ $directories = @scandir($testPath);
+ if ( ! $directories ) {
+ break;
+ }
+ foreach ($directories as $testDir) {
+ if ( strtolower($testDir) == strtolower($entry) ) {
+ if ( $testDir == $entry )
+ break;
- $entry = $testDir;
- }
- }
- $testPath .= $entry."/";
- }
- $config['value'] = implode("/",$configPath);
- }
- }
- }
- }
- $template['Config'] = $testarray;
- }
- $template['Name'] = str_replace(" ","-",$template['Name']);
- $alreadyInstalled = getAllInfo();
- foreach ( $alreadyInstalled as $installed ) {
- if ( strtolower($template['Name']) == $installed['Name'] ) {
- for ( ;; ) {
- if (is_file("{$caPaths['dockerManTemplates']}/my-{$template['Name']}.xml") ) {
- $template['Name'] .= "-1";
- } else break;
- }
- }
- }
- for ( ;; ) {
- if ($type == "second" && is_file("{$caPaths['dockerManTemplates']}/my-{$template['Name']}.xml") ) {
- $template['Name'] .= "-1";
- } else break;
- }
- if (! isset($template['Environment']) )
- $template['Environment']['Variable'] = ["Name"=>"test","Value"=>"yes"];
- if ( empty($template['Config']) ) // handles extra garbage entry being created on templates that are v1 only
- unset($template['Config']);
- $xml = makeXML($template);
- @mkdir(dirname($xmlFile));
- ca_file_put_contents($xmlFile,$xml);
- }
- postReturn(["status"=>"ok","cache"=>$cacheVolume ?? ""]);
+ $entry = $testDir;
+ }
+ }
+ $testPath .= $entry."/";
+ }
+ $config['value'] = implode("/",$configPath);
+ }
+ }
+ }
+ }
+ $template['Config'] = $testarray;
+ }
+ $template['Name'] = str_replace(" ","-",$template['Name']);
+ $alreadyInstalled = getAllInfo();
+ foreach ( $alreadyInstalled as $installed ) {
+ if ( strtolower($template['Name']) == $installed['Name'] ) {
+ for ( ;; ) {
+ if (is_file("{$caPaths['dockerManTemplates']}/my-{$template['Name']}.xml") ) {
+ $template['Name'] .= "-1";
+ } else break;
+ }
+ }
+ }
+ for ( ;; ) {
+ if ($type == "second" && is_file("{$caPaths['dockerManTemplates']}/my-{$template['Name']}.xml") ) {
+ $template['Name'] .= "-1";
+ } else break;
+ }
+ if (! isset($template['Environment']) )
+ $template['Environment']['Variable'] = ["Name"=>"test","Value"=>"yes"];
+ if ( empty($template['Config']) ) // handles extra garbage entry being created on templates that are v1 only
+ unset($template['Config']);
+ $xml = makeXML($template);
+ @mkdir(dirname($xmlFile));
+ ca_file_put_contents($xmlFile,$xml);
+ }
+ postReturn(["status"=>"ok","cache"=>$cacheVolume ?? ""]);
}
########################
# Switch to a language #
########################
function switchLanguage() {
- global $caPaths;
+ global $caPaths;
- $language = getPost("language","");
- if ( $language == "en_US" )
- $language = "";
+ $language = getPost("language","");
+ if ( $language == "en_US" )
+ $language = "";
- if ( ! is_dir("/usr/local/emhttp/languages/$language") ) {
- postReturn(["error"=>"language $language is not installed"]);
- return;
- }
- $dynamixSettings = @parse_ini_file($caPaths['dynamixSettings'],true);
- $dynamixSettings['display']['locale'] = $language;
- write_ini_file($caPaths['dynamixSettings'],$dynamixSettings);
- postReturn(["status"=> "ok"]);
+ if ( ! is_dir("/usr/local/emhttp/languages/$language") ) {
+ postReturn(["error"=>"language $language is not installed"]);
+ return;
+ }
+ $dynamixSettings = @parse_ini_file($caPaths['dynamixSettings'],true);
+ $dynamixSettings['display']['locale'] = $language;
+ write_ini_file($caPaths['dynamixSettings'],$dynamixSettings);
+ postReturn(["status"=> "ok"]);
}
#######################################################
# Delete multiple checked off apps from previous apps #
#######################################################
function remove_multiApplications() {
- $apps = getPostArray("apps");
- if ( ! count($apps) ) {
- postReturn(["error"=>"No apps were in post when trying to remove multiple applications"]);
- return;
- }
- foreach ($apps as $app) {
- if ( strpos(realpath($app),"/boot/config/") === false ) {
- $error = "Remove multiple apps: $app was not in /boot/config";
- break;
- }
- @unlink($app);
- }
- if ( $error )
- postReturn(["error"=>$error]);
- else
- postReturn(["status"=>"ok"]);
+ $apps = getPostArray("apps");
+ if ( ! count($apps) ) {
+ postReturn(["error"=>"No apps were in post when trying to remove multiple applications"]);
+ return;
+ }
+ foreach ($apps as $app) {
+ if ( strpos(realpath($app),"/boot/config/") === false ) {
+ $error = "Remove multiple apps: $app was not in /boot/config";
+ break;
+ }
+ @unlink($app);
+ }
+ if ( $error )
+ postReturn(["error"=>$error]);
+ else
+ postReturn(["status"=>"ok"]);
}
############################################
# Get's the categories present on a search #
############################################
function getCategoriesPresent() {
- global $caPaths;
+ global $caPaths;
- if ( is_file($caPaths['community-templates-allSearchResults']) )
- $displayed = readJsonFile($caPaths['community-templates-allSearchResults']);
- else
- $displayed = readJsonFile($caPaths['community-templates-displayed']);
+ if ( is_file($caPaths['community-templates-allSearchResults']) )
+ $displayed = readJsonFile($caPaths['community-templates-allSearchResults']);
+ else
+ $displayed = readJsonFile($caPaths['community-templates-displayed']);
- $categories = [];
- foreach ($displayed['community'] as $template) {
- $cats = explode(" ",$template['Category']);
- foreach ($cats as $category) {
- if (strpos($category,":")) {
- $categories[] = explode(":",$category)[0].":";
- }
- $categories[] = $category;
- }
- }
- if (! empty($categories) ) {
- $categories[] = "repos";
- $categories[] = "All";
- }
+ $categories = [];
+ foreach ($displayed['community'] as $template) {
+ $cats = explode(" ",$template['Category']);
+ foreach ($cats as $category) {
+ if (strpos($category,":")) {
+ $categories[] = explode(":",$category)[0].":";
+ }
+ $categories[] = $category;
+ }
+ }
+ if (! empty($categories) ) {
+ $categories[] = "repos";
+ $categories[] = "All";
+ }
- postReturn(array_values(array_unique($categories)));
+ postReturn(array_values(array_unique($categories)));
}
##################################
# Set's the favourite repository #
##################################
function toggleFavourite() {
- global $caPaths, $caSettings;
+ global $caPaths, $caSettings;
- $repository = html_entity_decode(getPost("repository",""),ENT_QUOTES);
- if ( $caSettings['favourite'] == $repository )
- $repository = "";
+ $repository = html_entity_decode(getPost("repository",""),ENT_QUOTES);
+ if ( $caSettings['favourite'] == $repository )
+ $repository = "";
- $caSettings['favourite'] = $repository;
- write_ini_file($caPaths['pluginSettings'],$caSettings);
- postReturn(['status'=>"ok",'fav'=>$repository]);
+ $caSettings['favourite'] = $repository;
+ write_ini_file($caPaths['pluginSettings'],$caSettings);
+ postReturn(['status'=>"ok",'fav'=>$repository]);
}
####################################
# Returns the favourite repository #
####################################
function getFavourite() {
- global $caSettings;
+ global $caSettings;
- postReturn(["favourite"=>$caSettings['favourite']]);
+ postReturn(["favourite"=>$caSettings['favourite']]);
}
##########################
# Changes the sort order #
##########################
function changeSortOrder() {
- global $caPaths, $sortOrder;
+ global $caPaths, $sortOrder;
- $sortOrder = getPostArray("sortOrder");
- writeJsonFile($caPaths['sortOrder'],$sortOrder);
+ $sortOrder = getPostArray("sortOrder");
+ writeJsonFile($caPaths['sortOrder'],$sortOrder);
- if ( is_file($caPaths['community-templates-displayed']) ) {
- $displayed = readJsonFile($caPaths['community-templates-displayed']);
- if ($displayed['community'])
- usort($displayed['community'],"mySort");
- writeJsonFile($caPaths['community-templates-displayed'],$displayed);
- }
- if ( is_file($caPaths['community-templates-allSearchResults']) ) {
- $allSearchResults = readJsonFile($caPaths['community-templates-allSearchResults']);
- if ( $allSearchResults['community'] )
- usort($allSearchResults['community'],"mySort");
- writeJsonFile($caPaths['community-templates-allSearchResults'],$allSearchResults);
- }
- if ( is_file($caPaths['community-templates-catSearchResults']) ) {
- $catSearchResults = readJsonFile($caPaths['community-templates-catSearchResults']);
- if ( $catSearchResults['community'] )
- usort($catSearchResults['community'],"mySort");
- writeJsonFile($caPaths['community-templates-catSearchResults'],$catSearchResults);
- }
- if ( is_file($caPaths['repositoriesDisplayed']) ) {
- $reposDisplayed = readJsonFile($caPaths['repositoriesDisplayed']);
- $bio = [];
- $nonbio = [];
- foreach ($reposDisplayed['community'] as $repo) {
- if ($repo['bio'])
- $bio[] = $repo;
- else
- $nonbio[] = $repo;
- }
- usort($bio,"mysort");
- usort($nonbio,"mysort");
- $reposDisplayed['community'] = array_merge($bio,$nonbio);
- writeJsonFile($caPaths['repositoriesDisplayed'],$reposDisplayed);
- }
- postReturn(['status'=>"ok"]);
+ if ( is_file($caPaths['community-templates-displayed']) ) {
+ $displayed = readJsonFile($caPaths['community-templates-displayed']);
+ if ($displayed['community'])
+ usort($displayed['community'],"mySort");
+ writeJsonFile($caPaths['community-templates-displayed'],$displayed);
+ }
+ if ( is_file($caPaths['community-templates-allSearchResults']) ) {
+ $allSearchResults = readJsonFile($caPaths['community-templates-allSearchResults']);
+ if ( $allSearchResults['community'] )
+ usort($allSearchResults['community'],"mySort");
+ writeJsonFile($caPaths['community-templates-allSearchResults'],$allSearchResults);
+ }
+ if ( is_file($caPaths['community-templates-catSearchResults']) ) {
+ $catSearchResults = readJsonFile($caPaths['community-templates-catSearchResults']);
+ if ( $catSearchResults['community'] )
+ usort($catSearchResults['community'],"mySort");
+ writeJsonFile($caPaths['community-templates-catSearchResults'],$catSearchResults);
+ }
+ if ( is_file($caPaths['repositoriesDisplayed']) ) {
+ $reposDisplayed = readJsonFile($caPaths['repositoriesDisplayed']);
+ $bio = [];
+ $nonbio = [];
+ foreach ($reposDisplayed['community'] as $repo) {
+ if ($repo['bio'])
+ $bio[] = $repo;
+ else
+ $nonbio[] = $repo;
+ }
+ usort($bio,"mysort");
+ usort($nonbio,"mysort");
+ $reposDisplayed['community'] = array_merge($bio,$nonbio);
+ writeJsonFile($caPaths['repositoriesDisplayed'],$reposDisplayed);
+ }
+ postReturn(['status'=>"ok"]);
}
############################################
# Gets the sort order when restoring state #
############################################
function getSortOrder() {
- global $sortOrder;
+ global $sortOrder;
- postReturn(["sortBy"=>$sortOrder['sortBy'],"sortDir"=>$sortOrder['sortDir']]);
+ postReturn(["sortBy"=>$sortOrder['sortBy'],"sortDir"=>$sortOrder['sortDir']]);
}
############################################################
# Reset the sort order to default when reloading Apps page #
############################################################
function defaultSortOrder() {
- global $caPaths, $sortOrder;
+ global $caPaths, $sortOrder;
- $sortOrder['sortBy'] = "Name";
- $sortOrder['sortDir'] = "Up";
- writeJsonFile($caPaths['sortOrder'],$sortOrder);
- postReturn(['status'=>"ok"]);
+ $sortOrder['sortBy'] = "Name";
+ $sortOrder['sortDir'] = "Up";
+ writeJsonFile($caPaths['sortOrder'],$sortOrder);
+ postReturn(['status'=>"ok"]);
}
###################################################################
# Checks whether we're on the startup screen when restoring state #
###################################################################
function onStartupScreen() {
- global $caPaths;
+ global $caPaths;
- postReturn(['status'=>is_file($caPaths['startupDisplayed'])]);
+ postReturn(['status'=>is_file($caPaths['startupDisplayed'])]);
}
#######################################################################
# convert_docker - called when system adds a container from dockerHub #
#######################################################################
function convert_docker() {
- global $caPaths, $dockerManPaths;
+ global $caPaths, $dockerManPaths;
- $dockerID = getPost("ID","");
+ $dockerID = getPost("ID","");
- $file = readJsonFile($caPaths['dockerSearchResults']);
- $dockerIndex = searchArray($file['results'],"ID",$dockerID);
- $docker = $file['results'][$dockerIndex];
- $docker['Description'] = str_replace("&", "&", $docker['Description']);
+ $file = readJsonFile($caPaths['dockerSearchResults']);
+ $dockerIndex = searchArray($file['results'],"ID",$dockerID);
+ $docker = $file['results'][$dockerIndex];
+ $docker['Description'] = str_replace("&", "&", $docker['Description']);
- $dockerfile['Name'] = $docker['Name'];
- $dockerfile['Support'] = $docker['DockerHub'];
- $dockerfile['Description'] = $docker['Description']."\n\nConverted By Community Applications Always verify this template (and values) against the support page for the container\n\n{$docker['DockerHub']}";
- $dockerfile['Overview'] = $dockerfile['Description'];
- $dockerfile['Registry'] = $docker['DockerHub'];
- $dockerfile['Repository'] = $docker['Repository'];
- $dockerfile['BindTime'] = "true";
- $dockerfile['Privileged'] = "false";
- $dockerfile['Networking']['Mode'] = "bridge";
+ $dockerfile['Name'] = $docker['Name'];
+ $dockerfile['Support'] = $docker['DockerHub'];
+ $dockerfile['Description'] = $docker['Description']."\n\nConverted By Community Applications Always verify this template (and values) against the support page for the container\n\n{$docker['DockerHub']}";
+ $dockerfile['Overview'] = $dockerfile['Description'];
+ $dockerfile['Registry'] = $docker['DockerHub'];
+ $dockerfile['Repository'] = $docker['Repository'];
+ $dockerfile['BindTime'] = "true";
+ $dockerfile['Privileged'] = "false";
+ $dockerfile['Networking']['Mode'] = "bridge";
- $existing_templates = array_diff(scandir($dockerManPaths['templates-user']),[".",".."]);
- foreach ( $existing_templates as $template ) {
- if ( strtolower($dockerfile['Name']) == strtolower(str_replace(["my-",".xml"],["",""],$template)) )
- $dockerfile['Name'] .= "-1";
- }
+ $existing_templates = array_diff(scandir($dockerManPaths['templates-user']),[".",".."]);
+ foreach ( $existing_templates as $template ) {
+ if ( strtolower($dockerfile['Name']) == strtolower(str_replace(["my-",".xml"],["",""],$template)) )
+ $dockerfile['Name'] .= "-1";
+ }
- $dockerXML = makeXML($dockerfile);
+ $dockerXML = makeXML($dockerfile);
- ca_file_put_contents($caPaths['dockerSearchInstall'],$dockerXML);
- postReturn(['xml'=>$caPaths['dockerSearchInstall']]);
+ ca_file_put_contents($caPaths['dockerSearchInstall'],$dockerXML);
+ postReturn(['xml'=>$caPaths['dockerSearchInstall']]);
}
#########################################################
# search_dockerhub - returns the results from dockerHub #
#########################################################
function search_dockerhub() {
- global $caPaths;
+ global $caPaths;
- $filter = getPost("filter","");
- $pageNumber = getPost("page","1");
+ $filter = getPost("filter","");
+ $pageNumber = getPost("page","1");
- $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'");
- $pageresults = json_decode($jsonPage,true);
- $num_pages = $pageresults['num_pages'];
+ $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'");
+ $pageresults = json_decode($jsonPage,true);
+ $num_pages = $pageresults['num_pages'];
- if ($pageresults['num_results'] == 0) {
- $o['display'] = "
".tr("No Matching Applications Found On Docker Hub")."
";
- $o['script'] = "$('#dockerSearch').hide();";
- postReturn($o);
- @unlink($caPaths['dockerSearchResults']);
- @unlink($caPaths['dockerSearchActive']);
- return;
- }
+ if ($pageresults['num_results'] == 0) {
+ $o['display'] = "
".tr("No Matching Applications Found On Docker Hub")."
";
+ $o['script'] = "$('#dockerSearch').hide();";
+ postReturn($o);
+ @unlink($caPaths['dockerSearchResults']);
+ @unlink($caPaths['dockerSearchActive']);
+ return;
+ }
- touch($caPaths['dockerSearchActive']);
- $i = 0;
- foreach ($pageresults['results'] as $result) {
- unset($o);
- $o['IconFA'] = "docker";
- $o['Repository'] = $result['name'];
- $details = explode("/",$result['name']);
- $o['Author'] = $details[0];
- $o['Name'] = $details[1];
- $o['Description'] = $result['description'];
- $o['Automated'] = $result['is_automated'];
- $o['Stars'] = $result['star_count'];
- $o['Official'] = $result['is_official'];
- $o['Trusted'] = $result['is_trusted'];
- if ( $o['Official'] ) {
- $o['DockerHub'] = "https://hub.docker.com/_/".$result['name']."/";
- $o['Name'] = $o['Author'];
- } else
- $o['DockerHub'] = "https://hub.docker.com/r/".$result['name']."/";
+ touch($caPaths['dockerSearchActive']);
+ $i = 0;
+ foreach ($pageresults['results'] as $result) {
+ unset($o);
+ $o['IconFA'] = "docker";
+ $o['Repository'] = $result['name'];
+ $details = explode("/",$result['name']);
+ $o['Author'] = $details[0];
+ $o['Name'] = $details[1];
+ $o['Description'] = $result['description'];
+ $o['Automated'] = $result['is_automated'];
+ $o['Stars'] = $result['star_count'];
+ $o['Official'] = $result['is_official'];
+ $o['Trusted'] = $result['is_trusted'];
+ if ( $o['Official'] ) {
+ $o['DockerHub'] = "https://hub.docker.com/_/".$result['name']."/";
+ $o['Name'] = $o['Author'];
+ } else
+ $o['DockerHub'] = "https://hub.docker.com/r/".$result['name']."/";
- $o['ID'] = $i;
- $searchName = str_replace("docker-","",$o['Name']);
- $searchName = str_replace("-docker","",$searchName);
+ $o['ID'] = $i;
+ $searchName = str_replace("docker-","",$o['Name']);
+ $searchName = str_replace("-docker","",$searchName);
- $dockerResults[$i] = addMissingVars($o);
- $i=++$i;
- }
- $dockerFile['num_pages'] = $num_pages;
- $dockerFile['page_number'] = $pageNumber;
- $dockerFile['results'] = $dockerResults;
+ $dockerResults[$i] = addMissingVars($o);
+ $i=++$i;
+ }
+ $dockerFile['num_pages'] = $num_pages;
+ $dockerFile['page_number'] = $pageNumber;
+ $dockerFile['results'] = $dockerResults;
- writeJsonFile($caPaths['dockerSearchResults'],$dockerFile);
- postReturn(['display'=>displaySearchResults($pageNumber)]);
+ writeJsonFile($caPaths['dockerSearchResults'],$dockerFile);
+ postReturn(['display'=>displaySearchResults($pageNumber)]);
}
##############################################
# Gets the last update issued to a container #
##############################################
function getLastUpdate($ID) {
- global $caPaths;
+ global $caPaths;
- $count = 0;
- $registry_json = null;
- while ( $count < 5 ) {
- $templates = &$GLOBALS['templates'];
- if ( $templates ) break;
- sleep(1); # keep trying in case of a collision between reading and writing
- $count++;
- }
- $index = searchArray($templates,"ID",$ID);
- if ( $index === false )
- return "Unknown";
+ $count = 0;
+ $registry_json = null;
+ while ( $count < 5 ) {
+ $templates = &$GLOBALS['templates'];
+ if ( $templates ) break;
+ sleep(1); # keep trying in case of a collision between reading and writing
+ $count++;
+ }
+ $index = searchArray($templates,"ID",$ID);
+ if ( $index === false )
+ return "Unknown";
- $app = $templates[$index];
- if ( $app['PluginURL'] || $app['LanguageURL'] )
- return;
+ $app = $templates[$index];
+ if ( $app['PluginURL'] || $app['LanguageURL'] )
+ return;
- if ( strpos($app['Repository'],"ghcr.io") !== false || strpos($app['Repository'],"cr.hotio.dev") !== false || strpos($app['Repository'],"lscr.io") !== false) { // try dockerhub for info on ghcr stuff
- $info = pathinfo($app['Repository']);
- $regs = basename($info['dirname'])."/".$info['filename'];
- } else {
- $regs = $app['Repository'];
- }
- $reg = explode(":",$regs);
- if ( ($reg[1] ?? "latest") !== "latest" )
- return tr("Unknown");
+ if ( strpos($app['Repository'],"ghcr.io") !== false || strpos($app['Repository'],"cr.hotio.dev") !== false || strpos($app['Repository'],"lscr.io") !== false) { // try dockerhub for info on ghcr stuff
+ $info = pathinfo($app['Repository']);
+ $regs = basename($info['dirname'])."/".$info['filename'];
+ } else {
+ $regs = $app['Repository'];
+ }
+ $reg = explode(":",$regs);
+ if ( ($reg[1] ?? "latest") !== "latest" )
+ return tr("Unknown");
- if ( !strpos($reg[0],"/") )
- $reg[0] = "library/{$reg[0]}";
+ if ( !strpos($reg[0],"/") )
+ $reg[0] = "library/{$reg[0]}";
- $count = 0;
- $registry = false;
- while ( ! $registry && $count < 5 ) {
- $registry = download_url("https://registry.hub.docker.com/v2/repositories/{$reg[0]}");
- if ( ! $registry ) {
- $count++;
- sleep(1);
- continue;
- }
- $registry_json = json_decode($registry,true);
- if ( ! $registry_json['last_updated'] )
- return;
+ $count = 0;
+ $registry = false;
+ while ( ! $registry && $count < 5 ) {
+ $registry = download_url("https://registry.hub.docker.com/v2/repositories/{$reg[0]}");
+ if ( ! $registry ) {
+ $count++;
+ sleep(1);
+ continue;
+ }
+ $registry_json = json_decode($registry,true);
+ if ( ! $registry_json['last_updated'] )
+ return;
- }
- $registry_json['last_updated'] = $registry_json['last_updated'] ?? false;
- $lastUpdated = $registry_json['last_updated'] ? tr(date("M j, Y",strtotime($registry_json['last_updated'])),0) : "Unknown";
+ }
+ $registry_json['last_updated'] = $registry_json['last_updated'] ?? false;
+ $lastUpdated = $registry_json['last_updated'] ? tr(date("M j, Y",strtotime($registry_json['last_updated'])),0) : "Unknown";
- return $lastUpdated;
+ return $lastUpdated;
}
######################################
# Changes the max per page displayed #
######################################
function changeMaxPerPage() {
- global $caPaths, $caSettings;
+ global $caPaths, $caSettings;
- $max = getPost("max",24);
- if ($caSettings['maxPerPage'] == $max)
- postReturn(["status"=>"same"]);
- else {
- $caSettings['maxPerPage'] = $max;
- write_ini_file($caPaths['pluginSettings'],$caSettings);
- postReturn(["status"=>"updated"]);
- }
+ $max = getPost("max",24);
+ if ($caSettings['maxPerPage'] == $max)
+ postReturn(["status"=>"same"]);
+ else {
+ $caSettings['maxPerPage'] = $max;
+ write_ini_file($caPaths['pluginSettings'],$caSettings);
+ postReturn(["status"=>"updated"]);
+ }
}
################################################################
# Enables if necessary the action centre #
# Basically a duplicate of action centre code in previous apps #
################################################################
function enableActionCentre() {
- global $caPaths, $caSettings, $DockerClient;
+ global $caPaths, $caSettings, $DockerClient;
# wait til check for updates is finished
- for ( $i=0;$i<100;$i++ ) {
- if ( is_file($caPaths['updateRunning']) && file_exists("/proc/".@file_get_contents($caPaths['updateRunning'])) ) {
- debug("Action Centre sleeping -> update running");
- sleep(5);
- clearstatcache();
- }
- else break;
- }
- if ( $i >= 100 ) {
- debug("Something went wrong. EnableActionCentre ran longer than 500 seconds");
- postReturn(['status'=>"noaction"]);
- return;
- }
+ for ( $i=0;$i<100;$i++ ) {
+ if ( is_file($caPaths['updateRunning']) && file_exists("/proc/".@file_get_contents($caPaths['updateRunning'])) ) {
+ debug("Action Centre sleeping -> update running");
+ sleep(5);
+ clearstatcache();
+ }
+ 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++ ) {
- if ( ! is_file($caPaths['haveTemplates']) ) {
- debug("Action Centre sleeping - no templates yet");
- sleep(5);
- } else {
- debug("action centre: have templates");
- break;
- }
- }
- if ( $i >= 100 ) {
- debug("Something went wrong. EnableActionCentre ran longer than 500 seconds");
- postReturn(['status'=>"noaction"]);
- return;
- }
- $file = readJsonFile($caPaths['community-templates-info']);
- $extraBlacklist = readJsonFile($caPaths['extraBlacklist']);
- $extraDeprecated = readJsonFile($caPaths['extraDeprecated']);
+ for ( $i=0;$i<100;$i++ ) {
+ if ( ! is_file($caPaths['haveTemplates']) ) {
+ debug("Action Centre sleeping - no templates yet");
+ sleep(5);
+ } else {
+ debug("action centre: have templates");
+ break;
+ }
+ }
+ if ( $i >= 100 ) {
+ debug("Something went wrong. EnableActionCentre ran longer than 500 seconds");
+ postReturn(['status'=>"noaction"]);
+ return;
+ }
+ $file = readJsonFile($caPaths['community-templates-info']);
+ $extraBlacklist = readJsonFile($caPaths['extraBlacklist']);
+ $extraDeprecated = readJsonFile($caPaths['extraDeprecated']);
- if ( is_file("/var/run/dockerd.pid") && is_dir("/proc/".@file_get_contents("/var/run/dockerd.pid")) ) {
- $dockerUpdateStatus = readJsonFile($caPaths['dockerUpdateStatus']);
- } else {
- $dockerUpdateStatus = [];
- }
+ if ( is_file("/var/run/dockerd.pid") && is_dir("/proc/".@file_get_contents("/var/run/dockerd.pid")) ) {
+ $dockerUpdateStatus = readJsonFile($caPaths['dockerUpdateStatus']);
+ } else {
+ $dockerUpdateStatus = [];
+ }
- $info = getAllInfo();
+ $info = getAllInfo();
# $info contains all installed containers
# now correlate that to a template;
# this section handles containers that have not been renamed from the appfeed
- if ( $caSettings['dockerRunning'] ) {
- $all_files = glob("{$caPaths['dockerManTemplates']}/*.xml");
- $all_files = $all_files ?: [];
- foreach ($all_files as $xmlfile) {
- $o = readXmlFile($xmlfile);
+ if ( $caSettings['dockerRunning'] ) {
+ $all_files = glob("{$caPaths['dockerManTemplates']}/*.xml");
+ $all_files = $all_files ?: [];
+ foreach ($all_files as $xmlfile) {
+ $o = readXmlFile($xmlfile);
- $runningflag = false;
- foreach ($info as $installedDocker) {
- $installedImage = str_replace("library/","",$installedDocker['Image']);
- $installedName = $installedDocker['Name'];
- if ( $installedName == $o['Name'] ) {
- if ( startsWith($installedImage, $o['Repository']) ) {
- $runningflag = true;
- $searchResult = searchArray($file,'Repository',$o['Repository']);
- if ( $searchResult === false) {
- $searchResult = searchArray($file,'Repository',explode(":",$o['Repository'])[0]);
- }
- if ( $searchResult === false ) {
- $runningFlag = true;
- if ( $extraBlacklist[$o['Repository']] ?? false ) {
- $o['Blacklist'] = true;
- }
- if ( $extraDeprecated[$o['Repository']] ?? false ) {
- $o['Deprecated'] = true;
- }
- }
- break;
- }
- }
- }
- if ( $runningflag ) {
- $tmpRepo = strpos($o['Repository'],":") ? $o['Repository'] : $o['Repository'].":latest";
- $tmpRepo = strpos($tmpRepo,"/") ? $tmpRepo : "library/$tmpRepo";
- if ( $tmpRepo ) {
- if ( isset($dockerUpdateStatus[$tmpRepo]['status']) && $dockerUpdateStatus[$tmpRepo]['status'] == "false" )
- $o['actionCentre'] = true;
- }
- if ( ! $o['Blacklist'] && ! $o['Deprecated'] ) {
- if ( isset($extraBlacklist[$o['Repository']]) ) {
- $o['Blacklist'] = true;
- }
- if ( isset($extraDeprecated[$o['Repository']]) ) {
- $o['Deprecated'] = true;
- }
- }
+ $runningflag = false;
+ foreach ($info as $installedDocker) {
+ $installedImage = str_replace("library/","",$installedDocker['Image']);
+ $installedName = $installedDocker['Name'];
+ if ( $installedName == $o['Name'] ) {
+ if ( startsWith($installedImage, $o['Repository']) ) {
+ $runningflag = true;
+ $searchResult = searchArray($file,'Repository',$o['Repository']);
+ if ( $searchResult === false) {
+ $searchResult = searchArray($file,'Repository',explode(":",$o['Repository'])[0]);
+ }
+ if ( $searchResult === false ) {
+ $runningFlag = true;
+ if ( $extraBlacklist[$o['Repository']] ?? false ) {
+ $o['Blacklist'] = true;
+ }
+ if ( $extraDeprecated[$o['Repository']] ?? false ) {
+ $o['Deprecated'] = true;
+ }
+ }
+ break;
+ }
+ }
+ }
+ if ( $runningflag ) {
+ $tmpRepo = strpos($o['Repository'],":") ? $o['Repository'] : $o['Repository'].":latest";
+ $tmpRepo = strpos($tmpRepo,"/") ? $tmpRepo : "library/$tmpRepo";
+ if ( $tmpRepo ) {
+ if ( isset($dockerUpdateStatus[$tmpRepo]['status']) && $dockerUpdateStatus[$tmpRepo]['status'] == "false" )
+ $o['actionCentre'] = true;
+ }
+ if ( ! $o['Blacklist'] && ! $o['Deprecated'] ) {
+ if ( isset($extraBlacklist[$o['Repository']]) ) {
+ $o['Blacklist'] = true;
+ }
+ if ( isset($extraDeprecated[$o['Repository']]) ) {
+ $o['Deprecated'] = true;
+ }
+ }
- if ( !$o['Blacklist'] && !$o['Deprecated'] && !$o['actionCentre'] )
- continue;
+ if ( !$o['Blacklist'] && !$o['Deprecated'] && !$o['actionCentre'] )
+ continue;
- $displayed[] = $o;
- break;
- }
- }
- }
+ $displayed[] = $o;
+ break;
+ }
+ }
+ }
# Now work on plugins
- foreach ($file as $template) {
- if ( ! $template['Plugin'] ) continue;
+ foreach ($file as $template) {
+ if ( ! $template['Plugin'] ) continue;
- if ( $template['Name'] == "Community Applications" )
- continue;
+ if ( $template['Name'] == "Community Applications" )
+ continue;
- $filename = pathinfo($template['Repository'],PATHINFO_BASENAME);
+ $filename = pathinfo($template['Repository'],PATHINFO_BASENAME);
- if ( checkInstalledPlugin($template) ) {
- $template['InstallPath'] = "/var/log/plugins/$filename";
- $template['Uninstall'] = true;
- if ( plugin("pluginURL","/var/log/plugins/$filename") !== $template['PluginURL'] )
- continue;
+ if ( checkInstalledPlugin($template) ) {
+ $template['InstallPath'] = "/var/log/plugins/$filename";
+ $template['Uninstall'] = true;
+ if ( plugin("pluginURL","/var/log/plugins/$filename") !== $template['PluginURL'] )
+ continue;
- $installedVersion = plugin("version","/var/log/plugins/$filename");
- if ( ( strcmp($installedVersion,$template['pluginVersion']) < 0 || $template['UpdateAvailable']) ) {
- $template['actionCentre'] = true;
- }
- if ( ! $template['actionCentre'] && is_file("/tmp/plugins/$filename") ) {
- if ( strcmp($installedVersion,plugin("version","/tmp/plugins/$filename")) < 0 )
- $template['actionCentre'] = true;
- }
+ $installedVersion = plugin("version","/var/log/plugins/$filename");
+ if ( ( strcmp($installedVersion,$template['pluginVersion']) < 0 || $template['UpdateAvailable']) ) {
+ $template['actionCentre'] = true;
+ }
+ if ( ! $template['actionCentre'] && is_file("/tmp/plugins/$filename") ) {
+ if ( strcmp($installedVersion,plugin("version","/tmp/plugins/$filename")) < 0 )
+ $template['actionCentre'] = true;
+ }
- if ( !$template['Blacklist'] && !$template['Deprecated'] && $template['Compatible'] && !$template['actionCentre'] )
- continue;
- $displayed[] = $template;
- break;
- }
- }
- $installedLanguages = array_diff(scandir($caPaths['languageInstalled']),[".","..","en_US"]);
- foreach ($installedLanguages as $language) {
- $index = searchArray($file,"LanguagePack",$language);
- if ( $index !== false ) {
- $tmpL = $file[$index];
- $tmpL['Uninstall'] = true;
+ if ( !$template['Blacklist'] && !$template['Deprecated'] && $template['Compatible'] && !$template['actionCentre'] )
+ continue;
+ $displayed[] = $template;
+ break;
+ }
+ }
+ $installedLanguages = array_diff(scandir($caPaths['languageInstalled']),[".","..","en_US"]);
+ foreach ($installedLanguages as $language) {
+ $index = searchArray($file,"LanguagePack",$language);
+ if ( $index !== false ) {
+ $tmpL = $file[$index];
+ $tmpL['Uninstall'] = true;
- if ( !languageCheck($tmpL) )
- continue;
+ if ( !languageCheck($tmpL) )
+ continue;
- $displayed[] = $tmpL;
- break;
- }
- }
- if ( isset($displayed) ) {
- debug("action center enabled");
- postReturn(['status'=>"action"]);
- } else {
- debug("action centre disabled");
- postReturn(['status'=>"noaction"]);
- }
+ $displayed[] = $tmpL;
+ break;
+ }
+ }
+ if ( isset($displayed) ) {
+ debug("action center enabled");
+ postReturn(['status'=>"action"]);
+ } else {
+ debug("action centre disabled");
+ postReturn(['status'=>"noaction"]);
+ }
}
###################################################
# Checks the requirements being met on an upgrade #
###################################################
function checkRequirements() {
- $requiresFile = getPost("requires","");
- if (! $requiresFile || ($requiresFile && is_file($requiresFile) ) ) {
- postReturn(['met'=>true]);
- } else {
- postReturn(['met'=>""]);
- }
+ $requiresFile = getPost("requires","");
+ if (! $requiresFile || ($requiresFile && is_file($requiresFile) ) ) {
+ postReturn(['met'=>true]);
+ } else {
+ postReturn(['met'=>""]);
+ }
}
########################################################
# Saves the list of plugins which are pending installs #
########################################################
function saveMultiPluginPending() {
- global $caPaths;
+ global $caPaths;
- $plugin = getPost("plugin","");
- $plugins = array_filter(explode("*",$plugin));
- if ( count($plugins) > 1 ) {
- exec("mkdir -p {$caPaths['pluginPending']}");
- foreach ($plugins as $plg) {
- if (! $plg ) continue;
- $pluginName = basename($plg);
- touch($caPaths['pluginPending'].$pluginName);
- }
- }
- postReturn(['status'=>'ok']);
+ $plugin = getPost("plugin","");
+ $plugins = array_filter(explode("*",$plugin));
+ if ( count($plugins) > 1 ) {
+ exec("mkdir -p {$caPaths['pluginPending']}");
+ foreach ($plugins as $plg) {
+ if (! $plg ) continue;
+ $pluginName = basename($plg);
+ touch($caPaths['pluginPending'].$pluginName);
+ }
+ }
+ postReturn(['status'=>'ok']);
}
##############################################
# Downloads the stats file in the background #
##############################################
function downloadStatistics() {
- global $caPaths;
+ global $caPaths;
- if ( ! is_file($caPaths['statistics']) )
- download_json($caPaths['statisticsURL'],$caPaths['statistics']);
+ if ( ! is_file($caPaths['statistics']) )
+ download_json($caPaths['statisticsURL'],$caPaths['statistics']);
}
###########################################################################
# Checks to see if a plugin installation or update is already in progress #
###########################################################################
function checkPluginInProgress() {
- global $caPaths;
+ global $caPaths;
- $pluginsPending = glob("{$caPaths['pluginPending']}/*");
+ $pluginsPending = glob("{$caPaths['pluginPending']}/*");
- postReturn(['inProgress'=>empty($pluginsPending)? "" : "true"]);
+ postReturn(['inProgress'=>empty($pluginsPending)? "" : "true"]);
}
@@ -2549,9 +2549,9 @@ function checkPluginInProgress() {
# Logs Javascript errors being caught #
#######################################
function javascriptError() {
- return;
- global $caPaths, $caSettings;
+ return;
+ global $caPaths, $caSettings;
- debug("******* ERROR **********\n".print_r($_POST,true));
+ debug("******* ERROR **********\n".print_r($_POST,true));
}
?>
\ No newline at end of file
diff --git a/source/community.applications/usr/local/emhttp/plugins/community.applications/include/helpers.php b/source/community.applications/usr/local/emhttp/plugins/community.applications/include/helpers.php
index 686f57a8..645e8be1 100644
--- a/source/community.applications/usr/local/emhttp/plugins/community.applications/include/helpers.php
+++ b/source/community.applications/usr/local/emhttp/plugins/community.applications/include/helpers.php
@@ -10,191 +10,191 @@
# Convert Array("one","two","three") to be Array("one"=>$defaultFlag, "two"=>$defaultFlag, "three"=>$defaultFlag #
##################################################################################################################
function arrayEntriesToObject($sourceArray,$defaultFlag=true) {
- return is_array($sourceArray) ? array_fill_keys($sourceArray,$defaultFlag) : [];
+ return is_array($sourceArray) ? array_fill_keys($sourceArray,$defaultFlag) : [];
}
###########################################################################
# Helper function to determine if a plugin has an update available or not #
###########################################################################
function checkPluginUpdate($filename) {
- global $caSettings;
+ global $caSettings;
- $filename = basename($filename);
- if ( ! is_file("/var/log/plugins/$filename") ) return false;
- $upgradeVersion = (is_file("/tmp/plugins/$filename")) ? plugin("version","/tmp/plugins/$filename") : "0";
- $installedVersion = $upgradeVersion ? plugin("version","/var/log/plugins/$filename") : 0;
+ $filename = basename($filename);
+ if ( ! is_file("/var/log/plugins/$filename") ) return false;
+ $upgradeVersion = (is_file("/tmp/plugins/$filename")) ? plugin("version","/tmp/plugins/$filename") : "0";
+ $installedVersion = $upgradeVersion ? plugin("version","/var/log/plugins/$filename") : 0;
- if ( $installedVersion < $upgradeVersion ) {
- $unRaid = plugin("unRAID","/tmp/plugins/$filename");
- return ( $unRaid === false || version_compare($caSettings['unRaidVersion'],$unRaid,">=") ) ? true : false;
- }
- return false;
+ if ( $installedVersion < $upgradeVersion ) {
+ $unRaid = plugin("unRAID","/tmp/plugins/$filename");
+ return ( $unRaid === false || version_compare($caSettings['unRaidVersion'],$unRaid,">=") ) ? true : false;
+ }
+ return false;
}
###################################################################################
# returns a random file name (/tmp/community.applications/tempFiles/34234234.tmp) #
###################################################################################
function randomFile() {
- global $caPaths;
+ global $caPaths;
- return tempnam($caPaths['tempFiles'],"CA-Temp-");
+ return tempnam($caPaths['tempFiles'],"CA-Temp-");
}
##################################################################
# 7 Functions to avoid typing the same lines over and over again #
##################################################################
function readJsonFile($filename) {
- global $caSettings, $caPaths;
+ global $caSettings, $caPaths;
- debug("CA Read JSON file $filename");
+ debug("CA Read JSON file $filename");
- $json = json_decode(@file_get_contents($filename),true);
- if ( $json === false ) {
- if ( ! is_file($filename) )
- debug("$filename not found");
+ $json = json_decode(@file_get_contents($filename),true);
+ if ( $json === false ) {
+ if ( ! is_file($filename) )
+ debug("$filename not found");
- debug("JSON Read Error ($filename)");
- }
- debug("Memory Usage:".round(memory_get_usage()/1048576,2)." MB");
- return is_array($json) ? $json : array();
+ debug("JSON Read Error ($filename)");
+ }
+ debug("Memory Usage:".round(memory_get_usage()/1048576,2)." MB");
+ return is_array($json) ? $json : array();
}
function writeJsonFile($filename,$jsonArray) {
- global $caSettings, $caPaths;
+ global $caSettings, $caPaths;
- debug("Write JSON File $filename");
- $jsonFlags = $caSettings['dev'] == "yes" ? JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT : JSON_UNESCAPED_SLASHES;
- $result = ca_file_put_contents($filename,json_encode($jsonArray, $jsonFlags));
- debug("Memory Usage:".round(memory_get_usage()/1048576,2)." MB");
+ debug("Write JSON File $filename");
+ $jsonFlags = $caSettings['dev'] == "yes" ? JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT : JSON_UNESCAPED_SLASHES;
+ $result = ca_file_put_contents($filename,json_encode($jsonArray, $jsonFlags));
+ debug("Memory Usage:".round(memory_get_usage()/1048576,2)." MB");
}
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 === false ) {
- debug("Failed to write to $filename");
- $GLOBALS['script'] = "alert('Failed to write to ".htmlentities($filename,ENT_QUOTES)."');";
- }
- return $result;
+ 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;
+ global $caSettings, $caPaths;
- debug("DOWNLOAD starting $url\n");
- $startTime = time();
+ debug("DOWNLOAD starting $url\n");
+ $startTime = time();
- $ch = curl_init();
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch,CURLOPT_FRESH_CONNECT,true);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
- curl_setopt($ch,CURLOPT_TIMEOUT,$timeout);
- curl_setopt($ch,CURLOPT_ENCODING,"");
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
- curl_setopt($ch,CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch,CURLOPT_FAILONERROR,true);
+ $ch = curl_init();
+ curl_setopt($ch,CURLOPT_URL,$url);
+ curl_setopt($ch,CURLOPT_FRESH_CONNECT,true);
+ curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
+ curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
+ curl_setopt($ch,CURLOPT_TIMEOUT,$timeout);
+ curl_setopt($ch,CURLOPT_ENCODING,"");
+ curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
+ curl_setopt($ch,CURLOPT_FOLLOWLOCATION, true);
+ curl_setopt($ch,CURLOPT_FAILONERROR,true);
- if ( is_file("/boot/config/plugins/community.applications/proxy.cfg") ) {
- $proxyCFG = parse_ini_file("/boot/config/plugins/community.applications/proxy.cfg");
- curl_setopt($ch, CURLOPT_PROXYPORT,intval($proxyCFG['port']));
- curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL,intval($proxyCFG['tunnel']));
- curl_setopt($ch, CURLOPT_PROXY,$proxyCFG['proxy']);
- }
- $out = curl_exec($ch);
- curl_close($ch);
- if ( $path )
- ca_file_put_contents($path,$out);
+ if ( is_file("/boot/config/plugins/community.applications/proxy.cfg") ) {
+ $proxyCFG = parse_ini_file("/boot/config/plugins/community.applications/proxy.cfg");
+ curl_setopt($ch, CURLOPT_PROXYPORT,intval($proxyCFG['port']));
+ curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL,intval($proxyCFG['tunnel']));
+ curl_setopt($ch, CURLOPT_PROXY,$proxyCFG['proxy']);
+ }
+ $out = curl_exec($ch);
+ curl_close($ch);
+ if ( $path )
+ ca_file_put_contents($path,$out);
- $totalTime = time() - $startTime;
- debug("DOWNLOAD $url Time: $totalTime RESULT:\n".var_dump_ret($out));
- return $out ?: false;
+ $totalTime = time() - $startTime;
+ debug("DOWNLOAD $url Time: $totalTime RESULT:\n".var_dump_ret($out));
+ return $out ?: false;
}
function download_json($url,$path="",$bg=false,$timeout=45) {
- return json_decode(download_url($url,$path,$bg,$timeout),true);
+ return json_decode(download_url($url,$path,$bg,$timeout),true);
}
function getPost($setting,$default) {
- return isset($_POST[$setting]) ? urldecode(($_POST[$setting])) : $default;
+ return isset($_POST[$setting]) ? urldecode(($_POST[$setting])) : $default;
}
function getPostArray($setting) {
- return $_POST[$setting];
+ return $_POST[$setting];
}
function var_dump_ret($mixed = null) {
- ob_start();
- var_dump($mixed);
- $content = ob_get_contents();
- ob_end_clean();
- return $content;
+ ob_start();
+ var_dump($mixed);
+ $content = ob_get_contents();
+ ob_end_clean();
+ return $content;
}
##############################################
# Determine if $haystack begins with $needle #
##############################################
function startsWith($haystack, $needle) {
- if ( !is_string($haystack) || ! is_string($needle) ) return false;
- return $needle === "" || strripos($haystack, $needle, -strlen($haystack)) !== FALSE;
+ if ( !is_string($haystack) || ! is_string($needle) ) return false;
+ return $needle === "" || strripos($haystack, $needle, -strlen($haystack)) !== FALSE;
}
#############################################
# Determine if $string ends with $endstring #
#############################################
function endsWith($string, $endString) {
- $len = strlen($endString);
- if ($len == 0) {
- return true;
- }
- return (substr($string, -$len) === $endString);
+ $len = strlen($endString);
+ if ($len == 0) {
+ return true;
+ }
+ return (substr($string, -$len) === $endString);
}
###########################################
# Replace the first occurance in a string #
###########################################
function first_str_replace($haystack, $needle, $replace) {
- $pos = strpos($haystack, $needle);
- return ($pos !== false) ? substr_replace($haystack, $replace, $pos, strlen($needle)) : $haystack;
+ $pos = strpos($haystack, $needle);
+ return ($pos !== false) ? substr_replace($haystack, $replace, $pos, strlen($needle)) : $haystack;
}
##########################################
# Replace the last occurance in a string #
##########################################
function last_str_replace($haystack, $needle, $replace) {
- $pos = strrpos($haystack, $needle);
- return ($pos !== false) ? substr_replace($haystack, $replace, $pos, strlen($needle)) : $haystack;
+ $pos = strrpos($haystack, $needle);
+ return ($pos !== false) ? substr_replace($haystack, $replace, $pos, strlen($needle)) : $haystack;
}
#######################
# Custom sort routine #
#######################
function mySort($a, $b) {
- global $sortOrder;
+ global $sortOrder;
- if ( $sortOrder['sortBy'] == "Name" )
- $sortOrder['sortBy'] = "SortName";
- if ( $sortOrder['sortBy'] != "downloads" && $sortOrder['sortBy'] != "trendDelta") {
- $c = strtolower($a[$sortOrder['sortBy']] ?? "");
- $d = strtolower($b[$sortOrder['sortBy']] ?? "");
- } else {
- $c = $a[$sortOrder['sortBy']];
- $d = $b[$sortOrder['sortBy']];
- }
+ if ( $sortOrder['sortBy'] == "Name" )
+ $sortOrder['sortBy'] = "SortName";
+ if ( $sortOrder['sortBy'] != "downloads" && $sortOrder['sortBy'] != "trendDelta") {
+ $c = strtolower($a[$sortOrder['sortBy']] ?? "");
+ $d = strtolower($b[$sortOrder['sortBy']] ?? "");
+ } else {
+ $c = $a[$sortOrder['sortBy']];
+ $d = $b[$sortOrder['sortBy']];
+ }
- $return1 = ($sortOrder['sortDir'] == "Down") ? -1 : 1;
- $return2 = ($sortOrder['sortDir'] == "Down") ? 1 : -1;
+ $return1 = ($sortOrder['sortDir'] == "Down") ? -1 : 1;
+ $return2 = ($sortOrder['sortDir'] == "Down") ? 1 : -1;
- if ( ! is_numeric($c) ) {
- $c = strtolower($c ?? "");
- $d = strtolower($d ?? "");
- }
- if ($c > $d) return $return1;
- else if ($c < $d) return $return2;
- else return 0;
+ if ( ! is_numeric($c) ) {
+ $c = strtolower($c ?? "");
+ $d = strtolower($d ?? "");
+ }
+ if ($c > $d) return $return1;
+ else if ($c < $d) return $return2;
+ else return 0;
}
function repositorySort($a,$b) {
- global $caSettings;
+ global $caSettings;
- if ( $a['RepoName'] == $caSettings['favourite'] ) return -1;
- if ( $b['RepoName'] == $caSettings['favourite'] ) return 1;
- return 0;
+ if ( $a['RepoName'] == $caSettings['favourite'] ) return -1;
+ if ( $b['RepoName'] == $caSettings['favourite'] ) return 1;
+ return 0;
}
function favouriteSort($a,$b) {
- global $caSettings;
+ global $caSettings;
- if ( $a['Repo'] == $caSettings['favourite'] ) return -1;
- if ( $b['Repo'] == $caSettings['favourite'] ) return 1;
- return 0;
+ if ( $a['Repo'] == $caSettings['favourite'] ) return -1;
+ if ( $b['Repo'] == $caSettings['favourite'] ) return 1;
+ return 0;
}
###############################################
# Search array for a particular key and value #
@@ -202,169 +202,169 @@ function favouriteSort($a,$b) {
# return value === false if not found #
###############################################
function searchArray($array,$key,$value,$startingIndex=0) {
- $result = false;
- if (is_array($array) && count($array) ) {
- for ($i = $startingIndex; $i <= max(array_keys($array)); $i++) {
- if ( $array[$i][$key] == $value ) {
- $result = $i;
- break;
- }
- }
- }
- return $result;
+ $result = false;
+ if (is_array($array) && count($array) ) {
+ for ($i = $startingIndex; $i <= max(array_keys($array)); $i++) {
+ if ( $array[$i][$key] == $value ) {
+ $result = $i;
+ break;
+ }
+ }
+ }
+ return $result;
}
########################################################
# Fix common problems (maintainer errors) in templates #
########################################################
function fixTemplates($template) {
- global $statistics, $caSettings;
+ global $statistics, $caSettings;
- if ( ! $template['MinVer'] ) $template['MinVer'] = $template['Plugin'] ? "6.1" : "6.0";
- if ( ! $template['Date'] ) $template['Date'] = (is_numeric($template['DateInstalled'])) ? $template['DateInstalled'] : 0;
- $template['Date'] = max($template['Date'],$template['FirstSeen']);
- if ($template['Date'] == 1) $template['Date'] = null;
- if ( ($template['Date'] == $template['FirstSeen']) && ( $template['FirstSeen'] >= 1538357652 )) {# 1538357652 is when the new appfeed first started
- $template['BrandNewApp'] = true;
- $template['Date'] = null;
- }
+ if ( ! $template['MinVer'] ) $template['MinVer'] = $template['Plugin'] ? "6.1" : "6.0";
+ if ( ! $template['Date'] ) $template['Date'] = (is_numeric($template['DateInstalled'])) ? $template['DateInstalled'] : 0;
+ $template['Date'] = max($template['Date'],$template['FirstSeen']);
+ if ($template['Date'] == 1) $template['Date'] = null;
+ if ( ($template['Date'] == $template['FirstSeen']) && ( $template['FirstSeen'] >= 1538357652 )) {# 1538357652 is when the new appfeed first started
+ $template['BrandNewApp'] = true;
+ $template['Date'] = null;
+ }
- # fix where template author includes
or entries in template (CA used booleans, but appfeed winds up saying "FALSE" which equates to be true
- $template['Deprecated'] = filter_var($template['Deprecated'],FILTER_VALIDATE_BOOLEAN);
- $template['Blacklist'] = filter_var($template['Blacklist'],FILTER_VALIDATE_BOOLEAN);
+ # fix where template author includes or entries in template (CA used booleans, but appfeed winds up saying "FALSE" which equates to be true
+ $template['Deprecated'] = filter_var($template['Deprecated'],FILTER_VALIDATE_BOOLEAN);
+ $template['Blacklist'] = filter_var($template['Blacklist'],FILTER_VALIDATE_BOOLEAN);
- if ( $template['DeprecatedMaxVer'] && version_compare($caSettings['unRaidVersion'],$template['DeprecatedMaxVer'],">") )
- $template['Deprecated'] = true;
+ if ( $template['DeprecatedMaxVer'] && version_compare($caSettings['unRaidVersion'],$template['DeprecatedMaxVer'],">") )
+ $template['Deprecated'] = true;
- if ( version_compare($caSettings['unRaidVersion'],"6.10.0-beta4",">") ) {
- if ( $template['Config'] ) {
- 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'] = "";
- }
- }
- }
- }
- }
- }
- return $template;
+ if ( version_compare($caSettings['unRaidVersion'],"6.10.0-beta4",">") ) {
+ if ( $template['Config'] ) {
+ 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'] = "";
+ }
+ }
+ }
+ }
+ }
+ }
+ return $template;
}
###############################################
# Function used to create XML's from appFeeds #
###############################################
function makeXML($template) {
- # ensure its a v2 template if the Config entries exist
- if ( isset($template['Config']) && ! isset($template['@attributes']) )
- $template['@attributes'] = ["version"=>2];
+ # ensure its a v2 template if the Config entries exist
+ if ( isset($template['Config']) && ! isset($template['@attributes']) )
+ $template['@attributes'] = ["version"=>2];
- if ($template['Overview']) $template['Description'] = $template['Overview'];
+ if ($template['Overview']) $template['Description'] = $template['Overview'];
- fixAttributes($template,"Network");
- fixAttributes($template,"Config");
+ fixAttributes($template,"Network");
+ fixAttributes($template,"Config");
# Sanitize the Requires entry if there is any CA links within it
- if ($template['Requires'] ?? false) {
- preg_match_all("/\/\/(.*?)\/m",$template['Requires'],$searchMatches);
+ if ($template['Requires'] ?? false) {
+ preg_match_all("/\/\/(.*?)\/m",$template['Requires'],$searchMatches);
- if ( isset($searchMatches[1]) && count($searchMatches[1]) ) {
- foreach ($searchMatches[1] as $searchResult) {
- $template['Requires'] = str_replace("//$searchResult\\\\",$searchResult,$template['Requires']);
- }
- }
- }
- $Array2XML = new Array2XML();
- $xml = $Array2XML->createXML("Container",$template);
- return $xml->saveXML();
+ if ( isset($searchMatches[1]) && count($searchMatches[1]) ) {
+ foreach ($searchMatches[1] as $searchResult) {
+ $template['Requires'] = str_replace("//$searchResult\\\\",$searchResult,$template['Requires']);
+ }
+ }
+ }
+ $Array2XML = new Array2XML();
+ $xml = $Array2XML->createXML("Container",$template);
+ return $xml->saveXML();
}
#################################################################################
# Function to fix differing schema in the appfeed vs what Array2XML class wants #
#################################################################################
function fixAttributes(&$template,$attribute) {
- if ( ! isset($template[$attribute]) ) return;
- if ( ! is_array($template[$attribute]) ) return;
- if ( isset($template[$attribute]['@attributes']) ) {
- $template[$attribute][0]['@attributes'] = $template[$attribute]['@attributes'];
- if ( $template[$attribute]['value'])
- $template[$attribute][0]['value'] = $template[$attribute]['value'];
+ if ( ! isset($template[$attribute]) ) return;
+ if ( ! is_array($template[$attribute]) ) return;
+ if ( isset($template[$attribute]['@attributes']) ) {
+ $template[$attribute][0]['@attributes'] = $template[$attribute]['@attributes'];
+ if ( $template[$attribute]['value'])
+ $template[$attribute][0]['value'] = $template[$attribute]['value'];
- unset($template[$attribute]['@attributes']);
- unset($template[$attribute]['value']);
- }
+ unset($template[$attribute]['@attributes']);
+ unset($template[$attribute]['value']);
+ }
- if ( $template[$attribute] ) {
- foreach ($template[$attribute] as $tempArray)
- $tempArray2[] = isset($tempArray['value']) ? ['@attributes'=>$tempArray['@attributes'],'@value'=>$tempArray['value']] : ['@attributes'=>$tempArray['@attributes']];
- $template[$attribute] = $tempArray2;
- }
+ if ( $template[$attribute] ) {
+ foreach ($template[$attribute] as $tempArray)
+ $tempArray2[] = isset($tempArray['value']) ? ['@attributes'=>$tempArray['@attributes'],'@value'=>$tempArray['value']] : ['@attributes'=>$tempArray['@attributes']];
+ $template[$attribute] = $tempArray2;
+ }
}
#################################################################
# checks the Min/Max version of an app against unRaid's version #
# Returns: TRUE if it's valid to run, FALSE if not #
#################################################################
function versionCheck($template) {
- global $caSettings;
+ global $caSettings;
- if ( $template['IncompatibleVersion'] ) {
- if ( ! is_array($template['IncompatibleVersion']) ) {
- $incompatible[] = $template['IncompatibleVersion'];
- } else {
- $incompatible = $template['IncompatibleVersion'];
- }
- foreach ($incompatible as $ver) {
- if ( $ver == $template['pluginVersion'] ) return false;
- }
- }
+ if ( $template['IncompatibleVersion'] ) {
+ if ( ! is_array($template['IncompatibleVersion']) ) {
+ $incompatible[] = $template['IncompatibleVersion'];
+ } else {
+ $incompatible = $template['IncompatibleVersion'];
+ }
+ foreach ($incompatible as $ver) {
+ if ( $ver == $template['pluginVersion'] ) return false;
+ }
+ }
- if ( $template['MinVer'] && ( version_compare($template['MinVer'],$caSettings['unRaidVersion']) > 0 ) ) return false;
- if ( $template['MaxVer'] && ( version_compare($template['MaxVer'],$caSettings['unRaidVersion']) < 0 ) ) return false;
- return true;
+ if ( $template['MinVer'] && ( version_compare($template['MinVer'],$caSettings['unRaidVersion']) > 0 ) ) return false;
+ if ( $template['MaxVer'] && ( version_compare($template['MaxVer'],$caSettings['unRaidVersion']) < 0 ) ) return false;
+ return true;
}
###############################################
# Function to read a template XML to an array #
###############################################
function readXmlFile($xmlfile,$generic=false,$stats=true) {
- global $statistics;
+ global $statistics;
- if ( ! $xmlfile || ! is_file($xmlfile) ) return false;
- $xml = file_get_contents($xmlfile);
- $o = TypeConverter::xmlToArray($xml,TypeConverter::XML_GROUP);
- $o = addMissingVars($o);
- if ( ! $o ) return false;
- if ( $generic ) return $o;
+ if ( ! $xmlfile || ! is_file($xmlfile) ) return false;
+ $xml = file_get_contents($xmlfile);
+ $o = TypeConverter::xmlToArray($xml,TypeConverter::XML_GROUP);
+ $o = addMissingVars($o);
+ if ( ! $o ) return false;
+ if ( $generic ) return $o;
- # Fix some errors in templates prior to continuing
+ # Fix some errors in templates prior to continuing
- $o['Path'] = $xmlfile;
- $o['Author'] = getAuthor($o);
- $o['DockerHubName'] = strtolower($o['Name']);
- $o['Base'] = $o['BaseImage'] ?? "";
- $o['SortAuthor'] = $o['Author'];
- $o['SortName'] = $o['Name'];
- $o['Forum'] = $Repo['forum'] ?? "";
+ $o['Path'] = $xmlfile;
+ $o['Author'] = getAuthor($o);
+ $o['DockerHubName'] = strtolower($o['Name']);
+ $o['Base'] = $o['BaseImage'] ?? "";
+ $o['SortAuthor'] = $o['Author'];
+ $o['SortName'] = $o['Name'];
+ $o['Forum'] = $Repo['forum'] ?? "";
# configure the config attributes to same format as appfeed
# handle the case where there is only a single entry
- if ( isset($o['Config']['@attributes']) )
- $o['Config'] = ['@attributes'=>$o['Config']['@attributes'],'value'=>$o['Config']['value']];
+ if ( isset($o['Config']['@attributes']) )
+ $o['Config'] = ['@attributes'=>$o['Config']['@attributes'],'value'=>$o['Config']['value']];
- if ( $stats) {
- $statistics['plugin'] = $statistics['plugin'] ?? 0;
- $statistics['docker'] = $statistics['docker'] ?? 0;
- if ( $o['Plugin'] ) {
- $o['Author'] = $o['PluginAuthor'];
- $o['Repository'] = $o['PluginURL'];
- $o['SortAuthor'] = $o['Author'];
- $o['SortName'] = $o['Name'];
- $statistics['plugin']++;
- } else
- $statistics['docker']++;
- }
- return $o;
+ if ( $stats) {
+ $statistics['plugin'] = $statistics['plugin'] ?? 0;
+ $statistics['docker'] = $statistics['docker'] ?? 0;
+ if ( $o['Plugin'] ) {
+ $o['Author'] = $o['PluginAuthor'];
+ $o['Repository'] = $o['PluginURL'];
+ $o['SortAuthor'] = $o['Author'];
+ $o['SortName'] = $o['Name'];
+ $statistics['plugin']++;
+ } else
+ $statistics['docker']++;
+ }
+ return $o;
}
###################################################################
# Function To Merge Moderation into templates array #
@@ -372,493 +372,493 @@ function readXmlFile($xmlfile,$generic=false,$stats=true) {
# If appfeed is updated, this is done when creating the templates #
###################################################################
function moderateTemplates() {
- global $caPaths,$caSettings;
+ global $caPaths,$caSettings;
// $templates = readJsonFile($caPaths['community-templates-info']);
- $templates = &$GLOBALS['templates'];
+ $templates = &$GLOBALS['templates'];
- if ( ! $templates ) return;
- foreach ($templates as $template) {
- $template['Compatible'] = versionCheck($template);
- if ( $template['MaxVer'] && version_compare($template['MaxVer'],$caSettings['unRaidVersion']) < 0 )
- $template['Featured'] = false;
- if ( $template['CAMinVer'] ?? false ) {
- $template['UninstallOnly'] = version_compare($template['CAMinVer'],$caSettings['unRaidVersion'],">=");
- }
+ if ( ! $templates ) return;
+ foreach ($templates as $template) {
+ $template['Compatible'] = versionCheck($template);
+ if ( $template['MaxVer'] && version_compare($template['MaxVer'],$caSettings['unRaidVersion']) < 0 )
+ $template['Featured'] = false;
+ if ( $template['CAMinVer'] ?? false ) {
+ $template['UninstallOnly'] = version_compare($template['CAMinVer'],$caSettings['unRaidVersion'],">=");
+ }
- if ( $template["DeprecatedMaxVer"] && version_compare($caSettings['unRaidVersion'],$template["DeprecatedMaxVer"],">") )
- $template['Deprecated'] = true;
+ if ( $template["DeprecatedMaxVer"] && version_compare($caSettings['unRaidVersion'],$template["DeprecatedMaxVer"],">") )
+ $template['Deprecated'] = true;
- $template['ModeratorComment'] = $template['CaComment'] ?: $template['ModeratorComment'];
- $o[] = $template;
- }
- writeJsonFile($caPaths['community-templates-info'],$o);
- $GLOBALS['templates'] = $o;
- pluginDupe();
+ $template['ModeratorComment'] = $template['CaComment'] ?: $template['ModeratorComment'];
+ $o[] = $template;
+ }
+ writeJsonFile($caPaths['community-templates-info'],$o);
+ $GLOBALS['templates'] = $o;
+ pluginDupe();
}
#######################################################
# Function to check for a valid URL #
#######################################################
function validURL($URL) {
- return filter_var($URL, FILTER_VALIDATE_URL);
+ return filter_var($URL, FILTER_VALIDATE_URL);
}
#######################################################
# Function used to determine if a search term matches #
#######################################################
function filterMatch($filter,$searchArray,$exact=true) {
- $filterwords = explode(" ",$filter);
- $foundword = null;
- foreach ( $filterwords as $testfilter) {
- if ( ! trim($testfilter) ) continue;
- foreach ($searchArray as $search) {
- if ( ! $search ) continue;
- if ( stripos($search,$testfilter) !== false ) {
- $foundword++;
- break;
- }
- }
- }
- return $exact ? ($foundword == count($filterwords)) : ($foundword > 0);
+ $filterwords = explode(" ",$filter);
+ $foundword = null;
+ foreach ( $filterwords as $testfilter) {
+ if ( ! trim($testfilter) ) continue;
+ foreach ($searchArray as $search) {
+ if ( ! $search ) continue;
+ if ( stripos($search,$testfilter) !== false ) {
+ $foundword++;
+ break;
+ }
+ }
+ }
+ return $exact ? ($foundword == count($filterwords)) : ($foundword > 0);
}
##########################################################
# Used to figure out which plugins have duplicated names #
##########################################################
function pluginDupe() {
- global $caPaths;
+ global $caPaths;
- $pluginList = [];
- $dupeList = [];
- foreach ($GLOBALS['templates'] as $template) {
- if ( $template['Plugin'] ) {
- if ( ! isset($pluginList[basename($template['Repository'])]) )
- $pluginList[basename($template['Repository'])] = 0;
- $pluginList[basename($template['Repository'])]++;
- }
- }
- foreach (array_keys($pluginList) as $plugin) {
- if ( $pluginList[$plugin] > 1 )
- $dupeList[$plugin] = 1;
- }
- writeJsonFile($caPaths['pluginDupes'],$dupeList);
+ $pluginList = [];
+ $dupeList = [];
+ foreach ($GLOBALS['templates'] as $template) {
+ if ( $template['Plugin'] ) {
+ if ( ! isset($pluginList[basename($template['Repository'])]) )
+ $pluginList[basename($template['Repository'])] = 0;
+ $pluginList[basename($template['Repository'])]++;
+ }
+ }
+ foreach (array_keys($pluginList) as $plugin) {
+ if ( $pluginList[$plugin] > 1 )
+ $dupeList[$plugin] = 1;
+ }
+ writeJsonFile($caPaths['pluginDupes'],$dupeList);
}
###################################
# Checks if a plugin is installed #
###################################
function checkInstalledPlugin($template) {
- global $caPaths;
+ global $caPaths;
- $pluginName = basename($template['PluginURL']);
- if ( ! file_exists("/var/log/plugins/$pluginName") ) return false;
- $dupeList = readJsonFile($caPaths['pluginDupes']);
- if ( ! isset($dupeList[$pluginName]) ) return true;
- return strtolower(trim(plugin("pluginURL","/var/log/plugins/$pluginName"))) == strtolower(trim($template['PluginURL']));
+ $pluginName = basename($template['PluginURL']);
+ if ( ! file_exists("/var/log/plugins/$pluginName") ) return false;
+ $dupeList = readJsonFile($caPaths['pluginDupes']);
+ if ( ! isset($dupeList[$pluginName]) ) return true;
+ return strtolower(trim(plugin("pluginURL","/var/log/plugins/$pluginName"))) == strtolower(trim($template['PluginURL']));
}
###########################################################
# Returns a string with only alphanumeric characters only #
###########################################################
function alphaNumeric($string) {
- return preg_replace("/[^a-zA-Z0-9]+/", "", $string);
+ return preg_replace("/[^a-zA-Z0-9]+/", "", $string);
}
##################################################################
# mobile browser detection from http://detectmobilebrowsers.com/ #
##################################################################
function isMobile() {
- global $caSettings;
+ global $caSettings;
- $useragent=$_SERVER['HTTP_USER_AGENT'];
- return (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4)));
+ $useragent=$_SERVER['HTTP_USER_AGENT'];
+ return (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4)));
}
################################################
# Returns the author from the Repository entry #
################################################
function getAuthor($template) {
- if ( isset($template['PluginURL']) ) return $template['PluginAuthor'];
+ if ( isset($template['PluginURL']) ) return $template['PluginAuthor'];
- if ( isset($template['Author']) ) return strip_tags($template['Author']);
- $template['Repository'] = str_replace(["lscr.io/","ghcr.io/","registry.hub.docker.com/","library/"],"",$template['Repository']);
- $repoEntry = explode("/",$template['Repository']);
- if (count($repoEntry) < 2)
- $repoEntry[] = "";
+ if ( isset($template['Author']) ) return strip_tags($template['Author']);
+ $template['Repository'] = str_replace(["lscr.io/","ghcr.io/","registry.hub.docker.com/","library/"],"",$template['Repository']);
+ $repoEntry = explode("/",$template['Repository']);
+ if (count($repoEntry) < 2)
+ $repoEntry[] = "";
- return strip_tags(explode(":",$repoEntry[count($repoEntry)-2])[0]);
+ return strip_tags(explode(":",$repoEntry[count($repoEntry)-2])[0]);
}
############################
# Trims the category lists #
############################
function categoryList($cat,$popUp = false) {
- $cat = str_replace([":,",": "," "],",",$cat);
- $cat = rtrim($cat,": ");
- $all_cat = explode(",",$cat);
- foreach ($all_cat as $trcat)
- $all_categories[] = tr($trcat);
+ $cat = str_replace([":,",": "," "],",",$cat);
+ $cat = rtrim($cat,": ");
+ $all_cat = explode(",",$cat);
+ foreach ($all_cat as $trcat)
+ $all_categories[] = tr($trcat);
- $categoryList = $popUp ? $all_categories : array_slice($all_categories,0,2);
+ $categoryList = $popUp ? $all_categories : array_slice($all_categories,0,2);
- if ( count($all_categories) > count($categoryList) ) {
- $excess = count($all_categories) - count($categoryList);
- $categoryList[] = " ".sprintf(tr("and %s more"),$excess);
- }
- return rtrim(implode(", ",$categoryList),", ");
+ if ( count($all_categories) > count($categoryList) ) {
+ $excess = count($all_categories) - count($categoryList);
+ $categoryList[] = " ".sprintf(tr("and %s more"),$excess);
+ }
+ return rtrim(implode(", ",$categoryList),", ");
}
##################################
# Trims the language author list #
##################################
function languageAuthorList($authors) {
- $allAuthors = explode(",",$authors);
- if ( count($allAuthors) > 3 ) {
- $newAuthors = array_slice($allAuthors,0,2);
- foreach ($newAuthors as $author) {
- $newAuthor .= trim($author).", ";
- }
- $excess = count($allAuthors) -2;
- $authors = rtrim($newAuthor,", ")." ".sprintf(tr("and %s more"),$excess);
- }
- return $authors;
+ $allAuthors = explode(",",$authors);
+ if ( count($allAuthors) > 3 ) {
+ $newAuthors = array_slice($allAuthors,0,2);
+ foreach ($newAuthors as $author) {
+ $newAuthor .= trim($author).", ";
+ }
+ $excess = count($allAuthors) -2;
+ $authors = rtrim($newAuthor,", ")." ".sprintf(tr("and %s more"),$excess);
+ }
+ return $authors;
}
#####################################
# Gets a rounded off download count #
#####################################
function getDownloads($downloads,$lowFlag=false) {
- $downloadCount = ["10000000000","5000000000","1000000000","500000000","100000000","50000000","25000000","10000000","5000000","2500000","1000000","500000","250000","100000","50000","25000","10000","5000","1000","500","100"];
- foreach ($downloadCount as $downloadtmp) {
- if ($downloads > $downloadtmp) {
- return sprintf(tr("More than %s"),number_format($downloadtmp));
- }
- }
- return ($lowFlag) ? $downloads : "";
+ $downloadCount = ["10000000000","5000000000","1000000000","500000000","100000000","50000000","25000000","10000000","5000000","2500000","1000000","500000","250000","100000","50000","25000","10000","5000","1000","500","100"];
+ foreach ($downloadCount as $downloadtmp) {
+ if ($downloads > $downloadtmp) {
+ return sprintf(tr("More than %s"),number_format($downloadtmp));
+ }
+ }
+ return ($lowFlag) ? $downloads : "";
}
#####################
# Stops a container #
#####################
function myStopContainer($id) {
- global $DockerClient;
+ global $DockerClient;
- $DockerClient->stopContainer($id);
+ $DockerClient->stopContainer($id);
}
#####################################
# Fix Descriptions on previous apps #
#####################################
function fixDescription($Description) {
- if ( is_string($Description) ) {
- $Description = preg_replace("#\[br\s*\]#i", "{}", $Description);
- $Description = preg_replace("#\[b[\\\]*\s*\]#i", "||", $Description);
- $Description = preg_replace('#\[([^\]]*)\]#', '<$1>', $Description);
- $Description = preg_replace("#]*>#i", '', $Description);
- $Description = preg_replace("#"."{}"."#i", '
', $Description);
- $Description = preg_replace("#"."\|\|"."#i", '', $Description);
- $Description = str_replace("<","<",$Description);
- $Description = str_replace(">",">",$Description);
- $Description = strip_tags($Description);
- $Description = trim($Description);
- }
- return is_string($Description) ? $Description : "";
+ if ( is_string($Description) ) {
+ $Description = preg_replace("#\[br\s*\]#i", "{}", $Description);
+ $Description = preg_replace("#\[b[\\\]*\s*\]#i", "||", $Description);
+ $Description = preg_replace('#\[([^\]]*)\]#', '<$1>', $Description);
+ $Description = preg_replace("#]*>#i", '', $Description);
+ $Description = preg_replace("#"."{}"."#i", '
', $Description);
+ $Description = preg_replace("#"."\|\|"."#i", '', $Description);
+ $Description = str_replace("<","<",$Description);
+ $Description = str_replace(">",">",$Description);
+ $Description = strip_tags($Description);
+ $Description = trim($Description);
+ }
+ return is_string($Description) ? $Description : "";
}
############################
# displays the branch tags #
############################
function formatTags($leadTemplate,$rename="false") {
- global $caPaths;
+ global $caPaths;
- $type = $rename == "true" ? "second" : "default";
+ $type = $rename == "true" ? "second" : "default";
- $file = &$GLOBALS['templates'];
+ $file = &$GLOBALS['templates'];
- $template = $file[$leadTemplate];
- $childTemplates = $file[$leadTemplate]['BranchID'];
- if ( ! is_array($childTemplates) )
- $o = tr("Something really went wrong here");
- else {
- $defaultTag = $template['BranchDefault'] ? $template['BranchDefault'] : "latest";
+ $template = $file[$leadTemplate];
+ $childTemplates = $file[$leadTemplate]['BranchID'];
+ if ( ! is_array($childTemplates) )
+ $o = tr("Something really went wrong here");
+ else {
+ $defaultTag = $template['BranchDefault'] ? $template['BranchDefault'] : "latest";
- $o = "";
- $o .= " | |
";
- foreach ($childTemplates as $child) {
- $o .= " | |
";
- }
- $o .= "
";
- }
- return $o;
+ $o = "";
+ $o .= " | |
";
+ foreach ($childTemplates as $child) {
+ $o .= " | |
";
+ }
+ $o .= "
";
+ }
+ return $o;
}
###########################
# handles the POST return #
###########################
function postReturn($retArray) {
- global $caSettings, $caPaths;
+ global $caSettings, $caPaths;
- if (is_array($retArray)) {
- if ( isset($GLOBALS['script']) )
- $retArray['globalScript'] = $GLOBALS['script'];
+ if (is_array($retArray)) {
+ if ( isset($GLOBALS['script']) )
+ $retArray['globalScript'] = $GLOBALS['script'];
- echo json_encode($retArray);
- } else
- echo $retArray;
- flush();
- debug("POST RETURN ({$_POST['action']})\n".var_dump_ret($retArray));
- debug("POST RETURN Memory Usage:".round(memory_get_usage()/1048576,2)." MB");
+ echo json_encode($retArray);
+ } else
+ echo $retArray;
+ flush();
+ debug("POST RETURN ({$_POST['action']})\n".var_dump_ret($retArray));
+ debug("POST RETURN Memory Usage:".round(memory_get_usage()/1048576,2)." MB");
}
####################################
# Translation backwards compatible #
####################################
if ( ! function_exists("tr") ) {
- function tr($string,$options=-1) {
- $translated = _($string,$options);
- if ( ! trim($translated) )
- $translated = $string;
+ function tr($string,$options=-1) {
+ $translated = _($string,$options);
+ if ( ! trim($translated) )
+ $translated = $string;
- if ( startsWith($translated,""") && endsWith($translated,""") )
- $translated = first_str_replace(last_str_replace($translated,""",""),""","");
+ if ( startsWith($translated,""") && endsWith($translated,""") )
+ $translated = first_str_replace(last_str_replace($translated,""",""),""","");
- $translated = str_replace(['"',"'"],[""","'"],$translated);
+ $translated = str_replace(['"',"'"],[""","'"],$translated);
- return $translated;
- }
+ return $translated;
+ }
}
#############################
# Check for language update #
#############################
function languageCheck($template) {
- global $caPaths;
+ global $caPaths;
- if ( ! $template['LanguageURL'] ) return false;
+ if ( ! $template['LanguageURL'] ) return false;
- $countryCode = $template['LanguagePack'];
- $installedLanguage = "{$caPaths['installedLanguages']}/lang-$countryCode.xml";
- $dynamixUpdate = "{$caPaths['dynamixUpdates']}/lang-$countryCode.xml";
- if ( ! is_file($installedLanguage) )
- return false;
+ $countryCode = $template['LanguagePack'];
+ $installedLanguage = "{$caPaths['installedLanguages']}/lang-$countryCode.xml";
+ $dynamixUpdate = "{$caPaths['dynamixUpdates']}/lang-$countryCode.xml";
+ if ( ! is_file($installedLanguage) )
+ return false;
- $OSupdates = readXmlFile($dynamixUpdate,true); // Because the OS might check for an update before the feed
- if ( ! $OSupdates )
- $OSupdates['Version'] = "1900.01.01";
+ $OSupdates = readXmlFile($dynamixUpdate,true); // Because the OS might check for an update before the feed
+ if ( ! $OSupdates )
+ $OSupdates['Version'] = "1900.01.01";
- $xmlFile = readXmlFile($installedLanguage,true);
+ $xmlFile = readXmlFile($installedLanguage,true);
- if ( !$xmlFile['Version'] ) return false;
- return (strcmp($template['Version'],$xmlFile['Version']) > 0) || (strcmp($OSupdates['Version'],$xmlFile['Version']) > 0);
+ if ( !$xmlFile['Version'] ) return false;
+ return (strcmp($template['Version'],$xmlFile['Version']) > 0) || (strcmp($OSupdates['Version'],$xmlFile['Version']) > 0);
}
######################
# Writes an ini file #
######################
function write_ini_file($file,$array) {
- $res = [];
- foreach($array as $key => $val) {
- if(is_array($val)) {
- $res[] = "[$key]";
- foreach($val as $skey => $sval)
- $res[] = $skey.'="'.$sval.'"';
- }
- else
- $res[] = $key.'="'.$val.'"';
- }
- ca_file_put_contents($file,implode("\r\n", $res),LOCK_EX);
+ $res = [];
+ foreach($array as $key => $val) {
+ if(is_array($val)) {
+ $res[] = "[$key]";
+ foreach($val as $skey => $sval)
+ $res[] = $skey.'="'.$sval.'"';
+ }
+ else
+ $res[] = $key.'="'.$val.'"';
+ }
+ ca_file_put_contents($file,implode("\r\n", $res),LOCK_EX);
}
###################################################
# Gets all the information about what's installed #
###################################################
function getAllInfo($force=false) {
- global $caSettings, $DockerTemplates, $DockerClient, $caPaths;
+ global $caSettings, $DockerTemplates, $DockerClient, $caPaths;
- $containers = readJsonFile($caPaths['info']);
+ $containers = readJsonFile($caPaths['info']);
- if ( $force || ! $containers || empty($containers) ) {
- if ( $caSettings['dockerRunning'] ?? false ) {
- $info = $DockerTemplates->getAllInfo(false,true,true);
- $containers = $DockerClient->getDockerContainers();
- foreach ($containers as &$container) {
- $container['running'] = $info[$container['Name']]['running'] ?? null;
- $container['url'] = $info[$container['Name']]['url'] ?? null;
- $container['template'] = $info[$container['Name']]['template'] ?? null;
- }
- }
- debug("Forced info update");
- writeJsonFile($caPaths['info'],$containers);
- } else {
- debug("Cached info update");
- }
- return $containers;
+ if ( $force || ! $containers || empty($containers) ) {
+ if ( $caSettings['dockerRunning'] ?? false ) {
+ $info = $DockerTemplates->getAllInfo(false,true,true);
+ $containers = $DockerClient->getDockerContainers();
+ foreach ($containers as &$container) {
+ $container['running'] = $info[$container['Name']]['running'] ?? null;
+ $container['url'] = $info[$container['Name']]['url'] ?? null;
+ $container['template'] = $info[$container['Name']]['template'] ?? null;
+ }
+ }
+ debug("Forced info update");
+ writeJsonFile($caPaths['info'],$containers);
+ } else {
+ debug("Cached info update");
+ }
+ return $containers;
}
#######################
# Logs the debug info #
#######################
function debug($str) {
- global $caSettings, $caPaths;
+ global $caSettings, $caPaths;
- if ( $caSettings['debugging'] == "yes" ) {
- if ( ! is_file($caPaths['logging']) ) {
- touch($caPaths['logging']);
- $caVersion = plugin("version","/var/log/plugins/community.applications.plg");
+ if ( $caSettings['debugging'] == "yes" ) {
+ if ( ! is_file($caPaths['logging']) ) {
+ touch($caPaths['logging']);
+ $caVersion = plugin("version","/var/log/plugins/community.applications.plg");
- 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";
- debug("Language: $lingo");
- debug("Settings:\n".print_r($caSettings,true));
- }
- @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
- }
+ 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";
+ debug("Language: $lingo");
+ debug("Settings:\n".print_r($caSettings,true));
+ }
+ @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
+ }
}
########################################
# Gets the default ports in a template #
########################################
function portsUsed($template) {
- if ( ($template['Network'] ?? "whatever") !== "bridge")
- return;
- $portsUsed = [];
- if ( isset($template['Config']['@attributes']) )
- $template['Config'] = ['@attributes'=>$template['Config']];
- if ( is_array($template['Config']) ) {
- foreach ($template['Config'] as $config) {
- if ( $config['@attributes']['Type'] !== "Port" )
- continue;
- $portsUsed[] = $config['value'] ?: $config['@attributes']['Default'];
- }
- }
- return json_encode($portsUsed);
+ if ( ($template['Network'] ?? "whatever") !== "bridge")
+ return;
+ $portsUsed = [];
+ if ( isset($template['Config']['@attributes']) )
+ $template['Config'] = ['@attributes'=>$template['Config']];
+ if ( is_array($template['Config']) ) {
+ foreach ($template['Config'] as $config) {
+ if ( $config['@attributes']['Type'] !== "Port" )
+ continue;
+ $portsUsed[] = $config['value'] ?: $config['@attributes']['Default'];
+ }
+ }
+ return json_encode($portsUsed);
}
########################
# Get the ports in use #
########################
function getPortsInUse() {
- global $var, $caPaths;
+ global $var, $caPaths;
- $addr = null;
- if ( !$var )
- $var = parse_ini_file($caPaths['unRaidVars']);
+ $addr = null;
+ if ( !$var )
+ $var = parse_ini_file($caPaths['unRaidVars']);
- $portsInUse = [];
- exec("lsof -Pni|awk '/LISTEN/ && \$9!~/127.0.0.1/ && \$9!~/\\[::1\\]/{print \$9}'|sort -u", $output);
+ $portsInUse = [];
+ exec("lsof -Pni|awk '/LISTEN/ && \$9!~/127.0.0.1/ && \$9!~/\\[::1\\]/{print \$9}'|sort -u", $output);
- $bind = $var['BIND_MGT']=='yes';
- $list = is_array($addr) ? array_merge(['*'],$addr) : ['*',$addr];
+ $bind = $var['BIND_MGT']=='yes';
+ $list = is_array($addr) ? array_merge(['*'],$addr) : ['*',$addr];
- foreach ($output as $line) {
- [$ip, $port] = ca_explode(':', $line);
- if (!in_array($port,$portsInUse) && (!$bind || in_array(plain($ip),$list)))
- if ( is_numeric($port) )
- $portsInUse[] = $port;
- }
+ foreach ($output as $line) {
+ [$ip, $port] = ca_explode(':', $line);
+ if (!in_array($port,$portsInUse) && (!$bind || in_array(plain($ip),$list)))
+ if ( is_numeric($port) )
+ $portsInUse[] = $port;
+ }
- return $portsInUse;
+ return $portsInUse;
}
function ca_explode($split,$text,$count=2) {
- return array_pad(explode($split,$text,$count),$count,'');
+ return array_pad(explode($split,$text,$count),$count,'');
}
function plain($ip) {
- return str_replace(['[',']'],'',$ip);
+ return str_replace(['[',']'],'',$ip);
}
##################################################################################
# Adds in all the various missing entries from the templates for PHP8 compliance #
##################################################################################
function addMissingVars($o) {
- if ( ! is_array($o) )
- return $o;
- $vars = [
- 'Category',
- 'CategoryList',
- 'CABlacklist',
- 'Blacklist',
- 'MinVer',
- 'MaxVer',
- 'UpdateMinVer',
- 'Plugin',
- 'PluginURL',
- 'Date',
- 'DonateText',
- 'DonateLink',
- 'Branch',
- 'OriginalOverview',
- 'DateInstalled',
- 'Config',
- 'trending',
- 'CAComment',
- 'ModeratorComment',
- 'DeprecatedMaxVer',
- 'downloads',
- 'FirstSeen',
- 'OriginalDescription',
- 'Deprecated',
- 'RecommendedRaw',
- 'Language',
- 'RequiresFile',
- 'Requires',
- 'trends',
- 'Description',
- 'OriginalDescription',
- 'Overview',
- 'Repository',
- 'Tag',
- 'Plugin',
- 'CaComment',
- 'IncompatibleVersion',
- 'Private',
- 'BranchName',
- 'display',
- 'RepositoryTemplate',
- 'bio',
- 'NoInstall',
- 'Twitter',
- 'Discord',
- 'Reddit',
- 'Facebook',
- 'ReadMe',
- 'display_dockerName',
- 'actionCentre',
- 'SupportLanguage',
- 'DockerHub',
- 'Official',
- 'Removable',
- 'IconFA',
- 'imageNoClick',
- 'RecommendedDate',
- 'UpdateAvailable',
- 'Installed',
- 'Uninstall',
- 'caTemplateExists',
- 'Support',
- 'Beta',
- 'Project',
- 'Trusted',
- 'InstallPath',
- 'LanguagePack',
- 'trendDelta',
- 'RepoTemplate',
- 'ExtraSearchTerms',
- 'Icon',
- 'LanguageDefault',
- 'translatedCategories',
- 'RepoShort',
- 'LanguageLocal',
- 'ExtraPriority',
- 'Registry',
- 'caTemplateURL',
- 'Changes',
- 'ChangeLogPresent',
- 'Photo',
- 'Screenshot',
- 'Video',
- 'RecommendedReason',
- 'stars',
- 'LanguageURL',
- 'LastUpdate',
- 'RecommendedWho',
- 'RepoName',
- 'SortName',
- 'ca_fav',
- 'Pinned'
+ if ( ! is_array($o) )
+ return $o;
+ $vars = [
+ 'Category',
+ 'CategoryList',
+ 'CABlacklist',
+ 'Blacklist',
+ 'MinVer',
+ 'MaxVer',
+ 'UpdateMinVer',
+ 'Plugin',
+ 'PluginURL',
+ 'Date',
+ 'DonateText',
+ 'DonateLink',
+ 'Branch',
+ 'OriginalOverview',
+ 'DateInstalled',
+ 'Config',
+ 'trending',
+ 'CAComment',
+ 'ModeratorComment',
+ 'DeprecatedMaxVer',
+ 'downloads',
+ 'FirstSeen',
+ 'OriginalDescription',
+ 'Deprecated',
+ 'RecommendedRaw',
+ 'Language',
+ 'RequiresFile',
+ 'Requires',
+ 'trends',
+ 'Description',
+ 'OriginalDescription',
+ 'Overview',
+ 'Repository',
+ 'Tag',
+ 'Plugin',
+ 'CaComment',
+ 'IncompatibleVersion',
+ 'Private',
+ 'BranchName',
+ 'display',
+ 'RepositoryTemplate',
+ 'bio',
+ 'NoInstall',
+ 'Twitter',
+ 'Discord',
+ 'Reddit',
+ 'Facebook',
+ 'ReadMe',
+ 'display_dockerName',
+ 'actionCentre',
+ 'SupportLanguage',
+ 'DockerHub',
+ 'Official',
+ 'Removable',
+ 'IconFA',
+ 'imageNoClick',
+ 'RecommendedDate',
+ 'UpdateAvailable',
+ 'Installed',
+ 'Uninstall',
+ 'caTemplateExists',
+ 'Support',
+ 'Beta',
+ 'Project',
+ 'Trusted',
+ 'InstallPath',
+ 'LanguagePack',
+ 'trendDelta',
+ 'RepoTemplate',
+ 'ExtraSearchTerms',
+ 'Icon',
+ 'LanguageDefault',
+ 'translatedCategories',
+ 'RepoShort',
+ 'LanguageLocal',
+ 'ExtraPriority',
+ 'Registry',
+ 'caTemplateURL',
+ 'Changes',
+ 'ChangeLogPresent',
+ 'Photo',
+ 'Screenshot',
+ 'Video',
+ 'RecommendedReason',
+ 'stars',
+ 'LanguageURL',
+ 'LastUpdate',
+ 'RecommendedWho',
+ 'RepoName',
+ 'SortName',
+ 'ca_fav',
+ 'Pinned'
- ];
+ ];
- foreach ($vars as $var) {
- $o[$var] = $o[$var] ?? null;
- }
- return $o;
+ foreach ($vars as $var) {
+ $o[$var] = $o[$var] ?? null;
+ }
+ return $o;
}
@@ -877,483 +877,483 @@ function addMissingVars($o) {
*/
class TypeConverter {
- /**
- * Disregard XML attributes and only return the value.
- */
- const XML_NONE = 0;
+ /**
+ * Disregard XML attributes and only return the value.
+ */
+ const XML_NONE = 0;
- /**
- * Merge attributes and the value into a single dimension; the values key will be "value".
- */
- const XML_MERGE = 1;
+ /**
+ * Merge attributes and the value into a single dimension; the values key will be "value".
+ */
+ const XML_MERGE = 1;
- /**
- * Group the attributes into a key "attributes" and the value into a key of "value".
- */
- const XML_GROUP = 2;
+ /**
+ * Group the attributes into a key "attributes" and the value into a key of "value".
+ */
+ const XML_GROUP = 2;
- /**
- * Attributes will only be returned.
- */
- const XML_OVERWRITE = 3;
+ /**
+ * Attributes will only be returned.
+ */
+ const XML_OVERWRITE = 3;
- /**
- * Returns a string for the detected type.
- *
- * @access public
- * @param mixed $data
- * @return string
- * @static
- */
- public static function is($data) {
- if (self::isArray($data)) {
- return 'array';
+ /**
+ * Returns a string for the detected type.
+ *
+ * @access public
+ * @param mixed $data
+ * @return string
+ * @static
+ */
+ public static function is($data) {
+ if (self::isArray($data)) {
+ return 'array';
- } else if (self::isObject($data)) {
- return 'object';
+ } else if (self::isObject($data)) {
+ return 'object';
- } else if (self::isJson($data)) {
- return 'json';
+ } else if (self::isJson($data)) {
+ return 'json';
- } else if (self::isSerialized($data)) {
- return 'serialized';
+ } else if (self::isSerialized($data)) {
+ return 'serialized';
- } else if (self::isXml($data)) {
- return 'xml';
- }
+ } else if (self::isXml($data)) {
+ return 'xml';
+ }
- return 'other';
- }
+ return 'other';
+ }
- /**
- * Check to see if data passed is an array.
- *
- * @access public
- * @param mixed $data
- * @return boolean
- * @static
- */
- public static function isArray($data) {
- return is_array($data);
- }
+ /**
+ * Check to see if data passed is an array.
+ *
+ * @access public
+ * @param mixed $data
+ * @return boolean
+ * @static
+ */
+ public static function isArray($data) {
+ return is_array($data);
+ }
- /**
- * Check to see if data passed is a JSON object.
- *
- * @access public
- * @param mixed $data
- * @return boolean
- * @static
- */
- public static function isJson($data) {
- return (@json_decode($data) !== null);
- }
+ /**
+ * Check to see if data passed is a JSON object.
+ *
+ * @access public
+ * @param mixed $data
+ * @return boolean
+ * @static
+ */
+ public static function isJson($data) {
+ return (@json_decode($data) !== null);
+ }
- /**
- * Check to see if data passed is an object.
- *
- * @access public
- * @param mixed $data
- * @return boolean
- * @static
- */
- public static function isObject($data) {
- return is_object($data);
- }
+ /**
+ * Check to see if data passed is an object.
+ *
+ * @access public
+ * @param mixed $data
+ * @return boolean
+ * @static
+ */
+ public static function isObject($data) {
+ return is_object($data);
+ }
- /**
- * Check to see if data passed has been serialized.
- *
- * @access public
- * @param mixed $data
- * @return boolean
- * @static
- */
- public static function isSerialized($data) {
- $ser = @unserialize($data);
+ /**
+ * Check to see if data passed has been serialized.
+ *
+ * @access public
+ * @param mixed $data
+ * @return boolean
+ * @static
+ */
+ public static function isSerialized($data) {
+ $ser = @unserialize($data);
- return ($ser !== false) ? $ser : false;
- }
+ return ($ser !== false) ? $ser : false;
+ }
- /**
- * Check to see if data passed is an XML document.
- *
- * @access public
- * @param mixed $data
- * @return boolean
- * @static
- */
- public static function isXml($data) {
- $xml = @simplexml_load_string($data);
+ /**
+ * Check to see if data passed is an XML document.
+ *
+ * @access public
+ * @param mixed $data
+ * @return boolean
+ * @static
+ */
+ public static function isXml($data) {
+ $xml = @simplexml_load_string($data);
- return ($xml instanceof SimpleXmlElement) ? $xml : false;
- }
+ return ($xml instanceof SimpleXmlElement) ? $xml : false;
+ }
- /**
- * Transforms a resource into an array.
- *
- * @access public
- * @param mixed $resource
- * @return array
- * @static
- */
- public static function toArray($resource) {
- if (self::isArray($resource)) {
- return $resource;
+ /**
+ * Transforms a resource into an array.
+ *
+ * @access public
+ * @param mixed $resource
+ * @return array
+ * @static
+ */
+ public static function toArray($resource) {
+ if (self::isArray($resource)) {
+ return $resource;
- } else if (self::isObject($resource)) {
- return self::buildArray($resource);
+ } else if (self::isObject($resource)) {
+ return self::buildArray($resource);
- } else if (self::isJson($resource)) {
- return json_decode($resource, true);
+ } else if (self::isJson($resource)) {
+ return json_decode($resource, true);
- } else if ($ser = self::isSerialized($resource)) {
- return self::toArray($ser);
+ } else if ($ser = self::isSerialized($resource)) {
+ return self::toArray($ser);
- } else if ($xml = self::isXml($resource)) {
- return self::xmlToArray($xml);
- }
+ } else if ($xml = self::isXml($resource)) {
+ return self::xmlToArray($xml);
+ }
- return $resource;
- }
+ return $resource;
+ }
- /**
- * Transforms a resource into a JSON object.
- *
- * @access public
- * @param mixed $resource
- * @return string (json)
- * @static
- */
- public static function toJson($resource) {
- if (self::isJson($resource)) {
- return $resource;
- }
+ /**
+ * Transforms a resource into a JSON object.
+ *
+ * @access public
+ * @param mixed $resource
+ * @return string (json)
+ * @static
+ */
+ public static function toJson($resource) {
+ if (self::isJson($resource)) {
+ return $resource;
+ }
- if ($xml = self::isXml($resource)) {
- $resource = self::xmlToArray($xml);
+ if ($xml = self::isXml($resource)) {
+ $resource = self::xmlToArray($xml);
- } else if ($ser = self::isSerialized($resource)) {
- $resource = $ser;
- }
+ } else if ($ser = self::isSerialized($resource)) {
+ $resource = $ser;
+ }
- return json_encode($resource);
- }
+ return json_encode($resource);
+ }
- /**
- * Transforms a resource into an object.
- *
- * @access public
- * @param mixed $resource
- * @return object
- * @static
- */
- public static function toObject($resource) {
- if (self::isObject($resource)) {
- return $resource;
+ /**
+ * Transforms a resource into an object.
+ *
+ * @access public
+ * @param mixed $resource
+ * @return object
+ * @static
+ */
+ public static function toObject($resource) {
+ if (self::isObject($resource)) {
+ return $resource;
- } else if (self::isArray($resource)) {
- return self::buildObject($resource);
+ } else if (self::isArray($resource)) {
+ return self::buildObject($resource);
- } else if (self::isJson($resource)) {
- return json_decode($resource);
+ } else if (self::isJson($resource)) {
+ return json_decode($resource);
- } else if ($ser = self::isSerialized($resource)) {
- return self::toObject($ser);
+ } else if ($ser = self::isSerialized($resource)) {
+ return self::toObject($ser);
- } else if ($xml = self::isXml($resource)) {
- return $xml;
- }
+ } else if ($xml = self::isXml($resource)) {
+ return $xml;
+ }
- return $resource;
- }
+ return $resource;
+ }
- /**
- * Transforms a resource into a serialized form.
- *
- * @access public
- * @param mixed $resource
- * @return string
- * @static
- */
- public static function toSerialize($resource) {
- if (!self::isArray($resource)) {
- $resource = self::toArray($resource);
- }
+ /**
+ * Transforms a resource into a serialized form.
+ *
+ * @access public
+ * @param mixed $resource
+ * @return string
+ * @static
+ */
+ public static function toSerialize($resource) {
+ if (!self::isArray($resource)) {
+ $resource = self::toArray($resource);
+ }
- return serialize($resource);
- }
+ return serialize($resource);
+ }
- /**
- * Transforms a resource into an XML document.
- *
- * @access public
- * @param mixed $resource
- * @param string $root
- * @return string (xml)
- * @static
- */
- public static function toXml($resource, $root = 'root') {
- if (self::isXml($resource)) {
- return $resource;
- }
+ /**
+ * Transforms a resource into an XML document.
+ *
+ * @access public
+ * @param mixed $resource
+ * @param string $root
+ * @return string (xml)
+ * @static
+ */
+ public static function toXml($resource, $root = 'root') {
+ if (self::isXml($resource)) {
+ return $resource;
+ }
- $array = self::toArray($resource);
+ $array = self::toArray($resource);
- if (!empty($array)) {
- $xml = simplexml_load_string('<'. $root .'>'. $root .'>');
- $response = self::buildXml($xml, $array);
+ if (!empty($array)) {
+ $xml = simplexml_load_string('<'. $root .'>'. $root .'>');
+ $response = self::buildXml($xml, $array);
- return $response->asXML();
- }
+ return $response->asXML();
+ }
- return $resource;
- }
+ return $resource;
+ }
- /**
- * Turn an object into an array. Alternative to array_map magic.
- *
- * @access public
- * @param object $object
- * @return array
- */
- public static function buildArray($object) {
- $array = array();
+ /**
+ * Turn an object into an array. Alternative to array_map magic.
+ *
+ * @access public
+ * @param object $object
+ * @return array
+ */
+ public static function buildArray($object) {
+ $array = array();
- foreach ($object as $key => $value) {
- if (is_object($value)) {
- $array[$key] = self::buildArray($value);
- } else {
- $array[$key] = $value;
- }
- }
+ foreach ($object as $key => $value) {
+ if (is_object($value)) {
+ $array[$key] = self::buildArray($value);
+ } else {
+ $array[$key] = $value;
+ }
+ }
- return $array;
- }
+ return $array;
+ }
- /**
- * Turn an array into an object. Alternative to array_map magic.
- *
- * @access public
- * @param array $array
- * @return object
- */
- public static function buildObject($array) {
- $obj = new \stdClass();
+ /**
+ * Turn an array into an object. Alternative to array_map magic.
+ *
+ * @access public
+ * @param array $array
+ * @return object
+ */
+ public static function buildObject($array) {
+ $obj = new \stdClass();
- foreach ($array as $key => $value) {
- if (is_array($value)) {
- $obj->{$key} = self::buildObject($value);
- } else {
- $obj->{$key} = $value;
- }
- }
+ foreach ($array as $key => $value) {
+ if (is_array($value)) {
+ $obj->{$key} = self::buildObject($value);
+ } else {
+ $obj->{$key} = $value;
+ }
+ }
- return $obj;
- }
+ return $obj;
+ }
- /**
- * Turn an array into an XML document. Alternative to array_map magic.
- *
- * @access public
- * @param object $xml
- * @param array $array
- * @return object
- */
- public static function buildXml(&$xml, $array) {
- if (is_array($array)) {
- foreach ($array as $key => $value) {
- // XML_NONE
- if (!is_array($value)) {
- $xml->addChild($key, $value);
- continue;
- }
+ /**
+ * Turn an array into an XML document. Alternative to array_map magic.
+ *
+ * @access public
+ * @param object $xml
+ * @param array $array
+ * @return object
+ */
+ public static function buildXml(&$xml, $array) {
+ if (is_array($array)) {
+ foreach ($array as $key => $value) {
+ // XML_NONE
+ if (!is_array($value)) {
+ $xml->addChild($key, $value);
+ continue;
+ }
- // Multiple nodes of the same name
- if (isset($value[0])) {
- foreach ($value as $kValue) {
- if (is_array($kValue)) {
- self::buildXml($xml, array($key => $kValue));
- } else {
- $xml->addChild($key, $kValue);
- }
- }
+ // Multiple nodes of the same name
+ if (isset($value[0])) {
+ foreach ($value as $kValue) {
+ if (is_array($kValue)) {
+ self::buildXml($xml, array($key => $kValue));
+ } else {
+ $xml->addChild($key, $kValue);
+ }
+ }
- // XML_GROUP
- } else if (isset($value['@attributes'])) {
- if (is_array($value['value'])) {
- $node = $xml->addChild($key);
- self::buildXml($node, $value['value']);
- } else {
- $node = $xml->addChild($key, $value['value']);
- }
+ // XML_GROUP
+ } else if (isset($value['@attributes'])) {
+ if (is_array($value['value'])) {
+ $node = $xml->addChild($key);
+ self::buildXml($node, $value['value']);
+ } else {
+ $node = $xml->addChild($key, $value['value']);
+ }
- if (!empty($value['@attributes'])) {
- foreach ($value['@attributes'] as $aKey => $aValue) {
- $node->addAttribute($aKey, $aValue);
- }
- }
+ if (!empty($value['@attributes'])) {
+ foreach ($value['@attributes'] as $aKey => $aValue) {
+ $node->addAttribute($aKey, $aValue);
+ }
+ }
- // XML_MERGE
- } else if (isset($value['value'])) {
- $node = $xml->addChild($key, $value['value']);
- unset($value['value']);
+ // XML_MERGE
+ } else if (isset($value['value'])) {
+ $node = $xml->addChild($key, $value['value']);
+ unset($value['value']);
- if (!empty($value)) {
- foreach ($value as $aKey => $aValue) {
- if (is_array($aValue)) {
- self::buildXml($node, array($aKey => $aValue));
- } else {
- $node->addAttribute($aKey, $aValue);
- }
- }
- }
+ if (!empty($value)) {
+ foreach ($value as $aKey => $aValue) {
+ if (is_array($aValue)) {
+ self::buildXml($node, array($aKey => $aValue));
+ } else {
+ $node->addAttribute($aKey, $aValue);
+ }
+ }
+ }
- // XML_OVERWRITE
- } else {
- $node = $xml->addChild($key);
+ // XML_OVERWRITE
+ } else {
+ $node = $xml->addChild($key);
- if (!empty($value)) {
- foreach ($value as $aKey => $aValue) {
- if (is_array($aValue)) {
- self::buildXml($node, array($aKey => $aValue));
- } else {
- $node->addChild($aKey, $aValue);
- }
- }
- }
- }
- }
- }
+ if (!empty($value)) {
+ foreach ($value as $aKey => $aValue) {
+ if (is_array($aValue)) {
+ self::buildXml($node, array($aKey => $aValue));
+ } else {
+ $node->addChild($aKey, $aValue);
+ }
+ }
+ }
+ }
+ }
+ }
- return $xml;
- }
+ return $xml;
+ }
- /**
- * Convert a SimpleXML object into an array.
- *
- * @access public
- * @param object $xml
- * @param int $format
- * @return array
- */
- public static function xmlToArray($xml, $format = self::XML_GROUP) {
- if (is_string($xml)) {
- $xml = @simplexml_load_string($xml);
- }
- if ( ! $xml ) { return false; }
- if (count($xml->children()) <= 0) {
- return (string)$xml;
- }
+ /**
+ * Convert a SimpleXML object into an array.
+ *
+ * @access public
+ * @param object $xml
+ * @param int $format
+ * @return array
+ */
+ public static function xmlToArray($xml, $format = self::XML_GROUP) {
+ if (is_string($xml)) {
+ $xml = @simplexml_load_string($xml);
+ }
+ if ( ! $xml ) { return false; }
+ if (count($xml->children()) <= 0) {
+ return (string)$xml;
+ }
- $array = array();
+ $array = array();
- foreach ($xml->children() as $element => $node) {
- $data = array();
+ foreach ($xml->children() as $element => $node) {
+ $data = array();
- if (!isset($array[$element])) {
+ if (!isset($array[$element])) {
# $array[$element] = "";
- $array[$element] = [];
- }
+ $array[$element] = [];
+ }
- if (!$node->attributes() || $format === self::XML_NONE) {
- $data = self::xmlToArray($node, $format);
+ if (!$node->attributes() || $format === self::XML_NONE) {
+ $data = self::xmlToArray($node, $format);
- } else {
- switch ($format) {
- case self::XML_GROUP:
- $data = array(
- '@attributes' => array(),
- 'value' => (string)$node
- );
+ } else {
+ switch ($format) {
+ case self::XML_GROUP:
+ $data = array(
+ '@attributes' => array(),
+ 'value' => (string)$node
+ );
- if (count($node->children()) > 0) {
- $data['value'] = self::xmlToArray($node, $format);
- }
+ if (count($node->children()) > 0) {
+ $data['value'] = self::xmlToArray($node, $format);
+ }
- foreach ($node->attributes() as $attr => $value) {
- $data['@attributes'][$attr] = (string)$value;
- }
- break;
+ foreach ($node->attributes() as $attr => $value) {
+ $data['@attributes'][$attr] = (string)$value;
+ }
+ break;
- case self::XML_MERGE:
- case self::XML_OVERWRITE:
- if ($format === self::XML_MERGE) {
- if (count($node->children()) > 0) {
- $data = $data + self::xmlToArray($node, $format);
- } else {
- $data['value'] = (string)$node;
- }
- }
+ case self::XML_MERGE:
+ case self::XML_OVERWRITE:
+ if ($format === self::XML_MERGE) {
+ if (count($node->children()) > 0) {
+ $data = $data + self::xmlToArray($node, $format);
+ } else {
+ $data['value'] = (string)$node;
+ }
+ }
- foreach ($node->attributes() as $attr => $value) {
- $data[$attr] = (string)$value;
- }
- break;
- }
- }
+ foreach ($node->attributes() as $attr => $value) {
+ $data[$attr] = (string)$value;
+ }
+ break;
+ }
+ }
- if (count($xml->{$element}) > 1) {
- $array[$element][] = $data;
- } else {
- $array[$element] = $data;
- }
- }
+ if (count($xml->{$element}) > 1) {
+ $array[$element][] = $data;
+ } else {
+ $array[$element] = $data;
+ }
+ }
- return $array;
- }
+ return $array;
+ }
- /**
- * Encode a resource object for UTF-8.
- *
- * @access public
- * @param mixed $data
- * @return array|string
- * @static
- */
- public static function utf8Encode($data) {
- if (is_string($data)) {
- return utf8_encode($data);
+ /**
+ * Encode a resource object for UTF-8.
+ *
+ * @access public
+ * @param mixed $data
+ * @return array|string
+ * @static
+ */
+ public static function utf8Encode($data) {
+ if (is_string($data)) {
+ return utf8_encode($data);
- } else if (is_array($data)) {
- foreach ($data as $key => $value) {
- $data[utf8_encode($key)] = self::utf8Encode($value);
- }
+ } else if (is_array($data)) {
+ foreach ($data as $key => $value) {
+ $data[utf8_encode($key)] = self::utf8Encode($value);
+ }
- } else if (is_object($data)) {
- foreach ($data as $key => $value) {
- $data->{$key} = self::utf8Encode($value);
- }
- }
+ } else if (is_object($data)) {
+ foreach ($data as $key => $value) {
+ $data->{$key} = self::utf8Encode($value);
+ }
+ }
- return $data;
- }
+ return $data;
+ }
- /**
- * Decode a resource object for UTF-8.
- *
- * @access public
- * @param mixed $data
- * @return array|string
- * @static
- */
- public static function utf8Decode($data) {
- if (is_string($data)) {
- return utf8_decode($data);
+ /**
+ * Decode a resource object for UTF-8.
+ *
+ * @access public
+ * @param mixed $data
+ * @return array|string
+ * @static
+ */
+ public static function utf8Decode($data) {
+ if (is_string($data)) {
+ return utf8_decode($data);
- } else if (is_array($data)) {
- foreach ($data as $key => $value) {
- $data[utf8_decode($key)] = self::utf8Decode($value);
- }
+ } else if (is_array($data)) {
+ foreach ($data as $key => $value) {
+ $data[utf8_decode($key)] = self::utf8Decode($value);
+ }
- } else if (is_object($data)) {
- foreach ($data as $key => $value) {
- $data->{$key} = self::utf8Decode($value);
- }
- }
+ } else if (is_object($data)) {
+ foreach ($data as $key => $value) {
+ $data->{$key} = self::utf8Decode($value);
+ }
+ }
- return $data;
- }
+ return $data;
+ }
}
@@ -1389,120 +1389,120 @@ class TypeConverter {
* echo $xml->saveXML();
*/
class Array2XML {
- private static $xml = null;
- private static $encoding = 'UTF-8';
- /**
- * Initialize the root XML node [optional]
- * @param $version
- * @param $encoding
- * @param $format_output
- */
- public static function init($version = '1.0', $encoding = 'UTF-8', $format_output = true) {
- self::$xml = new DomDocument($version, $encoding);
- self::$xml->formatOutput = $format_output;
- self::$encoding = $encoding;
- }
- /**
- * Convert an Array to XML
- * @param string $node_name - name of the root node to be converted
- * @param array $arr - aray to be converterd
- * @return DomDocument
- */
- public static function &createXML($node_name, $arr=array()) {
- $xml = self::getXMLRoot();
- $xml->appendChild(self::convert($node_name, $arr));
- self::$xml = null; // clear the xml node in the class for 2nd time use.
- return $xml;
- }
- /**
- * Convert an Array to XML
- * @param string $node_name - name of the root node to be converted
- * @param array $arr - aray to be converterd
- * @return DOMNode
- */
- private static function &convert($node_name, $arr=array()) {
- //print_arr($node_name);
- $xml = self::getXMLRoot();
- $node = $xml->createElement($node_name);
- if(is_array($arr)){
- // get the attributes first.;
- if(isset($arr['@attributes'])) {
- foreach($arr['@attributes'] as $key => $value) {
- if(!self::isValidTagName($key)) {
- throw new Exception('[Array2XML] Illegal character in attribute name. attribute: '.$key.' in node: '.$node_name);
- }
- $node->setAttribute($key, self::bool2str($value));
- }
- unset($arr['@attributes']); //remove the key from the array once done.
- }
- // check if it has a value stored in @value, if yes store the value and return
- // else check if its directly stored as string
- if(isset($arr['@value'])) {
- $node->appendChild($xml->createTextNode(self::bool2str($arr['@value'])));
- unset($arr['@value']); //remove the key from the array once done.
- //return from recursion, as a note with value cannot have child nodes.
- return $node;
- } else if(isset($arr['@cdata'])) {
- $node->appendChild($xml->createCDATASection(self::bool2str($arr['@cdata'])));
- unset($arr['@cdata']); //remove the key from the array once done.
- //return from recursion, as a note with cdata cannot have child nodes.
- return $node;
- }
- }
- //create subnodes using recursion
- if(is_array($arr)){
- // recurse to get the node for that key
- foreach($arr as $key=>$value){
- if(!self::isValidTagName($key)) {
- throw new Exception('[Array2XML] Illegal character in tag name. tag: '.$key.' in node: '.$node_name);
- }
- if(is_array($value) && is_numeric(key($value))) {
- // MORE THAN ONE NODE OF ITS KIND;
- // if the new array is numeric index, means it is array of nodes of the same kind
- // it should follow the parent key name
- foreach($value as $k=>$v){
- $node->appendChild(self::convert($key, $v));
- }
- } else {
- // ONLY ONE NODE OF ITS KIND
- $node->appendChild(self::convert($key, $value));
- }
- unset($arr[$key]); //remove the key from the array once done.
- }
- }
- // after we are done with all the keys in the array (if it is one)
- // we check if it has any text value, if yes, append it.
- if(!is_array($arr)) {
- $node->appendChild($xml->createTextNode(self::bool2str($arr ?? "")));
- }
- return $node;
- }
- /*
- * Get the root XML node, if there isn't one, create it.
- */
- private static function getXMLRoot(){
- if(empty(self::$xml)) {
- self::init();
- }
- return self::$xml;
- }
- /*
- * Get string representation of boolean value
- */
- private static function bool2str($v){
- //convert boolean to text value.
- $v = $v === true ? 'true' : $v;
- $v = $v === false ? 'false' : $v;
- return $v;
- }
- /*
- * Check if the tag name or attribute name contains illegal characters
- * Ref: http://www.w3.org/TR/xml/#sec-common-syn
- */
- private static function isValidTagName($tag){
- $pattern = '/^[a-z_]+[a-z0-9\:\-\.\_]*[^:]*$/i';
- return preg_match($pattern, $tag, $matches) && $matches[0] == $tag;
- }
+ private static $xml = null;
+ private static $encoding = 'UTF-8';
+ /**
+ * Initialize the root XML node [optional]
+ * @param $version
+ * @param $encoding
+ * @param $format_output
+ */
+ public static function init($version = '1.0', $encoding = 'UTF-8', $format_output = true) {
+ self::$xml = new DomDocument($version, $encoding);
+ self::$xml->formatOutput = $format_output;
+ self::$encoding = $encoding;
+ }
+ /**
+ * Convert an Array to XML
+ * @param string $node_name - name of the root node to be converted
+ * @param array $arr - aray to be converterd
+ * @return DomDocument
+ */
+ public static function &createXML($node_name, $arr=array()) {
+ $xml = self::getXMLRoot();
+ $xml->appendChild(self::convert($node_name, $arr));
+ self::$xml = null; // clear the xml node in the class for 2nd time use.
+ return $xml;
+ }
+ /**
+ * Convert an Array to XML
+ * @param string $node_name - name of the root node to be converted
+ * @param array $arr - aray to be converterd
+ * @return DOMNode
+ */
+ private static function &convert($node_name, $arr=array()) {
+ //print_arr($node_name);
+ $xml = self::getXMLRoot();
+ $node = $xml->createElement($node_name);
+ if(is_array($arr)){
+ // get the attributes first.;
+ if(isset($arr['@attributes'])) {
+ foreach($arr['@attributes'] as $key => $value) {
+ if(!self::isValidTagName($key)) {
+ throw new Exception('[Array2XML] Illegal character in attribute name. attribute: '.$key.' in node: '.$node_name);
+ }
+ $node->setAttribute($key, self::bool2str($value));
+ }
+ unset($arr['@attributes']); //remove the key from the array once done.
+ }
+ // check if it has a value stored in @value, if yes store the value and return
+ // else check if its directly stored as string
+ if(isset($arr['@value'])) {
+ $node->appendChild($xml->createTextNode(self::bool2str($arr['@value'])));
+ unset($arr['@value']); //remove the key from the array once done.
+ //return from recursion, as a note with value cannot have child nodes.
+ return $node;
+ } else if(isset($arr['@cdata'])) {
+ $node->appendChild($xml->createCDATASection(self::bool2str($arr['@cdata'])));
+ unset($arr['@cdata']); //remove the key from the array once done.
+ //return from recursion, as a note with cdata cannot have child nodes.
+ return $node;
+ }
+ }
+ //create subnodes using recursion
+ if(is_array($arr)){
+ // recurse to get the node for that key
+ foreach($arr as $key=>$value){
+ if(!self::isValidTagName($key)) {
+ throw new Exception('[Array2XML] Illegal character in tag name. tag: '.$key.' in node: '.$node_name);
+ }
+ if(is_array($value) && is_numeric(key($value))) {
+ // MORE THAN ONE NODE OF ITS KIND;
+ // if the new array is numeric index, means it is array of nodes of the same kind
+ // it should follow the parent key name
+ foreach($value as $k=>$v){
+ $node->appendChild(self::convert($key, $v));
+ }
+ } else {
+ // ONLY ONE NODE OF ITS KIND
+ $node->appendChild(self::convert($key, $value));
+ }
+ unset($arr[$key]); //remove the key from the array once done.
+ }
+ }
+ // after we are done with all the keys in the array (if it is one)
+ // we check if it has any text value, if yes, append it.
+ if(!is_array($arr)) {
+ $node->appendChild($xml->createTextNode(self::bool2str($arr ?? "")));
+ }
+ return $node;
+ }
+ /*
+ * Get the root XML node, if there isn't one, create it.
+ */
+ private static function getXMLRoot(){
+ if(empty(self::$xml)) {
+ self::init();
+ }
+ return self::$xml;
+ }
+ /*
+ * Get string representation of boolean value
+ */
+ private static function bool2str($v){
+ //convert boolean to text value.
+ $v = $v === true ? 'true' : $v;
+ $v = $v === false ? 'false' : $v;
+ return $v;
+ }
+ /*
+ * Check if the tag name or attribute name contains illegal characters
+ * Ref: http://www.w3.org/TR/xml/#sec-common-syn
+ */
+ private static function isValidTagName($tag){
+ $pattern = '/^[a-z_]+[a-z0-9\:\-\.\_]*[^:]*$/i';
+ return preg_match($pattern, $tag, $matches) && $matches[0] == $tag;
+ }
}
/**
@@ -1526,122 +1526,122 @@ class Array2XML {
class XML2Array {
- private static $xml = null;
- private static $encoding = 'UTF-8';
+ private static $xml = null;
+ private static $encoding = 'UTF-8';
- /**
- * Initialize the root XML node [optional]
- * @param $version
- * @param $encoding
- * @param $format_output
- */
- public static function init($version = '1.0', $encoding = 'UTF-8', $format_output = true) {
- self::$xml = new DOMDocument($version, $encoding);
- self::$xml->formatOutput = $format_output;
- self::$encoding = $encoding;
- }
+ /**
+ * Initialize the root XML node [optional]
+ * @param $version
+ * @param $encoding
+ * @param $format_output
+ */
+ public static function init($version = '1.0', $encoding = 'UTF-8', $format_output = true) {
+ self::$xml = new DOMDocument($version, $encoding);
+ self::$xml->formatOutput = $format_output;
+ self::$encoding = $encoding;
+ }
- /**
- * Convert an XML to Array
- * @param string $node_name - name of the root node to be converted
- * @param array $arr - aray to be converterd
- * @return DOMDocument
- */
- public static function &createArray($input_xml) {
- $xml = self::getXMLRoot();
- if(is_string($input_xml)) {
- $parsed = $xml->loadXML($input_xml);
- if(!$parsed) {
- throw new Exception('[XML2Array] Error parsing the XML string.');
- }
- } else {
- if(get_class($input_xml) != 'DOMDocument') {
- throw new Exception('[XML2Array] The input XML object should be of type: DOMDocument.');
- }
- $xml = self::$xml = $input_xml;
- }
- $array[$xml->documentElement->tagName] = self::convert($xml->documentElement);
- self::$xml = null; // clear the xml node in the class for 2nd time use.
- return $array;
- }
+ /**
+ * Convert an XML to Array
+ * @param string $node_name - name of the root node to be converted
+ * @param array $arr - aray to be converterd
+ * @return DOMDocument
+ */
+ public static function &createArray($input_xml) {
+ $xml = self::getXMLRoot();
+ if(is_string($input_xml)) {
+ $parsed = $xml->loadXML($input_xml);
+ if(!$parsed) {
+ throw new Exception('[XML2Array] Error parsing the XML string.');
+ }
+ } else {
+ if(get_class($input_xml) != 'DOMDocument') {
+ throw new Exception('[XML2Array] The input XML object should be of type: DOMDocument.');
+ }
+ $xml = self::$xml = $input_xml;
+ }
+ $array[$xml->documentElement->tagName] = self::convert($xml->documentElement);
+ self::$xml = null; // clear the xml node in the class for 2nd time use.
+ return $array;
+ }
- /**
- * Convert an Array to XML
- * @param mixed $node - XML as a string or as an object of DOMDocument
- * @return mixed
- */
- private static function &convert($node) {
- $output = array();
+ /**
+ * Convert an Array to XML
+ * @param mixed $node - XML as a string or as an object of DOMDocument
+ * @return mixed
+ */
+ private static function &convert($node) {
+ $output = array();
- switch ($node->nodeType) {
- case XML_CDATA_SECTION_NODE:
- $output['@cdata'] = trim($node->textContent);
- break;
+ switch ($node->nodeType) {
+ case XML_CDATA_SECTION_NODE:
+ $output['@cdata'] = trim($node->textContent);
+ break;
- case XML_TEXT_NODE:
- $output = trim($node->textContent);
- break;
+ case XML_TEXT_NODE:
+ $output = trim($node->textContent);
+ break;
- case XML_ELEMENT_NODE:
+ case XML_ELEMENT_NODE:
- // for each child node, call the covert function recursively
- for ($i=0, $m=$node->childNodes->length; $i<$m; $i++) {
- $child = $node->childNodes->item($i);
- $v = self::convert($child);
- if(isset($child->tagName)) {
- $t = $child->tagName;
+ // for each child node, call the covert function recursively
+ for ($i=0, $m=$node->childNodes->length; $i<$m; $i++) {
+ $child = $node->childNodes->item($i);
+ $v = self::convert($child);
+ if(isset($child->tagName)) {
+ $t = $child->tagName;
- // assume more nodes of same kind are coming
- if(!isset($output[$t])) {
- $output[$t] = array();
- }
- $output[$t][] = $v;
- } else {
- //check if it is not an empty text node
- if($v !== '') {
- $output = $v;
- }
- }
- }
+ // assume more nodes of same kind are coming
+ if(!isset($output[$t])) {
+ $output[$t] = array();
+ }
+ $output[$t][] = $v;
+ } else {
+ //check if it is not an empty text node
+ if($v !== '') {
+ $output = $v;
+ }
+ }
+ }
- if(is_array($output)) {
- // if only one node of its kind, assign it directly instead if array($value);
- foreach ($output as $t => $v) {
- if(is_array($v) && count($v)==1) {
- $output[$t] = $v[0];
- }
- }
- if(empty($output)) {
- //for empty nodes
- $output = '';
- }
- }
+ if(is_array($output)) {
+ // if only one node of its kind, assign it directly instead if array($value);
+ foreach ($output as $t => $v) {
+ if(is_array($v) && count($v)==1) {
+ $output[$t] = $v[0];
+ }
+ }
+ if(empty($output)) {
+ //for empty nodes
+ $output = '';
+ }
+ }
- // loop through the attributes and collect them
- if($node->attributes->length) {
- $a = array();
- foreach($node->attributes as $attrName => $attrNode) {
- $a[$attrName] = (string) $attrNode->value;
- }
- // if its an leaf node, store the value in @value instead of directly storing it.
- if(!is_array($output)) {
- $output = array('@value' => $output);
- }
- $output['@attributes'] = $a;
- }
- break;
- }
- return $output;
- }
+ // loop through the attributes and collect them
+ if($node->attributes->length) {
+ $a = array();
+ foreach($node->attributes as $attrName => $attrNode) {
+ $a[$attrName] = (string) $attrNode->value;
+ }
+ // if its an leaf node, store the value in @value instead of directly storing it.
+ if(!is_array($output)) {
+ $output = array('@value' => $output);
+ }
+ $output['@attributes'] = $a;
+ }
+ break;
+ }
+ return $output;
+ }
- /*
- * Get the root XML node, if there isn't one, create it.
- */
- private static function getXMLRoot(){
- if(empty(self::$xml)) {
- self::init();
- }
- return self::$xml;
- }
+ /*
+ * Get the root XML node, if there isn't one, create it.
+ */
+ private static function getXMLRoot(){
+ if(empty(self::$xml)) {
+ self::init();
+ }
+ return self::$xml;
+ }
}
?>
\ No newline at end of file
diff --git a/source/community.applications/usr/local/emhttp/plugins/community.applications/include/paths.php b/source/community.applications/usr/local/emhttp/plugins/community.applications/include/paths.php
index d661dee9..fa7039e7 100644
--- a/source/community.applications/usr/local/emhttp/plugins/community.applications/include/paths.php
+++ b/source/community.applications/usr/local/emhttp/plugins/community.applications/include/paths.php
@@ -12,18 +12,18 @@ require_once "$docroot/plugins/dynamix/include/Wrappers.php";
$CA = "community.applications";
if ( ! isset($dockerManPaths) ) {
- $dockerManPaths = [
- 'autostart-file' => "/var/lib/docker/unraid-autostart",
- 'update-status' => "/var/lib/docker/unraid-update-status.json",
- 'template-repos' => "/boot/config/plugins/dockerMan/template-repos",
- 'templates-user' => "/boot/config/plugins/dockerMan/templates-user",
- 'templates-usb' => "/boot/config/plugins/dockerMan/templates",
- 'images' => "/var/lib/docker/unraid/images",
- 'user-prefs' => "/boot/config/plugins/dockerMan/userprefs.cfg",
- 'plugin' => "$docroot/plugins/dynamix.docker.manager",
- 'images-ram' => "$docroot/state/plugins/dynamix.docker.manager/images",
- 'webui-info' => "$docroot/state/plugins/dynamix.docker.manager/docker.json"
- ];
+ $dockerManPaths = [
+ 'autostart-file' => "/var/lib/docker/unraid-autostart",
+ 'update-status' => "/var/lib/docker/unraid-update-status.json",
+ 'template-repos' => "/boot/config/plugins/dockerMan/template-repos",
+ 'templates-user' => "/boot/config/plugins/dockerMan/templates-user",
+ 'templates-usb' => "/boot/config/plugins/dockerMan/templates",
+ 'images' => "/var/lib/docker/unraid/images",
+ 'user-prefs' => "/boot/config/plugins/dockerMan/userprefs.cfg",
+ 'plugin' => "$docroot/plugins/dynamix.docker.manager",
+ 'images-ram' => "$docroot/state/plugins/dynamix.docker.manager/images",
+ 'webui-info' => "$docroot/state/plugins/dynamix.docker.manager/docker.json"
+ ];
}
$caPaths['tempFiles'] = "/tmp/$CA/tempFiles"; /* path to temporary files */
diff --git a/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/checkForUpdates.php b/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/checkForUpdates.php
index 03ab66d4..93df1403 100644
--- a/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/checkForUpdates.php
+++ b/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/checkForUpdates.php
@@ -14,8 +14,8 @@ require_once "$docroot/plugins/community.applications/include/paths.php";
require_once "$docroot/plugins/community.applications/include/helpers.php";
if ( is_file($caPaths['updateRunning']) && file_exists("/proc/".@file_get_contents($caPaths['updateRunning'])) ) {
- echo tr("Check for updates already running")."\n";
- exit();
+ echo tr("Check for updates already running")."\n";
+ exit();
}
file_put_contents($caPaths['updateRunning'],getmypid());
@@ -25,16 +25,16 @@ echo tr("Checking for docker container updates")."\n";
exec("$docroot/plugins/dynamix.docker.manager/scripts/dockerupdate check nonotify > /dev/null 2>&1");
echo tr("Checking for plugin updates")."\n";
foreach (glob("/var/log/plugins/*.plg") as $plg) {
- if ( $plg == "/var/log/plugins/community.applications.plg" || $plg == "/var/log/plugins/unRAIDServer.plg" || $plg == "/var/log/plugins/gui.search.plg" || $plg == "/var/log/plugins/page.notes.plg")
- continue; // avoid possible race condition since CA / gui.search automatically check for updates for themselves when on Apps tab
- echo sprintf(tr("Checking %s"),$plg)."\n";
- exec("$docroot/plugins/dynamix.plugin.manager/scripts/plugin check ".escapeshellarg(basename($plg))." > /dev/null 2>&1");
+ if ( $plg == "/var/log/plugins/community.applications.plg" || $plg == "/var/log/plugins/unRAIDServer.plg" || $plg == "/var/log/plugins/gui.search.plg" || $plg == "/var/log/plugins/page.notes.plg")
+ continue; // avoid possible race condition since CA / gui.search automatically check for updates for themselves when on Apps tab
+ echo sprintf(tr("Checking %s"),$plg)."\n";
+ exec("$docroot/plugins/dynamix.plugin.manager/scripts/plugin check ".escapeshellarg(basename($plg))." > /dev/null 2>&1");
}
echo tr("Checking for language updates")."\n";
foreach (glob("/var/log/plugins/lang-*.xml") as $lang) {
- $lingo = str_replace(["lang-",".xml"],["",""],$lang);
- echo sprintf(tr("Checking %s"),basename($lingo))."\n";
- exec("$docroot/plugins/dynamix.plugin.manager/scripts/language check ".basename($lingo));
+ $lingo = str_replace(["lang-",".xml"],["",""],$lang);
+ echo sprintf(tr("Checking %s"),basename($lingo))."\n";
+ exec("$docroot/plugins/dynamix.plugin.manager/scripts/language check ".basename($lingo));
}
@unlink($caPaths['updateRunning']);
?>
\ No newline at end of file
diff --git a/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/dockerConvert.php b/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/dockerConvert.php
index baba28b7..5e31b27a 100644
--- a/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/dockerConvert.php
+++ b/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/dockerConvert.php
@@ -28,141 +28,141 @@ $javascript = file_get_contents("/usr/local/emhttp/plugins/dynamix/javascript/dy
echo "";
if ( $_GET['ID'] !== false) {
- $dockerID = $_GET['ID'];
- $file = readJsonFile($caPaths['dockerSearchResults']);
- $dockerIndex = searchArray($file['results'],"ID",$dockerID);
- $docker = $file['results'][$dockerIndex];
- $docker['Description'] = str_replace("&", "&", $docker['Description']);
+ $dockerID = $_GET['ID'];
+ $file = readJsonFile($caPaths['dockerSearchResults']);
+ $dockerIndex = searchArray($file['results'],"ID",$dockerID);
+ $docker = $file['results'][$dockerIndex];
+ $docker['Description'] = str_replace("&", "&", $docker['Description']);
- $dockerfile['Name'] = "CA_TEST_CONTAINER_DOCKERHUB";
- $dockerfile['Support'] = $docker['DockerHub'];
- $dockerfile['Description'] = $docker['Description']."\n\nConverted By Community Applications Always verify this template (and values) against the support page for the container\n\n{$docker['DockerHub']}";
- $dockerfile['Overview'] = $dockerfile['Description'];
- $dockerfile['Registry'] = $docker['DockerHub'];
- $dockerfile['Repository'] = $docker['Repository'];
- $dockerfile['BindTime'] = "true";
- $dockerfile['Privileged'] = "false";
- $dockerfile['Networking']['Mode'] = "bridge";
- $dockerXML = makeXML($dockerfile);
- file_put_contents("/boot/config/plugins/dockerMan/templates-user/my-CA_TEST_CONTAINER_DOCKERHUB.xml",$dockerXML);
-
-
- echo "";
- $dockers = ["CA_TEST_CONTAINER_DOCKERHUB"];
- echo sprintf(tr("Installing test container"),str_replace(",",", ",$_GET['docker'] ?? ""))."
";
- $_GET['updateContainer'] = true;
- $_GET['ct'] = $dockers;
- $_GET['communityApplications'] = true;
- $_GET['mute'] = false;
- @include($exeFile); # under new GUI, this line returns a duplicated session_start() error.
- echo "
";
+ $dockerfile['Name'] = "CA_TEST_CONTAINER_DOCKERHUB";
+ $dockerfile['Support'] = $docker['DockerHub'];
+ $dockerfile['Description'] = $docker['Description']."\n\nConverted By Community Applications Always verify this template (and values) against the support page for the container\n\n{$docker['DockerHub']}";
+ $dockerfile['Overview'] = $dockerfile['Description'];
+ $dockerfile['Registry'] = $docker['DockerHub'];
+ $dockerfile['Repository'] = $docker['Repository'];
+ $dockerfile['BindTime'] = "true";
+ $dockerfile['Privileged'] = "false";
+ $dockerfile['Networking']['Mode'] = "bridge";
+ $dockerXML = makeXML($dockerfile);
+ file_put_contents("/boot/config/plugins/dockerMan/templates-user/my-CA_TEST_CONTAINER_DOCKERHUB.xml",$dockerXML);
+
+
+ echo "";
+ $dockers = ["CA_TEST_CONTAINER_DOCKERHUB"];
+ echo sprintf(tr("Installing test container"),str_replace(",",", ",$_GET['docker'] ?? ""))."
";
+ $_GET['updateContainer'] = true;
+ $_GET['ct'] = $dockers;
+ $_GET['communityApplications'] = true;
+ $_GET['mute'] = false;
+ @include($exeFile); # under new GUI, this line returns a duplicated session_start() error.
+ echo "
";
?>
- $output = shell_exec("docker inspect CA_TEST_CONTAINER_DOCKERHUB");
- echo "
".tr("Removing test installation")."
";
- exec("docker rm CA_TEST_CONTAINER_DOCKERHUB");
-
- exec("docker rmi {$docker['Repository']}");
- @unlink("/boot/config/plugins/dockerMan/templates-user/my-CA_TEST_CONTAINER_DOCKERHUB.xml");
-
- $json = json_decode($output,true);
- if ( $json ) {
- $paths = isset($json[0]['Mounts']) ? $json[0]['Mounts'] : [];
- $ports = isset($json[0]['Config']['ExposedPorts']) ? $json[0]['Config']['ExposedPorts'] : [];
- $vars = isset($json[0]['Config']['Env']) ? $json[0]['Config']['Env'] : [];
-
- $count = 1;
- $Config = [];
- foreach ($paths as $path) {
- $p = ["Name"=>"Container Path $count",'Type'=>"Path","Target"=>$path['Destination'],"Default"=>"","Mode"=>"rw","Display"=>"always","Required"=>"false","Mask"=>"false"];
- if ( $unRaid69 ) $p['Description'] = "Container Path: {$path['Destination']}";
- $Config[]['@attributes'] = $p;
- $count++;
- }
- $count = 1;
- foreach ($ports as $port => $name) {
- $pp = explode("/",$port);
- $p = ["Name"=>"Container Port $count",'Type'=>"Port","Target"=>$pp[0],"Default"=>$pp[0],"Mode"=>$pp[1],"Display"=>"always","Required"=>"false","Mask"=>"false","Description"=>""];
- if ( $unRaid69 ) $p['Description'] = "Container Port: {$pp[0]}";
- $Config[]['@attributes'] = $p;
- $count++;
- }
- $textvars = "";
- foreach ($vars as $var) {
- $textvars .= "$var\n";
- }
- $testvars = @parse_ini_string($textvars) ?: [];
- $defaultvars = ["HOST_HOSTNAME","HOST_OS","HOST_CONTAINERNAME","TZ","PATH"];
- $count = 1;
- foreach ($testvars as $var => $varcont) {
- if ( in_array($var,$defaultvars) )
- continue;
+ $output = shell_exec("docker inspect CA_TEST_CONTAINER_DOCKERHUB");
+ echo "
".tr("Removing test installation")."
";
+ exec("docker rm CA_TEST_CONTAINER_DOCKERHUB");
+
+ exec("docker rmi {$docker['Repository']}");
+ @unlink("/boot/config/plugins/dockerMan/templates-user/my-CA_TEST_CONTAINER_DOCKERHUB.xml");
+
+ $json = json_decode($output,true);
+ if ( $json ) {
+ $paths = isset($json[0]['Mounts']) ? $json[0]['Mounts'] : [];
+ $ports = isset($json[0]['Config']['ExposedPorts']) ? $json[0]['Config']['ExposedPorts'] : [];
+ $vars = isset($json[0]['Config']['Env']) ? $json[0]['Config']['Env'] : [];
+
+ $count = 1;
+ $Config = [];
+ foreach ($paths as $path) {
+ $p = ["Name"=>"Container Path $count",'Type'=>"Path","Target"=>$path['Destination'],"Default"=>"","Mode"=>"rw","Display"=>"always","Required"=>"false","Mask"=>"false"];
+ if ( $unRaid69 ) $p['Description'] = "Container Path: {$path['Destination']}";
+ $Config[]['@attributes'] = $p;
+ $count++;
+ }
+ $count = 1;
+ foreach ($ports as $port => $name) {
+ $pp = explode("/",$port);
+ $p = ["Name"=>"Container Port $count",'Type'=>"Port","Target"=>$pp[0],"Default"=>$pp[0],"Mode"=>$pp[1],"Display"=>"always","Required"=>"false","Mask"=>"false","Description"=>""];
+ if ( $unRaid69 ) $p['Description'] = "Container Port: {$pp[0]}";
+ $Config[]['@attributes'] = $p;
+ $count++;
+ }
+ $textvars = "";
+ foreach ($vars as $var) {
+ $textvars .= "$var\n";
+ }
+ $testvars = @parse_ini_string($textvars) ?: [];
+ $defaultvars = ["HOST_HOSTNAME","HOST_OS","HOST_CONTAINERNAME","TZ","PATH"];
+ $count = 1;
+ foreach ($testvars as $var => $varcont) {
+ if ( in_array($var,$defaultvars) )
+ continue;
- $p = ["Name"=>"Container Variable $count",'Target'=>$var,"Type"=>"Variable","Default"=>$varcont,"Description"=>"","Required"=>"false","Mask"=>"false","Display"=>"always"];
- if ( $unRaid69 ) $p['Description'] = "Container Variable: $var";
- $Config[]['@attributes'] = $p;
- $count++;
- }
- $Config[]['@attributes'] = ["Name"=>"Community Applications Conversion",'Target'=>"Community_Applications_Conversion","Type"=>"Variable","Default"=>"true","Description"=>"","Required"=>"false","Mask"=>"false","Display"=>"always"];
+ $p = ["Name"=>"Container Variable $count",'Target'=>$var,"Type"=>"Variable","Default"=>$varcont,"Description"=>"","Required"=>"false","Mask"=>"false","Display"=>"always"];
+ if ( $unRaid69 ) $p['Description'] = "Container Variable: $var";
+ $Config[]['@attributes'] = $p;
+ $count++;
+ }
+ $Config[]['@attributes'] = ["Name"=>"Community Applications Conversion",'Target'=>"Community_Applications_Conversion","Type"=>"Variable","Default"=>"true","Description"=>"","Required"=>"false","Mask"=>"false","Display"=>"always"];
- if ( !empty($Config) )
- $dockerfile['Config'] = $Config;
- } else {
- $error = tr("An error occurred - Could not determine configuration");
- }
- $dockerfile['Name'] = $docker['Name'];
+ if ( !empty($Config) )
+ $dockerfile['Config'] = $Config;
+ } else {
+ $error = tr("An error occurred - Could not determine configuration");
+ }
+ $dockerfile['Name'] = $docker['Name'];
- $existing_templates = array_diff(scandir($dockerManPaths['templates-user']),[".",".."]);
- foreach ( $existing_templates as $template ) {
- if ( strtolower($dockerfile['Name']) == strtolower(str_replace(["my-",".xml"],["",""],$template)) )
- $dockerfile['Name'] .= "-1";
- }
-
- file_put_contents($caPaths['dockerSearchInstall'],makeXML($dockerfile));
+ $existing_templates = array_diff(scandir($dockerManPaths['templates-user']),[".",".."]);
+ foreach ( $existing_templates as $template ) {
+ if ( strtolower($dockerfile['Name']) == strtolower(str_replace(["my-",".xml"],["",""],$template)) )
+ $dockerfile['Name'] .= "-1";
+ }
+
+ file_put_contents($caPaths['dockerSearchInstall'],makeXML($dockerfile));
}
?>
\ No newline at end of file
diff --git a/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/installMulti.php b/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/installMulti.php
index ec7a0f2c..977d025d 100644
--- a/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/installMulti.php
+++ b/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/installMulti.php
@@ -23,16 +23,16 @@ require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
$unRaidVersion = parse_ini_file($caPaths['unRaidVersion']);
function tr($string,$ret=true) {
- if ( function_exists("_") )
- $string = str_replace('"',""",str_replace("'","'",_($string)));
- if ( $ret )
- return $string;
- else
- echo $string;
+ if ( function_exists("_") )
+ $string = str_replace('"',""",str_replace("'","'",_($string)));
+ if ( $ret )
+ return $string;
+ else
+ echo $string;
}
function startsWith($haystack, $needle) {
- return $needle === "" || strripos($haystack, $needle, -strlen($haystack)) !== FALSE;
+ return $needle === "" || strripos($haystack, $needle, -strlen($haystack)) !== FALSE;
}
$exeFile = "/usr/local/emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php";
@@ -41,15 +41,15 @@ $javascript = file_get_contents("/usr/local/emhttp/plugins/dynamix/javascript/dy
echo "";
if ( $_GET['docker'] ) {
- echo "";
- $dockers = explode(",",$_GET['docker']);
- echo sprintf(tr("Installing docker applications %s"),str_replace(",",", ",$_GET['docker']))."
";
- $_GET['updateContainer'] = true;
- $_GET['ct'] = $dockers;
- $_GET['communityApplications'] = true;
- $_GET['mute'] = false;
- @include($exeFile); # under new GUI, this line returns a duplicated session_start() error.
- echo "
";
+ echo "";
+ $dockers = explode(",",$_GET['docker']);
+ echo sprintf(tr("Installing docker applications %s"),str_replace(",",", ",$_GET['docker']))."
";
+ $_GET['updateContainer'] = true;
+ $_GET['ct'] = $dockers;
+ $_GET['communityApplications'] = true;
+ $_GET['mute'] = false;
+ @include($exeFile); # under new GUI, this line returns a duplicated session_start() error.
+ echo "
";
?>
- $failFlag = false;
- foreach ($dockers as $docker) {
- echo sprintf(tr("Starting %s"),"$docker")."
";
- unset($output);
- exec("docker start $docker 2>&1",$output,$retval);
- if ($retval) {
- $failFlag = true;
- echo sprintf(tr("%s failed to start. You should install it by itself to fix the errors"),"$docker")."
";
- foreach ($output as $line) {
- echo "$line
";
- }
- echo "
";
- }
- }
- if ( ! is_file("/var/lib/docker/unraid-autostart") ) {
- echo "
".tr("Setting installed applications to autostart")."
";
- $autostartFile = array();
+ $failFlag = false;
+ foreach ($dockers as $docker) {
+ echo sprintf(tr("Starting %s"),"$docker")."
";
+ unset($output);
+ exec("docker start $docker 2>&1",$output,$retval);
+ if ($retval) {
+ $failFlag = true;
+ echo sprintf(tr("%s failed to start. You should install it by itself to fix the errors"),"$docker")."
";
+ foreach ($output as $line) {
+ echo "$line
";
+ }
+ echo "
";
+ }
+ }
+ if ( ! is_file("/var/lib/docker/unraid-autostart") ) {
+ echo "
".tr("Setting installed applications to autostart")."
";
+ $autostartFile = array();
- foreach ($dockers as $docker) {
- $autostart[$docker] = true;
- }
- $autostartFile = implode("\n",array_keys($autostart));
- file_put_contents("/var/lib/docker/unraid-autostart",$autostartFile);
- }
-
- echo "
".tr("Downloading docker icons")."
";
- $DockerTemplates->getAllInfo();
- exec("$docroot/plugins/dynamix.docker.manager/scripts/dockerupdate check nonotify > /dev/null 2>&1");
+ foreach ($dockers as $docker) {
+ $autostart[$docker] = true;
+ }
+ $autostartFile = implode("\n",array_keys($autostart));
+ file_put_contents("/var/lib/docker/unraid-autostart",$autostartFile);
+ }
+
+ echo "
".tr("Downloading docker icons")."
";
+ $DockerTemplates->getAllInfo();
+ exec("$docroot/plugins/dynamix.docker.manager/scripts/dockerupdate check nonotify > /dev/null 2>&1");
- if ( $failFlag || !$_GET['plugin']) {
- echo "
".tr("Docker Application Installation finished")."
";
- } else {
- echo "";
- }
- @unlink("/tmp/community.applications/tempFiles/newCreateDocker.php");
+ if ( $failFlag || !$_GET['plugin']) {
+ echo "
".tr("Docker Application Installation finished")."
";
+ } else {
+ echo "";
+ }
+ @unlink("/tmp/community.applications/tempFiles/newCreateDocker.php");
}
?>
\ No newline at end of file
diff --git a/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/installMultiPlugin.php b/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/installMultiPlugin.php
index 5eb29bf9..4fc42651 100644
--- a/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/installMultiPlugin.php
+++ b/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/installMultiPlugin.php
@@ -12,25 +12,25 @@ require_once "/usr/local/emhttp/plugins/community.applications/include/helpers.p
$apps = readJsonFile($caPaths['community-templates-info']);
$plugins = explode("*",$argv[1]);
foreach ($plugins as $plugin) {
- echo $plugin;
- if (! $plugin ) continue;
- $pluginName = basename($plugin);
- $pathInfo = pathinfo($plugin);
- if ( $pathInfo['extension'] !== "plg" ) {
- if ( is_file("/var/log/plugins/lang-$pluginName.xml") ) {
- passthru("/usr/local/emhttp/plugins/community.applications/scripts/languageInstall.sh update $pluginName");
- continue;
- }
- }
- if ( searchArray($apps,"PluginURL",$plugin) !== false ) {
- if ( is_file("/var/log/plugins/$pluginName") ) {
- passthru("/usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugin update $pluginName");
- } else {
- passthru("/usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugin install ".escapeshellarg($plugin));
- }
- } else
- echo "$plugin not found in application feed\n";
- @unlink("{$caPaths['pluginPending']}/$pluginName");
+ echo $plugin;
+ if (! $plugin ) continue;
+ $pluginName = basename($plugin);
+ $pathInfo = pathinfo($plugin);
+ if ( $pathInfo['extension'] !== "plg" ) {
+ if ( is_file("/var/log/plugins/lang-$pluginName.xml") ) {
+ passthru("/usr/local/emhttp/plugins/community.applications/scripts/languageInstall.sh update $pluginName");
+ continue;
+ }
+ }
+ if ( searchArray($apps,"PluginURL",$plugin) !== false ) {
+ if ( is_file("/var/log/plugins/$pluginName") ) {
+ passthru("/usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugin update $pluginName");
+ } else {
+ passthru("/usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugin install ".escapeshellarg($plugin));
+ }
+ } else
+ echo "$plugin not found in application feed\n";
+ @unlink("{$caPaths['pluginPending']}/$pluginName");
}
passthru("/usr/local/emhttp/plugins/community.applications/scripts/updatePluginSupport.php");
?>
\ No newline at end of file
diff --git a/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/installUpdate.php b/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/installUpdate.php
index 464d4fe0..3583291f 100644
--- a/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/installUpdate.php
+++ b/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/installUpdate.php
@@ -20,7 +20,7 @@ require_once "/usr/local/emhttp/plugins/dynamix/include/Helpers.php";
$_GET['updateContainer'] = "true";
$_GET['mute'] = false;
// $_GET['communityApplications'] = true;
- include("/usr/local/emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php");
+include("/usr/local/emhttp/plugins/dynamix.docker.manager/include/CreateDocker.php");
?>
\ No newline at end of file
diff --git a/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/updatePluginSupport.php b/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/updatePluginSupport.php
index fbae4c1c..298d669f 100644
--- a/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/updatePluginSupport.php
+++ b/source/community.applications/usr/local/emhttp/plugins/community.applications/scripts/updatePluginSupport.php
@@ -24,39 +24,39 @@ require_once("$docroot/plugins/dynamix/include/Translations.php");
$plugins = glob("/boot/config/plugins/*.plg");
$templates = readJsonFile($caPaths['community-templates-info']);
if ( ! $templates ) {
- echo "You must enter the apps tab before using this script\n";
- return;
+ echo "You must enter the apps tab before using this script\n";
+ return;
}
echo "\n".tr("Updating Support Links")."\n\n";
foreach ($plugins as $plugin) {
- $pluginURL = plugin("pluginURL",$plugin);
- $pluginEntry = searchArray($templates,"PluginURL",$pluginURL);
- if ( $pluginEntry === false ) {
- $pluginEntry = searchArray($templates,"PluginURL",str_replace("https://raw.github.com/","https://raw.githubusercontent.com/",$pluginURL));
- }
- if ( $pluginEntry !== false && $templates[$pluginEntry]['PluginURL']) {
- $xml = simplexml_load_file($plugin);
- if ( ! $templates[$pluginEntry]['Support'] ) {
- continue;
- }
- if ( @plugin("support",$plugin) !== $templates[$pluginEntry]['Support'] ) {
- // remove existing support attribute if it exists
- if ( @plugin("support",$plugin) ) {
- $existing_support = $xml->xpath("//PLUGIN/@support");
- foreach ($existing_support as $node) {
- unset($node[0]);
- }
- }
- $xml->addAttribute("support",$templates[$pluginEntry]['Support']);
- $dom = new DOMDocument('1.0');
- $dom->preserveWhiteSpace = false;
- $dom->formatOutput = true;
- $dom->loadXML($xml->asXML());
- file_put_contents($plugin, $dom->saveXML());
- echo "".plugin("name",$plugin)." --> {$templates[$pluginEntry]['Support']}\n";
- }
- }
+ $pluginURL = plugin("pluginURL",$plugin);
+ $pluginEntry = searchArray($templates,"PluginURL",$pluginURL);
+ if ( $pluginEntry === false ) {
+ $pluginEntry = searchArray($templates,"PluginURL",str_replace("https://raw.github.com/","https://raw.githubusercontent.com/",$pluginURL));
+ }
+ if ( $pluginEntry !== false && $templates[$pluginEntry]['PluginURL']) {
+ $xml = simplexml_load_file($plugin);
+ if ( ! $templates[$pluginEntry]['Support'] ) {
+ continue;
+ }
+ if ( @plugin("support",$plugin) !== $templates[$pluginEntry]['Support'] ) {
+ // remove existing support attribute if it exists
+ if ( @plugin("support",$plugin) ) {
+ $existing_support = $xml->xpath("//PLUGIN/@support");
+ foreach ($existing_support as $node) {
+ unset($node[0]);
+ }
+ }
+ $xml->addAttribute("support",$templates[$pluginEntry]['Support']);
+ $dom = new DOMDocument('1.0');
+ $dom->preserveWhiteSpace = false;
+ $dom->formatOutput = true;
+ $dom->loadXML($xml->asXML());
+ file_put_contents($plugin, $dom->saveXML());
+ echo "".plugin("name",$plugin)." --> {$templates[$pluginEntry]['Support']}\n";
+ }
+ }
}
echo "\n\n";
echo tr("Finished Installing. If the DONE button did not appear, then you will need to click the red X in the top right corner")."\n";
diff --git a/source/community.applications/usr/local/emhttp/plugins/community.applications/skins/Narrow/css.php b/source/community.applications/usr/local/emhttp/plugins/community.applications/skins/Narrow/css.php
index a1078de1..60c6958a 100644
--- a/source/community.applications/usr/local/emhttp/plugins/community.applications/skins/Narrow/css.php
+++ b/source/community.applications/usr/local/emhttp/plugins/community.applications/skins/Narrow/css.php
@@ -23,96 +23,96 @@ $unRaid66color = "#FF8C2F";
$linkColor = "#486dba";
$startupColor = "#FF8C2F";
switch ($theme) {
- case 'black':
- $donateBackground = "#ffffff";
- $donateText = "#000000";
- $templateBackground = "#191818";
- $templateHoverBackground = "#121212";
- $templateFavourite = "#333333";
- $hrColor = "#2b2b2b";
- $borderColor = "#2b2b2b";
- $watermarkColor = "rgba(43, 43, 43, 0.4)";
- $aColor = "#00b8d6";
- $sidebarBackground = "#000000";
- $sidebarText = "#f2f2f2";
- $betaPopupOffset = "0";
- $supportPopupText = "#000000";
- $supportPopupBackground = "#ffffff";
- $modCommentBorder = "#cf3131";
- $sidebarCloseBackground = "rgba(0,0,0,0.7)";
- break;
- case 'white':
- $donateBackground = "#1c1b1b";
- $donateText = "#f2f2f2";
- $templateBackground = "#f5f5f5";
- $templateHoverBackground = "#ffffff";
- $templateFavourite = "#d0d0d0";
- $hrColor = "lightgrey";
- $borderColor = "#e3e3e3";
- $watermarkColor = "rgba(211, 211, 211, 0.8)";
- $aColor = "#486dba";
- $sidebarBackground = "#ffffff";
- $sidebarText = "#000000";
- $betaPopupOffset = "0";
- $supportPopupText = "#f2f2f2";
- $supportPopupBackground = "#1c1b1b";
- $modCommentBorder = "#cf3131";
- $sidebarCloseBackground = "rgba(0,0,0,0.7)";
- break;
- case 'azure':
- $donateBackground = "#606e7f";
- $donateText = "#e4e2e4";
- $templateBackground = "transparent";
- $templateHoverBackground = "#edeaef";
- $templateFavourite = "#e0e0e0";
- $hrColor = "#606e7f";
- $border = "#9794a7";
- $watermarkColor = "rgba(96, 110, 127, 0.1)";
- $aColor = "#486dba";
- $sidebarBackground = "#edeaef";
- $sidebarText = "#606e7f";
- $betaPopupOffset = "1.5rem;";
- $supportPopupText = "#1b1d1b";
- $supportPopupBackground = "#ffffff";
- $modCommentBorder = "#cf3131";
- $sidebarCloseBackground = "rgba(0,0,0,0.7)";
- break;
- case 'gray':
- $donateBackground = "#606e7f";
- $donateText = "#1b1d1b";
- $templateBackground = "transparent";
- $templateHoverBackground = "#0c0f0b";
- $templateFavourite = "#2b2b2b";
- $hrColor = "#606e7f";
- $border = "#606e7f";
- $watermarkColor = "rgba(96, 110, 127, 0.1)";
- $aColor = "#00b8d6";
- $sidebarBackground = "#121510";
- $sidebarText = "#f2f2f2";
- $betaPopupOffset = "1.5rem;";
- $supportPopupText = "#1b1d1b";
- $supportPopupBackground = "#ffffff";
- $modCommentBorder = "#cf3131";
- $sidebarCloseBackground = "rgba(0,0,0,0.7)";
- break;
+ case 'black':
+ $donateBackground = "#ffffff";
+ $donateText = "#000000";
+ $templateBackground = "#191818";
+ $templateHoverBackground = "#121212";
+ $templateFavourite = "#333333";
+ $hrColor = "#2b2b2b";
+ $borderColor = "#2b2b2b";
+ $watermarkColor = "rgba(43, 43, 43, 0.4)";
+ $aColor = "#00b8d6";
+ $sidebarBackground = "#000000";
+ $sidebarText = "#f2f2f2";
+ $betaPopupOffset = "0";
+ $supportPopupText = "#000000";
+ $supportPopupBackground = "#ffffff";
+ $modCommentBorder = "#cf3131";
+ $sidebarCloseBackground = "rgba(0,0,0,0.7)";
+ break;
+ case 'white':
+ $donateBackground = "#1c1b1b";
+ $donateText = "#f2f2f2";
+ $templateBackground = "#f5f5f5";
+ $templateHoverBackground = "#ffffff";
+ $templateFavourite = "#d0d0d0";
+ $hrColor = "lightgrey";
+ $borderColor = "#e3e3e3";
+ $watermarkColor = "rgba(211, 211, 211, 0.8)";
+ $aColor = "#486dba";
+ $sidebarBackground = "#ffffff";
+ $sidebarText = "#000000";
+ $betaPopupOffset = "0";
+ $supportPopupText = "#f2f2f2";
+ $supportPopupBackground = "#1c1b1b";
+ $modCommentBorder = "#cf3131";
+ $sidebarCloseBackground = "rgba(0,0,0,0.7)";
+ break;
+ case 'azure':
+ $donateBackground = "#606e7f";
+ $donateText = "#e4e2e4";
+ $templateBackground = "transparent";
+ $templateHoverBackground = "#edeaef";
+ $templateFavourite = "#e0e0e0";
+ $hrColor = "#606e7f";
+ $border = "#9794a7";
+ $watermarkColor = "rgba(96, 110, 127, 0.1)";
+ $aColor = "#486dba";
+ $sidebarBackground = "#edeaef";
+ $sidebarText = "#606e7f";
+ $betaPopupOffset = "1.5rem;";
+ $supportPopupText = "#1b1d1b";
+ $supportPopupBackground = "#ffffff";
+ $modCommentBorder = "#cf3131";
+ $sidebarCloseBackground = "rgba(0,0,0,0.7)";
+ break;
+ case 'gray':
+ $donateBackground = "#606e7f";
+ $donateText = "#1b1d1b";
+ $templateBackground = "transparent";
+ $templateHoverBackground = "#0c0f0b";
+ $templateFavourite = "#2b2b2b";
+ $hrColor = "#606e7f";
+ $border = "#606e7f";
+ $watermarkColor = "rgba(96, 110, 127, 0.1)";
+ $aColor = "#00b8d6";
+ $sidebarBackground = "#121510";
+ $sidebarText = "#f2f2f2";
+ $betaPopupOffset = "1.5rem;";
+ $supportPopupText = "#1b1d1b";
+ $supportPopupBackground = "#ffffff";
+ $modCommentBorder = "#cf3131";
+ $sidebarCloseBackground = "rgba(0,0,0,0.7)";
+ break;
// Use settings for black as a fallback
- default:
- $donateBackground = "#f2f2f2";
- $donateText = "#1c1b1b";
- $templateBackground = "#0f0f0f";
- $templateFavourite = "#333333";
- $hrColor = "#2b2b2b";
- $borderColor = "#2b2b2b";
- $watermarkColor = "rgba(43, 43, 43, 0.4)";
- $aColor = "#00b8d6";
- $sidebarBackground = "#000000";
- $sidebarText = "#f2f2f2";
- $betaPopupOffset = "0";
- $supportPopupText = "#000000";
- $supportPopupBackground = "#ffffff";
- $modCommentBorder = "#cf3131";
- $sidebarCloseBackground = "rgba(0,0,0,.7)";
- break;
+ default:
+ $donateBackground = "#f2f2f2";
+ $donateText = "#1c1b1b";
+ $templateBackground = "#0f0f0f";
+ $templateFavourite = "#333333";
+ $hrColor = "#2b2b2b";
+ $borderColor = "#2b2b2b";
+ $watermarkColor = "rgba(43, 43, 43, 0.4)";
+ $aColor = "#00b8d6";
+ $sidebarBackground = "#000000";
+ $sidebarText = "#f2f2f2";
+ $betaPopupOffset = "0";
+ $supportPopupText = "#000000";
+ $supportPopupBackground = "#ffffff";
+ $modCommentBorder = "#cf3131";
+ $sidebarCloseBackground = "rgba(0,0,0,.7)";
+ break;
}
?>
a {color:=$aColor?>;}
@@ -462,8 +462,8 @@ table {background-color:transparent;}
@keyframes cycleRed {
- 0% {color: inherit;}
- 50% {color: #882626;}
+ 0% {color: inherit;}
+ 50% {color: #882626;}
}
.awesomplete [hidden] {display: none;}
.awesomplete .visually-hidden {position: absolute;clip: rect(0, 0, 0, 0);}
@@ -473,7 +473,7 @@ table {background-color:transparent;}
.awesomplete > ul:empty {display: none;}
.awesomplete > ul {border-radius: .3em;margin: .2em 0 0;background: hsla(0,0%,100%);background: linear-gradient(to bottom right, white, hsla(0,0%,100%));border: 1px solid rgba(0,0,0,.3);box-shadow: .05em .2em .6em rgba(0,0,0,.2);text-shadow: none;}
@supports (transform: scale(0)) {.awesomplete > ul {transition: .3s cubic-bezier(.4,.2,.5,1.4);transform-origin: 1.43em -.43em;}
- .awesomplete > ul[hidden],.awesomplete > ul:empty {opacity: 0;transform: scale(0);display: block;transition-timing-function: ease;}
+ .awesomplete > ul[hidden],.awesomplete > ul:empty {opacity: 0;transform: scale(0);display: block;transition-timing-function: ease;}
}
/* Pointer */
.awesomplete > ul:before {content: "";position: absolute;top: -.43em;left: 1em;width: 0; height: 0;padding: .4em;background: white;border: inherit;border-right: 0;border-bottom: 0;-webkit-transform: rotate(45deg);transform: rotate(45deg);}
@@ -543,22 +543,22 @@ img.mfp-img {width: auto;max-width: 100%;height: auto;display: block;line-height
.mfp-gallery .mfp-image-holder .mfp-figure {cursor: pointer; }
@media screen and (max-width: 800px) and (orientation: landscape), screen and (max-height: 300px) {
/**
- * Remove all paddings around the image on small screen
+ * Remove all paddings around the image on small screen
*/
- .mfp-img-mobile .mfp-image-holder {padding-left: 0;padding-right: 0; }
- .mfp-img-mobile img.mfp-img {padding: 0; }
- .mfp-img-mobile .mfp-figure:after {top: 0;bottom: 0; }
- .mfp-img-mobile .mfp-figure small {display: inline;margin-left: 5px; }
- .mfp-img-mobile .mfp-bottom-bar {background: rgba(0, 0, 0, 0.6);bottom: 0;margin: 0;top: auto;padding: 3px 5px;position: fixed;box-sizing: border-box; }
- .mfp-img-mobile .mfp-bottom-bar:empty {padding: 0; }
- .mfp-img-mobile .mfp-counter {right: 5px;top: 3px; }
- .mfp-img-mobile .mfp-close {top: 0;right: 0;width: 35px;height: 35px;line-height: 35px;background: rgba(0, 0, 0, 0.6);position: fixed;text-align: center;padding: 0; }
+ .mfp-img-mobile .mfp-image-holder {padding-left: 0;padding-right: 0; }
+ .mfp-img-mobile img.mfp-img {padding: 0; }
+ .mfp-img-mobile .mfp-figure:after {top: 0;bottom: 0; }
+ .mfp-img-mobile .mfp-figure small {display: inline;margin-left: 5px; }
+ .mfp-img-mobile .mfp-bottom-bar {background: rgba(0, 0, 0, 0.6);bottom: 0;margin: 0;top: auto;padding: 3px 5px;position: fixed;box-sizing: border-box; }
+ .mfp-img-mobile .mfp-bottom-bar:empty {padding: 0; }
+ .mfp-img-mobile .mfp-counter {right: 5px;top: 3px; }
+ .mfp-img-mobile .mfp-close {top: 0;right: 0;width: 35px;height: 35px;line-height: 35px;background: rgba(0, 0, 0, 0.6);position: fixed;text-align: center;padding: 0; }
}
@media all and (max-width: 900px) {
- .mfp-arrow {-webkit-transform: scale(0.75);transform: scale(0.75); }
- .mfp-arrow-left {-webkit-transform-origin: 0;transform-origin: 0; }
- .mfp-arrow-right {-webkit-transform-origin: 100%;transform-origin: 100%; }
- .mfp-container {padding-left: 6px;padding-right: 6px; }
+ .mfp-arrow {-webkit-transform: scale(0.75);transform: scale(0.75); }
+ .mfp-arrow-left {-webkit-transform-origin: 0;transform-origin: 0; }
+ .mfp-arrow-right {-webkit-transform-origin: 100%;transform-origin: 100%; }
+ .mfp-container {padding-left: 6px;padding-right: 6px; }
}
/* overlay at start */
.mfp-fade.mfp-bg {opacity: 0;-webkit-transition: all 0.5s ease-out;-moz-transition: all 0.5s ease-out;transition: all 0.5s ease-out;}
diff --git a/source/community.applications/usr/local/emhttp/plugins/community.applications/skins/Narrow/skin.html b/source/community.applications/usr/local/emhttp/plugins/community.applications/skins/Narrow/skin.html
index c9ece6eb..0796cb76 100644
--- a/source/community.applications/usr/local/emhttp/plugins/community.applications/skins/Narrow/skin.html
+++ b/source/community.applications/usr/local/emhttp/plugins/community.applications/skins/Narrow/skin.html
@@ -1,45 +1,45 @@
@@ -61,22 +61,22 @@
-
-
-
Community Applications
-
-
Andrew Zawadzki
-
-
bonienl, Lime Technology Inc
-
-
Magnus Engø
-
-
Andrew Zawadzki, Kode, Lime Technology Inc
-
-
CHBMB, SpaceInvaderOne, Sparklyballs, wgstarks, DJoss, Zer0Nin3r, Mex, prostuff1, bonienl, ljm42, kizer, trurl, Jos, Lime Technology Inc, SimonF, ich777, jimmy898, Alex.b, neruve, Eugeni_CAT, ChaseCares, TheEyeTGuy, dlandon
-
-
Awesomeplete (Lea Verou)
Chart.js (various)
chartjs-plugin-trendline (Marcus Alsterfjord)
XML2Array/Array2XML (Miles Johnson)
sprintf.js (Alexandru Mărășteanu) (< Unraid 6.10 only)
Magnific-Popup (Dmitry Semenov)
-
-
© 2015-2023 Andrew Zawadzki
-
+
+
+
Community Applications
+
+
Andrew Zawadzki
+
+
bonienl, Lime Technology Inc
+
+
Magnus Engø
+
+
Andrew Zawadzki, Kode, Lime Technology Inc
+
+
CHBMB, SpaceInvaderOne, Sparklyballs, wgstarks, DJoss, Zer0Nin3r, Mex, prostuff1, bonienl, ljm42, kizer, trurl, Jos, Lime Technology Inc, SimonF, ich777, jimmy898, Alex.b, neruve, Eugeni_CAT, ChaseCares, TheEyeTGuy, dlandon
+
+
Awesomeplete (Lea Verou)
Chart.js (various)
chartjs-plugin-trendline (Marcus Alsterfjord)
XML2Array/Array2XML (Miles Johnson)
sprintf.js (Alexandru Mărășteanu) (< Unraid 6.10 only)
Magnific-Popup (Dmitry Semenov)
+
+
© 2015-2023 Andrew Zawadzki
+
\ No newline at end of file
diff --git a/source/community.applications/usr/local/emhttp/plugins/community.applications/skins/Narrow/skin.php b/source/community.applications/usr/local/emhttp/plugins/community.applications/skins/Narrow/skin.php
index f2800b0d..9103ba98 100644
--- a/source/community.applications/usr/local/emhttp/plugins/community.applications/skins/Narrow/skin.php
+++ b/source/community.applications/usr/local/emhttp/plugins/community.applications/skins/Narrow/skin.php
@@ -7,447 +7,447 @@
###############################################################
function display_apps($pageNumber=1,$selectedApps=false,$startup=false) {
- global $caPaths, $caSettings, $sortOrder;
+ global $caPaths, $caSettings, $sortOrder;
- if ( is_file($caPaths['repositoriesDisplayed']) ) {
- $file = readJsonFile($caPaths['repositoriesDisplayed']);
- //$startup = true;
- } else {
- if ( is_file($caPaths['community-templates-catSearchResults']) )
- $file = readJsonFile($caPaths['community-templates-catSearchResults']);
- else
- $file = readJsonFile($caPaths['community-templates-displayed']);
- }
- $communityApplications = is_array($file['community']) ? $file['community'] : [];
- $totalApplications = count($communityApplications);
+ if ( is_file($caPaths['repositoriesDisplayed']) ) {
+ $file = readJsonFile($caPaths['repositoriesDisplayed']);
+ //$startup = true;
+ } else {
+ if ( is_file($caPaths['community-templates-catSearchResults']) )
+ $file = readJsonFile($caPaths['community-templates-catSearchResults']);
+ else
+ $file = readJsonFile($caPaths['community-templates-displayed']);
+ }
+ $communityApplications = is_array($file['community']) ? $file['community'] : [];
+ $totalApplications = count($communityApplications);
- $display = ( $totalApplications ) ? my_display_apps($communityApplications,$pageNumber,$selectedApps,$startup) : "
".tr("No Matching Applications Found")."
";
+ $display = ( $totalApplications ) ? my_display_apps($communityApplications,$pageNumber,$selectedApps,$startup) : "
".tr("No Matching Applications Found")."
";
- return $display;
+ return $display;
}
function my_display_apps($file,$pageNumber=1,$selectedApps=false,$startup=false) {
- global $caPaths, $caSettings, $plugin, $displayDeprecated, $sortOrder, $DockerTemplates, $DockerClient;
+ global $caPaths, $caSettings, $plugin, $displayDeprecated, $sortOrder, $DockerTemplates, $DockerClient;
- $dockerUpdateStatus = readJsonFile($caPaths['dockerUpdateStatus']);
- $repositories = readJsonFile($caPaths['repositoryList']);
- $extraBlacklist = readJsonFile($caPaths['extraBlacklist']);
- $extraDeprecated = readJsonFile($caPaths['extraDeprecated']);
- $ct = "";
- $count = 0;
+ $dockerUpdateStatus = readJsonFile($caPaths['dockerUpdateStatus']);
+ $repositories = readJsonFile($caPaths['repositoryList']);
+ $extraBlacklist = readJsonFile($caPaths['extraBlacklist']);
+ $extraDeprecated = readJsonFile($caPaths['extraDeprecated']);
+ $ct = "";
+ $count = 0;
- if ( is_file("/var/run/dockerd.pid") && is_dir("/proc/".@file_get_contents("/var/run/dockerd.pid")) ) {
- $caSettings['dockerRunning'] = "true";
- $info = getAllInfo();
- $dockerUpdateStatus = readJsonFile($caPaths['dockerUpdateStatus']);
- } else {
- $caSettings['dockerRunning'] = false;
- $info = [];
- $dockerUpdateStatus = [];
- }
+ if ( is_file("/var/run/dockerd.pid") && is_dir("/proc/".@file_get_contents("/var/run/dockerd.pid")) ) {
+ $caSettings['dockerRunning'] = "true";
+ $info = getAllInfo();
+ $dockerUpdateStatus = readJsonFile($caPaths['dockerUpdateStatus']);
+ } else {
+ $caSettings['dockerRunning'] = false;
+ $info = [];
+ $dockerUpdateStatus = [];
+ }
- if ( ! $selectedApps )
- $selectedApps = [];
+ if ( ! $selectedApps )
+ $selectedApps = [];
- $dockerWarningFlag = $dockerNotEnabled = (! $caSettings['dockerRunning'] && ! ($caSettings['NoInstalls'] ?? false) ) ? "true" : "false";
+ $dockerWarningFlag = $dockerNotEnabled = (! $caSettings['dockerRunning'] && ! ($caSettings['NoInstalls'] ?? false) ) ? "true" : "false";
- if ( $dockerNotEnabled == "true" ) {
- $unRaidVars = parse_ini_file($caPaths['unRaidVars']);
- $dockerVars = parse_ini_file($caPaths['docker_cfg']);
+ if ( $dockerNotEnabled == "true" ) {
+ $unRaidVars = parse_ini_file($caPaths['unRaidVars']);
+ $dockerVars = parse_ini_file($caPaths['docker_cfg']);
- if ( $unRaidVars['mdState'] == "STARTED" && $dockerVars['DOCKER_ENABLED'] !== "yes" )
- $dockerNotEnabled = 1; // Array started, docker not enabled
- if ( $unRaidVars['mdState'] == "STARTED" && $dockerVars['DOCKER_ENABLED'] == "yes" )
- $dockerNotEnabled = 2; // Docker failed to start
- if ( $unRaidVars['mdState'] !== "STARTED" )
- $dockerNotEnabled = 3; // Array not started
- }
- $displayHeader = "";
+ if ( $unRaidVars['mdState'] == "STARTED" && $dockerVars['DOCKER_ENABLED'] !== "yes" )
+ $dockerNotEnabled = 1; // Array started, docker not enabled
+ if ( $unRaidVars['mdState'] == "STARTED" && $dockerVars['DOCKER_ENABLED'] == "yes" )
+ $dockerNotEnabled = 2; // Docker failed to start
+ if ( $unRaidVars['mdState'] !== "STARTED" )
+ $dockerNotEnabled = 3; // Array not started
+ }
+ $displayHeader = "";
- $pinnedApps = readJsonFile($caPaths['pinnedV2']);
+ $pinnedApps = readJsonFile($caPaths['pinnedV2']);
- $selectedApps['docker'] = $selectedApps['docker'] ?? [];
- $selectedApps['plugin'] = $selectedApps['plugin'] ?? [];
- $checkedOffApps = arrayEntriesToObject(@array_merge(@array_values($selectedApps['docker']),@array_values($selectedApps['plugin'])));
+ $selectedApps['docker'] = $selectedApps['docker'] ?? [];
+ $selectedApps['plugin'] = $selectedApps['plugin'] ?? [];
+ $checkedOffApps = arrayEntriesToObject(@array_merge(@array_values($selectedApps['docker']),@array_values($selectedApps['plugin'])));
- $columnNumber = 0;
- $appCount = 0;
- $startingApp = ($pageNumber -1) * $caSettings['maxPerPage'] + 1;
- $startingAppCounter = 0;
+ $columnNumber = 0;
+ $appCount = 0;
+ $startingApp = ($pageNumber -1) * $caSettings['maxPerPage'] + 1;
+ $startingAppCounter = 0;
- $displayedTemplates = [];
- foreach ($file as $template) {
- $startingAppCounter++;
- if ( $startingAppCounter < $startingApp ) continue;
- $displayedTemplates[] = $template;
- }
+ $displayedTemplates = [];
+ foreach ($file as $template) {
+ $startingAppCounter++;
+ if ( $startingAppCounter < $startingApp ) continue;
+ $displayedTemplates[] = $template;
+ }
- # Create entries for skins.
- foreach ($displayedTemplates as $template) {
- if ( ! $template['RepositoryTemplate'] ) {
- if ( ! $template['Blacklist'] ) {
- if ( isset($extraBlacklist[$template['Repository']]) ) {
- $template['Blacklist'] = true;
- $template['ModeratorComment'] = $extraBlacklist[$template['Repository']];
- }
- }
- if ( ! $template['Deprecated'] && isset($extraDeprecated[$template['Repository']]) ) {
- $template['Deprecated'] = true;
- $template['ModeratorComment'] = $extraDeprecated[$template['Repository']];
- }
- }
- $template['Icon'] = $template["Icon-{$caSettings['dynamixTheme']}"] ?? $template['Icon'];
+ # Create entries for skins.
+ foreach ($displayedTemplates as $template) {
+ if ( ! $template['RepositoryTemplate'] ) {
+ if ( ! $template['Blacklist'] ) {
+ if ( isset($extraBlacklist[$template['Repository']]) ) {
+ $template['Blacklist'] = true;
+ $template['ModeratorComment'] = $extraBlacklist[$template['Repository']];
+ }
+ }
+ if ( ! $template['Deprecated'] && isset($extraDeprecated[$template['Repository']]) ) {
+ $template['Deprecated'] = true;
+ $template['ModeratorComment'] = $extraDeprecated[$template['Repository']];
+ }
+ }
+ $template['Icon'] = $template["Icon-{$caSettings['dynamixTheme']}"] ?? $template['Icon'];
- if ( $template['RepositoryTemplate'] ) {
- $template['Icon'] = $template['icon'] ?? "/plugins/dynamix.docker.manager/images/question.png";
+ if ( $template['RepositoryTemplate'] ) {
+ $template['Icon'] = $template['icon'] ?? "/plugins/dynamix.docker.manager/images/question.png";
- if ( ! isset($template['bio']) )
- $template['CardDescription'] = tr("No description present");
- else {
- $template['bio'] = strip_tags(markdown($template['bio']));
- $template['Description'] = $template['bio'];
- }
- $template['display_dockerName'] = $template['RepoName'];
+ if ( ! isset($template['bio']) )
+ $template['CardDescription'] = tr("No description present");
+ else {
+ $template['bio'] = strip_tags(markdown($template['bio']));
+ $template['Description'] = $template['bio'];
+ }
+ $template['display_dockerName'] = $template['RepoName'];
- $favClass = ( $caSettings['favourite'] && ($caSettings['favourite'] == $template['RepoName']) ) ? "ca_favouriteRepo" : "ca_non_favouriteRepo";
- $template['ca_fav'] = $caSettings['favourite'] && ($caSettings['favourite'] == $template['RepoName']);
- $niceRepoName = str_replace("'s Repository","",$template['RepoName']);
- $niceRepoName = str_replace("' Repository","",$niceRepoName);
- $niceRepoName = str_replace(" Repository","",$niceRepoName);
+ $favClass = ( $caSettings['favourite'] && ($caSettings['favourite'] == $template['RepoName']) ) ? "ca_favouriteRepo" : "ca_non_favouriteRepo";
+ $template['ca_fav'] = $caSettings['favourite'] && ($caSettings['favourite'] == $template['RepoName']);
+ $niceRepoName = str_replace("'s Repository","",$template['RepoName']);
+ $niceRepoName = str_replace("' Repository","",$niceRepoName);
+ $niceRepoName = str_replace(" Repository","",$niceRepoName);
- $ct .= displayCard($template);
- $count++;
- if ( $count == $caSettings['maxPerPage'] ) break;
- } else {
- $actionsContext = [];
- $selected = false;
- $installComment = $template['CAComment'];
+ $ct .= displayCard($template);
+ $count++;
+ if ( $count == $caSettings['maxPerPage'] ) break;
+ } else {
+ $actionsContext = [];
+ $selected = false;
+ $installComment = $template['CAComment'];
- if ( $template['Requires'] ) {
- $template['Requires'] = markdown(strip_tags(str_replace(["\r","\n","
","'"],["","
","","'"],trim($template['Requires'])),"
"));
- preg_match_all("/\/\/(.*?)\/m",$template['Requires'],$searchMatches);
- if ( count($searchMatches[1]) ) {
- foreach ($searchMatches[1] as $searchResult) {
- $template['Requires'] = str_replace("//$searchResult\","
$searchResult",$template['Requires']);
- }
- }
- $installComment = tr("This application has additional requirements")."
{$template['Requires']}
$installComment";
- }
+ if ( $template['Requires'] ) {
+ $template['Requires'] = markdown(strip_tags(str_replace(["\r","\n","
","'"],["","
","","'"],trim($template['Requires'])),"
"));
+ preg_match_all("/\/\/(.*?)\/m",$template['Requires'],$searchMatches);
+ if ( count($searchMatches[1]) ) {
+ foreach ($searchMatches[1] as $searchResult) {
+ $template['Requires'] = str_replace("//$searchResult\","
$searchResult",$template['Requires']);
+ }
+ }
+ $installComment = tr("This application has additional requirements")."
{$template['Requires']}
$installComment";
+ }
- $installComment = str_replace("\n","",$installComment ?: "");
- if ( ! $template['Language'] ) {
- if ( ! $template['NoInstall'] && ! ($caSettings['NoInstalls'] ?? false) ) {
- if ( ! $template['Plugin'] ) {
- if ( $caSettings['dockerRunning'] ) {
- foreach ($info as $testDocker) {
- $tmpRepo = strpos($template['Repository'],":") ? $template['Repository'] : $template['Repository'].":latest";
- $tmpRepo = strpos($tmpRepo,"/") ? $tmpRepo : "library/$tmpRepo";
- if ( ( ($tmpRepo == $testDocker['Image'] && $template['Name'] == $testDocker['Name']) || "{$tmpRepo}:latest" == $testDocker['Image']) && ($template['Name'] == $testDocker['Name']) ) {
- $selected = true;
- $name = $testDocker['Name'];
- break;
- }
- }
+ $installComment = str_replace("\n","",$installComment ?: "");
+ if ( ! $template['Language'] ) {
+ if ( ! $template['NoInstall'] && ! ($caSettings['NoInstalls'] ?? false) ) {
+ if ( ! $template['Plugin'] ) {
+ if ( $caSettings['dockerRunning'] ) {
+ foreach ($info as $testDocker) {
+ $tmpRepo = strpos($template['Repository'],":") ? $template['Repository'] : $template['Repository'].":latest";
+ $tmpRepo = strpos($tmpRepo,"/") ? $tmpRepo : "library/$tmpRepo";
+ if ( ( ($tmpRepo == $testDocker['Image'] && $template['Name'] == $testDocker['Name']) || "{$tmpRepo}:latest" == $testDocker['Image']) && ($template['Name'] == $testDocker['Name']) ) {
+ $selected = true;
+ $name = $testDocker['Name'];
+ break;
+ }
+ }
- $template['Installed'] = $selected;
- if ( $selected ) {
+ $template['Installed'] = $selected;
+ if ( $selected ) {
- $ind = searchArray($info,"Name",$name);
- if ( $info[$ind]['url'] && $info[$ind]['running'] ) {
- $actionsContext[] = ["icon"=>"ca_fa-globe","text"=>"WebUI","action"=>"openNewWindow('{$info[$ind]['url']}','_blank');"];
- }
+ $ind = searchArray($info,"Name",$name);
+ if ( $info[$ind]['url'] && $info[$ind]['running'] ) {
+ $actionsContext[] = ["icon"=>"ca_fa-globe","text"=>"WebUI","action"=>"openNewWindow('{$info[$ind]['url']}','_blank');"];
+ }
- if ( $dockerUpdateStatus[$tmpRepo]['status'] == "false" ) {
- $template['UpdateAvailable'] = true;
- $actionsContext[] = ["icon"=>"ca_fa-update","text"=>tr("Update"),"action"=>"updateDocker('$name');"];
- } else {
- $template['UpdateAvailable'] = false;
- }
- if ( $caSettings['defaultReinstall'] == "true" && ! $template['Blacklist']) {
- if ( $template['ID'] !== false ) { # don't allow 2nd if there's not a "default" within CA
- if ( $template['BranchID'] ?? false )
- $actionsContext[] = ["icon"=>"ca_fa-install","text"=>tr("Install second instance"),"action"=>"displayTags('{$template['ID']}',true,'".str_replace(" "," ",htmlspecialchars($installComment))."','".portsUsed($template)."');"];
- else
- $actionsContext[] = ["icon"=>"ca_fa-install","text"=>tr("Install second instance"),"action"=>"popupInstallXML('".addslashes($template['Path'])."','second','".str_replace(" "," ",htmlspecialchars($installComment))."','".portsUsed($template)."');"];
- }
- }
- if ( is_file($info[$ind]['template']) )
- $actionsContext[] = ["icon"=>"ca_fa-edit","text"=>tr("Edit"),"action"=>"popupInstallXML('".addslashes($info[$ind]['template'])."','edit');"];
+ if ( $dockerUpdateStatus[$tmpRepo]['status'] == "false" ) {
+ $template['UpdateAvailable'] = true;
+ $actionsContext[] = ["icon"=>"ca_fa-update","text"=>tr("Update"),"action"=>"updateDocker('$name');"];
+ } else {
+ $template['UpdateAvailable'] = false;
+ }
+ if ( $caSettings['defaultReinstall'] == "true" && ! $template['Blacklist']) {
+ if ( $template['ID'] !== false ) { # don't allow 2nd if there's not a "default" within CA
+ if ( $template['BranchID'] ?? false )
+ $actionsContext[] = ["icon"=>"ca_fa-install","text"=>tr("Install second instance"),"action"=>"displayTags('{$template['ID']}',true,'".str_replace(" "," ",htmlspecialchars($installComment))."','".portsUsed($template)."');"];
+ else
+ $actionsContext[] = ["icon"=>"ca_fa-install","text"=>tr("Install second instance"),"action"=>"popupInstallXML('".addslashes($template['Path'])."','second','".str_replace(" "," ",htmlspecialchars($installComment))."','".portsUsed($template)."');"];
+ }
+ }
+ if ( is_file($info[$ind]['template']) )
+ $actionsContext[] = ["icon"=>"ca_fa-edit","text"=>tr("Edit"),"action"=>"popupInstallXML('".addslashes($info[$ind]['template'])."','edit');"];
- $actionsContext[] = ["divider"=>true];
- if ($info[$ind]['template'])
- $actionsContext[] = ["icon"=>"ca_fa-delete","text"=>tr("Uninstall"),"action"=>"uninstallDocker('".addslashes($info[$ind]['template'])."','{$template['Name']}');"];
- if ( $template['DonateLink'] ) {
- $actionsContext[] = ["divider"=>true];
- $actionsContext[] = ["icon"=>"ca_fa-money","text"=>tr("Donate"),"action"=>"openNewWindow('".addslashes($template['DonateLink'])."','_blank');"];
- }
- } elseif ( ! $template['Blacklist'] || ! $template['Compatible']) {
- if ( $template['InstallPath'] ) {
- $userTemplate = readXmlFile($template['InstallPath'],false,false);
- if ( ! $template['Blacklist'] ) {
- $actionsContext[] = ["icon"=>"ca_fa-install","text"=>tr("Reinstall"),"action"=>"popupInstallXML('".addslashes($template['InstallPath'])."','user','','".portsUsed($userTemplate)."');"];
- $actionsContext[] = ["divider"=>true];
- }
- $actionsContext[] = ["icon"=>"ca_fa-delete","text"=>tr("Remove from Previous Apps"),"alternate"=>tr("Remove"),"action"=>"removeApp('{$template['InstallPath']}','{$template['Name']}');"];
- } else {
- if ( ! ($template['BranchID'] ?? null) ) {
- if ( is_file("{$caPaths['dockerManTemplates']}/my-{$template['Name']}.xml") ) {
- $test = readXmlFile("{$caPaths['dockerManTemplates']}/my-{$template['Name']}.xml",true);
- if ( $template['Repository'] == $test['Repository'] ) {
- $userTemplate = readXmlFile($template['InstallPath'],false,false);
- $actionsContext[] = ["icon"=>"ca_fa-install","text"=>"
".tr("Reinstall From Previous Apps")."","action"=>"popupInstallXML('".addslashes("{$caPaths['dockerManTemplates']}/my-{$template['Name']}").".xml','user','','".portsUsed($userTemplate)."');"];
- $actionsContext[] = ["divider"=>true];
- }
- }
- $actionsContext[] = ["icon"=>"ca_fa-install","text"=>tr("Install"),"action"=>"popupInstallXML('".addslashes($template['Path'])."','default','".str_replace(" "," ",htmlspecialchars($installComment))."','".portsUsed($template)."');"];
- } else {
- $actionsContext[] = ["icon"=>"ca_fa-install","text"=>tr("Install"),"action"=>"displayTags('{$template['ID']}',false,'".str_replace(" "," ",htmlspecialchars($installComment))."','".portsUsed($template)."');"];
- }
- }
- }
- }
- } else {
- $pluginName = basename($template['PluginURL']);
- $template['Installed'] = file_exists("/var/log/plugins/$pluginName");
- if ( $template['Installed'] ) {
- $pluginInstalledVersion = plugin("version","/var/log/plugins/$pluginName");
- if ( file_exists("/tmp/plugins/$pluginName") ) {
- $tmpPluginVersion = plugin("version","/tmp/plugins/$pluginName");
- if (strcmp($template['pluginVersion'],$tmpPluginVersion) < 0)
- $template['pluginVersion'] = $tmpPluginVersion;
- }
- $template['pluginVersion'] = plugin("version","/tmp/plugins/$pluginName");
+ $actionsContext[] = ["divider"=>true];
+ if ($info[$ind]['template'])
+ $actionsContext[] = ["icon"=>"ca_fa-delete","text"=>tr("Uninstall"),"action"=>"uninstallDocker('".addslashes($info[$ind]['template'])."','{$template['Name']}');"];
+ if ( $template['DonateLink'] ) {
+ $actionsContext[] = ["divider"=>true];
+ $actionsContext[] = ["icon"=>"ca_fa-money","text"=>tr("Donate"),"action"=>"openNewWindow('".addslashes($template['DonateLink'])."','_blank');"];
+ }
+ } elseif ( ! $template['Blacklist'] || ! $template['Compatible']) {
+ if ( $template['InstallPath'] ) {
+ $userTemplate = readXmlFile($template['InstallPath'],false,false);
+ if ( ! $template['Blacklist'] ) {
+ $actionsContext[] = ["icon"=>"ca_fa-install","text"=>tr("Reinstall"),"action"=>"popupInstallXML('".addslashes($template['InstallPath'])."','user','','".portsUsed($userTemplate)."');"];
+ $actionsContext[] = ["divider"=>true];
+ }
+ $actionsContext[] = ["icon"=>"ca_fa-delete","text"=>tr("Remove from Previous Apps"),"alternate"=>tr("Remove"),"action"=>"removeApp('{$template['InstallPath']}','{$template['Name']}');"];
+ } else {
+ if ( ! ($template['BranchID'] ?? null) ) {
+ if ( is_file("{$caPaths['dockerManTemplates']}/my-{$template['Name']}.xml") ) {
+ $test = readXmlFile("{$caPaths['dockerManTemplates']}/my-{$template['Name']}.xml",true);
+ if ( $template['Repository'] == $test['Repository'] ) {
+ $userTemplate = readXmlFile($template['InstallPath'],false,false);
+ $actionsContext[] = ["icon"=>"ca_fa-install","text"=>"
".tr("Reinstall From Previous Apps")."","action"=>"popupInstallXML('".addslashes("{$caPaths['dockerManTemplates']}/my-{$template['Name']}").".xml','user','','".portsUsed($userTemplate)."');"];
+ $actionsContext[] = ["divider"=>true];
+ }
+ }
+ $actionsContext[] = ["icon"=>"ca_fa-install","text"=>tr("Install"),"action"=>"popupInstallXML('".addslashes($template['Path'])."','default','".str_replace(" "," ",htmlspecialchars($installComment))."','".portsUsed($template)."');"];
+ } else {
+ $actionsContext[] = ["icon"=>"ca_fa-install","text"=>tr("Install"),"action"=>"displayTags('{$template['ID']}',false,'".str_replace(" "," ",htmlspecialchars($installComment))."','".portsUsed($template)."');"];
+ }
+ }
+ }
+ }
+ } else {
+ $pluginName = basename($template['PluginURL']);
+ $template['Installed'] = file_exists("/var/log/plugins/$pluginName");
+ if ( $template['Installed'] ) {
+ $pluginInstalledVersion = plugin("version","/var/log/plugins/$pluginName");
+ if ( file_exists("/tmp/plugins/$pluginName") ) {
+ $tmpPluginVersion = plugin("version","/tmp/plugins/$pluginName");
+ if (strcmp($template['pluginVersion'],$tmpPluginVersion) < 0)
+ $template['pluginVersion'] = $tmpPluginVersion;
+ }
+ $template['pluginVersion'] = plugin("version","/tmp/plugins/$pluginName");
- if ( ( strcmp($pluginInstalledVersion,$template['pluginVersion']) < 0 || $template['UpdateAvailable']) && $template['Name'] !== "Community Applications" && ( ! ($template['UninstallOnly'] ?? false) ) ) {
- @copy($caPaths['pluginTempDownload'],"/tmp/plugins/$pluginName");
- $template['UpdateAvailable'] = true;
- $actionsContext[] = ["icon"=>"ca_fa-update","text"=>tr("Update"),"action"=>"installPlugin('$pluginName',true,'','{$template['RequiresFile']}');"];
- } else {
- if ( ! $template['UpdateAvailable'] ) # this handles if the feed hasn't caught up to the update yet
- $template['UpdateAvailable'] = false;
- }
- $pluginSettings = ($pluginName == "community.applications.plg") ? "ca_settings" : plugin("launch","/var/log/plugins/$pluginName");
- if ( $pluginSettings ) {
- $actionsContext[] = ["icon"=>"ca_fa-pluginSettings","text"=>tr("Settings"),"action"=>"openNewWindow('/Apps/$pluginSettings');"];
- }
+ if ( ( strcmp($pluginInstalledVersion,$template['pluginVersion']) < 0 || $template['UpdateAvailable']) && $template['Name'] !== "Community Applications" && ( ! ($template['UninstallOnly'] ?? false) ) ) {
+ @copy($caPaths['pluginTempDownload'],"/tmp/plugins/$pluginName");
+ $template['UpdateAvailable'] = true;
+ $actionsContext[] = ["icon"=>"ca_fa-update","text"=>tr("Update"),"action"=>"installPlugin('$pluginName',true,'','{$template['RequiresFile']}');"];
+ } else {
+ if ( ! $template['UpdateAvailable'] ) # this handles if the feed hasn't caught up to the update yet
+ $template['UpdateAvailable'] = false;
+ }
+ $pluginSettings = ($pluginName == "community.applications.plg") ? "ca_settings" : plugin("launch","/var/log/plugins/$pluginName");
+ if ( $pluginSettings ) {
+ $actionsContext[] = ["icon"=>"ca_fa-pluginSettings","text"=>tr("Settings"),"action"=>"openNewWindow('/Apps/$pluginSettings');"];
+ }
- if ( $pluginName != "community.applications.plg" ) {
- if ( ! empty($actionsContext) )
- $actionsContext[] = ["divider"=>true];
+ if ( $pluginName != "community.applications.plg" ) {
+ if ( ! empty($actionsContext) )
+ $actionsContext[] = ["divider"=>true];
- $actionsContext[] = ["icon"=>"ca_fa-delete","text"=>tr("Uninstall"),"action"=>"uninstallApp('/var/log/plugins/$pluginName','".str_replace(" "," ",$template['Name'])."');"];
- }
- if ( $template['DonateLink'] ) {
- $actionsContext[] = ["divider"=>true];
- $actionsContext[] = ["icon"=>"ca_fa-money","text"=>tr("Donate"),"action"=>"openNewWindow('".addslashes($template['DonateLink'])."','_blank');"];
- }
- } elseif ( ! $template['Blacklist'] || ! $template['Compatible'] ) {
- $buttonTitle = $template['InstallPath'] ? tr("Reinstall") : tr("Install");
- if ( ! $template['InstallPath'] ) {
- $installComment = $template['CAComment'];
- if ( ! $installComment && $template['Requires'] ){
- // Remove the flags to indicate a search taking place
- preg_match_all("/\/\/(.*?)\\\\/m",$template['Requires'],$searchMatches);
- if ( count($searchMatches[1]) ) {
- foreach ($searchMatches[1] as $searchResult) {
- $template['Requires'] = str_replace("//$searchResult\\\\",$searchResult,$template['Requires']);
- }
- }
- $installComment = tr("This application has additional requirements")."
".markdown($template['Requires']);
- }
- }
- $isDeprecated = $template['Deprecated'] ? "&deprecated" : "";
- $isDeprecated = $template['Compatible'] ? "&incompatible" : "";
+ $actionsContext[] = ["icon"=>"ca_fa-delete","text"=>tr("Uninstall"),"action"=>"uninstallApp('/var/log/plugins/$pluginName','".str_replace(" "," ",$template['Name'])."');"];
+ }
+ if ( $template['DonateLink'] ) {
+ $actionsContext[] = ["divider"=>true];
+ $actionsContext[] = ["icon"=>"ca_fa-money","text"=>tr("Donate"),"action"=>"openNewWindow('".addslashes($template['DonateLink'])."','_blank');"];
+ }
+ } elseif ( ! $template['Blacklist'] || ! $template['Compatible'] ) {
+ $buttonTitle = $template['InstallPath'] ? tr("Reinstall") : tr("Install");
+ if ( ! $template['InstallPath'] ) {
+ $installComment = $template['CAComment'];
+ if ( ! $installComment && $template['Requires'] ){
+ // Remove the flags to indicate a search taking place
+ preg_match_all("/\/\/(.*?)\\\\/m",$template['Requires'],$searchMatches);
+ if ( count($searchMatches[1]) ) {
+ foreach ($searchMatches[1] as $searchResult) {
+ $template['Requires'] = str_replace("//$searchResult\\\\",$searchResult,$template['Requires']);
+ }
+ }
+ $installComment = tr("This application has additional requirements")."
".markdown($template['Requires']);
+ }
+ }
+ $isDeprecated = $template['Deprecated'] ? "&deprecated" : "";
+ $isDeprecated = $template['Compatible'] ? "&incompatible" : "";
- $updateFlag = false;
- $requiresText = "";
- if ( $template['RequiresFile'] && ! is_file($template['RequiresFile']) ) {
- $requiresText = "AnythingHere";
- $updateFlag = true; // This forces the system to double check the requirements and abort the install
- } else {
- $installComment = $template['RequiresFile'] ? "" : $installComment;
- }
- if ( ! ($template['UninstallOnly'] ?? false) ) {
- if ( $template['Compatible'] )
- $actionsContext[] = ["icon"=>"ca_fa-install","text"=>$buttonTitle,"action"=>"installPlugin('{$template['PluginURL']}$isDeprecated','$updateFlag','".str_replace([" ","\n"],[" ",""],htmlspecialchars($installComment ?? ""))."','$requiresText');"];
- }
- if ( $template['InstallPath'] ) {
- if ( ! empty($actionsContext) )
- $actionsContext[] = ["divider"=>true];
- $actionsContext[] = ["icon"=>"ca_fa-delete","text"=>tr("Remove from Previous Apps"),"action"=>"removeApp('{$template['InstallPath']}','$pluginName');"];
- }
- }
- if ( file_exists($caPaths['pluginPending'].$pluginName) ) {
- unset($actionsContext);
- $actionsContext[] = ["text"=>tr("Pending")];
- }
- }
- }
- }
- if ( $template['Language'] ) {
- $countryCode = $template['LanguageDefault'] ? "en_US" : $template['LanguagePack'];
- $dynamixSettings = @parse_ini_file($caPaths['dynamixSettings'],true);
- $currentLanguage = $dynamixSettings['display']['locale'] ?? "en_US";
- $installedLanguages = array_diff(scandir("/usr/local/emhttp/languages"),[".",".."]);
- $installedLanguages = array_filter($installedLanguages,function($v) {
- return is_dir("/usr/local/emhttp/languages/$v");
- });
- $installedLanguages[] = "en_US";
- $currentLanguage = (is_dir("/usr/local/emhttp/languages/$currentLanguage") ) ? $currentLanguage : "en_US";
- if ( in_array($countryCode,$installedLanguages) ) {
- if ( $currentLanguage != $countryCode ) {
- $actionsContext[] = ["icon"=>"ca_fa-switchto","text"=>$template['SwitchLanguage'],"action"=>"CAswitchLanguage('$countryCode');"];
- }
- } else {
- $actionsContext[] = ["icon"=>"ca_fa-install","text"=>tr("Install"),"action"=>"installLanguage('{$template['TemplateURL']}','$countryCode');"];
- }
- if ( file_exists("/var/log/plugins/lang-$countryCode.xml") ) {
- $template['Installed'] = true;
- if ( languageCheck($template) ) {
- $template['UpdateAvailable'] = true;
- $actionsContext[] = ["icon"=>"ca_fa-update","text"=>$template['UpdateLanguage'],"action"=>"updateLanguage('$countryCode');"];
- }
- if ( $currentLanguage != $countryCode ) {
- if ( ! empty($actionsContext) )
- $actionsContext[] = ["divider"=>true];
- $actionsContext[] = ["icon"=>"ca_fa-delete","text"=>tr("Remove Language Pack"),"action"=>"removeLanguage('$countryCode');"];
- }
- }
- if ( file_exists($caPaths['pluginPending'].$template['LanguagePack']) || file_exists("{$caPaths['pluginPending']}lang-{$template['LanguagePack']}.xml") ) {
- unset($actionsContext);
- $actionsContext[] = ["text"=>tr("Pending")];
- }
- }
+ $updateFlag = false;
+ $requiresText = "";
+ if ( $template['RequiresFile'] && ! is_file($template['RequiresFile']) ) {
+ $requiresText = "AnythingHere";
+ $updateFlag = true; // This forces the system to double check the requirements and abort the install
+ } else {
+ $installComment = $template['RequiresFile'] ? "" : $installComment;
+ }
+ if ( ! ($template['UninstallOnly'] ?? false) ) {
+ if ( $template['Compatible'] )
+ $actionsContext[] = ["icon"=>"ca_fa-install","text"=>$buttonTitle,"action"=>"installPlugin('{$template['PluginURL']}$isDeprecated','$updateFlag','".str_replace([" ","\n"],[" ",""],htmlspecialchars($installComment ?? ""))."','$requiresText');"];
+ }
+ if ( $template['InstallPath'] ) {
+ if ( ! empty($actionsContext) )
+ $actionsContext[] = ["divider"=>true];
+ $actionsContext[] = ["icon"=>"ca_fa-delete","text"=>tr("Remove from Previous Apps"),"action"=>"removeApp('{$template['InstallPath']}','$pluginName');"];
+ }
+ }
+ if ( file_exists($caPaths['pluginPending'].$pluginName) ) {
+ unset($actionsContext);
+ $actionsContext[] = ["text"=>tr("Pending")];
+ }
+ }
+ }
+ }
+ if ( $template['Language'] ) {
+ $countryCode = $template['LanguageDefault'] ? "en_US" : $template['LanguagePack'];
+ $dynamixSettings = @parse_ini_file($caPaths['dynamixSettings'],true);
+ $currentLanguage = $dynamixSettings['display']['locale'] ?? "en_US";
+ $installedLanguages = array_diff(scandir("/usr/local/emhttp/languages"),[".",".."]);
+ $installedLanguages = array_filter($installedLanguages,function($v) {
+ return is_dir("/usr/local/emhttp/languages/$v");
+ });
+ $installedLanguages[] = "en_US";
+ $currentLanguage = (is_dir("/usr/local/emhttp/languages/$currentLanguage") ) ? $currentLanguage : "en_US";
+ if ( in_array($countryCode,$installedLanguages) ) {
+ if ( $currentLanguage != $countryCode ) {
+ $actionsContext[] = ["icon"=>"ca_fa-switchto","text"=>$template['SwitchLanguage'],"action"=>"CAswitchLanguage('$countryCode');"];
+ }
+ } else {
+ $actionsContext[] = ["icon"=>"ca_fa-install","text"=>tr("Install"),"action"=>"installLanguage('{$template['TemplateURL']}','$countryCode');"];
+ }
+ if ( file_exists("/var/log/plugins/lang-$countryCode.xml") ) {
+ $template['Installed'] = true;
+ if ( languageCheck($template) ) {
+ $template['UpdateAvailable'] = true;
+ $actionsContext[] = ["icon"=>"ca_fa-update","text"=>$template['UpdateLanguage'],"action"=>"updateLanguage('$countryCode');"];
+ }
+ if ( $currentLanguage != $countryCode ) {
+ if ( ! empty($actionsContext) )
+ $actionsContext[] = ["divider"=>true];
+ $actionsContext[] = ["icon"=>"ca_fa-delete","text"=>tr("Remove Language Pack"),"action"=>"removeLanguage('$countryCode');"];
+ }
+ }
+ if ( file_exists($caPaths['pluginPending'].$template['LanguagePack']) || file_exists("{$caPaths['pluginPending']}lang-{$template['LanguagePack']}.xml") ) {
+ unset($actionsContext);
+ $actionsContext[] = ["text"=>tr("Pending")];
+ }
+ }
- $template['actionsContext'] = $actionsContext;
+ $template['actionsContext'] = $actionsContext;
- $template['ca_fav'] = $caSettings['favourite'] && ($caSettings['favourite'] == $template['RepoName']);
- if ( strpos($template['Repository'],"/") === false )
- $template['Pinned'] = $pinnedApps["library/{$template['Repository']}&{$template['SortName']}"] ?? false;
- else
- $template['Pinned'] = $pinnedApps["{$template['Repository']}&{$template['SortName']}"] ?? false;
- if ( isset($template['Repo']) ) {
- $template['Twitter'] = $template['Twitter'] ?? ($repositories[$template['Repo']]['Twitter'] ?? null);
- $template['Reddit'] = $template['Reddit'] ?? ($repositories[$template['Repo']]['Reddit'] ?? null);
- $template['Facebook'] = $template['Facebook'] ?? ($repositories[$template['Repo']]['Facebook'] ?? null);
- $template['Discord'] = $template['Discord'] ?? ($repositories[$template['RepoName']]['Discord'] ?? null);
- } else {
- $template['Twitter'] = $template['Twitter'] ?? null;
- $template['Reddit'] = $template['Reddit'] ?? null;
- $template['Facebook'] = $template['Facebook'] ?? null;
- $template['Discord'] = $template['Discord'] ?? null;
- }
+ $template['ca_fav'] = $caSettings['favourite'] && ($caSettings['favourite'] == $template['RepoName']);
+ if ( strpos($template['Repository'],"/") === false )
+ $template['Pinned'] = $pinnedApps["library/{$template['Repository']}&{$template['SortName']}"] ?? false;
+ else
+ $template['Pinned'] = $pinnedApps["{$template['Repository']}&{$template['SortName']}"] ?? false;
+ if ( isset($template['Repo']) ) {
+ $template['Twitter'] = $template['Twitter'] ?? ($repositories[$template['Repo']]['Twitter'] ?? null);
+ $template['Reddit'] = $template['Reddit'] ?? ($repositories[$template['Repo']]['Reddit'] ?? null);
+ $template['Facebook'] = $template['Facebook'] ?? ($repositories[$template['Repo']]['Facebook'] ?? null);
+ $template['Discord'] = $template['Discord'] ?? ($repositories[$template['RepoName']]['Discord'] ?? null);
+ } else {
+ $template['Twitter'] = $template['Twitter'] ?? null;
+ $template['Reddit'] = $template['Reddit'] ?? null;
+ $template['Facebook'] = $template['Facebook'] ?? null;
+ $template['Discord'] = $template['Discord'] ?? null;
+ }
- $previousAppName = $template['Plugin'] ? $template['PluginURL'] : $template['Name'];
- if ( isset($checkedOffApps[$previousAppName]) )
- $template['checked'] = $checkedOffApps[$previousAppName] ? "checked" : "";
+ $previousAppName = $template['Plugin'] ? $template['PluginURL'] : $template['Name'];
+ if ( isset($checkedOffApps[$previousAppName]) )
+ $template['checked'] = $checkedOffApps[$previousAppName] ? "checked" : "";
- if ( ! $template['Plugin'] ) {
- $tmpRepo = $template['Repository'];
- if ( ! strpos($tmpRepo,"/") ) {
- $tmpRepo = "library/$tmpRepo";
- }
- foreach ($info as $testDocker) {
- if ( ($tmpRepo == $testDocker['Image'] || "$tmpRepo:latest" == $testDocker['Image']) && ($template['Name'] == $testDocker['Name']) ) {
- $template['Installed'] = true;
+ if ( ! $template['Plugin'] ) {
+ $tmpRepo = $template['Repository'];
+ if ( ! strpos($tmpRepo,"/") ) {
+ $tmpRepo = "library/$tmpRepo";
+ }
+ foreach ($info as $testDocker) {
+ if ( ($tmpRepo == $testDocker['Image'] || "$tmpRepo:latest" == $testDocker['Image']) && ($template['Name'] == $testDocker['Name']) ) {
+ $template['Installed'] = true;
- break;
- }
- }
- } else {
- $pluginName = basename($template['PluginURL']);
- $template['Installed'] = checkInstalledPlugin($template) ;
+ break;
+ }
+ }
+ } else {
+ $pluginName = basename($template['PluginURL']);
+ $template['Installed'] = checkInstalledPlugin($template) ;
- }
+ }
- if ( $template['Language'] ) {
- $template['Installed'] = is_dir("{$caPaths['languageInstalled']}{$template['LanguagePack']}") && ! $template['Uninstall'];
- }
+ if ( $template['Language'] ) {
+ $template['Installed'] = is_dir("{$caPaths['languageInstalled']}{$template['LanguagePack']}") && ! $template['Uninstall'];
+ }
- if ( startsWith($template['Repository'],"library/") || startsWith($template['Repository'],"registry.hub.docker.com/library/") || strpos($template['Repository'],"/") === false)
- $template['Official'] = true;
+ if ( startsWith($template['Repository'],"library/") || startsWith($template['Repository'],"registry.hub.docker.com/library/") || strpos($template['Repository'],"/") === false)
+ $template['Official'] = true;
- # Entries created. Now display it
- $ct .= displayCard($template);
- $count++;
- if ( $count == $caSettings['maxPerPage'] ) break;
- }
- }
+ # Entries created. Now display it
+ $ct .= displayCard($template);
+ $count++;
+ if ( $count == $caSettings['maxPerPage'] ) break;
+ }
+ }
- $ct .= getPageNavigation($pageNumber,count($file),false,true);
+ $ct .= getPageNavigation($pageNumber,count($file),false,true);
- if ( ! $count )
- $displayHeader .= "
".tr("No Matching Applications Found")."
";
+ if ( ! $count )
+ $displayHeader .= "
".tr("No Matching Applications Found")."
";
- if ( $count == 1 && ! isset($template['homeScreen']) ) {
- if ( $template['RepositoryTemplate'] ) {
- $displayHeader .= "";
- } else {
- if ($template['InstallPath'])
- $template['Path'] = $template['InstallPath'];
+ if ( $count == 1 && ! isset($template['homeScreen']) ) {
+ if ( $template['RepositoryTemplate'] ) {
+ $displayHeader .= "";
+ } else {
+ if ($template['InstallPath'])
+ $template['Path'] = $template['InstallPath'];
- $displayHeader .= "";
- }
- }
- // Handle MaxPerPage changing on a different tab
- $displayHeader .= "";
+ $displayHeader .= "";
+ }
+ }
+ // Handle MaxPerPage changing on a different tab
+ $displayHeader .= "";
- return "$displayHeader$ct";
+ return "$displayHeader$ct";
}
function getPageNavigation($pageNumber,$totalApps,$dockerSearch,$displayCount = true) {
- global $caSettings;
+ global $caSettings;
- $pageFunction = $dockerSearch ? "dockerSearch": "changePage";
- if ( $dockerSearch )
- $caSettings['maxPerPage'] = 25;
+ $pageFunction = $dockerSearch ? "dockerSearch": "changePage";
+ if ( $dockerSearch )
+ $caSettings['maxPerPage'] = 25;
- if ( $caSettings['maxPerPage'] < 0 ) return;
- $swipeScript = "";
+ if ($totalPages <= 1) return "";
- $startApp = ($pageNumber - 1) * $caSettings['maxPerPage'] + 1;
- $endApp = $pageNumber * $caSettings['maxPerPage'];
- if ( $endApp > $totalApps )
- $endApp = $totalApps;
+ $startApp = ($pageNumber - 1) * $caSettings['maxPerPage'] + 1;
+ $endApp = $pageNumber * $caSettings['maxPerPage'];
+ if ( $endApp > $totalApps )
+ $endApp = $totalApps;
- $o = "