1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
pkg_mgr.php
|
5
|
Copyright (C) 2004, 2005 Scott Ullrich
|
6
|
All rights reserved.
|
7
|
|
8
|
Redistribution and use in source and binary forms, with or without
|
9
|
modification, are permitted provided that the following conditions are met:
|
10
|
|
11
|
1. Redistributions of source code must retain the above copyright notice,
|
12
|
this list of conditions and the following disclaimer.
|
13
|
|
14
|
2. Redistributions in binary form must reproduce the above copyright
|
15
|
notice, this list of conditions and the following disclaimer in the
|
16
|
documentation and/or other materials provided with the distribution.
|
17
|
|
18
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
POSSIBILITY OF SUCH DAMAGE.
|
28
|
*/
|
29
|
|
30
|
##|+PRIV
|
31
|
##|*IDENT=page-system-packagemanager
|
32
|
##|*NAME=System: Package Manager page
|
33
|
##|*DESCR=Allow access to the 'System: Package Manager' page.
|
34
|
##|*MATCH=pkg_mgr.php*
|
35
|
##|-PRIV
|
36
|
|
37
|
|
38
|
require_once("guiconfig.inc");
|
39
|
require_once("pkg-utils.inc");
|
40
|
|
41
|
$pkg_info = get_pkg_info('all', array('name', 'category', 'website', 'version', 'status', 'descr', 'maintainer', 'required_version'));
|
42
|
if($pkg_info) {
|
43
|
$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
|
44
|
fwrite($fout, serialize($pkg_info));
|
45
|
fclose($fout);
|
46
|
//$pkg_sizes = get_pkg_sizes();
|
47
|
} else {
|
48
|
$using_cache = true;
|
49
|
if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
|
50
|
$savemsg = "Unable to retrieve package info from {$g['xmlrpcbaseurl']}. Cached data will be used.";
|
51
|
$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
|
52
|
} else {
|
53
|
$savemsg = "Unable to communicate to {$g['product_website']}. Please check DNS, default gateway, etc.";
|
54
|
}
|
55
|
}
|
56
|
|
57
|
if (! empty($_GET)) {
|
58
|
if (isset($_GET['ver'])) {
|
59
|
$requested_version = htmlspecialchars($_GET['ver']);
|
60
|
}
|
61
|
}
|
62
|
|
63
|
$pgtitle = array("System","Package Manager");
|
64
|
include("head.inc");
|
65
|
|
66
|
?>
|
67
|
|
68
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
69
|
<?php
|
70
|
include("fbegin.inc");
|
71
|
?>
|
72
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
73
|
<?php
|
74
|
|
75
|
?>
|
76
|
|
77
|
<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td>
|
78
|
<?php
|
79
|
$version = file_get_contents("/etc/version");
|
80
|
$dot = strpos($version, ".");
|
81
|
$hyphen = strpos($version, "-");
|
82
|
$major = substr($version, 0, $dot);
|
83
|
$minor = substr($version, $dot + 1, $hyphen - $dot - 1);
|
84
|
$testing_version = substr($version, $hyphen + 1, strlen($version) - $hyphen);
|
85
|
|
86
|
$tab_array = array();
|
87
|
$tab_array[] = array("Available {$version} packages", $requested_version <> "" ? false : true, "pkg_mgr.php");
|
88
|
$tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
|
89
|
/* $tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other"); */
|
90
|
$tab_array[] = array("Installed Packages", false, "pkg_mgr_installed.php");
|
91
|
display_top_tabs($tab_array);
|
92
|
?>
|
93
|
</td></tr>
|
94
|
<tr>
|
95
|
<td>
|
96
|
<div id="mainarea">
|
97
|
<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
|
98
|
<tr>
|
99
|
<td width="10%" class="listhdrr">Package Name</td>
|
100
|
<td width="25%" class="listhdrr">Category</td>
|
101
|
<!--
|
102
|
<td width="10%" class="listhdrr">Size</td>
|
103
|
-->
|
104
|
<td width="5%" class="listhdrr">Status</td>
|
105
|
<td width="5%" class="listhdrr">Maintainer</td>
|
106
|
<td width="50%" class="listhdr">Description</td>
|
107
|
</tr>
|
108
|
|
109
|
<?php
|
110
|
if(!$pkg_info) {
|
111
|
echo "<tr><td colspan=\"5\"><center>There are currently no packages available for installation.</td></tr>";
|
112
|
} else {
|
113
|
$pkgs = array();
|
114
|
$instpkgs = array();
|
115
|
if($config['installedpackages']['package'] != "")
|
116
|
foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
|
117
|
$pkg_names = array_keys($pkg_info);
|
118
|
$pkg_keys = array();
|
119
|
foreach($pkg_names as $name) {
|
120
|
if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
|
121
|
}
|
122
|
sort($pkg_keys);
|
123
|
if(count($pkg_keys) != 0) {
|
124
|
foreach($pkg_keys as $key) {
|
125
|
$index = &$pkg_info[$key];
|
126
|
if(in_array($index['name'], $instpkgs)) continue;
|
127
|
$dot = strpos($index['required_version'], ".");
|
128
|
$index['major_version'] = substr($index['required_version'], 0, $dot);
|
129
|
|
130
|
if ($version <> "HEAD" &&
|
131
|
$index['required_version'] == "HEAD" &&
|
132
|
$requested_version <> "other") { continue; }
|
133
|
if (empty($index['required_version']) &&
|
134
|
$requested_version <> "none") { continue; }
|
135
|
if($index['major_version'] > $major &&
|
136
|
$requested_version <> "other") { continue; }
|
137
|
if(isset($index['major_version']) &&
|
138
|
$requested_version == "none") { continue; }
|
139
|
if($index['major_version'] == $major &&
|
140
|
$requested_version == "other") { continue; }
|
141
|
|
142
|
?>
|
143
|
<tr valign="top">
|
144
|
<td class="listlr">
|
145
|
<A target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
|
146
|
</td>
|
147
|
<td class="listlr">
|
148
|
<?= $index['category'] ?>
|
149
|
</td>
|
150
|
<?php
|
151
|
/*
|
152
|
if(!$using_cache) {
|
153
|
$size = get_package_install_size($index['name'], $pkg_sizes);
|
154
|
$size = squash_from_bytes($size[$index['name']], 1);
|
155
|
}
|
156
|
if(!$size) $size = "Unknown.";
|
157
|
*/
|
158
|
?>
|
159
|
<!--
|
160
|
<td class="listlr">
|
161
|
<?= $size ?>
|
162
|
</td>
|
163
|
-->
|
164
|
<td class="listlr">
|
165
|
<?= $index['status'] ?>
|
166
|
<br>
|
167
|
<?= $index['version'] ?>
|
168
|
<br />
|
169
|
platform: <?= $index['required_version'] ?>
|
170
|
</td>
|
171
|
<td class="listlr">
|
172
|
<?php
|
173
|
if($index['maintainer'] != "") {
|
174
|
echo "<a href='mailto:{$index['maintainer']}'>{$index['maintainer']}</a>";
|
175
|
} else {
|
176
|
echo "Nobody. <a href='mailto:{$g['product_email']}'>Apply</a> for it!";
|
177
|
}
|
178
|
?>
|
179
|
</td>
|
180
|
<td class="listbg" class="listbg" style="color: #FFFFFF; overflow: hidden;">
|
181
|
<?= $index['descr'] ?>
|
182
|
</td>
|
183
|
<td valign="middle" class="list" nowrap>
|
184
|
<a onclick="return confirm('Do you really want to install this package?')" href="pkg_mgr_install.php?id=<?=$index['name'];?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a>
|
185
|
</td>
|
186
|
</tr>
|
187
|
<?php
|
188
|
}
|
189
|
} else {
|
190
|
echo '<tr><td colspan="5"><center>There are currently no packages available for installation.</center></td></tr>';
|
191
|
}
|
192
|
}
|
193
|
?>
|
194
|
</table>
|
195
|
</div>
|
196
|
</td>
|
197
|
</tr>
|
198
|
</table>
|
199
|
<?php include("fend.inc"); ?>
|
200
|
</body>
|
201
|
</html>
|