1 |
ee11cc6e
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
ee11cc6e
|
Scott Ullrich
|
/*
|
4 |
29840546
|
Renato Botelho
|
pkg_mgr.php
|
5 |
7f696ba0
|
Phil Davis
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
6 |
29840546
|
Renato Botelho
|
Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
|
7 |
|
|
Copyright (C) 2013 Marcello Coutinho
|
8 |
|
|
|
9 |
|
|
All rights reserved.
|
10 |
|
|
|
11 |
|
|
Redistribution and use in source and binary forms, with or without
|
12 |
|
|
modification, 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 the
|
19 |
|
|
documentation and/or other materials provided with the distribution.
|
20 |
|
|
|
21 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
31 |
ee11cc6e
|
Scott Ullrich
|
*/
|
32 |
1d333258
|
Scott Ullrich
|
/*
|
33 |
|
|
pfSense_BUILDER_BINARIES: /sbin/ifconfig
|
34 |
|
|
pfSense_MODULE: pkgs
|
35 |
|
|
*/
|
36 |
ee11cc6e
|
Scott Ullrich
|
|
37 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
38 |
|
|
##|*IDENT=page-system-packagemanager
|
39 |
|
|
##|*NAME=System: Package Manager page
|
40 |
|
|
##|*DESCR=Allow access to the 'System: Package Manager' page.
|
41 |
|
|
##|*MATCH=pkg_mgr.php*
|
42 |
|
|
##|-PRIV
|
43 |
|
|
|
44 |
0089af7c
|
Scott Ullrich
|
ini_set('max_execution_time', '0');
|
45 |
|
|
|
46 |
9bcf197e
|
Scott Ullrich
|
require_once("globals.inc");
|
47 |
9f9dcd98
|
Scott Ullrich
|
require_once("guiconfig.inc");
|
48 |
f8e335a3
|
Scott Ullrich
|
require_once("pkg-utils.inc");
|
49 |
ee11cc6e
|
Scott Ullrich
|
|
50 |
c8083ee2
|
Phil Davis
|
$timezone = $config['system']['timezone'];
|
51 |
943994ff
|
Scott Ullrich
|
if (!$timezone)
|
52 |
|
|
$timezone = "Etc/UTC";
|
53 |
|
|
|
54 |
|
|
date_default_timezone_set($timezone);
|
55 |
|
|
|
56 |
261c7de8
|
jim-p
|
/* if upgrade in progress, alert user */
|
57 |
|
|
if(is_subsystem_dirty('packagelock')) {
|
58 |
|
|
$pgtitle = array(gettext("System"),gettext("Package Manager"));
|
59 |
|
|
include("head.inc");
|
60 |
31f03b6c
|
Sjon Hortensius
|
print_info_box_np("Please wait while packages are reinstalled in the background.");
|
61 |
|
|
include("foot.inc");
|
62 |
261c7de8
|
jim-p
|
exit;
|
63 |
|
|
}
|
64 |
31f03b6c
|
Sjon Hortensius
|
|
65 |
9b4df982
|
marcelloc
|
//get_pkg_info only if cache file has more then $g[min_pkg_cache_file_time] seconds
|
66 |
|
|
$pkg_cache_file_time=($g['min_pkg_cache_file_time'] ? $g['min_pkg_cache_file_time'] : 120);
|
67 |
|
|
|
68 |
7c8f3711
|
jim-p
|
$xmlrpc_base_url = get_active_xml_rpc_base_url();
|
69 |
29840546
|
Renato Botelho
|
if (!file_exists("{$g['tmp_path']}/pkg_info.cache") || (time() - filemtime("{$g['tmp_path']}/pkg_info.cache")) > $pkg_cache_file_time) {
|
70 |
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"));
|
71 |
29840546
|
Renato Botelho
|
//create cache file after get_pkg_info
|
72 |
9b4df982
|
marcelloc
|
if($pkg_info) {
|
73 |
|
|
$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
|
74 |
|
|
fwrite($fout, serialize($pkg_info));
|
75 |
|
|
fclose($fout);
|
76 |
|
|
//$pkg_sizes = get_pkg_sizes();
|
77 |
29840546
|
Renato Botelho
|
} else {
|
78 |
9b4df982
|
marcelloc
|
$using_cache = true;
|
79 |
|
|
if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
|
80 |
|
|
$savemsg = sprintf(gettext("Unable to retrieve package info from %s. Cached data will be used."), $xmlrpc_base_url);
|
81 |
|
|
$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
|
82 |
|
|
} else {
|
83 |
|
|
$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']);
|
84 |
|
|
}
|
85 |
47c44d0a
|
Scott Ullrich
|
}
|
86 |
29840546
|
Renato Botelho
|
} else {
|
87 |
|
|
$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
|
88 |
|
|
}
|
89 |
52380979
|
Scott Ullrich
|
|
90 |
d591e2e1
|
Matthew Grooms
|
if (! empty($_GET))
|
91 |
|
|
if (isset($_GET['ver']))
|
92 |
|
|
$requested_version = htmlspecialchars($_GET['ver']);
|
93 |
61a48553
|
Scott Ullrich
|
|
94 |
82b15b70
|
Carlos Eduardo Ramos
|
$pgtitle = array(gettext("System"),gettext("Package Manager"));
|
95 |
52380979
|
Scott Ullrich
|
include("head.inc");
|
96 |
|
|
|
97 |
31f03b6c
|
Sjon Hortensius
|
/* Print package server mismatch warning. See https://redmine.pfsense.org/issues/484 */
|
98 |
|
|
if (!verify_all_package_servers())
|
99 |
|
|
print_info_box(package_server_mismatch_message());
|
100 |
c55dfc4a
|
jim-p
|
|
101 |
31f03b6c
|
Sjon Hortensius
|
/* Print package server SSL warning. See https://redmine.pfsense.org/issues/484 */
|
102 |
|
|
if (check_package_server_ssl() === false)
|
103 |
|
|
print_info_box(package_server_ssl_failure_message());
|
104 |
c55dfc4a
|
jim-p
|
|
105 |
31f03b6c
|
Sjon Hortensius
|
if ($savemsg)
|
106 |
|
|
print_info_box($savemsg);
|
107 |
6916360e
|
jim-p
|
|
108 |
31f03b6c
|
Sjon Hortensius
|
$version = rtrim(file_get_contents("/etc/version"));
|
109 |
d591e2e1
|
Matthew Grooms
|
|
110 |
31f03b6c
|
Sjon Hortensius
|
$tab_array = array();
|
111 |
|
|
$tab_array[] = array(gettext("Available Packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
|
112 |
|
|
$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
|
113 |
|
|
display_top_tabs($tab_array);
|
114 |
|
|
|
115 |
|
|
$version = rtrim(file_get_contents("/etc/version"));
|
116 |
|
|
if($pkg_info) {
|
117 |
|
|
$pkg_keys = array_keys($pkg_info);
|
118 |
|
|
natcasesort($pkg_keys);
|
119 |
|
|
|
120 |
|
|
//Check categories
|
121 |
|
|
$categories=array();
|
122 |
|
|
if(is_array($pkg_keys)) {
|
123 |
|
|
foreach($pkg_keys as $key) {
|
124 |
|
|
if (!package_skip_tests($pkg_info[$key],$requested_version))
|
125 |
|
|
$categories[$pkg_info[$key]['category']]++;
|
126 |
9b4df982
|
marcelloc
|
}
|
127 |
f70121be
|
Renato Botelho
|
}
|
128 |
31f03b6c
|
Sjon Hortensius
|
ksort($categories);
|
129 |
|
|
$cm_count=0;
|
130 |
|
|
$tab_array = array();
|
131 |
|
|
$visible_categories=array();
|
132 |
|
|
$categories_min_count=($g['pkg_categories_min_count'] ? $g['pkg_categories_min_count'] : 3);
|
133 |
|
|
$categories_max_display=($g['pkg_categories_max_display'] ? $g['pkg_categories_max_display'] : 6);
|
134 |
|
|
|
135 |
|
|
/* check selected category or define default category to show */
|
136 |
|
|
if (isset($_REQUEST['category']))
|
137 |
|
|
$menu_category = $_REQUEST['category'];
|
138 |
|
|
else if (isset($g['pkg_default_category']))
|
139 |
|
|
$menu_category = $g['pkg_default_category'];
|
140 |
|
|
else
|
141 |
|
|
$menu_category = "All";
|
142 |
|
|
|
143 |
|
|
$menu_category = (isset($_REQUEST['category']) ? $_REQUEST['category'] : "All");
|
144 |
|
|
$show_category = ($menu_category == "Other" || $menu_category == "All");
|
145 |
|
|
|
146 |
|
|
$tab_array[] = array(gettext("All"), $menu_category=="All" ? true : false, "pkg_mgr.php?category=All");
|
147 |
|
|
foreach ($categories as $category => $c_count) {
|
148 |
|
|
if ($c_count >= $categories_min_count && $cm_count <= $categories_max_display) {
|
149 |
|
|
$tab_array[] = array(gettext($category) , $menu_category==$category ? true : false, "pkg_mgr.php?category={$category}");
|
150 |
|
|
$visible_categories[]=$category;
|
151 |
|
|
$cm_count++;
|
152 |
|
|
}
|
153 |
f70121be
|
Renato Botelho
|
}
|
154 |
31f03b6c
|
Sjon Hortensius
|
$tab_array[] = array(gettext("Other Categories"), $menu_category=="Other" ? true : false, "pkg_mgr.php?category=Other");
|
155 |
|
|
if (count($categories) > 1)
|
156 |
|
|
display_top_tabs($tab_array);
|
157 |
|
|
}
|
158 |
29840546
|
Renato Botelho
|
|
159 |
2d26ee5e
|
Sjon Hortensius
|
if(!$pkg_info || !is_array($pkg_keys)):?>
|
160 |
|
|
<div class="alert alert-warning">
|
161 |
|
|
<?=gettext("There are currently no packages available for installation.")?>
|
162 |
|
|
</div>
|
163 |
|
|
<?php else: ?>
|
164 |
89f64f0f
|
Sander van Leeuwen
|
<div class="table-responsive">
|
165 |
|
|
<table class="table table-striped table-hover">
|
166 |
2d26ee5e
|
Sjon Hortensius
|
<thead>
|
167 |
|
|
<tr>
|
168 |
|
|
<th><?=gettext("Name")?></th>
|
169 |
|
|
<?php if ($show_category):?>
|
170 |
|
|
<th><?=gettext("Category")?></th>
|
171 |
|
|
<?php endif;?>
|
172 |
|
|
<th><?=gettext("Status")?></th>
|
173 |
|
|
<?php if (!$g['disablepackagehistory']):?>
|
174 |
|
|
<th><?=gettext("Version")?></th>
|
175 |
|
|
<?php endif;?>
|
176 |
|
|
<th><?=gettext("Platform")?></th>
|
177 |
|
|
<th><?=gettext("Description")?></th>
|
178 |
|
|
</tr>
|
179 |
|
|
</thead>
|
180 |
|
|
<tbody>
|
181 |
f70121be
|
Renato Botelho
|
<?php
|
182 |
2d26ee5e
|
Sjon Hortensius
|
foreach($pkg_keys as $key):
|
183 |
|
|
$index = &$pkg_info[$key];
|
184 |
|
|
if(get_pkg_id($index['name']) >= 0 )
|
185 |
|
|
continue;
|
186 |
|
|
|
187 |
|
|
if (package_skip_tests($index,$requested_version))
|
188 |
|
|
continue;
|
189 |
|
|
|
190 |
|
|
/* get history/changelog git dir */
|
191 |
|
|
$commit_dir=explode("/",$index['config_file']);
|
192 |
|
|
$changeloglink = "https://github.com/pfsense/pfsense-packages/commits/master/config/";
|
193 |
|
|
if ($commit_dir[(count($commit_dir)-2)] == "config")
|
194 |
|
|
$changeloglink .= $commit_dir[(count($commit_dir)-1)];
|
195 |
|
|
else
|
196 |
|
|
$changeloglink .= $commit_dir[(count($commit_dir)-2)];
|
197 |
|
|
|
198 |
|
|
if ($menu_category != "All" && $index['category'] != $menu_category && !($menu_category == "Other" && !in_array($index['category'], $visible_categories)))
|
199 |
|
|
continue;
|
200 |
f70121be
|
Renato Botelho
|
?>
|
201 |
2d26ee5e
|
Sjon Hortensius
|
<tr>
|
202 |
|
|
<td>
|
203 |
|
|
<?php if ($index['website']):?>
|
204 |
|
|
<a title="<?=gettext("Visit official website")?>" target="_blank" href="<?=htmlspecialchars($index['website'])?>">
|
205 |
|
|
<?php endif; ?>
|
206 |
|
|
<?=htmlspecialchars($index['name'])?>
|
207 |
|
|
</a>
|
208 |
|
|
</td>
|
209 |
|
|
<?php if ($show_category):?>
|
210 |
|
|
<td>
|
211 |
|
|
<?=gettext($index['category'])?>
|
212 |
|
|
</td>
|
213 |
|
|
<?php endif;?>
|
214 |
|
|
<td>
|
215 |
|
|
<?=ucfirst(strtolower($index['status']))?>
|
216 |
|
|
</td>
|
217 |
|
|
<?php if (!$g['disablepackagehistory']):?>
|
218 |
|
|
<td>
|
219 |
|
|
<a target="_blank" title="<?=gettext("View changelog")?>" href="<?=htmlspecialchars($changeloglink)?>">
|
220 |
|
|
<?=htmlspecialchars($index['version'])?>
|
221 |
|
|
</a>
|
222 |
|
|
</td>
|
223 |
|
|
<?php endif;?>
|
224 |
|
|
<td>
|
225 |
|
|
<?=$index['required_version']?>
|
226 |
|
|
<?php if ($index['maximum_version']):?>
|
227 |
|
|
(< $index['maximum_version'])
|
228 |
|
|
<?php endif;?>
|
229 |
|
|
</td>
|
230 |
|
|
<td>
|
231 |
|
|
<?=$index['descr']?>
|
232 |
|
|
</td>
|
233 |
|
|
<td>
|
234 |
7c804c69
|
Sjon Hortensius
|
<a title="<?=gettext("Click to install")?>" href="pkg_mgr_install.php?id=<?=$index['name']?>" class="btn btn-success">install</a>
|
235 |
2d26ee5e
|
Sjon Hortensius
|
<?php if(!$g['disablepackageinfo'] && $index['pkginfolink'] && $index['pkginfolink'] != $index['website']):?>
|
236 |
7c804c69
|
Sjon Hortensius
|
<a target="_blank" title="<?=gettext("View more inforation")?>" href="<?=htmlspecialchars($index['pkginfolink'])?>" class="btn btn-default">info</a>
|
237 |
2d26ee5e
|
Sjon Hortensius
|
<?php endif;?>
|
238 |
|
|
</td>
|
239 |
|
|
</tr>
|
240 |
f70121be
|
Renato Botelho
|
<?php
|
241 |
2d26ee5e
|
Sjon Hortensius
|
endforeach;
|
242 |
|
|
endif;?>
|
243 |
89f64f0f
|
Sander van Leeuwen
|
</tbody>
|
244 |
|
|
</table>
|
245 |
|
|
</div>
|
246 |
2d26ee5e
|
Sjon Hortensius
|
<?php include("foot.inc")?>
|