Project

General

Profile

Download (9.18 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	pkg_mgr.php
5
*/
6
/* ====================================================================
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
/*
59
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
60
	pfSense_MODULE: pkgs
61
*/
62

    
63
##|+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
ini_set('max_execution_time', '0');
71

    
72
require_once("globals.inc");
73
require_once("guiconfig.inc");
74
require_once("pkg-utils.inc");
75

    
76
$timezone = $config['system']['timezone'];
77
if (!$timezone)
78
	$timezone = "Etc/UTC";
79

    
80
date_default_timezone_set($timezone);
81

    
82
/* 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
	print_info_box_np("Please wait while packages are reinstalled in the background.");
87
	include("foot.inc");
88
	exit;
89
}
90

    
91
//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
$xmlrpc_base_url = get_active_xml_rpc_base_url();
95
if (!file_exists("{$g['tmp_path']}/pkg_info.cache") || (time() - filemtime("{$g['tmp_path']}/pkg_info.cache")) > $pkg_cache_file_time) {
96
	$pkg_info = get_pkg_info('all', array("noembedded", "name", "category", "website", "version", "status", "descr", "maintainer", "required_version", "maximum_version", "pkginfolink", "config_file"));
97
	//create cache file after get_pkg_info
98
	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
	} else {
104
		$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
	}
112
} else {
113
	$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
114
}
115

    
116
if (! empty($_GET))
117
	if (isset($_GET['ver']))
118
		$requested_version = htmlspecialchars($_GET['ver']);
119

    
120
$pgtitle = array(gettext("System"),gettext("Package Manager"));
121
include("head.inc");
122

    
123
/* 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

    
127
/* 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

    
131
if ($savemsg)
132
	print_info_box($savemsg);
133

    
134
$version = rtrim(file_get_contents("/etc/version"));
135

    
136
$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
			}
152
		}
153
	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
	}
179
	$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

    
184
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
	<div class="table-responsive">
190
	<table class="table table-striped table-hover">
191
	<thead>
192
	<tr>
193
		<th><?=gettext("Name")?></th>
194
<?php if (!$g['disablepackagehistory']):?>
195
		<th><?=gettext("Version")?></th>
196
<?php endif;?>
197

    
198
		<th><?=gettext("Description")?></th>
199
	</tr>
200
	</thead>
201
	<tbody>
202
<?php
203
	foreach($pkg_keys as $key):
204
		$index = &$pkg_info[$key];
205

    
206
		if(get_pkg_id($index['name']) >= 0 )
207
			continue;
208
		continue;
209

    
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
?>
221
		<tr>
222
			<td>
223
<?php if ($index['www']):?>
224
				<a title="<?=gettext("Visit official website")?>" target="_blank" href="<?=htmlspecialchars($index['www'])?>">
225
<?php endif; ?>
226
					<?=htmlspecialchars($index['name'])?>
227
				</a>
228
			</td>
229

    
230
<?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
				<?=$index['desc']?>
239
			</td>
240
			<td>
241
				<a title="<?=gettext("Click to install")?>" href="pkg_mgr_install.php?id=<?=$index['name']?>" class="btn btn-success">install</a>
242
<?php if(!$g['disablepackageinfo'] && $index['pkginfolink'] && $index['pkginfolink'] != $index['website']):?>
243
				<a target="_blank" title="<?=gettext("View more inforation")?>" href="<?=htmlspecialchars($index['pkginfolink'])?>" class="btn btn-default">info</a>
244
<?php endif;?>
245
			</td>
246
		</tr>
247
<?php
248
	endforeach;
249
endif;?>
250
	</tbody>
251
	</table>
252
	</div>
253
<?php include("foot.inc")?>
(115-115/235)