3 |
3 |
/*
|
4 |
4 |
pkg_mgr.php
|
5 |
5 |
Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
|
|
6 |
Copyright (C) 2013 Marcello Coutinho
|
|
7 |
|
6 |
8 |
All rights reserved.
|
7 |
9 |
|
8 |
10 |
Redistribution and use in source and binary forms, with or without
|
... | ... | |
69 |
71 |
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');\"";
|
70 |
72 |
}
|
71 |
73 |
}
|
72 |
|
$pkg_info = get_pkg_info('all', array("noembedded", "name", "category", "website", "version", "status", "descr", "maintainer", "required_version", "maximum_version", "pkginfolink", "supportedbybsdperimeter","config_file"));
|
73 |
|
if($pkg_info) {
|
74 |
|
$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
|
75 |
|
fwrite($fout, serialize($pkg_info));
|
76 |
|
fclose($fout);
|
77 |
|
//$pkg_sizes = get_pkg_sizes();
|
78 |
|
} else {
|
79 |
|
$using_cache = true;
|
80 |
|
$xmlrpc_base_url = isset($config['system']['altpkgrepo']['enable']) ? $config['system']['altpkgrepo']['xmlrpcbaseurl'] : $g['xmlrpcbaseurl'];
|
81 |
|
if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
|
82 |
|
$savemsg = sprintf(gettext("Unable to retrieve package info from %s. Cached data will be used."), $xmlrpc_base_url);
|
83 |
|
$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
|
84 |
|
} else {
|
85 |
|
$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']);
|
|
74 |
//get_pkg_info only if cache file has more then $g[min_pkg_cache_file_time] seconds
|
|
75 |
$pkg_cache_file_time=($g['min_pkg_cache_file_time'] ? $g['min_pkg_cache_file_time'] : 120);
|
|
76 |
|
|
77 |
if (!file_exists("{$g['tmp_path']}/pkg_info.cache") || (time() - filemtime("{$g['tmp_path']}/pkg_info.cache")) > $pkg_cache_file_time){
|
|
78 |
$pkg_info = get_pkg_info('all', array("noembedded", "name", "category", "website", "version", "status", "descr", "maintainer", "required_version", "maximum_version", "pkginfolink", "supportedbybsdperimeter","config_file"));
|
|
79 |
//create cache file after get_pkg_info
|
|
80 |
if($pkg_info) {
|
|
81 |
$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
|
|
82 |
fwrite($fout, serialize($pkg_info));
|
|
83 |
fclose($fout);
|
|
84 |
//$pkg_sizes = get_pkg_sizes();
|
|
85 |
}else {
|
|
86 |
$using_cache = true;
|
|
87 |
$xmlrpc_base_url = isset($config['system']['altpkgrepo']['enable']) ? $config['system']['altpkgrepo']['xmlrpcbaseurl'] : $g['xmlrpcbaseurl'];
|
|
88 |
if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
|
|
89 |
$savemsg = sprintf(gettext("Unable to retrieve package info from %s. Cached data will be used."), $xmlrpc_base_url);
|
|
90 |
$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
|
|
91 |
} else {
|
|
92 |
$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']);
|
|
93 |
}
|
|
94 |
}
|
|
95 |
}else{
|
|
96 |
$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
|
86 |
97 |
}
|
87 |
|
}
|
88 |
98 |
|
89 |
99 |
if (! empty($_GET))
|
90 |
100 |
if (isset($_GET['ver']))
|
... | ... | |
109 |
119 |
print_info_box($savemsg);
|
110 |
120 |
?>
|
111 |
121 |
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="package manager">
|
112 |
|
<tr>
|
113 |
|
<td>
|
114 |
|
<?php
|
115 |
|
$version = rtrim(file_get_contents("/etc/version"));
|
|
122 |
<tr><td>
|
|
123 |
<?php
|
|
124 |
$version = rtrim(file_get_contents("/etc/version"));
|
116 |
125 |
|
117 |
|
$tab_array = array();
|
118 |
|
$tab_array[] = array(gettext("Available Packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
|
119 |
|
// $tab_array[] = array($version . gettext("packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
|
120 |
|
// $tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
|
121 |
|
// $tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other");
|
122 |
|
$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
|
|
126 |
$tab_array = array();
|
|
127 |
$tab_array[] = array(gettext("Available Packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
|
|
128 |
$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
|
|
129 |
display_top_tabs($tab_array);
|
|
130 |
?>
|
|
131 |
</td></tr>
|
|
132 |
<tr><td>
|
|
133 |
<?php
|
|
134 |
$version = rtrim(file_get_contents("/etc/version"));
|
|
135 |
if($pkg_info) {
|
|
136 |
$pkg_keys = array_keys($pkg_info);
|
|
137 |
natcasesort($pkg_keys);
|
|
138 |
|
|
139 |
//Check categories
|
|
140 |
$categories=array();
|
|
141 |
if(is_array($pkg_keys)) {
|
|
142 |
foreach($pkg_keys as $key){
|
|
143 |
if (!package_skip_tests($pkg_info[$key],$requested_version))
|
|
144 |
$categories[$pkg_info[$key]['category']]++;
|
|
145 |
}
|
|
146 |
}
|
|
147 |
ksort($categories);
|
|
148 |
$cm_count=0;
|
|
149 |
$tab_array = array();
|
|
150 |
$visible_categories=array();
|
|
151 |
$categories_min_count=($g[$pkg_categories_min_count] ? $g[$pkg_categories_min_count] : 3);
|
|
152 |
$categories_max_display=($g[$pkg_categories_max_display] ? $g[$pkg_categories_max_display] : 6);
|
|
153 |
|
|
154 |
//check selected category or define defaul category to show
|
|
155 |
if (isset($_REQUEST['category'])){
|
|
156 |
$menu_category=$_REQUEST['category'];
|
|
157 |
}
|
|
158 |
else{
|
|
159 |
$menu_category=($g[$pkg_default_category] ? $g[$pkg_default_category] : "Services");
|
|
160 |
}
|
|
161 |
|
|
162 |
foreach ($categories as $category => $c_count){
|
|
163 |
if ($c_count >= $categories_min_count && $cm_count <= $categories_max_display){
|
|
164 |
$tab_array[] = array(gettext($category) , $menu_category==$category ? true : false, "pkg_mgr.php?category={$category}");
|
|
165 |
$visible_categories[]=$category;
|
|
166 |
$cm_count++;
|
|
167 |
}
|
|
168 |
}
|
|
169 |
$tab_array[] = array(gettext("Other Categories"), $menu_category=="Other" ? true : false, "pkg_mgr.php?category=Other");
|
|
170 |
if (count($categories) > 1)
|
123 |
171 |
display_top_tabs($tab_array);
|
|
172 |
}?>
|
|
173 |
</td></tr>
|
|
174 |
<tr><td>
|
|
175 |
<div id="mainarea">
|
|
176 |
<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
|
|
177 |
<tr><td width="<? print $menu_category=="Other" ? "10%" : "20%"; ?>" class="listhdrr"><?=gettext("Name"); ?></td>
|
|
178 |
<?php
|
|
179 |
if ($menu_category== "Other")
|
|
180 |
print '<td width="18%" class="listhdrr">'.gettext("Category").'</td>'."\n";
|
124 |
181 |
?>
|
125 |
|
</td>
|
126 |
|
</tr>
|
127 |
|
<tr>
|
128 |
|
<td>
|
129 |
|
<div id="mainarea">
|
130 |
|
<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
|
131 |
|
<tr>
|
132 |
|
<td width="12%" class="listhdrr"><?=gettext("Name"); ?></td>
|
133 |
|
<td width="18%" class="listhdrr"><?=gettext("Category"); ?></td>
|
134 |
|
<td width="15%" class="listhdrr"><?=gettext("Status"); ?></td>
|
135 |
|
<td width="53%" class="listhdr"><?=gettext("Description"); ?></td>
|
136 |
|
<td width="17"> </td>
|
137 |
|
</tr>
|
138 |
|
<?php
|
139 |
|
if(!$pkg_info) {
|
140 |
|
echo "<tr><td colspan=\"5\"><center>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
|
141 |
|
} else {
|
142 |
|
$pkgs = array();
|
143 |
|
$instpkgs = array();
|
144 |
|
if($config['installedpackages']['package'] != "")
|
145 |
|
foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
|
146 |
|
$pkg_names = array_keys($pkg_info);
|
147 |
|
$pkg_keys = array();
|
148 |
|
|
149 |
|
foreach($pkg_names as $name)
|
150 |
|
if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
|
151 |
|
$pkg_keys = msort($pkg_keys);
|
152 |
|
if(count($pkg_keys) != 0) {
|
153 |
|
foreach($pkg_keys as $key) {
|
154 |
|
$index = &$pkg_info[$key];
|
155 |
|
if(in_array($index['name'], $instpkgs))
|
156 |
|
continue;
|
157 |
|
if($g['platform'] == "nanobsd")
|
158 |
|
if($index['noembedded'])
|
159 |
|
continue;
|
160 |
|
/* If we are on not on HEAD, and the package wants it, skip */
|
161 |
|
if ($version <> "HEAD" &&
|
162 |
|
$index['required_version'] == "HEAD" &&
|
163 |
|
$requested_version <> "other")
|
164 |
|
continue;
|
165 |
|
/* If there is no required version, and the requested package
|
166 |
|
version is not 'none', then skip */
|
167 |
|
if (empty($index['required_version']) &&
|
168 |
|
$requested_version <> "none")
|
169 |
|
continue;
|
170 |
|
/* If the requested version is not 'other', and the required version is newer than what we have, skip. */
|
171 |
|
if($requested_version <> "other" &&
|
172 |
|
(pfs_version_compare("", $version, $index['required_version']) < 0))
|
173 |
|
continue;
|
174 |
|
/* If the requestion version is 'other' and we are on the version requested, skip. */
|
175 |
|
if($requested_version == "other" &&
|
176 |
|
(pfs_version_compare("", $version, $index['required_version']) == 0))
|
177 |
|
continue;
|
178 |
|
/* Package is only for an older version, lets skip */
|
179 |
|
if($index['maximum_version'] &&
|
180 |
|
(pfs_version_compare("", $version, $index['maximum_version']) > 0))
|
181 |
|
continue;
|
182 |
|
/* get history/changelog git dir */
|
183 |
|
$commit_dir=explode("/",$index['config_file']);
|
184 |
|
$changeloglink ="https://github.com/pfsense/pfsense-packages/commits/master/config/".$commit_dir[(count($commit_dir)-2)];
|
185 |
|
/* Check package info link */
|
186 |
|
if($index['pkginfolink']){
|
187 |
|
$pkginfolink = $index['pkginfolink'];
|
188 |
|
$pkginfo=gettext("Package info");
|
189 |
|
}
|
190 |
|
else{
|
191 |
|
$pkginfolink = "http://forum.pfsense.org/index.php/board,15.0.html";
|
192 |
|
$pkginfo=gettext("No package info, check the forum");
|
193 |
|
}
|
194 |
|
?>
|
195 |
|
<tr valign="top">
|
|
182 |
<td width="<? print $menu_category=="Other" ? "15%" : "20%"; ?>" class="listhdr"><?=gettext("Status"); ?></td>
|
|
183 |
<td width="<? print $menu_category=="Other" ? "58%" : "60%"; ?>" class="listhdr"><?=gettext("Description"); ?></td>
|
|
184 |
<td width="17"> </td></tr>
|
|
185 |
<?php
|
|
186 |
if(!$pkg_info) {
|
|
187 |
echo "<tr><td colspan=\"5\"><center>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
|
|
188 |
} else {
|
|
189 |
if(is_array($pkg_keys)) {
|
|
190 |
foreach($pkg_keys as $key) {
|
|
191 |
$index = &$pkg_info[$key];
|
|
192 |
if(get_pkg_id($index['name']) >= 0 )
|
|
193 |
continue;
|
|
194 |
|
|
195 |
if (package_skip_tests($index,$requested_version))
|
|
196 |
continue;
|
|
197 |
|
|
198 |
/* get history/changelog git dir */
|
|
199 |
$commit_dir=explode("/",$index['config_file']);
|
|
200 |
$changeloglink ="https://github.com/pfsense/pfsense-packages/commits/master/config/".$commit_dir[(count($commit_dir)-2)];
|
|
201 |
|
|
202 |
/* Check package info link */
|
|
203 |
if($index['pkginfolink']){
|
|
204 |
$pkginfolink = $index['pkginfolink'];
|
|
205 |
$pkginfo=gettext("Package info");
|
|
206 |
}else{
|
|
207 |
$pkginfolink = "http://forum.pfsense.org/index.php/board,15.0.html";
|
|
208 |
$pkginfo=gettext("No package info, check the forum");
|
|
209 |
}
|
|
210 |
if ($index['category'] == $menu_category || ($menu_category == "Other" && !in_array($index['category'],$visible_categories)) ){?>
|
|
211 |
<tr valign="top" class="<?= $index['category'] ?>">
|
196 |
212 |
<td class="listlr" <?=domTT_title(gettext("Click on package name to access its website."))?>>
|
197 |
213 |
<a target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
|
198 |
214 |
</td>
|
199 |
|
<td class="listr">
|
200 |
|
<?= $index['category'] ?>
|
201 |
|
</td>
|
202 |
|
<?php
|
203 |
|
/*
|
204 |
|
if(!$using_cache) {
|
205 |
|
$size = get_package_install_size($index['name'], $pkg_sizes);
|
206 |
|
$size = squash_from_bytes($size[$index['name']], 1);
|
|
215 |
<?php
|
|
216 |
if ($menu_category== "Other")
|
|
217 |
print '<td class="listlr">'.gettext($index['category']).'</td>'."\n";
|
|
218 |
|
|
219 |
if ($g['disablepackagehistory']){
|
|
220 |
print '<td class="listr">'."\n";
|
|
221 |
}else{
|
|
222 |
print '<td class="listr" ';
|
|
223 |
domTT_title(gettext("Click ").ucfirst($index['name']).gettext(" version to check its change log."));
|
|
224 |
print ">\n";
|
207 |
225 |
}
|
208 |
|
if(!$size)
|
209 |
|
$size = "Unknown.";
|
210 |
|
*/
|
211 |
|
?>
|
212 |
|
<!--
|
213 |
|
<td class="listr">
|
214 |
|
<?= $size ?>
|
215 |
|
</td>
|
216 |
|
-->
|
217 |
|
<?php if ($g['disablepackagehistory']){?>
|
218 |
|
<td class="listr">
|
219 |
|
<?php }else{?>
|
220 |
|
<td class="listr" <?=domTT_title(gettext("Click ".ucfirst($index['name'])." version to check its change log."))?>>
|
221 |
|
<?php }?>
|
222 |
|
<?=$index['status'] ?>
|
223 |
|
<br/>
|
224 |
|
<?php
|
|
226 |
|
|
227 |
print "{$index['status']} <br>\n";
|
|
228 |
|
225 |
229 |
if ($g['disablepackagehistory'])
|
226 |
230 |
echo"<a>{$index['version']}</a>";
|
227 |
231 |
else
|
... | ... | |
241 |
245 |
</td>
|
242 |
246 |
<td valign="middle" class="list nowrap" width="17">
|
243 |
247 |
<a onclick="return confirm('<?=gettext("Do you really want to install ".ucfirst($index['name'])." package?"); ?>')" href="pkg_mgr_install.php?id=<?=$index['name'];?>"><img <?=domTT_title(gettext("Install ".ucfirst($index['name'])." package."))?> src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" /></a>
|
244 |
|
</td>
|
245 |
|
</tr>
|
|
248 |
</td></tr>
|
246 |
249 |
<?php
|
247 |
|
}
|
248 |
|
} else {
|
249 |
|
echo "<tr><td colspan='5' align='center'>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
|
250 |
|
}
|
251 |
250 |
}
|
252 |
|
?>
|
253 |
|
</table>
|
254 |
|
</div>
|
255 |
|
</td>
|
256 |
|
</tr>
|
|
251 |
}
|
|
252 |
} else {
|
|
253 |
echo "<tr><td colspan='5' align='center'>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
|
|
254 |
}
|
|
255 |
}?>
|
|
256 |
</table>
|
|
257 |
</div>
|
|
258 |
</td></tr>
|
257 |
259 |
</table>
|
258 |
260 |
<?php include("fend.inc"); ?>
|
259 |
261 |
</body>
|
Add dynamic category tabs for better listing all available packages