Project

General

Profile

Download (10.5 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 82b15b70 Carlos Eduardo Ramos
$pgtitle = array(gettext("System"),gettext("Package Manager"));
94 52380979 Scott Ullrich
include("head.inc");
95
96 ee11cc6e Scott Ullrich
?>
97 36d82968 Marcello Coutinho
<script type="text/javascript" src="javascript/domTT/domLib.js"></script>
98
<script type="text/javascript" src="javascript/domTT/domTT.js"></script>
99
<script type="text/javascript" src="javascript/domTT/behaviour.js"></script>
100
<script type="text/javascript" src="javascript/domTT/fadomatic.js"></script>
101
<script type="text/javascript" language="javascript" src="/javascript/row_helper_dynamic.js"></script>
102 ee11cc6e Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
103 859329c8 Scott Ullrich
<?php
104 d591e2e1 Matthew Grooms
	include("fbegin.inc");
105
	if ($savemsg)
106
		print_info_box($savemsg);
107 5bd87465 Scott Ullrich
?>
108 d591e2e1 Matthew Grooms
<table width="100%" border="0" cellpadding="0" cellspacing="0">
109
	<tr>
110
		<td>
111 ee11cc6e Scott Ullrich
		<?php
112 e44e5f3a jim-p
			$version = rtrim(file_get_contents("/etc/version"));
113 d591e2e1 Matthew Grooms
114
			$tab_array = array();
115 bf924b16 Chris Buechler
			$tab_array[] = array(gettext("Available Packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
116
//			$tab_array[] = array($version . gettext("packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
117 be8de62e Scott Ullrich
//			$tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
118 d591e2e1 Matthew Grooms
//			$tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other");
119 82b15b70 Carlos Eduardo Ramos
			$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
120 d591e2e1 Matthew Grooms
			display_top_tabs($tab_array);
121
		?>
122
		</td>
123
	</tr>
124
	<tr>
125
		<td>
126
			<div id="mainarea">
127 815f9631 Scott Ullrich
				<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0">
128 d591e2e1 Matthew Grooms
					<tr>
129 36d82968 Marcello Coutinho
						<td width="12%" class="listhdrr"><?=gettext("Name"); ?></td>
130
						<td width="18%" class="listhdrr"><?=gettext("Category"); ?></td>
131
						<td width="15%" class="listhdrr"><?=gettext("Status"); ?></td>
132
						<td width="53%" class="listhdr"><?=gettext("Description"); ?></td>
133
						<td width="17">&nbsp</td>
134 d591e2e1 Matthew Grooms
					</tr>
135 76341f29 Scott Ullrich
					<?php
136 d591e2e1 Matthew Grooms
						if(!$pkg_info) {
137 82b15b70 Carlos Eduardo Ramos
							echo "<tr><td colspan=\"5\"><center>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
138 76341f29 Scott Ullrich
						} else {
139 d591e2e1 Matthew Grooms
							$pkgs = array();
140
							$instpkgs = array();
141
							if($config['installedpackages']['package'] != "")
142
								foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
143
									$pkg_names = array_keys($pkg_info);
144
							$pkg_keys = array();
145 4a8bc5a2 Scott Ullrich
							
146 d591e2e1 Matthew Grooms
							foreach($pkg_names as $name)
147
								if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
148 4a8bc5a2 Scott Ullrich
							$pkg_keys = msort($pkg_keys);
149 d591e2e1 Matthew Grooms
							if(count($pkg_keys) != 0) {
150
								foreach($pkg_keys as $key) {
151
									$index = &$pkg_info[$key];
152 57fe6d53 Scott Ullrich
									if(in_array($index['name'], $instpkgs)) 
153
										continue;
154 9bcf197e Scott Ullrich
									if($g['platform'] == "nanobsd")
155
										if($index['noembedded']) 
156
											continue;
157 e44e5f3a jim-p
									/* If we are on not on HEAD, and the package wants it, skip */
158 d591e2e1 Matthew Grooms
									if ($version <> "HEAD" &&
159
										$index['required_version'] == "HEAD" &&
160
										$requested_version <> "other")
161
										continue;
162 e44e5f3a jim-p
									/* If there is no required version, and the requested package 
163
										version is not 'none', then skip */
164 d591e2e1 Matthew Grooms
									if (empty($index['required_version']) &&
165
										$requested_version <> "none")
166
										continue;
167 e44e5f3a jim-p
									/* If the requested version is not 'other', and the required version is newer than what we have, skip. */
168
									if($requested_version <> "other" &&
169
										(pfs_version_compare("", $version, $index['required_version']) < 0))
170 d591e2e1 Matthew Grooms
										continue;
171 e44e5f3a jim-p
									/* If the requestion version is 'other' and we are on the version requested, skip. */
172
									if($requested_version == "other" &&
173
										(pfs_version_compare("", $version, $index['required_version']) == 0))
174 d591e2e1 Matthew Grooms
										continue;
175 e44e5f3a jim-p
									/* Package is only for an older version, lets skip */
176
									if($index['maximum_version'] &&
177
										(pfs_version_compare("", $version, $index['maximum_version']) > 0))
178 68c97918 Scott Ullrich
										continue;
179 36d82968 Marcello Coutinho
									/* get history/changelog git dir */
180 aa2f8cab Phil Davis
									$commit_dir=explode("/",$index['config_file']);
181 36d82968 Marcello Coutinho
									$changeloglink ="https://github.com/bsdperimeter/pfsense-packages/commits/master/config/".$commit_dir[(count($commit_dir)-2)];
182
									/* Check package info link */
183
									if($index['pkginfolink']){
184
										$pkginfolink = $index['pkginfolink'];
185
										$pkginfo=gettext("Package info");
186
										}
187
									else{
188
										$pkginfolink = "http://forum.pfsense.org/index.php/board,15.0.html";
189
										$pkginfo=gettext("No package info, check the forum");
190
										}
191 d591e2e1 Matthew Grooms
					?>
192
					<tr valign="top">
193 eb004d5d Chris Buechler
						<td class="listlr" <?=domTT_title(gettext("Click on package name to access its website."))?>>
194 d591e2e1 Matthew Grooms
							<A target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
195
						</td>
196
						<td class="listr">
197
							<?= $index['category'] ?>
198
						</td>
199
						<?php
200
							/*
201
							if(!$using_cache) {
202
								$size = get_package_install_size($index['name'], $pkg_sizes);
203
								$size = squash_from_bytes($size[$index['name']], 1);
204
							}
205
							if(!$size)
206
								$size = "Unknown.";
207
							*/
208
						?>
209
<!--
210
						<td class="listr">
211
							<?= $size ?>
212
						</td>
213
-->
214 9a19c316 jim-p
						<?php if ($g['disablepackagehistory']){?>
215 36d82968 Marcello Coutinho
							<td	class="listr">
216
						<?php }else{?>
217 eb004d5d Chris Buechler
							<td class="listr" <?=domTT_title(gettext("Click ".ucfirst($index['name'])." version to check its change log."))?>>
218 36d82968 Marcello Coutinho
						<?php }?>
219
						<?=$index['status'] ?>
220
						<br/>
221 eac7d67c Chris Buechler
						<?php
222 9a19c316 jim-p
						if ($g['disablepackagehistory'])
223 36d82968 Marcello Coutinho
							echo"<a>{$index['version']}</a>";
224
						else
225
							echo "<a target='_new' href='{$changeloglink}'>{$index['version']}</a>";
226 eac7d67c Chris Buechler
						?>
227 36d82968 Marcello Coutinho
						<br/>
228
						<?=gettext("platform") .": ". $index['required_version'] ?>
229
						<br/>
230
						<?=$index['maximum_version'] ?>
231 d591e2e1 Matthew Grooms
						</td>
232 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."))?>>
233 93888ad9 jim-p
						<?= $index['descr'] ?>
234
						<?php if (! $g['disablepackageinfo']): ?>
235
						<br><br>
236 36d82968 Marcello Coutinho
						<a target='_new' href='<?=$pkginfolink?>' style='align:center;color:#ffffff; filter:Glow(color=#ff0000, strength=12);'><?=$pkginfo?></a>
237 93888ad9 jim-p
						<?php endif; ?>
238 d591e2e1 Matthew Grooms
						</td>
239 36d82968 Marcello Coutinho
						<td valign="middle" class="list" nowrap width="17">
240
							<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"></a>
241 d591e2e1 Matthew Grooms
						</td>
242
					</tr>
243
					<?php
244
								}
245
							} else {
246 82b15b70 Carlos Eduardo Ramos
								echo "<tr><td colspan='5'><center>" . gettext("There are currently no packages available for installation.") . "</center></td></tr>";
247 d591e2e1 Matthew Grooms
							}
248 76341f29 Scott Ullrich
						}
249
					?>
250 d591e2e1 Matthew Grooms
				</table>
251
			</div>
252
		</td>
253
	</tr>
254 ee11cc6e Scott Ullrich
</table>
255
<?php include("fend.inc"); ?>
256
</body>
257
</html>