fix packagemanager array erros

This commit is contained in:
dmacias72
2016-09-18 13:51:12 -06:00
parent 654b561dee
commit 14bb526fb7
5 changed files with 49 additions and 19 deletions

View File

@ -8,22 +8,22 @@ if (!is_dir($pkg_path))
$pkg_desc = 'https://raw.githubusercontent.com/dmacias72/unRAID-plugins/master/plugins/packages-desc';
$pkg_repo = "https://api.github.com/repos/dmacias72/unRAID-plugins/contents/packages/$os_version";
$desc_file = $pkg_path.'packages-desc';
$repo_file = $pkg_path.'packages.json';
$desc_file = $pkg_path.'packages-desc';
$repo_file = $pkg_path.'packages.json';
$config_file = $plg_path.'NerdPack.cfg';
// get package configs
$pkg_cfg = (is_file($config_file)) ? parse_ini_file($config_file) : [];
$pkg_cfg = file_exists($config_file) ? parse_ini_file($config_file) : [];
// get array of downloaded packages
$pkgs_downloaded = file_exists($pkg_path) ? array_diff(scandir($pkg_path, 1), ['.', '..','packages.json','packages-desc']) : [];
$pkgs_downloaded = is_dir($pkg_path) ? array_diff(scandir($pkg_path, 1), ['.', '..','packages.json','packages-desc']) : [];
// get array of all installed packages
$pkgs_installed = array_diff(scandir("/var/log/packages", 1), ['.', '..']);
$pkgs_installed = array_diff(scandir("/var/log/packages", 1), ['.', '..']);
$pkgs_desc_array = (file_exists($desc_file)) ? json_decode(file_get_contents($desc_file), true) : '[]';
$pkgs_desc_array = file_exists($desc_file) ? json_decode(file_get_contents($desc_file), true) : [];
$pkgs_github_array = (file_exists($repo_file)) ? json_decode(file_get_contents($repo_file), true) : '[]';
$pkgs_github_array = file_exists($repo_file) ? json_decode(file_get_contents($repo_file), true) : [];
function logger($output, $quiet = false) {
exec('echo '.escapeshellarg($output).' 2>&1 | logger -tnerdpack');

View File

@ -6,8 +6,8 @@ require_once '/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php';
if (!file_exists($repo_file) || !empty($_GET['force']) || (filemtime($repo_file) < (time() - 3600))) {
get_content_from_github($pkg_repo, $repo_file);
get_content_from_github($pkg_desc, $desc_file);
$pkgs_desc_array = (file_exists($desc_file)) ? json_decode(file_get_contents($desc_file), true) : '[]';
$pkgs_github_array = (file_exists($repo_file)) ? json_decode(file_get_contents($repo_file), true) : '[]';
$pkgs_desc_array = file_exists($desc_file) ? json_decode(file_get_contents($desc_file), true) : [];
$pkgs_github_array = file_exists($repo_file) ? json_decode(file_get_contents($repo_file), true) : [];
}
$pkgs_array = [];
@ -25,7 +25,7 @@ foreach ($pkgs_github_array as $pkg_github) {
$pkg_version = $pkg_nameArray[sizeof($pkg_nameArray) - 3]; // get package version
$pkg_nver = $pkg_name.'-'.str_replace('.', '_', $pkg_version); // add underscored version to package name
$pkg_nver = $pkg_name.'-'.str_replace('.', '_', $pkg_version); // add underscored version to package name
$pkg_pattern = '/^'.$pkg_name.'.*/'; // search pattern for packages