function get_pkg_table() { $pkg_info = get_pkg_info(); if (!$pkg_info) { print "error"; exit; } $pkgtbl = '<table id="pkgtable" class="table table-striped table-hover">' . "\n"; $pkgtbl .= '<thead>' . "\n"; $pkgtbl .= '<tr>' . "\n"; $pkgtbl .= '<th>' . gettext("Name") . "</th>\n"; $pkgtbl .= '<th>' . gettext("Version") . "</th>\n"; $pkgtbl .= '<th>' . gettext("Description") . "</th>\n"; $pkgtbl .= '<th></th>' . "\n"; $pkgtbl .= '</tr>' . "\n"; $pkgtbl .= '</thead>' . "\n"; $pkgtbl .= '<tbody>' . "\n"; foreach ($pkg_info as $index) { if (isset($index['installed'])) { continue; } $pkgtbl .= '<tr>' . "\n"; $pkgtbl .= '<td>' . "\n"; if ($index['www'] && $index['www'] != "UNKNOWN") { $pkgtbl .= '<a title="' . gettext("Visit official website") . '" target="_blank" href="' . htmlspecialchars($index['www']) . '">' . "\n"; $pkgtbl .= htmlspecialchars($index['shortname']) . '</a>' . "\n"; } else { $pkgtbl .= htmlspecialchars($index['shortname']); } $pkgtbl .= '</td>' . "\n"; $pkgtbl .= '<td>' . "\n"; if (!$g['disablepackagehistory']) { $pkgtbl .= '<a target="_blank" title="' . gettext("View changelog") . '" href="' . htmlspecialchars($index['changeloglink']) . '">' . "\n"; $pkgtbl .= htmlspecialchars($index['version']) . '</a>' . "\n"; } else { $pkgtbl .= htmlspecialchars($index['version']); } $pkgtbl .= '</td>' . "\n"; $pkgtbl .= '<td>' . "\n"; $pkgtbl .= $index['desc']; if (is_array($index['deps']) && count($index['deps'])) { $pkgtbl .= '<br /><br />' . gettext("Package Dependencies") . ":<br/>\n"; foreach ($index['deps'] as $pdep) { $pkgtbl .= '<a target="_blank" href="https://freshports.org/' . $pdep['origin'] . '"> <i class="fa fa-paperclip"></i> ' . basename($pdep['origin']) . '-' . $pdep['version'] . '</a> ' . "\n"; } $pkgtbl .= "\n"; } $pkgtbl .= '</td>' . "\n"; $pkgtbl .= '<td>' . "\n"; $pkgtbl .= '<a title="' . gettext("Click to install") . '" href="pkg_mgr_install.php?pkg=' . $index['name'] . '" class="btn btn-success btn-sm"><i class="fa fa-plus icon-embed-btn"></i>Install</a>' . "\n"; if (!$g['disablepackageinfo'] && $index['pkginfolink'] && $index['pkginfolink'] != $index['www']) { $pkgtbl .= '<a target="_blank" title="' . gettext("View more information") . '" href="' . htmlspecialchars($index['pkginfolink']) . '" class="btn btn-default btn-sm">info</a>' . "\n"; } $pkgtbl .= '</td>' . "\n"; $pkgtbl .= '</tr>' . "\n"; } $pkgtbl .= '</tbody>' . "\n"; $pkgtbl .= '</table>' . "\n"; return $pkgtbl; }
##|*DESCR=Allow access to the 'System: Package Manager' page. ##|*MATCH=pkg_mgr.php* ##|-PRIV ini_set('max_execution_time', '0'); require_once "globals.inc"; require_once "guiconfig.inc"; require_once "pkg-utils.inc"; /* if upgrade in progress, alert user */ if (is_subsystem_dirty('packagelock')) { $pgtitle = array(gettext("System"), gettext("Package Manager")); include "head.inc"; print_info_box_np("Please wait while packages are reinstalled in the background."); include "foot.inc"; exit; } $pkg_info = get_pkg_info(); $pgtitle = array(gettext("System"), gettext("Package Manager"), gettext("Available Packages")); include "head.inc"; $tab_array = array(); $tab_array[] = array(gettext("Available Packages"), true, "pkg_mgr.php"); $tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php"); display_top_tabs($tab_array); if ($pkg_info) { //Check categories $categories = array(); foreach ($pkg_info as $pkg_data) { if (isset($pkg_data['categories'][0])) { $categories[$pkg_data['categories'][0]]++; } } ksort($categories, SORT_STRING | SORT_FLAG_CASE);
if (!empty($title_msg)) { $title_msg = preg_replace("/\\s+/", " ", $title_msg); $title_msg = preg_replace("/'/", "\\'", $title_msg); $title = "onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\" onmouseover=\"domTT_activate(this, event, 'content', '{$title_msg}', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle');\""; if ($return == "echo") { echo $title; } else { return $title; } } } if (is_array($config['installedpackages']['package'])) { foreach ($config['installedpackages']['package'] as $instpkg) { $tocheck[] = $instpkg['name']; } $currentvers = get_pkg_info($tocheck, array('version', 'xmlver', 'pkginfolink', 'descr')); } $closehead = false; $pgtitle = array(gettext("System"), gettext("Package Manager")); include "head.inc"; ?> <script type="text/javascript" src="javascript/domTT/domLib.js"></script> <script type="text/javascript" src="javascript/domTT/domTT.js"></script> <script type="text/javascript" src="javascript/domTT/behaviour.js"></script> <script type="text/javascript" src="javascript/domTT/fadomatic.js"></script> <script type="text/javascript" src="/javascript/row_helper_dynamic.js"></script> </head> <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <?php include "fbegin.inc";
function get_pkg_table() { $installed_packages = array(); $package_list = get_pkg_info(); if (!$package_list) { print "error"; exit; } foreach ($package_list as $pkg) { if (!isset($pkg['installed']) && !isset($pkg['broken'])) { continue; } $installed_packages[] = $pkg; } $pkgtbl = ""; if (empty($installed_packages)) { print "nopkg"; exit; } $pkgtbl .= ' <div class="table-responsive">'; $pkgtbl .= ' <table class="table table-striped table-hover table-condensed">'; $pkgtbl .= ' <thead>'; $pkgtbl .= ' <tr>'; $pkgtbl .= ' <th><!-- Status icon --></th>'; $pkgtbl .= ' <th>' . gettext("Name") . '</th>'; $pkgtbl .= ' <th>' . gettext("Category") . '</th>'; $pkgtbl .= ' <th>' . gettext("Version") . '</th>'; $pkgtbl .= ' <th>' . gettext("Description") . '</th>'; $pkgtbl .= ' <th>' . gettext("Actions") . '</th>'; $pkgtbl .= ' </tr>'; $pkgtbl .= ' </thead>'; $pkgtbl .= ' <tbody>'; foreach ($installed_packages as $pkg) { if (!$pkg['name']) { continue; } #check package version $txtcolor = ""; $upgradeavail = false; $missing = false; $vergetstr = ""; if (isset($pkg['broken'])) { // package is configured, but does not exist in the system $txtcolor = "text-danger"; $missing = true; $status = gettext('Package is configured, but not installed!'); } else { if (isset($pkg['installed_version']) && isset($pkg['version'])) { $version_compare = pkg_version_compare($pkg['installed_version'], $pkg['version']); if ($version_compare == '>') { // we're running a newer version of the package $status = sprintf(gettext('Newer than available (%s)'), $pkg['version']); } else { if ($version_compare == '<') { // we're running an older version of the package $status = sprintf(gettext('Upgrade available to %s'), $pkg['version']); $txtcolor = "text-warning"; $upgradeavail = true; $vergetstr = '&from=' . $pkg['installed_version'] . '&to=' . $pkg['version']; } else { if ($version_compare == '=') { // we're running the current version $status = gettext('Up-to-date'); } else { $status = gettext('Error comparing version'); } } } } else { // unknown available package version $status = gettext('Unknown'); $statusicon = 'question'; } } $pkgtbl .= ' <tr>'; $pkgtbl .= ' <td>'; if ($upgradeavail) { $pkgtbl .= ' <a title="' . $status . '" href="pkg_mgr_install.php?mode=reinstallpkg&pkg=' . $pkg['name'] . $vergetstr . '" class="fa fa-refresh"></a>'; } elseif ($missing) { $pkgtbl .= ' <span class="text-danger"><i title="' . $status . '" class="fa fa-exclamation"></i></span>'; } else { $pkgtbl .= ' <i title="' . $status . '" class="fa fa-check"></i>'; } $pkgtbl .= ' </td>'; $pkgtbl .= ' <td>'; $pkgtbl .= ' <span class="' . $txtcolor . '">' . $pkg['shortname'] . '</span>'; $pkgtbl .= ' </td>'; $pkgtbl .= ' <td>'; $pkgtbl .= ' ' . implode(" ", $pkg['categories']); $pkgtbl .= ' </td>'; $pkgtbl .= ' <td>'; if (!$g['disablepackagehistory']) { $pkgtbl .= ' <a target="_blank" title="' . gettext("View changelog") . '" href="' . htmlspecialchars($pkg['changeloglink']) . '">' . htmlspecialchars($pkg['installed_version']) . '</a>'; } else { $pkgtbl .= ' ' . htmlspecialchars($pkg['installed_version']); } $pkgtbl .= ' </td>'; $pkgtbl .= ' <td>'; $pkgtbl .= ' ' . $pkg['desc']; if (is_array($pkg['deps']) && count($pkg['deps'])) { $pkgtbl .= ' <br /><br />' . gettext("Package Dependencies") . ':<br/>'; foreach ($pkg['deps'] as $pdep) { $pkgtbl .= ' <a target="_blank" href="https://freshports.org/' . $pdep['origin'] . '"> ' . '<i class="fa fa-paperclip"></i> ' . basename($pdep['origin']) . '-' . $pdep['version'] . '</a> '; } } $pkgtbl .= ' </td>'; $pkgtbl .= ' <td>'; $pkgtbl .= ' <a title="' . sprintf(gettext("Remove package %s"), $pkg['name']) . '" href="pkg_mgr_install.php?mode=delete&pkg=' . $pkg['name'] . '" class="fa fa-trash"></a>'; if ($upgradeavail) { $pkgtbl .= ' <a title="' . sprintf(gettext("Update package %s"), $pkg['name']) . '" href="pkg_mgr_install.php?mode=reinstallpkg&pkg=' . $pkg['name'] . $vergetstr . '" class="fa fa-refresh"></a>'; } else { $pkgtbl .= ' <a title="' . sprintf(gettext("Reinstall package %s"), $pkg['name']) . '" href="pkg_mgr_install.php?mode=reinstallpkg&pkg=' . $pkg['name'] . '" class="fa fa-retweet"></a>'; } if (!isset($g['disablepackageinfo']) && $pkg['www'] != 'UNKNOWN') { $pkgtbl .= ' <a target="_blank" title="' . gettext("View more information") . '" href="' . htmlspecialchars($pkg['www']) . '" class="fa fa-info"></a>'; } $pkgtbl .= ' </td>'; $pkgtbl .= ' </tr>'; } $pkgtbl .= ' </tbody>'; $pkgtbl .= ' </table>'; $pkgtbl .= ' </div>'; $pkgtbl .= ' </div>'; $pkgtbl .= ' <br />'; $pkgtbl .= ' <div class="text-center">'; $pkgtbl .= ' <p>'; $pkgtbl .= ' <i class="fa fa-refresh"></i> = ' . gettext('Update') . ' '; $pkgtbl .= ' <i class="fa fa-check"></i> = ' . gettext('Current') . ' '; $pkgtbl .= ' </p>'; $pkgtbl .= ' <p>'; $pkgtbl .= ' <i class="fa fa-trash"></i> = ' . gettext('Remove') . ' '; $pkgtbl .= ' <i class="fa fa-info"></i> = ' . gettext('Information') . ' '; $pkgtbl .= ' <i class="fa fa-retweet"></i> = ' . gettext('Reinstall'); $pkgtbl .= ' </p>'; $pkgtbl .= ' <p><span class="text-warning">' . gettext("Newer version available") . '</span></p>'; $pkgtbl .= ' <p><span class="text-danger">' . gettext("Package is configured but not (fully) installed") . '</span></p>'; return $pkgtbl; }
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * */ $nocsrf = true; require_once "guiconfig.inc"; require_once "pfsense-utils.inc"; require_once "functions.inc"; require_once "/usr/local/www/widgets/include/installed_packages.inc"; require_once "pkg-utils.inc"; if ($_REQUEST && $_REQUEST['ajax']) { $package_list = get_pkg_info(); $installed_packages = array_filter($package_list, function ($v) { return isset($v['installed']) || isset($v['broken']); }); if (empty($installed_packages)) { print_info_box(gettext("No packages installed.") . " " . gettext('You can install packages <a href="pkg_mgr.php" class="alert-link">here</a>.'), 'warning', false); exit; } print "<thead>\n"; print "<tr>\n"; print "<th>" . gettext("Name") . "</th>\n"; print "<th>" . gettext("Category") . "</th>\n"; print "<th>" . gettext("Version") . "</th>\n"; print "<th>" . gettext("Actions") . "</th>\n"; print "</tr>\n"; print "</thead>\n";
$timezone = "Etc/UTC"; } date_default_timezone_set($timezone); /* if upgrade in progress, alert user */ if (is_subsystem_dirty('packagelock')) { $pgtitle = array(gettext("System"), gettext("Package Manager")); include "head.inc"; echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n"; include "fbegin.inc"; echo "Please wait while packages are reinstalled in the background."; include "fend.inc"; echo "</body>"; echo "</html>"; exit; } $pkg_info = get_pkg_info('all', array("noembedded", "name", "category", "website", "version", "status", "descr", "maintainer", "required_version", "maximum_version", "pkginfolink", "supportedbybsdperimeter")); if ($pkg_info) { $fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w"); fwrite($fout, serialize($pkg_info)); fclose($fout); //$pkg_sizes = get_pkg_sizes(); } else { $using_cache = true; $xmlrpc_base_url = isset($config['system']['altpkgrepo']['enable']) ? $config['system']['altpkgrepo']['xmlrpcbaseurl'] : $g['xmlrpcbaseurl']; if (file_exists("{$g['tmp_path']}/pkg_info.cache")) { $savemsg = sprintf(gettext("Unable to retrieve package info from %s. Cached data will be used."), $xmlrpc_base_url); $pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache")); } else { $savemsg = sprintf(gettext('Unable to communicate with %1$s. Please verify DNS and interface configuration, and that %2$s has functional Internet connectivity.'), $xmlrpc_base_url, $g['product_name']); } }
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ $nocsrf = true; require_once "guiconfig.inc"; require_once "pfsense-utils.inc"; require_once "functions.inc"; require_once "/usr/local/www/widgets/include/installed_packages.inc"; require_once "pkg-utils.inc"; if (is_array($config['installedpackages']['package'])) { foreach ($config['installedpackages']['package'] as $instpkg) { $tocheck[] = $instpkg['name']; } $currentvers = get_pkg_info($tocheck, array('version', 'xmlver')); } $updateavailable = false; ?> <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="installed packages"> <tr> <td width="15%" class="listhdrr">Package Name</td> <td width="15%" class="listhdrr">Category</td> <td width="30%" class="listhdrr">Package Version</td> </tr> <?php if ($config['installedpackages']['package'] != "") { $instpkgs = array(); foreach ($config['installedpackages']['package'] as $instpkg) { $instpkgs[] = $instpkg['name'];
$timezone = "Etc/UTC"; } date_default_timezone_set($timezone); /* if upgrade in progress, alert user */ if (is_subsystem_dirty('packagelock')) { $pgtitle = array(gettext("System"), gettext("Package Manager")); include "head.inc"; print_info_box_np("Please wait while packages are reinstalled in the background."); include "foot.inc"; exit; } //get_pkg_info only if cache file has more then $g[min_pkg_cache_file_time] seconds $pkg_cache_file_time = $g['min_pkg_cache_file_time'] ? $g['min_pkg_cache_file_time'] : 120; $xmlrpc_base_url = get_active_xml_rpc_base_url(); if (!file_exists("{$g['tmp_path']}/pkg_info.cache") || time() - filemtime("{$g['tmp_path']}/pkg_info.cache") > $pkg_cache_file_time) { $pkg_info = get_pkg_info('all', array("noembedded", "name", "category", "website", "version", "status", "descr", "maintainer", "required_version", "maximum_version", "pkginfolink", "config_file")); //create cache file after get_pkg_info if ($pkg_info) { $fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w"); fwrite($fout, serialize($pkg_info)); fclose($fout); //$pkg_sizes = get_pkg_sizes(); } else { $using_cache = true; if (file_exists("{$g['tmp_path']}/pkg_info.cache")) { $savemsg = sprintf(gettext("Unable to retrieve package info from %s. Cached data will be used."), $xmlrpc_base_url); $pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache")); } else { $savemsg = sprintf(gettext('Unable to communicate with %1$s. Please verify DNS and interface configuration, and that %2$s has functional Internet connectivity.'), $xmlrpc_base_url, $g['product_name']); } }
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ $nocsrf = true; require_once "guiconfig.inc"; require_once "pfsense-utils.inc"; require_once "functions.inc"; require_once "/usr/local/www/widgets/include/installed_packages.inc"; require_once "pkg-utils.inc"; if (is_array($config['installedpackages']['package'])) { $instpkgs = array(); foreach ($config['installedpackages']['package'] as $instpkg) { $instpkgs[$instpkg['name']] = $instpkg; } ksort($instpkgs); $currentvers = get_pkg_info(array_keys($instpkgs), array('version', 'xmlver')); } ?> <?php if (empty($config['installedpackages']['package'])) { ?> <div class="alert alert-warning" role="alert"> <strong>No packages installed.</strong> You can install packages <a href="pkg_mgr.php" class="alert-link">here</a>. </div> <?php } else { ?> <table class="table table-striped table-hover"> <thead>
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ require_once "globals.inc"; require_once "guiconfig.inc"; require_once "pkg-utils.inc"; $pkg_info = get_pkg_info('all', array('noembedded', 'name', 'category', 'website', 'version', 'status', 'descr', 'maintainer', 'required_version', 'pkginfolink')); if ($pkg_info) { $fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w"); fwrite($fout, serialize($pkg_info)); fclose($fout); //$pkg_sizes = get_pkg_sizes(); } else { $using_cache = true; if (file_exists("{$g['tmp_path']}/pkg_info.cache")) { $savemsg = "Unable to retrieve package info from {$g['xmlrpcbaseurl']}. Cached data will be used."; $pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache")); } else { $savemsg = "Unable to communicate to {$g['product_name']}.com. Please check DNS, default gateway, etc."; } } if (!empty($_GET)) {