Project

General

Profile

Download (6.9 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
/* if upgrade in progress, alert user */
77
if(is_subsystem_dirty('packagelock')) {
78
	$pgtitle = array(gettext("System"),gettext("Package Manager"));
79
	include("head.inc");
80
	print_info_box_np("Please wait while packages are reinstalled in the background.");
81
	include("foot.inc");
82
	exit;
83
}
84

    
85
include("head.inc");
86

    
87
$pkg_info = get_pkg_info();
88

    
89
$pgtitle = array(gettext("System"),gettext("Package Manager"));
90

    
91
$tab_array = array();
92
$tab_array[] = array(gettext("Available Packages"), true, "pkg_mgr.php");
93
$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
94
display_top_tabs($tab_array);
95

    
96
if($pkg_info) {
97
	//Check categories
98
	$categories=array();
99
	foreach ($pkg_info as $pkg_data) {
100
		if (isset($pkg_data['categories'][0])) {
101
			$categories[$pkg_data['categories'][0]]++;
102
		}
103
	}
104

    
105
	ksort($categories, SORT_STRING|SORT_FLAG_CASE);
106
	$cm_count=0;
107
	$tab_array = array();
108
	$visible_categories=array();
109
	$categories_min_count=($g['pkg_categories_min_count'] ? $g['pkg_categories_min_count'] : 3);
110
	$categories_max_display=($g['pkg_categories_max_display'] ? $g['pkg_categories_max_display'] : 6);
111

    
112
	/* check selected category or define default category to show */
113
	if (isset($_REQUEST['category']))
114
		$menu_category = $_REQUEST['category'];
115
	else if (isset($g['pkg_default_category']))
116
		$menu_category = $g['pkg_default_category'];
117
	else
118
		$menu_category = "All";
119

    
120
	$menu_category = (isset($_REQUEST['category']) ? $_REQUEST['category'] : "All");
121
	$show_category = ($menu_category == "Other" || $menu_category == "All");
122

    
123
	$tab_array[] = array(gettext("All"), $menu_category=="All" ? true : false, "pkg_mgr.php?category=All");
124
	foreach ($categories as $category => $c_count) {
125
		if ($c_count >= $categories_min_count && $cm_count <= $categories_max_display) {
126
			$tab_array[] = array(gettext($category) , $menu_category==$category ? true : false, "pkg_mgr.php?category={$category}");
127
			$visible_categories[]=$category;
128
			$cm_count++;
129
		}
130
	}
131

    
132
	$tab_array[] = array(gettext("Other Categories"), $menu_category=="Other" ? true : false, "pkg_mgr.php?category=Other");
133
	if (count($categories) > 1)
134
		display_top_tabs($tab_array);
135
}
136

    
137
if(!$pkg_info || !is_array($pkg_info)):?>
138
	<div class="alert alert-warning">
139
		<?=gettext("There are currently no packages available for installation.")?>
140
	</div>
141
<?php else: ?>
142
	<div class="table-responsive">
143
	<table class="table table-striped table-hover">
144
	<thead>
145
	<tr>
146
		<th><?=gettext("Name")?></th>
147
<?php if (!$g['disablepackagehistory']):?>
148
		<th><?=gettext("Version")?></th>
149
<?php endif;?>
150

    
151
		<th><?=gettext("Description")?></th>
152
	</tr>
153
	</thead>
154
	<tbody>
155
<?php
156

    
157
	foreach($pkg_info as $index):
158
		if (isset($index['installed'])) {
159
			continue;
160
		}
161

    
162
		$shortname = $index['name'];
163
		pkg_remove_prefix($shortname);
164

    
165
		if ($menu_category != "All" && $index['categories'][0] != $menu_category && !($menu_category == "Other" && !in_array($index['categories'][0], $visible_categories))) {
166
			continue;
167
		}
168

    
169
?>
170
		<tr>
171
			<td>
172
<?php if ($index['www']):?>
173
				<a title="<?=gettext("Visit official website")?>" target="_blank" href="<?=htmlspecialchars($index['www'])?>">
174
<?php endif; ?>
175
					<?=htmlspecialchars($shortname)?>
176
				</a>
177
			</td>
178

    
179
<?php
180
	 if (!$g['disablepackagehistory']):?>
181
			<td>
182
<!-- We no longer have a package revision history URL
183
	$changeloglink is undefined
184
				<a target="_blank" title="<?=gettext("View changelog")?>" href="<?=htmlspecialchars($changeloglink)?>">
185
-->
186
				<?=htmlspecialchars($index['version'])?>
187
<!--
188
				</a>
189
-->
190
			</td>
191
<?php
192
endif;
193
?>
194
			<td>
195
				<?=$index['desc']?>
196
			</td>
197
			<td>
198
				<a title="<?=gettext("Click to install")?>" href="pkg_mgr_install.php?id=<?=$index['name']?>" class="btn btn-success btn-sm">install</a>
199
<?php if(!$g['disablepackageinfo'] && $index['pkginfolink'] && $index['pkginfolink'] != $index['www']):?>
200
				<a target="_blank" title="<?=gettext("View more information")?>" href="<?=htmlspecialchars($index['pkginfolink'])?>" class="btn btn-default btn-sm">info</a>
201
<?php endif;?>
202
			</td>
203
		</tr>
204
<?php
205
	endforeach;
206
endif;?>
207
	</tbody>
208
	</table>
209
	</div>
210
<?php include("foot.inc")?>
(115-115/234)