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 |
c8083ee2
|
Phil Davis
|
$timezone = $config['system']['timezone'];
|
77 |
943994ff
|
Scott Ullrich
|
if (!$timezone)
|
78 |
|
|
$timezone = "Etc/UTC";
|
79 |
|
|
|
80 |
|
|
date_default_timezone_set($timezone);
|
81 |
|
|
|
82 |
261c7de8
|
jim-p
|
/* if upgrade in progress, alert user */
|
83 |
|
|
if(is_subsystem_dirty('packagelock')) {
|
84 |
|
|
$pgtitle = array(gettext("System"),gettext("Package Manager"));
|
85 |
|
|
include("head.inc");
|
86 |
31f03b6c
|
Sjon Hortensius
|
print_info_box_np("Please wait while packages are reinstalled in the background.");
|
87 |
|
|
include("foot.inc");
|
88 |
261c7de8
|
jim-p
|
exit;
|
89 |
|
|
}
|
90 |
31f03b6c
|
Sjon Hortensius
|
|
91 |
9b4df982
|
marcelloc
|
//get_pkg_info only if cache file has more then $g[min_pkg_cache_file_time] seconds
|
92 |
|
|
$pkg_cache_file_time=($g['min_pkg_cache_file_time'] ? $g['min_pkg_cache_file_time'] : 120);
|
93 |
|
|
|
94 |
7c8f3711
|
jim-p
|
$xmlrpc_base_url = get_active_xml_rpc_base_url();
|
95 |
29840546
|
Renato Botelho
|
if (!file_exists("{$g['tmp_path']}/pkg_info.cache") || (time() - filemtime("{$g['tmp_path']}/pkg_info.cache")) > $pkg_cache_file_time) {
|
96 |
6dc2a349
|
Chris Buechler
|
$pkg_info = get_pkg_info('all', array("noembedded", "name", "category", "website", "version", "status", "descr", "maintainer", "required_version", "maximum_version", "pkginfolink", "config_file"));
|
97 |
29840546
|
Renato Botelho
|
//create cache file after get_pkg_info
|
98 |
9b4df982
|
marcelloc
|
if($pkg_info) {
|
99 |
|
|
$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
|
100 |
|
|
fwrite($fout, serialize($pkg_info));
|
101 |
|
|
fclose($fout);
|
102 |
|
|
//$pkg_sizes = get_pkg_sizes();
|
103 |
29840546
|
Renato Botelho
|
} else {
|
104 |
9b4df982
|
marcelloc
|
$using_cache = true;
|
105 |
|
|
if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
|
106 |
|
|
$savemsg = sprintf(gettext("Unable to retrieve package info from %s. Cached data will be used."), $xmlrpc_base_url);
|
107 |
|
|
$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
|
108 |
|
|
} else {
|
109 |
|
|
$savemsg = sprintf(gettext('Unable to communicate with %1$s. Please verify DNS and interface configuration, and that %2$s has functional Internet connectivity.'), $xmlrpc_base_url, $g['product_name']);
|
110 |
|
|
}
|
111 |
47c44d0a
|
Scott Ullrich
|
}
|
112 |
29840546
|
Renato Botelho
|
} else {
|
113 |
|
|
$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
|
114 |
|
|
}
|
115 |
52380979
|
Scott Ullrich
|
|
116 |
d591e2e1
|
Matthew Grooms
|
if (! empty($_GET))
|
117 |
|
|
if (isset($_GET['ver']))
|
118 |
|
|
$requested_version = htmlspecialchars($_GET['ver']);
|
119 |
61a48553
|
Scott Ullrich
|
|
120 |
82b15b70
|
Carlos Eduardo Ramos
|
$pgtitle = array(gettext("System"),gettext("Package Manager"));
|
121 |
52380979
|
Scott Ullrich
|
include("head.inc");
|
122 |
|
|
|
123 |
31f03b6c
|
Sjon Hortensius
|
/* Print package server mismatch warning. See https://redmine.pfsense.org/issues/484 */
|
124 |
|
|
if (!verify_all_package_servers())
|
125 |
|
|
print_info_box(package_server_mismatch_message());
|
126 |
c55dfc4a
|
jim-p
|
|
127 |
31f03b6c
|
Sjon Hortensius
|
/* Print package server SSL warning. See https://redmine.pfsense.org/issues/484 */
|
128 |
|
|
if (check_package_server_ssl() === false)
|
129 |
|
|
print_info_box(package_server_ssl_failure_message());
|
130 |
c55dfc4a
|
jim-p
|
|
131 |
31f03b6c
|
Sjon Hortensius
|
if ($savemsg)
|
132 |
|
|
print_info_box($savemsg);
|
133 |
6916360e
|
jim-p
|
|
134 |
31f03b6c
|
Sjon Hortensius
|
$version = rtrim(file_get_contents("/etc/version"));
|
135 |
d591e2e1
|
Matthew Grooms
|
|
136 |
31f03b6c
|
Sjon Hortensius
|
$tab_array = array();
|
137 |
|
|
$tab_array[] = array(gettext("Available Packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
|
138 |
|
|
$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
|
139 |
|
|
display_top_tabs($tab_array);
|
140 |
|
|
|
141 |
|
|
$version = rtrim(file_get_contents("/etc/version"));
|
142 |
|
|
if($pkg_info) {
|
143 |
|
|
$pkg_keys = array_keys($pkg_info);
|
144 |
|
|
natcasesort($pkg_keys);
|
145 |
|
|
|
146 |
|
|
//Check categories
|
147 |
|
|
$categories=array();
|
148 |
|
|
if(is_array($pkg_keys)) {
|
149 |
|
|
foreach($pkg_keys as $key) {
|
150 |
|
|
$categories[$pkg_info[$key]['category']]++;
|
151 |
9b4df982
|
marcelloc
|
}
|
152 |
f70121be
|
Renato Botelho
|
}
|
153 |
31f03b6c
|
Sjon Hortensius
|
ksort($categories);
|
154 |
|
|
$cm_count=0;
|
155 |
|
|
$tab_array = array();
|
156 |
|
|
$visible_categories=array();
|
157 |
|
|
$categories_min_count=($g['pkg_categories_min_count'] ? $g['pkg_categories_min_count'] : 3);
|
158 |
|
|
$categories_max_display=($g['pkg_categories_max_display'] ? $g['pkg_categories_max_display'] : 6);
|
159 |
|
|
|
160 |
|
|
/* check selected category or define default category to show */
|
161 |
|
|
if (isset($_REQUEST['category']))
|
162 |
|
|
$menu_category = $_REQUEST['category'];
|
163 |
|
|
else if (isset($g['pkg_default_category']))
|
164 |
|
|
$menu_category = $g['pkg_default_category'];
|
165 |
|
|
else
|
166 |
|
|
$menu_category = "All";
|
167 |
|
|
|
168 |
|
|
$menu_category = (isset($_REQUEST['category']) ? $_REQUEST['category'] : "All");
|
169 |
|
|
$show_category = ($menu_category == "Other" || $menu_category == "All");
|
170 |
|
|
|
171 |
|
|
$tab_array[] = array(gettext("All"), $menu_category=="All" ? true : false, "pkg_mgr.php?category=All");
|
172 |
|
|
foreach ($categories as $category => $c_count) {
|
173 |
|
|
if ($c_count >= $categories_min_count && $cm_count <= $categories_max_display) {
|
174 |
|
|
$tab_array[] = array(gettext($category) , $menu_category==$category ? true : false, "pkg_mgr.php?category={$category}");
|
175 |
|
|
$visible_categories[]=$category;
|
176 |
|
|
$cm_count++;
|
177 |
|
|
}
|
178 |
f70121be
|
Renato Botelho
|
}
|
179 |
31f03b6c
|
Sjon Hortensius
|
$tab_array[] = array(gettext("Other Categories"), $menu_category=="Other" ? true : false, "pkg_mgr.php?category=Other");
|
180 |
|
|
if (count($categories) > 1)
|
181 |
|
|
display_top_tabs($tab_array);
|
182 |
|
|
}
|
183 |
29840546
|
Renato Botelho
|
|
184 |
2d26ee5e
|
Sjon Hortensius
|
if(!$pkg_info || !is_array($pkg_keys)):?>
|
185 |
|
|
<div class="alert alert-warning">
|
186 |
|
|
<?=gettext("There are currently no packages available for installation.")?>
|
187 |
|
|
</div>
|
188 |
|
|
<?php else: ?>
|
189 |
89f64f0f
|
Sander van Leeuwen
|
<div class="table-responsive">
|
190 |
|
|
<table class="table table-striped table-hover">
|
191 |
2d26ee5e
|
Sjon Hortensius
|
<thead>
|
192 |
|
|
<tr>
|
193 |
|
|
<th><?=gettext("Name")?></th>
|
194 |
|
|
<?php if (!$g['disablepackagehistory']):?>
|
195 |
|
|
<th><?=gettext("Version")?></th>
|
196 |
|
|
<?php endif;?>
|
197 |
239b5161
|
Stephen Beaver
|
|
198 |
2d26ee5e
|
Sjon Hortensius
|
<th><?=gettext("Description")?></th>
|
199 |
|
|
</tr>
|
200 |
|
|
</thead>
|
201 |
|
|
<tbody>
|
202 |
f70121be
|
Renato Botelho
|
<?php
|
203 |
2d26ee5e
|
Sjon Hortensius
|
foreach($pkg_keys as $key):
|
204 |
|
|
$index = &$pkg_info[$key];
|
205 |
|
|
|
206 |
239b5161
|
Stephen Beaver
|
if(get_pkg_id($index['name']) >= 0 )
|
207 |
2d26ee5e
|
Sjon Hortensius
|
continue;
|
208 |
239b5161
|
Stephen Beaver
|
continue;
|
209 |
2d26ee5e
|
Sjon Hortensius
|
|
210 |
|
|
/* get history/changelog git dir */
|
211 |
|
|
$commit_dir=explode("/",$index['config_file']);
|
212 |
|
|
$changeloglink = "https://github.com/pfsense/pfsense-packages/commits/master/config/";
|
213 |
|
|
if ($commit_dir[(count($commit_dir)-2)] == "config")
|
214 |
|
|
$changeloglink .= $commit_dir[(count($commit_dir)-1)];
|
215 |
|
|
else
|
216 |
|
|
$changeloglink .= $commit_dir[(count($commit_dir)-2)];
|
217 |
|
|
|
218 |
|
|
if ($menu_category != "All" && $index['category'] != $menu_category && !($menu_category == "Other" && !in_array($index['category'], $visible_categories)))
|
219 |
|
|
continue;
|
220 |
f70121be
|
Renato Botelho
|
?>
|
221 |
2d26ee5e
|
Sjon Hortensius
|
<tr>
|
222 |
|
|
<td>
|
223 |
239b5161
|
Stephen Beaver
|
<?php if ($index['www']):?>
|
224 |
|
|
<a title="<?=gettext("Visit official website")?>" target="_blank" href="<?=htmlspecialchars($index['www'])?>">
|
225 |
2d26ee5e
|
Sjon Hortensius
|
<?php endif; ?>
|
226 |
|
|
<?=htmlspecialchars($index['name'])?>
|
227 |
|
|
</a>
|
228 |
|
|
</td>
|
229 |
239b5161
|
Stephen Beaver
|
|
230 |
2d26ee5e
|
Sjon Hortensius
|
<?php if (!$g['disablepackagehistory']):?>
|
231 |
|
|
<td>
|
232 |
|
|
<a target="_blank" title="<?=gettext("View changelog")?>" href="<?=htmlspecialchars($changeloglink)?>">
|
233 |
|
|
<?=htmlspecialchars($index['version'])?>
|
234 |
|
|
</a>
|
235 |
|
|
</td>
|
236 |
|
|
<?php endif;?>
|
237 |
|
|
<td>
|
238 |
239b5161
|
Stephen Beaver
|
<?=$index['desc']?>
|
239 |
2d26ee5e
|
Sjon Hortensius
|
</td>
|
240 |
|
|
<td>
|
241 |
7c804c69
|
Sjon Hortensius
|
<a title="<?=gettext("Click to install")?>" href="pkg_mgr_install.php?id=<?=$index['name']?>" class="btn btn-success">install</a>
|
242 |
2d26ee5e
|
Sjon Hortensius
|
<?php if(!$g['disablepackageinfo'] && $index['pkginfolink'] && $index['pkginfolink'] != $index['website']):?>
|
243 |
7c804c69
|
Sjon Hortensius
|
<a target="_blank" title="<?=gettext("View more inforation")?>" href="<?=htmlspecialchars($index['pkginfolink'])?>" class="btn btn-default">info</a>
|
244 |
2d26ee5e
|
Sjon Hortensius
|
<?php endif;?>
|
245 |
|
|
</td>
|
246 |
|
|
</tr>
|
247 |
f70121be
|
Renato Botelho
|
<?php
|
248 |
2d26ee5e
|
Sjon Hortensius
|
endforeach;
|
249 |
|
|
endif;?>
|
250 |
89f64f0f
|
Sander van Leeuwen
|
</tbody>
|
251 |
|
|
</table>
|
252 |
|
|
</div>
|
253 |
2d26ee5e
|
Sjon Hortensius
|
<?php include("foot.inc")?>
|