1 |
ee11cc6e
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
29840546
|
Renato Botelho
|
pkg_mgr.php
|
4 |
ee11cc6e
|
Scott Ullrich
|
*/
|
5 |
239b5161
|
Stephen Beaver
|
/* ====================================================================
|
6 |
|
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
7 |
|
|
* Copyright (c) 2013 Marcello Coutinho
|
8 |
|
|
*
|
9 |
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
10 |
|
|
* are permitted provided that the following conditions are met:
|
11 |
|
|
*
|
12 |
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
13 |
|
|
* this list of conditions and the following disclaimer.
|
14 |
|
|
*
|
15 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
16 |
|
|
* notice, this list of conditions and the following disclaimer in
|
17 |
|
|
* the documentation and/or other materials provided with the
|
18 |
|
|
* distribution.
|
19 |
|
|
*
|
20 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
21 |
|
|
* must display the following acknowledgment:
|
22 |
|
|
* "This product includes software developed by the pfSense Project
|
23 |
|
|
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
24 |
|
|
*
|
25 |
|
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
26 |
|
|
* endorse or promote products derived from this software without
|
27 |
|
|
* prior written permission. For written permission, please contact
|
28 |
|
|
* coreteam@pfsense.org.
|
29 |
|
|
*
|
30 |
|
|
* 5. Products derived from this software may not be called "pfSense"
|
31 |
|
|
* nor may "pfSense" appear in their names without prior written
|
32 |
|
|
* permission of the Electric Sheep Fencing, LLC.
|
33 |
|
|
*
|
34 |
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
35 |
|
|
* acknowledgment:
|
36 |
|
|
*
|
37 |
|
|
* "This product includes software developed by the pfSense Project
|
38 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
39 |
|
|
*
|
40 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
41 |
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
42 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
43 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
44 |
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
45 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
46 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
47 |
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
48 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
49 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
50 |
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
51 |
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
52 |
|
|
*
|
53 |
|
|
* ====================================================================
|
54 |
|
|
*
|
55 |
|
|
*/
|
56 |
ee11cc6e
|
Scott Ullrich
|
|
57 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
58 |
|
|
##|*IDENT=page-system-packagemanager
|
59 |
5230f468
|
jim-p
|
##|*NAME=System: Package Manager
|
60 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'System: Package Manager' page.
|
61 |
|
|
##|*MATCH=pkg_mgr.php*
|
62 |
|
|
##|-PRIV
|
63 |
|
|
|
64 |
0089af7c
|
Scott Ullrich
|
ini_set('max_execution_time', '0');
|
65 |
|
|
|
66 |
9bcf197e
|
Scott Ullrich
|
require_once("globals.inc");
|
67 |
9f9dcd98
|
Scott Ullrich
|
require_once("guiconfig.inc");
|
68 |
f8e335a3
|
Scott Ullrich
|
require_once("pkg-utils.inc");
|
69 |
ee11cc6e
|
Scott Ullrich
|
|
70 |
261c7de8
|
jim-p
|
/* if upgrade in progress, alert user */
|
71 |
0f649c97
|
Phil Davis
|
if (is_subsystem_dirty('packagelock')) {
|
72 |
|
|
$pgtitle = array(gettext("System"), gettext("Package Manager"));
|
73 |
261c7de8
|
jim-p
|
include("head.inc");
|
74 |
31f03b6c
|
Sjon Hortensius
|
print_info_box_np("Please wait while packages are reinstalled in the background.");
|
75 |
|
|
include("foot.inc");
|
76 |
261c7de8
|
jim-p
|
exit;
|
77 |
|
|
}
|
78 |
31f03b6c
|
Sjon Hortensius
|
|
79 |
a69afe44
|
Renato Botelho
|
$pkg_info = get_pkg_info();
|
80 |
61a48553
|
Scott Ullrich
|
|
81 |
0f649c97
|
Phil Davis
|
$pgtitle = array(gettext("System"), gettext("Package Manager"), gettext("Available Packages"));
|
82 |
52380979
|
Scott Ullrich
|
|
83 |
7409fde6
|
Stephen Beaver
|
include("head.inc");
|
84 |
|
|
|
85 |
31f03b6c
|
Sjon Hortensius
|
$tab_array = array();
|
86 |
a69afe44
|
Renato Botelho
|
$tab_array[] = array(gettext("Available Packages"), true, "pkg_mgr.php");
|
87 |
31f03b6c
|
Sjon Hortensius
|
$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
|
88 |
|
|
display_top_tabs($tab_array);
|
89 |
|
|
|
90 |
0f649c97
|
Phil Davis
|
if ($pkg_info) {
|
91 |
31f03b6c
|
Sjon Hortensius
|
//Check categories
|
92 |
|
|
$categories=array();
|
93 |
a69afe44
|
Renato Botelho
|
foreach ($pkg_info as $pkg_data) {
|
94 |
|
|
if (isset($pkg_data['categories'][0])) {
|
95 |
|
|
$categories[$pkg_data['categories'][0]]++;
|
96 |
f70121be
|
Renato Botelho
|
}
|
97 |
a69afe44
|
Renato Botelho
|
}
|
98 |
5c22f8ef
|
Stephen Beaver
|
|
99 |
eb3743d8
|
Stephen Beaver
|
ksort($categories, SORT_STRING|SORT_FLAG_CASE);
|
100 |
31f03b6c
|
Sjon Hortensius
|
$cm_count=0;
|
101 |
|
|
$tab_array = array();
|
102 |
|
|
$visible_categories=array();
|
103 |
|
|
$categories_min_count=($g['pkg_categories_min_count'] ? $g['pkg_categories_min_count'] : 3);
|
104 |
|
|
$categories_max_display=($g['pkg_categories_max_display'] ? $g['pkg_categories_max_display'] : 6);
|
105 |
|
|
|
106 |
|
|
/* check selected category or define default category to show */
|
107 |
0f649c97
|
Phil Davis
|
if (isset($_REQUEST['category'])) {
|
108 |
31f03b6c
|
Sjon Hortensius
|
$menu_category = $_REQUEST['category'];
|
109 |
0f649c97
|
Phil Davis
|
} else if (isset($g['pkg_default_category'])) {
|
110 |
31f03b6c
|
Sjon Hortensius
|
$menu_category = $g['pkg_default_category'];
|
111 |
0f649c97
|
Phil Davis
|
} else {
|
112 |
31f03b6c
|
Sjon Hortensius
|
$menu_category = "All";
|
113 |
0f649c97
|
Phil Davis
|
}
|
114 |
31f03b6c
|
Sjon Hortensius
|
|
115 |
|
|
$menu_category = (isset($_REQUEST['category']) ? $_REQUEST['category'] : "All");
|
116 |
|
|
$show_category = ($menu_category == "Other" || $menu_category == "All");
|
117 |
|
|
|
118 |
0f649c97
|
Phil Davis
|
$tab_array[] = array(gettext("All"), $menu_category == "All" ? true : false, "pkg_mgr.php?category=All");
|
119 |
31f03b6c
|
Sjon Hortensius
|
foreach ($categories as $category => $c_count) {
|
120 |
|
|
if ($c_count >= $categories_min_count && $cm_count <= $categories_max_display) {
|
121 |
0f649c97
|
Phil Davis
|
$tab_array[] = array(gettext($category) , $menu_category == $category ? true : false, "pkg_mgr.php?category={$category}");
|
122 |
31f03b6c
|
Sjon Hortensius
|
$visible_categories[]=$category;
|
123 |
|
|
$cm_count++;
|
124 |
|
|
}
|
125 |
f70121be
|
Renato Botelho
|
}
|
126 |
5c22f8ef
|
Stephen Beaver
|
|
127 |
0f649c97
|
Phil Davis
|
$tab_array[] = array(gettext("Other Categories"), $menu_category == "Other" ? true : false, "pkg_mgr.php?category=Other");
|
128 |
98dfca18
|
Stephen Beaver
|
|
129 |
|
|
// if (count($categories) > 1)
|
130 |
|
|
// display_top_tabs($tab_array);
|
131 |
31f03b6c
|
Sjon Hortensius
|
}
|
132 |
29840546
|
Renato Botelho
|
|
133 |
0f649c97
|
Phil Davis
|
if (!$pkg_info || !is_array($pkg_info)):
|
134 |
|
|
?>
|
135 |
98dfca18
|
Stephen Beaver
|
<div class="alert alert-warning">
|
136 |
|
|
<?=gettext("There are currently no packages available for installation.")?>
|
137 |
|
|
</div>
|
138 |
2d26ee5e
|
Sjon Hortensius
|
<?php else: ?>
|
139 |
98dfca18
|
Stephen Beaver
|
|
140 |
|
|
<div class="panel panel-default" id="search-panel">
|
141 |
|
|
<div class="panel-heading"><?=gettext('Search')?>
|
142 |
d7e7a132
|
Stephen Beaver
|
<span class="widget-heading-icon pull-right">
|
143 |
98dfca18
|
Stephen Beaver
|
<a data-toggle="collapse" href="#search-panel .panel-body" name="search-panel">
|
144 |
1b7379f9
|
Jared Dillard
|
<i class="fa fa-plus-circle"></i>
|
145 |
98dfca18
|
Stephen Beaver
|
</a>
|
146 |
|
|
</span>
|
147 |
|
|
</div>
|
148 |
1deed240
|
Stephen Beaver
|
<div class="panel-body collapse in">
|
149 |
98dfca18
|
Stephen Beaver
|
<div class="form-group">
|
150 |
|
|
<label class="col-sm-2 control-label">
|
151 |
|
|
Search term
|
152 |
|
|
</label>
|
153 |
|
|
<div class="col-sm-5"><input class="form-control" name="searchstr" id="searchstr" type="text"/></div>
|
154 |
3a28934c
|
Stephen Beaver
|
<div class="col-sm-2">
|
155 |
|
|
<select id="where" class="form-control">
|
156 |
|
|
<option value="0"><?=gettext("Name")?></option>
|
157 |
|
|
<option value="1"><?=gettext("Description")?></option>
|
158 |
1da8a2e3
|
Stephen Beaver
|
<option value="2" selected><?=gettext("Both")?></option>
|
159 |
3a28934c
|
Stephen Beaver
|
</select>
|
160 |
|
|
</div>
|
161 |
995df6c3
|
Stephen Beaver
|
<div class="col-sm-3">
|
162 |
|
|
<a id="btnsearch" type="button" title="<?=gettext("Search")?>" class="btn btn-primary btn-sm"><?=gettext("Search")?></a>
|
163 |
|
|
<a id="btnclear" type="button" title="<?=gettext("Clear")?>" class="btn btn-default btn-sm"><?=gettext("Clear")?></a>
|
164 |
|
|
</div>
|
165 |
98dfca18
|
Stephen Beaver
|
<div class="col-sm-10 col-sm-offset-2">
|
166 |
d63edb34
|
Phil Davis
|
<span class="help-block">Enter a search string or *nix regular expression to search package names and descriptions.</span>
|
167 |
98dfca18
|
Stephen Beaver
|
</div>
|
168 |
|
|
</div>
|
169 |
|
|
</div>
|
170 |
|
|
</div>
|
171 |
|
|
|
172 |
|
|
<div class="panel panel-default">
|
173 |
|
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Packages')?></h2></div>
|
174 |
|
|
<div class="panel-body table-responsive">
|
175 |
3a28934c
|
Stephen Beaver
|
<table id="pkgtable" class="table table-striped table-hover">
|
176 |
98dfca18
|
Stephen Beaver
|
<thead>
|
177 |
|
|
<tr>
|
178 |
|
|
<th><?=gettext("Name")?></th>
|
179 |
2d26ee5e
|
Sjon Hortensius
|
<?php if (!$g['disablepackagehistory']):?>
|
180 |
98dfca18
|
Stephen Beaver
|
<th><?=gettext("Version")?></th>
|
181 |
2d26ee5e
|
Sjon Hortensius
|
<?php endif;?>
|
182 |
239b5161
|
Stephen Beaver
|
|
183 |
98dfca18
|
Stephen Beaver
|
<th><?=gettext("Description")?></th>
|
184 |
713e39e1
|
Colin Fleming
|
<th></th>
|
185 |
98dfca18
|
Stephen Beaver
|
</tr>
|
186 |
|
|
</thead>
|
187 |
|
|
<tbody>
|
188 |
f70121be
|
Renato Botelho
|
<?php
|
189 |
5c22f8ef
|
Stephen Beaver
|
|
190 |
0f649c97
|
Phil Davis
|
foreach ($pkg_info as $index):
|
191 |
6544cb18
|
Renato Botelho
|
if (isset($index['installed'])) {
|
192 |
2d26ee5e
|
Sjon Hortensius
|
continue;
|
193 |
a69afe44
|
Renato Botelho
|
}
|
194 |
2d26ee5e
|
Sjon Hortensius
|
|
195 |
a69afe44
|
Renato Botelho
|
if ($menu_category != "All" && $index['categories'][0] != $menu_category && !($menu_category == "Other" && !in_array($index['categories'][0], $visible_categories))) {
|
196 |
2d26ee5e
|
Sjon Hortensius
|
continue;
|
197 |
a69afe44
|
Renato Botelho
|
}
|
198 |
0071ef19
|
Stephen Beaver
|
|
199 |
f70121be
|
Renato Botelho
|
?>
|
200 |
98dfca18
|
Stephen Beaver
|
<tr>
|
201 |
|
|
<td>
|
202 |
239b5161
|
Stephen Beaver
|
<?php if ($index['www']):?>
|
203 |
98dfca18
|
Stephen Beaver
|
<a title="<?=gettext("Visit official website")?>" target="_blank" href="<?=htmlspecialchars($index['www'])?>">
|
204 |
2d26ee5e
|
Sjon Hortensius
|
<?php endif; ?>
|
205 |
25fc475c
|
Renato Botelho
|
<?=htmlspecialchars($index['shortname'])?>
|
206 |
98dfca18
|
Stephen Beaver
|
</a>
|
207 |
|
|
</td>
|
208 |
239b5161
|
Stephen Beaver
|
|
209 |
af71b288
|
Stephen Beaver
|
<?php
|
210 |
0f649c97
|
Phil Davis
|
if (!$g['disablepackagehistory']):
|
211 |
|
|
?>
|
212 |
98dfca18
|
Stephen Beaver
|
<td>
|
213 |
|
|
<?=htmlspecialchars($index['version'])?>
|
214 |
|
|
</td>
|
215 |
0071ef19
|
Stephen Beaver
|
<?php
|
216 |
0f649c97
|
Phil Davis
|
endif;
|
217 |
af71b288
|
Stephen Beaver
|
?>
|
218 |
98dfca18
|
Stephen Beaver
|
<td>
|
219 |
|
|
<?=$index['desc']?>
|
220 |
c6c599f6
|
jim-p
|
<?php if (is_array($index['deps']) && count($index['deps'])): ?>
|
221 |
|
|
<br /><br /><?= gettext("Package Dependencies") ?>:
|
222 |
|
|
<?php foreach ($index['deps'] as $pdep): ?>
|
223 |
|
|
<br /><i class="fa fa-paperclip"></i> <?= basename($pdep['origin']) ?>-<?= $pdep['version'] ?>
|
224 |
|
|
<?php endforeach; ?>
|
225 |
|
|
<?php endif; ?>
|
226 |
98dfca18
|
Stephen Beaver
|
</td>
|
227 |
|
|
<td>
|
228 |
6c36aab3
|
Stephen Beaver
|
<a title="<?=gettext("Click to install")?>" href="pkg_mgr_install.php?id=<?=$index['name']?>" class="btn btn-success btn-sm">install</a>
|
229 |
0f649c97
|
Phil Davis
|
<?php
|
230 |
|
|
if (!$g['disablepackageinfo'] && $index['pkginfolink'] && $index['pkginfolink'] != $index['www']):
|
231 |
|
|
?>
|
232 |
98dfca18
|
Stephen Beaver
|
<a target="_blank" title="<?=gettext("View more information")?>" href="<?=htmlspecialchars($index['pkginfolink'])?>" class="btn btn-default btn-sm">info</a>
|
233 |
0f649c97
|
Phil Davis
|
<?php
|
234 |
|
|
endif;
|
235 |
|
|
?>
|
236 |
98dfca18
|
Stephen Beaver
|
</td>
|
237 |
|
|
</tr>
|
238 |
f70121be
|
Renato Botelho
|
<?php
|
239 |
2d26ee5e
|
Sjon Hortensius
|
endforeach;
|
240 |
0f649c97
|
Phil Davis
|
endif;
|
241 |
|
|
?>
|
242 |
98dfca18
|
Stephen Beaver
|
</tbody>
|
243 |
|
|
</table>
|
244 |
89f64f0f
|
Sander van Leeuwen
|
</div>
|
245 |
98dfca18
|
Stephen Beaver
|
</div>
|
246 |
|
|
|
247 |
8fd9052f
|
Colin Fleming
|
<script type="text/javascript">
|
248 |
98dfca18
|
Stephen Beaver
|
//<![CDATA[
|
249 |
0f649c97
|
Phil Davis
|
events.push(function() {
|
250 |
98dfca18
|
Stephen Beaver
|
|
251 |
6c36aab3
|
Stephen Beaver
|
// Initial state & toggle icons of collapsed panel
|
252 |
0f649c97
|
Phil Davis
|
$('.panel-heading a[data-toggle="collapse"]').each(function (idx, el) {
|
253 |
6c36aab3
|
Stephen Beaver
|
var body = $(el).parents('.panel').children('.panel-body')
|
254 |
|
|
var isOpen = body.hasClass('in');
|
255 |
|
|
|
256 |
1b7379f9
|
Jared Dillard
|
$(el).children('i').toggleClass('fa-plus-circle', !isOpen);
|
257 |
|
|
$(el).children('i').toggleClass('fa-minus-circle', isOpen);
|
258 |
6c36aab3
|
Stephen Beaver
|
|
259 |
0f649c97
|
Phil Davis
|
body.on('shown.bs.collapse', function() {
|
260 |
1b7379f9
|
Jared Dillard
|
$(el).children('i').toggleClass('fa-minus-circle', true);
|
261 |
|
|
$(el).children('i').toggleClass('fa-plus-circle', false);
|
262 |
6c36aab3
|
Stephen Beaver
|
});
|
263 |
|
|
});
|
264 |
|
|
|
265 |
1da8a2e3
|
Stephen Beaver
|
// Make these controls plain buttons
|
266 |
0f649c97
|
Phil Davis
|
$("#btnsearch").prop('type', 'button');
|
267 |
|
|
$("#btnclear").prop('type', 'button');
|
268 |
919d91f9
|
Phil Davis
|
|
269 |
1da8a2e3
|
Stephen Beaver
|
// Search for a term in the package name and/or description
|
270 |
3a28934c
|
Stephen Beaver
|
$("#btnsearch").click(function() {
|
271 |
|
|
var searchstr = $('#searchstr').val().toLowerCase();
|
272 |
|
|
var table = $("table tbody");
|
273 |
|
|
var where = $('#where').val();
|
274 |
|
|
|
275 |
|
|
table.find('tr').each(function (i) {
|
276 |
|
|
var $tds = $(this).find('td'),
|
277 |
|
|
shortname = $tds.eq(0).text().trim().toLowerCase(),
|
278 |
|
|
descr = $tds.eq(2).text().trim().toLowerCase();
|
279 |
|
|
|
280 |
|
|
regexp = new RegExp(searchstr);
|
281 |
0f649c97
|
Phil Davis
|
if (searchstr.length > 0) {
|
282 |
|
|
if (!(regexp.test(shortname) && (where != 1)) && !(regexp.test(descr) && (where != 0))) {
|
283 |
3a28934c
|
Stephen Beaver
|
$(this).hide();
|
284 |
|
|
} else {
|
285 |
|
|
$(this).show();
|
286 |
|
|
}
|
287 |
|
|
} else {
|
288 |
|
|
$(this).show(); // A blank search string shows all
|
289 |
|
|
}
|
290 |
|
|
});
|
291 |
|
|
});
|
292 |
|
|
|
293 |
1da8a2e3
|
Stephen Beaver
|
// Clear the search term and unhide all rows (that were hidden during a previous search)
|
294 |
3a28934c
|
Stephen Beaver
|
$("#btnclear").click(function() {
|
295 |
|
|
var table = $("table tbody");
|
296 |
|
|
|
297 |
1da8a2e3
|
Stephen Beaver
|
$('#searchstr').val("");
|
298 |
|
|
|
299 |
3a28934c
|
Stephen Beaver
|
table.find('tr').each(function (i) {
|
300 |
|
|
$(this).show();
|
301 |
|
|
});
|
302 |
|
|
});
|
303 |
919d91f9
|
Phil Davis
|
|
304 |
1da8a2e3
|
Stephen Beaver
|
// Hitting the enter key will do the same as clicking the search button
|
305 |
|
|
$("#searchstr").on("keyup", function (event) {
|
306 |
0f649c97
|
Phil Davis
|
if (event.keyCode == 13) {
|
307 |
1da8a2e3
|
Stephen Beaver
|
$("#btnsearch").get(0).click();
|
308 |
|
|
}
|
309 |
|
|
});
|
310 |
98dfca18
|
Stephen Beaver
|
});
|
311 |
|
|
//]]>
|
312 |
|
|
</script>
|
313 |
|
|
|
314 |
6c36aab3
|
Stephen Beaver
|
<?php include("foot.inc");
|