1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
pkg_mgr.php
|
5
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
6
|
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
|
*/
|
32
|
/*
|
33
|
pfSense_BUILDER_BINARIES: /sbin/ifconfig
|
34
|
pfSense_MODULE: pkgs
|
35
|
*/
|
36
|
|
37
|
##|+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
|
ini_set('max_execution_time', '0');
|
45
|
|
46
|
require_once("globals.inc");
|
47
|
require_once("guiconfig.inc");
|
48
|
require_once("pkg-utils.inc");
|
49
|
|
50
|
$timezone = $config['system']['timezone'];
|
51
|
if (!$timezone)
|
52
|
$timezone = "Etc/UTC";
|
53
|
|
54
|
date_default_timezone_set($timezone);
|
55
|
|
56
|
/* 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
|
print_info_box_np("Please wait while packages are reinstalled in the background.");
|
61
|
include("foot.inc");
|
62
|
exit;
|
63
|
}
|
64
|
|
65
|
//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
|
$xmlrpc_base_url = get_active_xml_rpc_base_url();
|
69
|
if (!file_exists("{$g['tmp_path']}/pkg_info.cache") || (time() - filemtime("{$g['tmp_path']}/pkg_info.cache")) > $pkg_cache_file_time) {
|
70
|
$pkg_info = get_pkg_info('all', array("noembedded", "name", "category", "website", "version", "status", "descr", "maintainer", "required_version", "maximum_version", "pkginfolink", "config_file"));
|
71
|
//create cache file after get_pkg_info
|
72
|
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
|
} else {
|
78
|
$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
|
}
|
86
|
} else {
|
87
|
$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
|
88
|
}
|
89
|
|
90
|
if (! empty($_GET))
|
91
|
if (isset($_GET['ver']))
|
92
|
$requested_version = htmlspecialchars($_GET['ver']);
|
93
|
|
94
|
$pgtitle = array(gettext("System"),gettext("Package Manager"));
|
95
|
include("head.inc");
|
96
|
|
97
|
/* 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
|
|
101
|
/* 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
|
|
105
|
if ($savemsg)
|
106
|
print_info_box($savemsg);
|
107
|
|
108
|
$version = rtrim(file_get_contents("/etc/version"));
|
109
|
|
110
|
$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
|
}
|
127
|
}
|
128
|
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
|
}
|
154
|
$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
|
|
159
|
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
|
<div class="table-responsive">
|
165
|
<table class="table table-striped table-hover">
|
166
|
<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
|
<?php
|
182
|
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
|
?>
|
201
|
<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
|
<a title="<?=gettext("Click to install")?>" href="pkg_mgr_install.php?id=<?=$index['name']?>" class="btn btn-success">install</a>
|
235
|
<?php if(!$g['disablepackageinfo'] && $index['pkginfolink'] && $index['pkginfolink'] != $index['website']):?>
|
236
|
<a target="_blank" title="<?=gettext("View more inforation")?>" href="<?=htmlspecialchars($index['pkginfolink'])?>" class="btn btn-default">info</a>
|
237
|
<?php endif;?>
|
238
|
</td>
|
239
|
</tr>
|
240
|
<?php
|
241
|
endforeach;
|
242
|
endif;?>
|
243
|
</tbody>
|
244
|
</table>
|
245
|
</div>
|
246
|
<?php include("foot.inc")?>
|