Project

General

Profile

Download (8.69 KB) Statistics
| Branch: | Tag: | Revision:
1 ee11cc6e Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 ee11cc6e Scott Ullrich
/*
4
    pkg_mgr.php
5 4f6a5e6a Scott Ullrich
    Copyright (C) 2004-2010 Scott Ullrich <sullrich@gmail.com>
6 ee11cc6e Scott Ullrich
    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 1d333258 Scott Ullrich
/*
30
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
31
	pfSense_MODULE:	pkgs
32
*/
33 ee11cc6e Scott Ullrich
34 6b07c15a Matthew Grooms
##|+PRIV
35
##|*IDENT=page-system-packagemanager
36
##|*NAME=System: Package Manager page
37
##|*DESCR=Allow access to the 'System: Package Manager' page.
38
##|*MATCH=pkg_mgr.php*
39
##|-PRIV
40
41 0089af7c Scott Ullrich
ini_set('max_execution_time', '0');
42
43 9bcf197e Scott Ullrich
require_once("globals.inc");
44 9f9dcd98 Scott Ullrich
require_once("guiconfig.inc");
45 f8e335a3 Scott Ullrich
require_once("pkg-utils.inc");
46 ee11cc6e Scott Ullrich
47 943994ff Scott Ullrich
$timezone = $syscfg['timezone'];
48
if (!$timezone)
49
	$timezone = "Etc/UTC";
50
51
date_default_timezone_set($timezone);
52
53 261c7de8 jim-p
/* if upgrade in progress, alert user */
54
if(is_subsystem_dirty('packagelock')) {
55
	$pgtitle = array(gettext("System"),gettext("Package Manager"));
56
	include("head.inc");
57
	echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
58
	include("fbegin.inc");
59
	echo "Please wait while packages are reinstalled in the background.";
60
	include("fend.inc");
61
	echo "</body>";
62
	echo "</html>";
63
	exit;
64
}
65
66 e18dcdc0 Scott Ullrich
$pkg_info = get_pkg_info('all', array("noembedded", "name", "category", "website", "version", "status", "descr", "maintainer", "required_version", "maximum_version", "pkginfolink", "supportedbybsdperimeter"));
67 3f3a5bef Colin Smith
if($pkg_info) {
68
	$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
69
	fwrite($fout, serialize($pkg_info));
70 1d1630ec Colin Smith
	fclose($fout);
71 d591e2e1 Matthew Grooms
	//$pkg_sizes = get_pkg_sizes();
72 3f3a5bef Colin Smith
} else {
73
	$using_cache = true;
74 b6c3aebc Chris Buechler
	$xmlrpc_base_url = isset($config['system']['altpkgrepo']['enable']) ? $config['system']['altpkgrepo']['xmlrpcbaseurl'] : $g['xmlrpcbaseurl'];
75 47c44d0a Scott Ullrich
	if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
76 f0d1af93 Carlos Eduardo Ramos
		$savemsg = sprintf(gettext("Unable to retrieve package info from %s. Cached data will be used."), $xmlrpc_base_url);
77 47c44d0a Scott Ullrich
		$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
78
	} else {
79 ddc55e12 Erik Fonnesbeck
		$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']);
80 47c44d0a Scott Ullrich
	}
81 3f3a5bef Colin Smith
}
82 52380979 Scott Ullrich
83 d591e2e1 Matthew Grooms
if (! empty($_GET))
84
	if (isset($_GET['ver']))
85
		$requested_version = htmlspecialchars($_GET['ver']);
86 61a48553 Scott Ullrich
87 82b15b70 Carlos Eduardo Ramos
$pgtitle = array(gettext("System"),gettext("Package Manager"));
88 52380979 Scott Ullrich
include("head.inc");
89
90 ee11cc6e Scott Ullrich
?>
91
92
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
93 859329c8 Scott Ullrich
<?php
94 d591e2e1 Matthew Grooms
	include("fbegin.inc");
95
	if ($savemsg)
96
		print_info_box($savemsg);
97 5bd87465 Scott Ullrich
?>
98 d591e2e1 Matthew Grooms
<table width="100%" border="0" cellpadding="0" cellspacing="0">
99
	<tr>
100
		<td>
101 ee11cc6e Scott Ullrich
		<?php
102 e44e5f3a jim-p
			$version = rtrim(file_get_contents("/etc/version"));
103 d591e2e1 Matthew Grooms
104
			$tab_array = array();
105 bf924b16 Chris Buechler
			$tab_array[] = array(gettext("Available Packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
106
//			$tab_array[] = array($version . gettext("packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
107 be8de62e Scott Ullrich
//			$tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
108 d591e2e1 Matthew Grooms
//			$tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other");
109 82b15b70 Carlos Eduardo Ramos
			$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
110 d591e2e1 Matthew Grooms
			display_top_tabs($tab_array);
111
		?>
112
		</td>
113
	</tr>
114
	<tr>
115
		<td>
116
			<div id="mainarea">
117 815f9631 Scott Ullrich
				<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0">
118 d591e2e1 Matthew Grooms
					<tr>
119 82b15b70 Carlos Eduardo Ramos
						<td width="10%" class="listhdrr"><?=gettext("Package Name"); ?></td>
120 968b84bc Chris Buechler
						<td width="25%" class="listhdrr"><?=gettext("Category"); ?></td>
121 d591e2e1 Matthew Grooms
<!--					<td width="10%" class="listhdrr">Size</td>	-->
122 82b15b70 Carlos Eduardo Ramos
						<td width="5%" class="listhdrr"><?=gettext("Status"); ?></td>
123
						<td width="5%" class="listhdrr"><?=gettext("Package Info"); ?></td>
124
						<td width="50%" class="listhdr"><?=gettext("Description"); ?></td>
125 d591e2e1 Matthew Grooms
					</tr>
126 76341f29 Scott Ullrich
					<?php
127 d591e2e1 Matthew Grooms
						if(!$pkg_info) {
128 82b15b70 Carlos Eduardo Ramos
							echo "<tr><td colspan=\"5\"><center>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
129 76341f29 Scott Ullrich
						} else {
130 d591e2e1 Matthew Grooms
							$pkgs = array();
131
							$instpkgs = array();
132
							if($config['installedpackages']['package'] != "")
133
								foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
134
									$pkg_names = array_keys($pkg_info);
135
							$pkg_keys = array();
136 4a8bc5a2 Scott Ullrich
							
137 d591e2e1 Matthew Grooms
							foreach($pkg_names as $name)
138
								if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
139 4a8bc5a2 Scott Ullrich
							$pkg_keys = msort($pkg_keys);
140 d591e2e1 Matthew Grooms
							if(count($pkg_keys) != 0) {
141
								foreach($pkg_keys as $key) {
142
									$index = &$pkg_info[$key];
143 57fe6d53 Scott Ullrich
									if(in_array($index['name'], $instpkgs)) 
144
										continue;
145 9bcf197e Scott Ullrich
									if($g['platform'] == "nanobsd")
146
										if($index['noembedded']) 
147
											continue;
148 e44e5f3a jim-p
									/* If we are on not on HEAD, and the package wants it, skip */
149 d591e2e1 Matthew Grooms
									if ($version <> "HEAD" &&
150
										$index['required_version'] == "HEAD" &&
151
										$requested_version <> "other")
152
										continue;
153 e44e5f3a jim-p
									/* If there is no required version, and the requested package 
154
										version is not 'none', then skip */
155 d591e2e1 Matthew Grooms
									if (empty($index['required_version']) &&
156
										$requested_version <> "none")
157
										continue;
158 e44e5f3a jim-p
									/* If the requested version is not 'other', and the required version is newer than what we have, skip. */
159
									if($requested_version <> "other" &&
160
										(pfs_version_compare("", $version, $index['required_version']) < 0))
161 d591e2e1 Matthew Grooms
										continue;
162 e44e5f3a jim-p
									/* If the requestion version is 'other' and we are on the version requested, skip. */
163
									if($requested_version == "other" &&
164
										(pfs_version_compare("", $version, $index['required_version']) == 0))
165 d591e2e1 Matthew Grooms
										continue;
166 e44e5f3a jim-p
									/* Package is only for an older version, lets skip */
167
									if($index['maximum_version'] &&
168
										(pfs_version_compare("", $version, $index['maximum_version']) > 0))
169 68c97918 Scott Ullrich
										continue;
170 d591e2e1 Matthew Grooms
					?>
171
					<tr valign="top">
172
						<td class="listlr">
173
							<A target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
174
						</td>
175
						<td class="listr">
176
							<?= $index['category'] ?>
177
						</td>
178
						<?php
179
							/*
180
							if(!$using_cache) {
181
								$size = get_package_install_size($index['name'], $pkg_sizes);
182
								$size = squash_from_bytes($size[$index['name']], 1);
183
							}
184
							if(!$size)
185
								$size = "Unknown.";
186
							*/
187
						?>
188
<!--
189
						<td class="listr">
190
							<?= $size ?>
191
						</td>
192
-->
193
						<td class="listr">
194 82b15b70 Carlos Eduardo Ramos
							<?=$index['status'] ?>
195 d591e2e1 Matthew Grooms
							<br/>
196 82b15b70 Carlos Eduardo Ramos
							<?=$index['version'] ?>
197 d591e2e1 Matthew Grooms
							<br/>
198 79eaddf4 Renato Botelho
							<?=gettext("platform") .": ". $index['required_version'] ?>
199 57fe6d53 Scott Ullrich
							<br/>
200 82b15b70 Carlos Eduardo Ramos
							<?=$index['maximum_version'] ?>
201 d591e2e1 Matthew Grooms
						</td>
202
						<td class="listr">
203 eac7d67c Chris Buechler
						<?php
204
						if($index['pkginfolink']) {
205
							$pkginfolink = $index['pkginfolink'];
206 58c550f6 Vinicius Coque
							echo "<a target='_new' href='$pkginfolink'>". gettext("Package Info") ."</a>";
207 eac7d67c Chris Buechler
						} else {
208 c099a987 Scott Ullrich
							echo gettext("No info, check the") . " <a href='http://forum.pfsense.org/index.php/board,15.0.html'>" . gettext("forum") . "</a>";
209 eac7d67c Chris Buechler
						}
210
						?>
211 d591e2e1 Matthew Grooms
						</td>
212 33300c73 Scott Ullrich
						<td class="listbg" class="listbg" style="overflow: hidden;">
213 d591e2e1 Matthew Grooms
							<?= $index['descr'] ?>
214
						</td>
215
						<td valign="middle" class="list" nowrap>
216 82b15b70 Carlos Eduardo Ramos
							<a onclick="return confirm('<?=gettext("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>
217 d591e2e1 Matthew Grooms
						</td>
218
					</tr>
219
					<?php
220
								}
221
							} else {
222 82b15b70 Carlos Eduardo Ramos
								echo "<tr><td colspan='5'><center>" . gettext("There are currently no packages available for installation.") . "</center></td></tr>";
223 d591e2e1 Matthew Grooms
							}
224 76341f29 Scott Ullrich
						}
225
					?>
226 d591e2e1 Matthew Grooms
				</table>
227
			</div>
228
		</td>
229
	</tr>
230 ee11cc6e Scott Ullrich
</table>
231
<?php include("fend.inc"); ?>
232
</body>
233
</html>