Project

General

Profile

Download (7.95 KB) Statistics
| Branch: | Tag: | Revision:
1 ee11cc6e Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 ee11cc6e Scott Ullrich
/*
4
    pkg_mgr.php
5 b49448ac Scott Ullrich
    Copyright (C) 2004, 2005 Scott Ullrich
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 9bcf197e Scott Ullrich
require_once("globals.inc");
42 9f9dcd98 Scott Ullrich
require_once("guiconfig.inc");
43 f8e335a3 Scott Ullrich
require_once("pkg-utils.inc");
44 ee11cc6e Scott Ullrich
45 8b099656 Scott Ullrich
$pkg_info = get_pkg_info('all', array('noembedded', 'name', 'category', 'website', 'version', 'status', 'descr', 'maintainer', 'required_version', 'maximum_version', 'pkginfolink'));
46 3f3a5bef Colin Smith
if($pkg_info) {
47
	$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
48
	fwrite($fout, serialize($pkg_info));
49 1d1630ec Colin Smith
	fclose($fout);
50 d591e2e1 Matthew Grooms
	//$pkg_sizes = get_pkg_sizes();
51 3f3a5bef Colin Smith
} else {
52
	$using_cache = true;
53 47c44d0a Scott Ullrich
	if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
54 ffba4976 jim-p
		$xmlrpc_base_url = isset($config['system']['altpkgrepo']['enable']) ? $config['system']['altpkgrepo']['xmlrpcbaseurl'] : $g['xmlrpcbaseurl'];
55
		$savemsg = "Unable to retrieve package info from {$xmlrpc_base_url}. Cached data will be used.";
56 47c44d0a Scott Ullrich
		$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
57
	} else {
58 36d0358b Scott Ullrich
		$savemsg = "Unable to communicate to {$g['product_website']}.  Please check DNS, default gateway, etc.";
59 47c44d0a Scott Ullrich
	}
60 3f3a5bef Colin Smith
}
61 52380979 Scott Ullrich
62 d591e2e1 Matthew Grooms
if (! empty($_GET))
63
	if (isset($_GET['ver']))
64
		$requested_version = htmlspecialchars($_GET['ver']);
65 61a48553 Scott Ullrich
66 d88c6a9f Scott Ullrich
$pgtitle = array("System","Package Manager");
67 52380979 Scott Ullrich
include("head.inc");
68
69 ee11cc6e Scott Ullrich
?>
70
71
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
72 859329c8 Scott Ullrich
<?php
73 d591e2e1 Matthew Grooms
	include("fbegin.inc");
74
	if ($savemsg)
75
		print_info_box($savemsg);
76 5bd87465 Scott Ullrich
?>
77 d591e2e1 Matthew Grooms
<table width="100%" border="0" cellpadding="0" cellspacing="0">
78
	<tr>
79
		<td>
80 ee11cc6e Scott Ullrich
		<?php
81 d591e2e1 Matthew Grooms
			$version = file_get_contents("/etc/version");
82 57fe6d53 Scott Ullrich
			$dash = strpos($version, ".");
83 d591e2e1 Matthew Grooms
			$hyphen = strpos($version, "-");
84 57fe6d53 Scott Ullrich
			$major = substr($version, 0, $dash);
85
			$minor = substr($version, $dash + 1, $hyphen - $dash - 1);
86 d591e2e1 Matthew Grooms
			$testing_version = substr($version, $hyphen + 1, strlen($version) - $hyphen);
87
88
			$tab_array = array();
89 2b9fbe3a Scott Ullrich
			$tab_array[] = array("{$version} packages", $requested_version <> "" ? false : true, "pkg_mgr.php");
90 be8de62e Scott Ullrich
//			$tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
91 d591e2e1 Matthew Grooms
//			$tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other");
92
			$tab_array[] = array("Installed Packages", false, "pkg_mgr_installed.php");
93
			display_top_tabs($tab_array);
94
		?>
95
		</td>
96
	</tr>
97
	<tr>
98
		<td>
99
			<div id="mainarea">
100 815f9631 Scott Ullrich
				<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0">
101 d591e2e1 Matthew Grooms
					<tr>
102
						<td width="10%" class="listhdrr">Package Name</td>
103
						<td width="25%" class="listhdrr">Category</td>
104
<!--					<td width="10%" class="listhdrr">Size</td>	-->
105
						<td width="5%" class="listhdrr">Status</td>
106 eac7d67c Chris Buechler
						<td width="5%" class="listhdrr">Package Info</td>
107 d591e2e1 Matthew Grooms
						<td width="50%" class="listhdr">Description</td>
108
					</tr>
109 76341f29 Scott Ullrich
					<?php
110 d591e2e1 Matthew Grooms
						if(!$pkg_info) {
111
							echo "<tr><td colspan=\"5\"><center>There are currently no packages available for installation.</td></tr>";
112 76341f29 Scott Ullrich
						} else {
113 68c97918 Scott Ullrich
							$installed_pfsense_version = rtrim(file_get_contents("/etc/version"));
114 57fe6d53 Scott Ullrich
							$dash = strpos($installed_pfsense_version, "-");
115
							$installed_pfsense_version = substr($installed_pfsense_version, 0, $dash);
116 d591e2e1 Matthew Grooms
							$pkgs = array();
117
							$instpkgs = array();
118
							if($config['installedpackages']['package'] != "")
119
								foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
120
									$pkg_names = array_keys($pkg_info);
121
							$pkg_keys = array();
122 4a8bc5a2 Scott Ullrich
							
123 d591e2e1 Matthew Grooms
							foreach($pkg_names as $name)
124
								if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
125 4a8bc5a2 Scott Ullrich
							$pkg_keys = msort($pkg_keys);
126 d591e2e1 Matthew Grooms
							if(count($pkg_keys) != 0) {
127
								foreach($pkg_keys as $key) {
128
									$index = &$pkg_info[$key];
129 57fe6d53 Scott Ullrich
									if(in_array($index['name'], $instpkgs)) 
130
										continue;
131 9bcf197e Scott Ullrich
									if($g['platform'] == "nanobsd")
132
										if($index['noembedded']) 
133
											continue;
134 57fe6d53 Scott Ullrich
									$dash = strpos($index['required_version'], "-");
135
									$index['major_version'] = substr($index['required_version'], 0, $dash);
136 d591e2e1 Matthew Grooms
									if ($version <> "HEAD" &&
137
										$index['required_version'] == "HEAD" &&
138
										$requested_version <> "other")
139
										continue;
140
									if (empty($index['required_version']) &&
141
										$requested_version <> "none")
142
										continue;
143
									if($index['major_version'] > $major &&
144
										$requested_version <> "other")
145
										continue;
146
									if(isset($index['major_version']) &&
147
										$requested_version == "none")
148
										continue;
149
									if($index['major_version'] == $major &&
150
										$requested_version == "other")
151
										continue;
152 68c97918 Scott Ullrich
									/* Package is for a newer version, lets skip */
153
									if($installed_pfsense_version < $index['required_version'])
154
										continue;
155 bb7f2c3f Scott Ullrich
									if($index['maximum_version'])
156
										if($installed_pfsense_version > $index['maximum_version'])
157
											continue;
158 d591e2e1 Matthew Grooms
					?>
159
					<tr valign="top">
160
						<td class="listlr">
161
							<A target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
162
						</td>
163
						<td class="listr">
164
							<?= $index['category'] ?>
165
						</td>
166
						<?php
167
							/*
168
							if(!$using_cache) {
169
								$size = get_package_install_size($index['name'], $pkg_sizes);
170
								$size = squash_from_bytes($size[$index['name']], 1);
171
							}
172
							if(!$size)
173
								$size = "Unknown.";
174
							*/
175
						?>
176
<!--
177
						<td class="listr">
178
							<?= $size ?>
179
						</td>
180
-->
181
						<td class="listr">
182
							<?= $index['status'] ?>
183
							<br/>
184
							<?= $index['version'] ?>
185
							<br/>
186
							platform: <?= $index['required_version'] ?>
187 57fe6d53 Scott Ullrich
							<br/>
188
							<?= $index['maximum_version']; ?>
189 d591e2e1 Matthew Grooms
						</td>
190
						<td class="listr">
191 eac7d67c Chris Buechler
						<?php
192
						if($index['pkginfolink']) {
193
							$pkginfolink = $index['pkginfolink'];
194 ff4487c7 Scott Ullrich
							echo "<a target='_new' href='$pkginfolink'>Package Info</a>";
195 eac7d67c Chris Buechler
						} else {
196
							echo "No info, check the <a href='http://forum.pfsense.org/index.php/board,15.0.html'>forum</a>";
197
						}
198
						?>
199 d591e2e1 Matthew Grooms
						</td>
200 33300c73 Scott Ullrich
						<td class="listbg" class="listbg" style="overflow: hidden;">
201 d591e2e1 Matthew Grooms
							<?= $index['descr'] ?>
202
						</td>
203
						<td valign="middle" class="list" nowrap>
204
							<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>
205
						</td>
206
					</tr>
207
					<?php
208
								}
209
							} else {
210
								echo '<tr><td colspan="5"><center>There are currently no packages available for installation.</center></td></tr>';
211
							}
212 76341f29 Scott Ullrich
						}
213
					?>
214 d591e2e1 Matthew Grooms
				</table>
215
			</div>
216
		</td>
217
	</tr>
218 ee11cc6e Scott Ullrich
</table>
219
<?php include("fend.inc"); ?>
220
</body>
221
</html>