Project

General

Profile

Download (10.6 KB) Statistics
| Branch: | Tag: | Revision:
1 ee11cc6e Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 ee11cc6e Scott Ullrich
/*
4
    pkg_mgr.php
5 36d82968 Marcello Coutinho
    Copyright (C) 2004-2012 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 c8083ee2 Phil Davis
$timezone = $config['system']['timezone'];
48 943994ff Scott Ullrich
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 36d82968 Marcello Coutinho
function domTT_title($title_msg){
66
	if (!empty($title_msg)){
67
		$title_msg=preg_replace("/\s+/"," ",$title_msg);
68
        $title_msg=preg_replace("/'/","\'",$title_msg);
69
		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
	}
71
}
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 3f3a5bef Colin Smith
if($pkg_info) {
74
	$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
75
	fwrite($fout, serialize($pkg_info));
76 1d1630ec Colin Smith
	fclose($fout);
77 d591e2e1 Matthew Grooms
	//$pkg_sizes = get_pkg_sizes();
78 3f3a5bef Colin Smith
} else {
79
	$using_cache = true;
80 b6c3aebc Chris Buechler
	$xmlrpc_base_url = isset($config['system']['altpkgrepo']['enable']) ? $config['system']['altpkgrepo']['xmlrpcbaseurl'] : $g['xmlrpcbaseurl'];
81 47c44d0a Scott Ullrich
	if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
82 f0d1af93 Carlos Eduardo Ramos
		$savemsg = sprintf(gettext("Unable to retrieve package info from %s. Cached data will be used."), $xmlrpc_base_url);
83 47c44d0a Scott Ullrich
		$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
84
	} else {
85 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']);
86 47c44d0a Scott Ullrich
	}
87 3f3a5bef Colin Smith
}
88 52380979 Scott Ullrich
89 d591e2e1 Matthew Grooms
if (! empty($_GET))
90
	if (isset($_GET['ver']))
91
		$requested_version = htmlspecialchars($_GET['ver']);
92 61a48553 Scott Ullrich
93 bf5b29ec Colin Fleming
$closehead = false;
94 82b15b70 Carlos Eduardo Ramos
$pgtitle = array(gettext("System"),gettext("Package Manager"));
95 52380979 Scott Ullrich
include("head.inc");
96
97 ee11cc6e Scott Ullrich
?>
98 36d82968 Marcello Coutinho
<script type="text/javascript" src="javascript/domTT/domLib.js"></script>
99
<script type="text/javascript" src="javascript/domTT/domTT.js"></script>
100
<script type="text/javascript" src="javascript/domTT/behaviour.js"></script>
101
<script type="text/javascript" src="javascript/domTT/fadomatic.js"></script>
102
<script type="text/javascript" language="javascript" src="/javascript/row_helper_dynamic.js"></script>
103 bf5b29ec Colin Fleming
</head>
104
105 ee11cc6e Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
106 859329c8 Scott Ullrich
<?php
107 d591e2e1 Matthew Grooms
	include("fbegin.inc");
108
	if ($savemsg)
109
		print_info_box($savemsg);
110 5bd87465 Scott Ullrich
?>
111 bf5b29ec Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="package manager">
112 d591e2e1 Matthew Grooms
	<tr>
113
		<td>
114 ee11cc6e Scott Ullrich
		<?php
115 e44e5f3a jim-p
			$version = rtrim(file_get_contents("/etc/version"));
116 d591e2e1 Matthew Grooms
117
			$tab_array = array();
118 bf924b16 Chris Buechler
			$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 be8de62e Scott Ullrich
//			$tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
121 d591e2e1 Matthew Grooms
//			$tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other");
122 82b15b70 Carlos Eduardo Ramos
			$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
123 d591e2e1 Matthew Grooms
			display_top_tabs($tab_array);
124
		?>
125
		</td>
126
	</tr>
127
	<tr>
128
		<td>
129
			<div id="mainarea">
130 bf5b29ec Colin Fleming
				<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
131 d591e2e1 Matthew Grooms
					<tr>
132 36d82968 Marcello Coutinho
						<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 bf5b29ec Colin Fleming
						<td width="17">&nbsp;</td>
137 d591e2e1 Matthew Grooms
					</tr>
138 76341f29 Scott Ullrich
					<?php
139 d591e2e1 Matthew Grooms
						if(!$pkg_info) {
140 82b15b70 Carlos Eduardo Ramos
							echo "<tr><td colspan=\"5\"><center>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
141 76341f29 Scott Ullrich
						} else {
142 d591e2e1 Matthew Grooms
							$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 4a8bc5a2 Scott Ullrich
							
149 d591e2e1 Matthew Grooms
							foreach($pkg_names as $name)
150
								if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
151 4a8bc5a2 Scott Ullrich
							$pkg_keys = msort($pkg_keys);
152 d591e2e1 Matthew Grooms
							if(count($pkg_keys) != 0) {
153
								foreach($pkg_keys as $key) {
154
									$index = &$pkg_info[$key];
155 57fe6d53 Scott Ullrich
									if(in_array($index['name'], $instpkgs)) 
156
										continue;
157 9bcf197e Scott Ullrich
									if($g['platform'] == "nanobsd")
158
										if($index['noembedded']) 
159
											continue;
160 e44e5f3a jim-p
									/* If we are on not on HEAD, and the package wants it, skip */
161 d591e2e1 Matthew Grooms
									if ($version <> "HEAD" &&
162
										$index['required_version'] == "HEAD" &&
163
										$requested_version <> "other")
164
										continue;
165 e44e5f3a jim-p
									/* If there is no required version, and the requested package 
166
										version is not 'none', then skip */
167 d591e2e1 Matthew Grooms
									if (empty($index['required_version']) &&
168
										$requested_version <> "none")
169
										continue;
170 e44e5f3a jim-p
									/* 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 d591e2e1 Matthew Grooms
										continue;
174 e44e5f3a jim-p
									/* 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 d591e2e1 Matthew Grooms
										continue;
178 e44e5f3a jim-p
									/* Package is only for an older version, lets skip */
179
									if($index['maximum_version'] &&
180
										(pfs_version_compare("", $version, $index['maximum_version']) > 0))
181 68c97918 Scott Ullrich
										continue;
182 36d82968 Marcello Coutinho
									/* get history/changelog git dir */
183 aa2f8cab Phil Davis
									$commit_dir=explode("/",$index['config_file']);
184 d5280de6 Chris Buechler
									$changeloglink ="https://github.com/pfsense/pfsense-packages/commits/master/config/".$commit_dir[(count($commit_dir)-2)];
185 36d82968 Marcello Coutinho
									/* 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 d591e2e1 Matthew Grooms
					?>
195
					<tr valign="top">
196 eb004d5d Chris Buechler
						<td class="listlr" <?=domTT_title(gettext("Click on package name to access its website."))?>>
197 bf5b29ec Colin Fleming
							<a target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
198 d591e2e1 Matthew Grooms
						</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);
207
							}
208
							if(!$size)
209
								$size = "Unknown.";
210
							*/
211
						?>
212
<!--
213
						<td class="listr">
214
							<?= $size ?>
215
						</td>
216
-->
217 9a19c316 jim-p
						<?php if ($g['disablepackagehistory']){?>
218 36d82968 Marcello Coutinho
							<td	class="listr">
219
						<?php }else{?>
220 eb004d5d Chris Buechler
							<td class="listr" <?=domTT_title(gettext("Click ".ucfirst($index['name'])." version to check its change log."))?>>
221 36d82968 Marcello Coutinho
						<?php }?>
222
						<?=$index['status'] ?>
223
						<br/>
224 eac7d67c Chris Buechler
						<?php
225 9a19c316 jim-p
						if ($g['disablepackagehistory'])
226 36d82968 Marcello Coutinho
							echo"<a>{$index['version']}</a>";
227
						else
228 bf5b29ec Colin Fleming
							echo "<a target='_blank' href='{$changeloglink}'>{$index['version']}</a>";
229 eac7d67c Chris Buechler
						?>
230 36d82968 Marcello Coutinho
						<br/>
231
						<?=gettext("platform") .": ". $index['required_version'] ?>
232
						<br/>
233
						<?=$index['maximum_version'] ?>
234 d591e2e1 Matthew Grooms
						</td>
235 36d82968 Marcello Coutinho
						<td class="listbg" style="overflow:hidden; text-align:justify;" <?=domTT_title(gettext("Click package info for more details about ".ucfirst($index['name'])." package."))?>>
236 93888ad9 jim-p
						<?= $index['descr'] ?>
237
						<?php if (! $g['disablepackageinfo']): ?>
238 bf5b29ec Colin Fleming
						<br/><br/>
239
						<a target='_blank' href='<?=$pkginfolink?>' style='align:center;color:#ffffff; filter:Glow(color=#ff0000, strength=12);'><?=$pkginfo?></a>
240 93888ad9 jim-p
						<?php endif; ?>
241 d591e2e1 Matthew Grooms
						</td>
242 bf5b29ec Colin Fleming
						<td valign="middle" class="list nowrap" width="17">
243
							<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 d591e2e1 Matthew Grooms
						</td>
245
					</tr>
246
					<?php
247
								}
248
							} else {
249 bf5b29ec Colin Fleming
								echo "<tr><td colspan='5' align='center'>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
250 d591e2e1 Matthew Grooms
							}
251 76341f29 Scott Ullrich
						}
252
					?>
253 d591e2e1 Matthew Grooms
				</table>
254
			</div>
255
		</td>
256
	</tr>
257 ee11cc6e Scott Ullrich
</table>
258
<?php include("fend.inc"); ?>
259
</body>
260
</html>