Project

General

Profile

Download (7.25 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
function compareName($a, $b) {
138
    return(strcasecmp ($a['name'], $b['name']));
139
}
140

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

    
155
		<th><?=gettext("Description")?></th>
156
	</tr>
157
	</thead>
158
	<tbody>
159
<?php
160

    
161
	// Sort case insensitve (so we get AbCdEf not ACEcdf)
162
	usort($pkg_info, 'compareName');
163

    
164
	foreach($pkg_info as $index):
165

    
166
		if(get_package_id($index['name']) >= 0 ) {
167
			continue;
168
		}
169

    
170
		$shortname = $index['name'];
171
		pkg_remove_prefix($shortname);
172

    
173
		if ($menu_category != "All" && $index['categories'][0] != $menu_category && !($menu_category == "Other" && !in_array($index['categories'][0], $visible_categories))) {
174
			continue;
175
		}
176

    
177
		// Check to see if it is already installed
178
		foreach($config['installedpackages']['package'] as $installedpkg) {
179
			if($installedpkg['name'] == $shortname) {
180
				continue(2);
181
			}
182
		}
183

    
184
?>
185
		<tr>
186
			<td>
187
<?php if ($index['www']):?>
188
				<a title="<?=gettext("Visit official website")?>" target="_blank" href="<?=htmlspecialchars($index['www'])?>">
189
<?php endif; ?>
190
					<?=htmlspecialchars($shortname)?>
191
				</a>
192
			</td>
193

    
194
<?php
195
	 if (!$g['disablepackagehistory']):?>
196
			<td>
197
<!-- We no longer have a package revision history URL
198
	$changeloglink is undefined
199
				<a target="_blank" title="<?=gettext("View changelog")?>" href="<?=htmlspecialchars($changeloglink)?>">
200
-->
201
				<?=htmlspecialchars($index['version'])?>
202
<!--
203
				</a>
204
-->
205
			</td>
206
<?php
207
endif;
208
?>
209
			<td>
210
				<?=$index['desc']?>
211
			</td>
212
			<td>
213
				<a title="<?=gettext("Click to install")?>" href="pkg_mgr_install.php?id=<?=$index['name']?>" class="btn btn-success">install</a>
214
<?php if(!$g['disablepackageinfo'] && $index['pkginfolink'] && $index['pkginfolink'] != $index['www']):?>
215
				<a target="_blank" title="<?=gettext("View more inforation")?>" href="<?=htmlspecialchars($index['pkginfolink'])?>" class="btn btn-default">info</a>
216
<?php endif;?>
217
			</td>
218
		</tr>
219
<?php
220
	endforeach;
221
endif;?>
222
	</tbody>
223
	</table>
224
	</div>
225
<?php include("foot.inc")?>
(115-115/235)