From f674f79ee7780a754e0f6227d55e29fc4709e5a1 Mon Sep 17 00:00:00 2001 From: dmacias72 Date: Sat, 8 Oct 2016 14:45:37 -0600 Subject: [PATCH] formatting, filter md5 --- .../plugins/NerdPack/include/PackageQuery.php | 98 ++++++++++--------- 1 file changed, 51 insertions(+), 47 deletions(-) diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php index 199c03e9..cb88c1c7 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php @@ -15,58 +15,62 @@ $pkgs_array = []; foreach ($pkgs_github_array as $pkg_github) { $pkg_nameArray = explode('-', $pkg_github['name']); // split package name into array - $pkg_name = $pkg_nameArray[0]; + // strip md5 files + if(!strpos(end($pkg_nameArray),'.md5')) { - if (sizeof($pkg_nameArray) > 4) { //if package name has a subset get it - for ($ii = 1; $ii < sizeof($pkg_nameArray)-3; $ii++) { - $pkg_name .= '-'.$pkg_nameArray[$ii]; - } - } + $pkg_name = $pkg_nameArray[0]; - $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_pattern = '/^'.$pkg_name.'.*/'; // search pattern for packages - - // check all plugins for package dependency - $plugins = []; - exec("cd /boot/config/plugins ; find *.plg | xargs grep '${pkg_name}-${pkg_version}' -sl",$plugins); - $pkg_plgs = '--'; - if ($plugins){ - foreach ($plugins as $plugin){ - $pkg_plgs .= pathinfo($plugin, PATHINFO_FILENAME).', '; - } - $pkg_plgs = substr($pkg_plgs, 2, -2); - } - - // get package preference from config file - $pkg_set = "no"; - foreach ($pkg_cfg as $pkg_key => $pkg_line) { - if (preg_match('/^'.$pkg_name.'.*/',$pkg_key)){ - if(sizeof(array_diff(split('-', $pkg_key), split('-', $pkg_name))) < 2 ){ - $pkg_set = $pkg_line; - break; + if (sizeof($pkg_nameArray) > 4) { //if package name has a subset get it + for ($ii = 1; $ii < sizeof($pkg_nameArray)-3; $ii++) { + $pkg_name .= '-'.$pkg_nameArray[$ii]; } } + + $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_pattern = '/^'.$pkg_name.'-.*/'; // search pattern for packages + + // check all plugins for package dependency + $plugins = []; + exec("cd /boot/config/plugins ; find *.plg | xargs grep '${pkg_name}-${pkg_version}' -sl",$plugins); + $pkg_plgs = '--'; + if ($plugins){ + foreach ($plugins as $plugin){ + $pkg_plgs .= pathinfo($plugin, PATHINFO_FILENAME).', '; + } + $pkg_plgs = substr($pkg_plgs, 2, -2); + } + + // get package preference from config file + $pkg_set = "no"; + foreach ($pkg_cfg as $pkg_key => $pkg_line) { + if (preg_match('/^'.$pkg_name.'.*/',$pkg_key)){ + if(sizeof(array_diff(split('-', $pkg_key), split('-', $pkg_name))) < 2 ){ + $pkg_set = $pkg_line; + break; + } + } + } + + $pkg = [ + 'name' => $pkg_github['name'], // add full package name + 'pkgname' => $pkg_name, // add package name only + 'pkgnver' => $pkg_nver, // add package name with underscored version + 'pkgversion' => $pkg_version, // add package name with raw version + 'size' => format_size($pkg_github['size'], 1, '?'), // add package size + 'installed' => preg_grep($pkg_pattern, $pkgs_installed) ? 'yes' : 'no', // checks if package name is installed + 'installeq' => in_array(pathinfo($pkg_github['name'], PATHINFO_FILENAME), $pkgs_installed) ? 'yes' : 'no', // checks if package installed equals github exactly + 'downloaded' => preg_grep($pkg_pattern, $pkgs_downloaded) ? 'yes' : 'no', // checks if package name is downloaded + 'downloadeq' => in_array($pkg_github['name'], $pkgs_downloaded) ? 'yes' : 'no', // checks if package downloaded equals github exactly + 'config' => $pkg_set, // install preference + 'plugins' => $pkg_plgs, // plugins dependency on package + 'desc' => $pkgs_desc_array[$pkg_name] + ]; + + $pkgs_array[] = $pkg; } - - $pkg = [ - 'name' => $pkg_github['name'], // add full package name - 'pkgname' => $pkg_name, // add package name only - 'pkgnver' => $pkg_nver, // add package name with underscored version - 'pkgversion' => $pkg_version, // add package name with raw version - 'size' => format_size($pkg_github['size'], 1, '?'), // add package size - 'installed' => preg_grep($pkg_pattern, $pkgs_installed) ? 'yes' : 'no', // checks if package name is installed - 'installeq' => in_array(pathinfo($pkg_github['name'], PATHINFO_FILENAME), $pkgs_installed) ? 'yes' : 'no', // checks if package installed equals github exactly - 'downloaded' => preg_grep($pkg_pattern, $pkgs_downloaded) ? 'yes' : 'no', // checks if package name is downloaded - 'downloadeq' => in_array($pkg_github['name'], $pkgs_downloaded) ? 'yes' : 'no', // checks if package downloaded equals github exactly - 'config' => $pkg_set, // install preference - 'plugins' => $pkg_plgs, // plugins dependency on package - 'desc' => $pkgs_desc_array[$pkg_name] - ]; - - $pkgs_array[] = $pkg; } $return = [