diff options
author | Colin Smith <colin@pfsense.org> | 2005-07-18 01:33:49 +0000 |
---|---|---|
committer | Colin Smith <colin@pfsense.org> | 2005-07-18 01:33:49 +0000 |
commit | 3f3a5bef7c56ab71b36a58fd4ce3e19d617ef8f1 (patch) | |
tree | fef0e56e1c45cd1967a8ea073d7e4fb393ec6565 /usr/local/www/pkg_mgr.php | |
parent | 2f019b26d369b5832cc65b8e484f7137f9149a30 (diff) | |
download | pfsense-3f3a5bef7c56ab71b36a58fd4ce3e19d617ef8f1.zip pfsense-3f3a5bef7c56ab71b36a58fd4ce3e19d617ef8f1.tar.gz |
Cache package information. If we are unable to connect to the XMLRPC server, attempt to use this cache.
Diffstat (limited to 'usr/local/www/pkg_mgr.php')
-rwxr-xr-x | usr/local/www/pkg_mgr.php | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/usr/local/www/pkg_mgr.php b/usr/local/www/pkg_mgr.php index 7ed7313..70e7aa1 100755 --- a/usr/local/www/pkg_mgr.php +++ b/usr/local/www/pkg_mgr.php @@ -52,6 +52,16 @@ if ($_POST) { } } +$pkg_info = get_pkg_info('all', array('name', 'category', 'website', 'version', 'status', 'descr')); +if($pkg_info) { + $fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w"); + fwrite($fout, serialize($pkg_info)); + $pkg_sizes = get_pkg_sizes(); +} else { + $using_cache = true; + $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")); +} $pgtitle = "System: Package Manager"; include("head.inc"); @@ -66,9 +76,6 @@ include("fbegin.inc"); <?php if ($savemsg) print_info_box($savemsg); ?> <?php -$pkg_info = get_pkg_info('all', array('name', 'category', 'website', 'version', 'status', 'descr')); -$pkg_sizes = get_pkg_sizes(); - ?> <br> @@ -94,6 +101,9 @@ $pkg_sizes = get_pkg_sizes(); </tr> <?php + if(!$pkg_info) { + echo "<tr><td colspan=\"5\"><center>There are currently no available packages for installation.</td></tr>"; + } else { $pkgs = array(); $instpkgs = array(); if($config['installedpackages']['package'] != "") @@ -117,16 +127,19 @@ $pkg_sizes = get_pkg_sizes(); <?= $index['category'] ?> </td> <?php - $size = get_package_install_size($index['name'], $pkg_sizes); - $size = squash_from_bytes($size[$index['name']], 1); + if(!$using_cache) { + $size = get_package_install_size($index['name'], $pkg_sizes); + $size = squash_from_bytes($size[$index['name']], 1); + } + if(!$size) $size = "Unknown."; ?> <td class="listlr"> - <?= $size ?> - </td> + <?= $size ?> + </td> <td class="listlr"> - <?= $index['status'] ?> - <br> - <?= $index['version'] ?> + <?= $index['status'] ?> + <br> + <?= $index['version'] ?> </td> <td class="listbg"> <font color="#ffffff"> @@ -141,6 +154,7 @@ $pkg_sizes = get_pkg_sizes(); } else { echo "<tr><td colspan=\"5\"><center>There are currently no available packages for installation.</td></tr>"; } + } ?> </table> </div> |