1
|
<?php
|
2
|
/*
|
3
|
$Id$
|
4
|
Copyright 2007 Scott Dale
|
5
|
Part of pfSense widgets (https://www.pfsense.org)
|
6
|
originally based on m0n0wall (http://m0n0.ch/wall)
|
7
|
|
8
|
Copyright (C) 2004-2005 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net>
|
9
|
and Jonathan Watt <jwatt@jwatt.org>.
|
10
|
All rights reserved.
|
11
|
|
12
|
Redistribution and use in source and binary forms, with or without
|
13
|
modification, are permitted provided that the following conditions are met:
|
14
|
|
15
|
1. Redistributions of source code must retain the above copyright notice,
|
16
|
this list of conditions and the following disclaimer.
|
17
|
|
18
|
2. Redistributions in binary form must reproduce the above copyright
|
19
|
notice, this list of conditions and the following disclaimer in the
|
20
|
documentation and/or other materials provided with the distribution.
|
21
|
|
22
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
23
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
24
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
25
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
26
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
29
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31
|
POSSIBILITY OF SUCH DAMAGE.
|
32
|
*/
|
33
|
|
34
|
$nocsrf = true;
|
35
|
|
36
|
require_once("guiconfig.inc");
|
37
|
require_once("pfsense-utils.inc");
|
38
|
require_once("functions.inc");
|
39
|
require_once("/usr/local/www/widgets/include/installed_packages.inc");
|
40
|
require_once("pkg-utils.inc");
|
41
|
|
42
|
if(is_array($config['installedpackages']['package'])) {
|
43
|
foreach($config['installedpackages']['package'] as $instpkg) {
|
44
|
$tocheck[] = $instpkg['name'];
|
45
|
}
|
46
|
$currentvers = get_pkg_info($tocheck, array('version', 'xmlver'));
|
47
|
}
|
48
|
|
49
|
$updateavailable = false;
|
50
|
?>
|
51
|
|
52
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="installed packages">
|
53
|
<tr>
|
54
|
<td width="15%" class="listhdrr">Package Name</td>
|
55
|
<td width="15%" class="listhdrr">Category</td>
|
56
|
<td width="30%" class="listhdrr">Package Version</td>
|
57
|
</tr>
|
58
|
<?php
|
59
|
if($config['installedpackages']['package'] != "") {
|
60
|
$instpkgs = array();
|
61
|
foreach($config['installedpackages']['package'] as $instpkg)
|
62
|
$instpkgs[] = $instpkg['name'];
|
63
|
natcasesort($instpkgs);
|
64
|
$y=1;
|
65
|
foreach ($instpkgs as $index => $pkgname){
|
66
|
|
67
|
$pkg = $config['installedpackages']['package'][$index];
|
68
|
if($pkg['name'] <> "") { ?>
|
69
|
<tr valign="top">
|
70
|
<td class="listlr">
|
71
|
<?= $pkg['name'] ?>
|
72
|
</td>
|
73
|
<td class="listr">
|
74
|
<?= $pkg['category'] ?>
|
75
|
</td>
|
76
|
<td class="listr">
|
77
|
<?php
|
78
|
$latest_package = $currentvers[$pkg['name']]['version'];
|
79
|
if($latest_package == false) {
|
80
|
// We can't determine this package's version status.
|
81
|
echo "Current: Unknown.<br />Installed: " . $pkg['version'];
|
82
|
} elseif(strcmp($pkg['version'], $latest_package) > 0) {
|
83
|
/* we're running a newer version of the package */
|
84
|
echo "Current: {$latest_package}";
|
85
|
echo "<br />Installed: {$pkg['version']}";
|
86
|
} elseif(strcmp($pkg['version'], $latest_package) < 0) {
|
87
|
/* our package is out of date */
|
88
|
$updateavailable = true;
|
89
|
?>
|
90
|
<div id="updatediv-<?php echo $y; ?>" style="color:red">
|
91
|
<b>Update Available!</b></div><div style="float:left">
|
92
|
Current: <?php echo $latest_package; ?><br />
|
93
|
Installed: <?php echo $pkg['version']; ?></div><div style="float:right">
|
94
|
<a href="pkg_mgr_install.php?mode=reinstallpkg&pkg=<?= $pkg['name']; ?>"><img title="Update this package." src="./themes/<?= $g['theme']; ?>/images/icons/icon_reinstall_pkg.gif" width="17" height="17" border="0" alt="reinstall" /></a>
|
95
|
</div>
|
96
|
<?php
|
97
|
$y++;
|
98
|
} else {
|
99
|
echo $pkg['version'];
|
100
|
} ?>
|
101
|
</td>
|
102
|
</tr>
|
103
|
<?php }
|
104
|
}
|
105
|
} else {
|
106
|
echo "<tr><td colspan=\"5\" align=\"center\">There are no packages currently installed.</td></tr>";
|
107
|
}
|
108
|
?>
|
109
|
</table>
|
110
|
|
111
|
<?php if ($updateavailable): ?>
|
112
|
<script type="text/javascript">
|
113
|
//<![CDATA[
|
114
|
window.onload = function(in_event)
|
115
|
{
|
116
|
for (y=1; y<=<?php echo $y;?>; y++){
|
117
|
textID = "#updatediv-" + y;
|
118
|
jQuery(textID).effect('pulsate');
|
119
|
}
|
120
|
}
|
121
|
//]]>
|
122
|
</script>
|
123
|
<?php endif; ?>
|