1 |
ee11cc6e
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
ee11cc6e
|
Scott Ullrich
|
/*
|
4 |
29840546
|
Renato Botelho
|
pkg_mgr.php
|
5 |
ee11cc6e
|
Scott Ullrich
|
*/
|
6 |
239b5161
|
Stephen Beaver
|
/* ====================================================================
|
7 |
|
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
8 |
|
|
* Copyright (c) 2004, 2005 Scott Ullrich
|
9 |
|
|
* Copyright (c) 2013 Marcello Coutinho
|
10 |
|
|
*
|
11 |
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
12 |
|
|
* are permitted provided that the following conditions are met:
|
13 |
|
|
*
|
14 |
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
15 |
|
|
* this list of conditions and the following disclaimer.
|
16 |
|
|
*
|
17 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
18 |
|
|
* notice, this list of conditions and the following disclaimer in
|
19 |
|
|
* the documentation and/or other materials provided with the
|
20 |
|
|
* distribution.
|
21 |
|
|
*
|
22 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
23 |
|
|
* must display the following acknowledgment:
|
24 |
|
|
* "This product includes software developed by the pfSense Project
|
25 |
|
|
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
26 |
|
|
*
|
27 |
|
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
28 |
|
|
* endorse or promote products derived from this software without
|
29 |
|
|
* prior written permission. For written permission, please contact
|
30 |
|
|
* coreteam@pfsense.org.
|
31 |
|
|
*
|
32 |
|
|
* 5. Products derived from this software may not be called "pfSense"
|
33 |
|
|
* nor may "pfSense" appear in their names without prior written
|
34 |
|
|
* permission of the Electric Sheep Fencing, LLC.
|
35 |
|
|
*
|
36 |
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
37 |
|
|
* acknowledgment:
|
38 |
|
|
*
|
39 |
|
|
* "This product includes software developed by the pfSense Project
|
40 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
41 |
|
|
*
|
42 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
43 |
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
44 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
45 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
46 |
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
47 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
48 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
49 |
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
50 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
51 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
52 |
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
53 |
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
54 |
|
|
*
|
55 |
|
|
* ====================================================================
|
56 |
|
|
*
|
57 |
|
|
*/
|
58 |
1d333258
|
Scott Ullrich
|
/*
|
59 |
|
|
pfSense_BUILDER_BINARIES: /sbin/ifconfig
|
60 |
239b5161
|
Stephen Beaver
|
pfSense_MODULE: pkgs
|
61 |
1d333258
|
Scott Ullrich
|
*/
|
62 |
ee11cc6e
|
Scott Ullrich
|
|
63 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
64 |
|
|
##|*IDENT=page-system-packagemanager
|
65 |
|
|
##|*NAME=System: Package Manager page
|
66 |
|
|
##|*DESCR=Allow access to the 'System: Package Manager' page.
|
67 |
|
|
##|*MATCH=pkg_mgr.php*
|
68 |
|
|
##|-PRIV
|
69 |
|
|
|
70 |
0089af7c
|
Scott Ullrich
|
ini_set('max_execution_time', '0');
|
71 |
|
|
|
72 |
9bcf197e
|
Scott Ullrich
|
require_once("globals.inc");
|
73 |
9f9dcd98
|
Scott Ullrich
|
require_once("guiconfig.inc");
|
74 |
f8e335a3
|
Scott Ullrich
|
require_once("pkg-utils.inc");
|
75 |
ee11cc6e
|
Scott Ullrich
|
|
76 |
261c7de8
|
jim-p
|
/* if upgrade in progress, alert user */
|
77 |
|
|
if(is_subsystem_dirty('packagelock')) {
|
78 |
|
|
$pgtitle = array(gettext("System"),gettext("Package Manager"));
|
79 |
|
|
include("head.inc");
|
80 |
31f03b6c
|
Sjon Hortensius
|
print_info_box_np("Please wait while packages are reinstalled in the background.");
|
81 |
|
|
include("foot.inc");
|
82 |
261c7de8
|
jim-p
|
exit;
|
83 |
|
|
}
|
84 |
31f03b6c
|
Sjon Hortensius
|
|
85 |
5c22f8ef
|
Stephen Beaver
|
include("head.inc");
|
86 |
|
|
|
87 |
a69afe44
|
Renato Botelho
|
$pkg_info = get_pkg_info();
|
88 |
61a48553
|
Scott Ullrich
|
|
89 |
82b15b70
|
Carlos Eduardo Ramos
|
$pgtitle = array(gettext("System"),gettext("Package Manager"));
|
90 |
52380979
|
Scott Ullrich
|
|
91 |
31f03b6c
|
Sjon Hortensius
|
$tab_array = array();
|
92 |
a69afe44
|
Renato Botelho
|
$tab_array[] = array(gettext("Available Packages"), true, "pkg_mgr.php");
|
93 |
31f03b6c
|
Sjon Hortensius
|
$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
|
94 |
|
|
display_top_tabs($tab_array);
|
95 |
|
|
|
96 |
|
|
if($pkg_info) {
|
97 |
|
|
//Check categories
|
98 |
|
|
$categories=array();
|
99 |
a69afe44
|
Renato Botelho
|
foreach ($pkg_info as $pkg_data) {
|
100 |
|
|
if (isset($pkg_data['categories'][0])) {
|
101 |
|
|
$categories[$pkg_data['categories'][0]]++;
|
102 |
f70121be
|
Renato Botelho
|
}
|
103 |
a69afe44
|
Renato Botelho
|
}
|
104 |
5c22f8ef
|
Stephen Beaver
|
|
105 |
eb3743d8
|
Stephen Beaver
|
ksort($categories, SORT_STRING|SORT_FLAG_CASE);
|
106 |
31f03b6c
|
Sjon Hortensius
|
$cm_count=0;
|
107 |
|
|
$tab_array = array();
|
108 |
|
|
$visible_categories=array();
|
109 |
|
|
$categories_min_count=($g['pkg_categories_min_count'] ? $g['pkg_categories_min_count'] : 3);
|
110 |
|
|
$categories_max_display=($g['pkg_categories_max_display'] ? $g['pkg_categories_max_display'] : 6);
|
111 |
|
|
|
112 |
|
|
/* check selected category or define default category to show */
|
113 |
|
|
if (isset($_REQUEST['category']))
|
114 |
|
|
$menu_category = $_REQUEST['category'];
|
115 |
|
|
else if (isset($g['pkg_default_category']))
|
116 |
|
|
$menu_category = $g['pkg_default_category'];
|
117 |
|
|
else
|
118 |
|
|
$menu_category = "All";
|
119 |
|
|
|
120 |
|
|
$menu_category = (isset($_REQUEST['category']) ? $_REQUEST['category'] : "All");
|
121 |
|
|
$show_category = ($menu_category == "Other" || $menu_category == "All");
|
122 |
|
|
|
123 |
|
|
$tab_array[] = array(gettext("All"), $menu_category=="All" ? true : false, "pkg_mgr.php?category=All");
|
124 |
|
|
foreach ($categories as $category => $c_count) {
|
125 |
|
|
if ($c_count >= $categories_min_count && $cm_count <= $categories_max_display) {
|
126 |
|
|
$tab_array[] = array(gettext($category) , $menu_category==$category ? true : false, "pkg_mgr.php?category={$category}");
|
127 |
|
|
$visible_categories[]=$category;
|
128 |
|
|
$cm_count++;
|
129 |
|
|
}
|
130 |
f70121be
|
Renato Botelho
|
}
|
131 |
5c22f8ef
|
Stephen Beaver
|
|
132 |
31f03b6c
|
Sjon Hortensius
|
$tab_array[] = array(gettext("Other Categories"), $menu_category=="Other" ? true : false, "pkg_mgr.php?category=Other");
|
133 |
|
|
if (count($categories) > 1)
|
134 |
|
|
display_top_tabs($tab_array);
|
135 |
|
|
}
|
136 |
29840546
|
Renato Botelho
|
|
137 |
eb3743d8
|
Stephen Beaver
|
function compareName($a, $b) {
|
138 |
|
|
return(strcasecmp ($a['name'], $b['name']));
|
139 |
|
|
}
|
140 |
|
|
|
141 |
a69afe44
|
Renato Botelho
|
if(!$pkg_info || !is_array($pkg_info)):?>
|
142 |
2d26ee5e
|
Sjon Hortensius
|
<div class="alert alert-warning">
|
143 |
|
|
<?=gettext("There are currently no packages available for installation.")?>
|
144 |
|
|
</div>
|
145 |
|
|
<?php else: ?>
|
146 |
89f64f0f
|
Sander van Leeuwen
|
<div class="table-responsive">
|
147 |
|
|
<table class="table table-striped table-hover">
|
148 |
2d26ee5e
|
Sjon Hortensius
|
<thead>
|
149 |
|
|
<tr>
|
150 |
|
|
<th><?=gettext("Name")?></th>
|
151 |
|
|
<?php if (!$g['disablepackagehistory']):?>
|
152 |
|
|
<th><?=gettext("Version")?></th>
|
153 |
|
|
<?php endif;?>
|
154 |
239b5161
|
Stephen Beaver
|
|
155 |
2d26ee5e
|
Sjon Hortensius
|
<th><?=gettext("Description")?></th>
|
156 |
|
|
</tr>
|
157 |
|
|
</thead>
|
158 |
|
|
<tbody>
|
159 |
f70121be
|
Renato Botelho
|
<?php
|
160 |
5c22f8ef
|
Stephen Beaver
|
|
161 |
eb3743d8
|
Stephen Beaver
|
// Sort case insensitve (so we get AbCdEf not ACEcdf)
|
162 |
|
|
usort($pkg_info, 'compareName');
|
163 |
0071ef19
|
Stephen Beaver
|
|
164 |
a69afe44
|
Renato Botelho
|
foreach($pkg_info as $index):
|
165 |
af71b288
|
Stephen Beaver
|
|
166 |
a69afe44
|
Renato Botelho
|
if(get_package_id($index['name']) >= 0 ) {
|
167 |
2d26ee5e
|
Sjon Hortensius
|
continue;
|
168 |
a69afe44
|
Renato Botelho
|
}
|
169 |
2d26ee5e
|
Sjon Hortensius
|
|
170 |
a69afe44
|
Renato Botelho
|
$shortname = $index['name'];
|
171 |
|
|
pkg_remove_prefix($shortname);
|
172 |
2d26ee5e
|
Sjon Hortensius
|
|
173 |
a69afe44
|
Renato Botelho
|
if ($menu_category != "All" && $index['categories'][0] != $menu_category && !($menu_category == "Other" && !in_array($index['categories'][0], $visible_categories))) {
|
174 |
2d26ee5e
|
Sjon Hortensius
|
continue;
|
175 |
a69afe44
|
Renato Botelho
|
}
|
176 |
0071ef19
|
Stephen Beaver
|
|
177 |
|
|
// Check to see if it is already installed
|
178 |
54c8ef44
|
Stephen Beaver
|
if(isset($config['installedpackages']['package'])) {
|
179 |
|
|
foreach($config['installedpackages']['package'] as $installedpkg) {
|
180 |
|
|
if($installedpkg['name'] == $shortname) {
|
181 |
|
|
continue(2);
|
182 |
|
|
}
|
183 |
0071ef19
|
Stephen Beaver
|
}
|
184 |
|
|
}
|
185 |
|
|
|
186 |
f70121be
|
Renato Botelho
|
?>
|
187 |
2d26ee5e
|
Sjon Hortensius
|
<tr>
|
188 |
|
|
<td>
|
189 |
239b5161
|
Stephen Beaver
|
<?php if ($index['www']):?>
|
190 |
|
|
<a title="<?=gettext("Visit official website")?>" target="_blank" href="<?=htmlspecialchars($index['www'])?>">
|
191 |
2d26ee5e
|
Sjon Hortensius
|
<?php endif; ?>
|
192 |
a69afe44
|
Renato Botelho
|
<?=htmlspecialchars($shortname)?>
|
193 |
2d26ee5e
|
Sjon Hortensius
|
</a>
|
194 |
|
|
</td>
|
195 |
239b5161
|
Stephen Beaver
|
|
196 |
af71b288
|
Stephen Beaver
|
<?php
|
197 |
|
|
if (!$g['disablepackagehistory']):?>
|
198 |
2d26ee5e
|
Sjon Hortensius
|
<td>
|
199 |
c4f5e057
|
Phil Davis
|
<!-- We no longer have a package revision history URL
|
200 |
|
|
$changeloglink is undefined
|
201 |
2d26ee5e
|
Sjon Hortensius
|
<a target="_blank" title="<?=gettext("View changelog")?>" href="<?=htmlspecialchars($changeloglink)?>">
|
202 |
c4f5e057
|
Phil Davis
|
-->
|
203 |
|
|
<?=htmlspecialchars($index['version'])?>
|
204 |
|
|
<!--
|
205 |
2d26ee5e
|
Sjon Hortensius
|
</a>
|
206 |
c4f5e057
|
Phil Davis
|
-->
|
207 |
2d26ee5e
|
Sjon Hortensius
|
</td>
|
208 |
0071ef19
|
Stephen Beaver
|
<?php
|
209 |
af71b288
|
Stephen Beaver
|
endif;
|
210 |
|
|
?>
|
211 |
2d26ee5e
|
Sjon Hortensius
|
<td>
|
212 |
239b5161
|
Stephen Beaver
|
<?=$index['desc']?>
|
213 |
2d26ee5e
|
Sjon Hortensius
|
</td>
|
214 |
|
|
<td>
|
215 |
8237727a
|
Stephen Beaver
|
<a title="<?=gettext("Click to install")?>" href="pkg_mgr_install.php?id=<?=$index['name']?>" class="btn btn-success btn-sm">install</a>
|
216 |
a69afe44
|
Renato Botelho
|
<?php if(!$g['disablepackageinfo'] && $index['pkginfolink'] && $index['pkginfolink'] != $index['www']):?>
|
217 |
66999e39
|
Chris Buechler
|
<a target="_blank" title="<?=gettext("View more information")?>" href="<?=htmlspecialchars($index['pkginfolink'])?>" class="btn btn-default btn-sm">info</a>
|
218 |
2d26ee5e
|
Sjon Hortensius
|
<?php endif;?>
|
219 |
|
|
</td>
|
220 |
|
|
</tr>
|
221 |
f70121be
|
Renato Botelho
|
<?php
|
222 |
2d26ee5e
|
Sjon Hortensius
|
endforeach;
|
223 |
|
|
endif;?>
|
224 |
89f64f0f
|
Sander van Leeuwen
|
</tbody>
|
225 |
|
|
</table>
|
226 |
|
|
</div>
|
227 |
a69afe44
|
Renato Botelho
|
<?php include("foot.inc")?>
|