1 |
ee11cc6e
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
ee11cc6e
|
Scott Ullrich
|
/*
|
4 |
|
|
pkg_mgr.php
|
5 |
b49448ac
|
Scott Ullrich
|
Copyright (C) 2004, 2005 Scott Ullrich
|
6 |
ee11cc6e
|
Scott Ullrich
|
All rights reserved.
|
7 |
|
|
|
8 |
|
|
Redistribution and use in source and binary forms, with or without
|
9 |
|
|
modification, are permitted provided that the following conditions are met:
|
10 |
|
|
|
11 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
12 |
|
|
this list of conditions and the following disclaimer.
|
13 |
|
|
|
14 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
15 |
|
|
notice, this list of conditions and the following disclaimer in the
|
16 |
|
|
documentation and/or other materials provided with the distribution.
|
17 |
|
|
|
18 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
28 |
|
|
*/
|
29 |
|
|
|
30 |
a983b48b
|
Scott Ullrich
|
require_once("globals.inc");
|
31 |
9f9dcd98
|
Scott Ullrich
|
require_once("guiconfig.inc");
|
32 |
f8e335a3
|
Scott Ullrich
|
require_once("pkg-utils.inc");
|
33 |
ee11cc6e
|
Scott Ullrich
|
|
34 |
1b48ab03
|
Scott Ullrich
|
$pkg_info = get_pkg_info('all', array('noembedded', 'name', 'category', 'website', 'version', 'status', 'descr', 'maintainer', 'required_version', 'pkginfolink'));
|
35 |
3f3a5bef
|
Colin Smith
|
if($pkg_info) {
|
36 |
|
|
$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
|
37 |
|
|
fwrite($fout, serialize($pkg_info));
|
38 |
1d1630ec
|
Colin Smith
|
fclose($fout);
|
39 |
47c44d0a
|
Scott Ullrich
|
//$pkg_sizes = get_pkg_sizes();
|
40 |
3f3a5bef
|
Colin Smith
|
} else {
|
41 |
|
|
$using_cache = true;
|
42 |
47c44d0a
|
Scott Ullrich
|
if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
|
43 |
|
|
$savemsg = "Unable to retrieve package info from {$g['xmlrpcbaseurl']}. Cached data will be used.";
|
44 |
|
|
$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
|
45 |
|
|
} else {
|
46 |
c317e04e
|
Scott Ullrich
|
$savemsg = "Unable to communicate to {$g['product_name']}.com. Please check DNS, default gateway, etc.";
|
47 |
47c44d0a
|
Scott Ullrich
|
}
|
48 |
3f3a5bef
|
Colin Smith
|
}
|
49 |
52380979
|
Scott Ullrich
|
|
50 |
61a48553
|
Scott Ullrich
|
if (! empty($_GET)) {
|
51 |
|
|
if (isset($_GET['ver'])) {
|
52 |
b5aebbf5
|
Scott Ullrich
|
$requested_version = htmlspecialchars($_GET['ver']);
|
53 |
61a48553
|
Scott Ullrich
|
}
|
54 |
|
|
}
|
55 |
|
|
|
56 |
96d9f5c9
|
Bill Marquette
|
$pgtitle = "System: Package Manager";
|
57 |
52380979
|
Scott Ullrich
|
include("head.inc");
|
58 |
|
|
|
59 |
ee11cc6e
|
Scott Ullrich
|
?>
|
60 |
|
|
|
61 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
62 |
859329c8
|
Scott Ullrich
|
<?php
|
63 |
|
|
include("fbegin.inc");
|
64 |
|
|
?>
|
65 |
96d9f5c9
|
Bill Marquette
|
<p class="pgtitle"><?=$pgtitle?></p>
|
66 |
ee11cc6e
|
Scott Ullrich
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
67 |
|
|
<?php
|
68 |
859329c8
|
Scott Ullrich
|
|
69 |
ee11cc6e
|
Scott Ullrich
|
?>
|
70 |
323d040b
|
Scott Ullrich
|
|
71 |
ee11cc6e
|
Scott Ullrich
|
<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td>
|
72 |
e3ebc979
|
Scott Ullrich
|
<?php
|
73 |
61a48553
|
Scott Ullrich
|
$version = file_get_contents("/etc/version");
|
74 |
64b243d2
|
Scott Ullrich
|
$dot = strpos($version, ".");
|
75 |
|
|
$hyphen = strpos($version, "-");
|
76 |
|
|
$major = substr($version, 0, $dot);
|
77 |
|
|
$minor = substr($version, $dot + 1, $hyphen - $dot - 1);
|
78 |
|
|
$testing_version = substr($version, $hyphen + 1, strlen($version) - $hyphen);
|
79 |
|
|
|
80 |
e3ebc979
|
Scott Ullrich
|
$tab_array = array();
|
81 |
69de054a
|
Scott Ullrich
|
$tab_array[] = array("{$version} packages", $requested_version <> "" ? false : true, "pkg_mgr.php");
|
82 |
e4980b14
|
Scott Ullrich
|
// $tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
|
83 |
64b243d2
|
Scott Ullrich
|
/* $tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other"); */
|
84 |
61a48553
|
Scott Ullrich
|
$tab_array[] = array("Installed Packages", false, "pkg_mgr_installed.php");
|
85 |
e3ebc979
|
Scott Ullrich
|
display_top_tabs($tab_array);
|
86 |
5bd87465
|
Scott Ullrich
|
?>
|
87 |
ee11cc6e
|
Scott Ullrich
|
</td></tr>
|
88 |
|
|
<tr>
|
89 |
d732f186
|
Bill Marquette
|
<td>
|
90 |
|
|
<div id="mainarea">
|
91 |
|
|
<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
|
92 |
ee11cc6e
|
Scott Ullrich
|
<tr>
|
93 |
a15a15e7
|
Scott Ullrich
|
<td width="10%" class="listhdrr">Package Name</td>
|
94 |
ee11cc6e
|
Scott Ullrich
|
<td width="25%" class="listhdrr">Category</td>
|
95 |
bfccf041
|
Colin Smith
|
<!--
|
96 |
ea395bfd
|
Colin Smith
|
<td width="10%" class="listhdrr">Size</td>
|
97 |
bfccf041
|
Colin Smith
|
-->
|
98 |
9345a13c
|
Colin Smith
|
<td width="5%" class="listhdrr">Status</td>
|
99 |
0a28e1fa
|
Chris Buechler
|
<td width="5%" class="listhdrr">Package Info</td>
|
100 |
ee11cc6e
|
Scott Ullrich
|
<td width="50%" class="listhdr">Description</td>
|
101 |
|
|
</tr>
|
102 |
|
|
|
103 |
|
|
<?php
|
104 |
3f3a5bef
|
Colin Smith
|
if(!$pkg_info) {
|
105 |
58d797bf
|
Colin Smith
|
echo "<tr><td colspan=\"5\"><center>There are currently no packages available for installation.</td></tr>";
|
106 |
3f3a5bef
|
Colin Smith
|
} else {
|
107 |
9174b524
|
Scott Ullrich
|
$pfSense_installed_version = rtrim(file_get_contents("/etc/version"));
|
108 |
|
|
$pkgs = array();
|
109 |
|
|
$instpkgs = array();
|
110 |
94fbf631
|
Colin Smith
|
if($config['installedpackages']['package'] != "")
|
111 |
|
|
foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
|
112 |
b426850b
|
Colin Smith
|
$pkg_names = array_keys($pkg_info);
|
113 |
1507bd61
|
Colin Smith
|
$pkg_keys = array();
|
114 |
b426850b
|
Colin Smith
|
foreach($pkg_names as $name) {
|
115 |
9174b524
|
Scott Ullrich
|
if(!in_array($name, $instpkgs))
|
116 |
|
|
$pkg_keys[] = $name;
|
117 |
0db271e0
|
Colin Smith
|
}
|
118 |
b426850b
|
Colin Smith
|
sort($pkg_keys);
|
119 |
|
|
if(count($pkg_keys) != 0) {
|
120 |
|
|
foreach($pkg_keys as $key) {
|
121 |
|
|
$index = &$pkg_info[$key];
|
122 |
|
|
if(in_array($index['name'], $instpkgs)) continue;
|
123 |
9174b524
|
Scott Ullrich
|
$dot = strpos($index['required_version'], ".");
|
124 |
|
|
$index['major_version'] = substr($index['required_version'], 0, $dot);
|
125 |
a983b48b
|
Scott Ullrich
|
if($g['platform'] == "nanobsd")
|
126 |
|
|
if($index['noembedded'])
|
127 |
|
|
continue;
|
128 |
9174b524
|
Scott Ullrich
|
if ($version <> "HEAD" &&
|
129 |
|
|
$index['required_version'] == "HEAD" &&
|
130 |
|
|
$requested_version <> "other") { continue; }
|
131 |
|
|
if (empty($index['required_version']) &&
|
132 |
64b243d2
|
Scott Ullrich
|
$requested_version <> "none") { continue; }
|
133 |
9174b524
|
Scott Ullrich
|
if($index['major_version'] > $major &&
|
134 |
|
|
$requested_version <> "other") { continue; }
|
135 |
|
|
if(isset($index['major_version']) &&
|
136 |
|
|
$requested_version == "none") { continue; }
|
137 |
|
|
if($index['major_version'] == $major &&
|
138 |
|
|
$requested_version == "other") { continue; }
|
139 |
|
|
|
140 |
|
|
?>
|
141 |
ee11cc6e
|
Scott Ullrich
|
<tr valign="top">
|
142 |
|
|
<td class="listlr">
|
143 |
61a48553
|
Scott Ullrich
|
<A target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
|
144 |
ee11cc6e
|
Scott Ullrich
|
</td>
|
145 |
|
|
<td class="listlr">
|
146 |
b426850b
|
Colin Smith
|
<?= $index['category'] ?>
|
147 |
9345a13c
|
Colin Smith
|
</td>
|
148 |
|
|
<?php
|
149 |
bfccf041
|
Colin Smith
|
/*
|
150 |
3f3a5bef
|
Colin Smith
|
if(!$using_cache) {
|
151 |
|
|
$size = get_package_install_size($index['name'], $pkg_sizes);
|
152 |
|
|
$size = squash_from_bytes($size[$index['name']], 1);
|
153 |
|
|
}
|
154 |
|
|
if(!$size) $size = "Unknown.";
|
155 |
bfccf041
|
Colin Smith
|
*/
|
156 |
9345a13c
|
Colin Smith
|
?>
|
157 |
bfccf041
|
Colin Smith
|
<!--
|
158 |
9345a13c
|
Colin Smith
|
<td class="listlr">
|
159 |
3f3a5bef
|
Colin Smith
|
<?= $size ?>
|
160 |
|
|
</td>
|
161 |
bfccf041
|
Colin Smith
|
-->
|
162 |
9345a13c
|
Colin Smith
|
<td class="listlr">
|
163 |
3f3a5bef
|
Colin Smith
|
<?= $index['status'] ?>
|
164 |
|
|
<br>
|
165 |
|
|
<?= $index['version'] ?>
|
166 |
61a48553
|
Scott Ullrich
|
<br />
|
167 |
|
|
platform: <?= $index['required_version'] ?>
|
168 |
ee11cc6e
|
Scott Ullrich
|
</td>
|
169 |
0a28e1fa
|
Chris Buechler
|
<td class="listlr">
|
170 |
|
|
<?php
|
171 |
|
|
if($index['pkginfolink']) {
|
172 |
|
|
$pkginfolink = $index['pkginfolink'];
|
173 |
d73497d4
|
Scott Ullrich
|
echo "<a target='_new' href='$pkginfolink'>Package Info</a>";
|
174 |
0a28e1fa
|
Chris Buechler
|
} else {
|
175 |
|
|
echo "No info, check the <a href='http://forum.pfsense.org/index.php/board,15.0.html'>forum</a>";
|
176 |
|
|
}
|
177 |
|
|
?>
|
178 |
|
|
</td>
|
179 |
61a48553
|
Scott Ullrich
|
<td class="listbg" class="listbg" style="color: #FFFFFF; overflow: hidden;">
|
180 |
b426850b
|
Colin Smith
|
<?= $index['descr'] ?>
|
181 |
ee11cc6e
|
Scott Ullrich
|
</td>
|
182 |
|
|
<td valign="middle" class="list" nowrap>
|
183 |
677c0869
|
Erik Kristensen
|
<a onclick="return confirm('Do you really want to install this package?')" href="pkg_mgr_install.php?id=<?=$index['name'];?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a>
|
184 |
ee11cc6e
|
Scott Ullrich
|
</td>
|
185 |
|
|
</tr>
|
186 |
|
|
<?php
|
187 |
b426850b
|
Colin Smith
|
}
|
188 |
|
|
} else {
|
189 |
bfccf041
|
Colin Smith
|
echo '<tr><td colspan="5"><center>There are currently no packages available for installation.</center></td></tr>';
|
190 |
b426850b
|
Colin Smith
|
}
|
191 |
3f3a5bef
|
Colin Smith
|
}
|
192 |
ee11cc6e
|
Scott Ullrich
|
?>
|
193 |
|
|
</table>
|
194 |
d732f186
|
Bill Marquette
|
</div>
|
195 |
ee11cc6e
|
Scott Ullrich
|
</td>
|
196 |
|
|
</tr>
|
197 |
|
|
</table>
|
198 |
|
|
<?php include("fend.inc"); ?>
|
199 |
|
|
</body>
|
200 |
|
|
</html>
|