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
|
/* if upgrade in progress, alert user */
|
51
|
if (is_subsystem_dirty('packagelock')) {
|
52
|
$pgtitle = array(gettext("System"), gettext("Package Manager"));
|
53
|
include("head.inc");
|
54
|
echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
|
55
|
include("fbegin.inc");
|
56
|
echo "Please wait while packages are reinstalled in the background.";
|
57
|
include("fend.inc");
|
58
|
echo "</body>";
|
59
|
echo "</html>";
|
60
|
exit;
|
61
|
}
|
62
|
function domTT_title($title_msg) {
|
63
|
if (!empty($title_msg)) {
|
64
|
$title_msg = preg_replace("/\s+/", " ", $title_msg);
|
65
|
$title_msg = preg_replace("/'/", "\'", $title_msg);
|
66
|
echo "onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\" onmouseover=\"domTT_activate(this, event, 'content', '{$title_msg}', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle');\"";
|
67
|
}
|
68
|
}
|
69
|
|
70
|
$pkg_info = get_pkg_info();
|
71
|
|
72
|
$closehead = false;
|
73
|
$pgtitle = array(gettext("System"), gettext("Package Manager"));
|
74
|
include("head.inc");
|
75
|
|
76
|
?>
|
77
|
<script type="text/javascript" src="javascript/domTT/domLib.js"></script>
|
78
|
<script type="text/javascript" src="javascript/domTT/domTT.js"></script>
|
79
|
<script type="text/javascript" src="javascript/domTT/behaviour.js"></script>
|
80
|
<script type="text/javascript" src="javascript/domTT/fadomatic.js"></script>
|
81
|
<script type="text/javascript" src="/javascript/row_helper_dynamic.js"></script>
|
82
|
</head>
|
83
|
|
84
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
85
|
<?php
|
86
|
include("fbegin.inc");
|
87
|
?>
|
88
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="package manager">
|
89
|
<tr><td>
|
90
|
<?php
|
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
|
</td></tr>
|
97
|
<tr><td>
|
98
|
<?php
|
99
|
if ($pkg_info) {
|
100
|
//Check categories
|
101
|
$categories = array();
|
102
|
foreach ($pkg_info as $pkg_data) {
|
103
|
if (isset($pkg_data['categories'][0])) {
|
104
|
$categories[$pkg_data['categories'][0]]++;
|
105
|
}
|
106
|
}
|
107
|
ksort($categories);
|
108
|
$cm_count = 0;
|
109
|
$tab_array = array();
|
110
|
$visible_categories = array();
|
111
|
$categories_min_count = ($g['pkg_categories_min_count'] ? $g['pkg_categories_min_count'] : 3);
|
112
|
$categories_max_display = ($g['pkg_categories_max_display'] ? $g['pkg_categories_max_display'] : 6);
|
113
|
|
114
|
/* check selected category or define default category to show */
|
115
|
if (isset($_REQUEST['category'])) {
|
116
|
$menu_category = $_REQUEST['category'];
|
117
|
} else if (isset($g['pkg_default_category'])) {
|
118
|
$menu_category = $g['pkg_default_category'];
|
119
|
} else {
|
120
|
$menu_category = "All";
|
121
|
}
|
122
|
|
123
|
$menu_category = (isset($_REQUEST['category']) ? $_REQUEST['category'] : "All");
|
124
|
$show_category = ($menu_category == "Other" || $menu_category == "All");
|
125
|
|
126
|
$tab_array[] = array(gettext("All"), $menu_category == "All" ? true : false, "pkg_mgr.php?category=All");
|
127
|
foreach ($categories as $category => $c_count) {
|
128
|
if ($c_count >= $categories_min_count && $cm_count <= $categories_max_display) {
|
129
|
$tab_array[] = array(gettext($category) , $menu_category == $category ? true : false, "pkg_mgr.php?category={$category}");
|
130
|
$visible_categories[]=$category;
|
131
|
$cm_count++;
|
132
|
}
|
133
|
}
|
134
|
$tab_array[] = array(gettext("Other Categories"), $menu_category == "Other" ? true : false, "pkg_mgr.php?category=Other");
|
135
|
if (count($categories) > 1) {
|
136
|
display_top_tabs($tab_array);
|
137
|
}
|
138
|
}
|
139
|
?>
|
140
|
</td></tr>
|
141
|
<tr>
|
142
|
<td>
|
143
|
<div id="mainarea">
|
144
|
<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
|
145
|
<tr>
|
146
|
<td width="10%" class="listhdrr"><?=gettext("Name"); ?></td>
|
147
|
<?php
|
148
|
if ($show_category) {
|
149
|
print '<td width="18%" class="listhdr">'.gettext("Category").'</td>'."\n";
|
150
|
}
|
151
|
?>
|
152
|
<td width="<?php print $show_category ? "15%" : "20%"; ?>" class="listhdr"><?=gettext("Version"); ?></td>
|
153
|
<td width="<?php print $show_category ? "58%" : "70%"; ?>" class="listhdr"><?=gettext("Description"); ?></td>
|
154
|
<td width="17"> </td>
|
155
|
</tr>
|
156
|
<?php
|
157
|
if (!$pkg_info) {
|
158
|
echo "<tr><td colspan=\"5\"><center>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
|
159
|
} else {
|
160
|
if (is_array($pkg_info)) {
|
161
|
foreach ($pkg_info as $index):
|
162
|
if (get_package_id($index['name']) >= 0) {
|
163
|
continue;
|
164
|
}
|
165
|
|
166
|
$shortname = $index['name'];
|
167
|
pkg_remove_prefix($shortname);
|
168
|
|
169
|
/* Check package info link */
|
170
|
if ($index['www'] && $index['www'] != 'UNKNOWN') {
|
171
|
$pkginfolink = $index['www'];
|
172
|
$pkginfo=gettext("Package info");
|
173
|
} else {
|
174
|
$pkginfolink = "https://forum.pfsense.org/index.php/board,15.0.html";
|
175
|
$pkginfo=gettext("No package info, check the forum");
|
176
|
}
|
177
|
|
178
|
if ($menu_category == "All" || $index['categories'][0] == $menu_category || ($menu_category == "Other" && !in_array($index['categories'][0], $visible_categories))):
|
179
|
?>
|
180
|
<tr valign="top" class="<?= $index['categories'][0] ?>">
|
181
|
<td class="listlr" <?=domTT_title(gettext("Click on package name to access its website."))?>>
|
182
|
<a target="_blank" href="<?= $index['www'] ?>"><?=$shortname;?></a>
|
183
|
</td>
|
184
|
<?php
|
185
|
if ($show_category) {
|
186
|
print '<td class="listr">'.gettext($index['categories'][0]).'</td>'."\n";
|
187
|
}
|
188
|
|
189
|
?>
|
190
|
<td class="listr"><?=$index['version'];?></td>
|
191
|
<td class="listbg" style="overflow:hidden; text-align:justify;" <?=domTT_title(gettext("Click package info for more details about ".ucfirst($shortname)." package."))?>>
|
192
|
<?=str_replace("\n", '<br />', $index['desc']);?>
|
193
|
<?php
|
194
|
if (!$g['disablepackageinfo']):
|
195
|
?>
|
196
|
<br /><br />
|
197
|
<a target='_blank' href='<?=$pkginfolink?>' style='align:center;color:#ffffff; filter:Glow(color=#ff0000, strength=12);'><?=$pkginfo?></a>
|
198
|
<?php
|
199
|
endif;
|
200
|
?>
|
201
|
</td>
|
202
|
<td valign="middle" class="list nowrap" width="17">
|
203
|
<a href="pkg_mgr_install.php?id=<?=$shortname;?>"><img <?=domTT_title(gettext("Install ".ucfirst($shortname)." package."))?> src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" /></a>
|
204
|
</td>
|
205
|
</tr>
|
206
|
<?php
|
207
|
endif;
|
208
|
endforeach;
|
209
|
} else {
|
210
|
echo "<tr><td colspan='5' align='center'>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
|
211
|
} /* if (is_array($pkg_info)) */
|
212
|
} /* if (!$pkg_info) */
|
213
|
?>
|
214
|
</table>
|
215
|
</div>
|
216
|
</td>
|
217
|
</tr>
|
218
|
</table>
|
219
|
<?php include("fend.inc"); ?>
|
220
|
</body>
|
221
|
</html>
|