Project

General

Profile

Download (10.5 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    pkg_mgr.php
5
    Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
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
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
31
	pfSense_MODULE:	pkgs
32
*/
33

    
34
##|+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
ini_set('max_execution_time', '0');
42

    
43
require_once("globals.inc");
44
require_once("guiconfig.inc");
45
require_once("pkg-utils.inc");
46

    
47
$timezone = $config['system']['timezone'];
48
if (!$timezone)
49
	$timezone = "Etc/UTC";
50

    
51
date_default_timezone_set($timezone);
52

    
53
/* 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
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
if($pkg_info) {
74
	$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
75
	fwrite($fout, serialize($pkg_info));
76
	fclose($fout);
77
	//$pkg_sizes = get_pkg_sizes();
78
} else {
79
	$using_cache = true;
80
	$xmlrpc_base_url = isset($config['system']['altpkgrepo']['enable']) ? $config['system']['altpkgrepo']['xmlrpcbaseurl'] : $g['xmlrpcbaseurl'];
81
	if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
82
		$savemsg = sprintf(gettext("Unable to retrieve package info from %s. Cached data will be used."), $xmlrpc_base_url);
83
		$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
84
	} else {
85
		$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
	}
87
}
88

    
89
if (! empty($_GET))
90
	if (isset($_GET['ver']))
91
		$requested_version = htmlspecialchars($_GET['ver']);
92

    
93
$pgtitle = array(gettext("System"),gettext("Package Manager"));
94
include("head.inc");
95

    
96
?>
97
<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
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
103
<?php
104
	include("fbegin.inc");
105
	if ($savemsg)
106
		print_info_box($savemsg);
107
?>
108
<table width="100%" border="0" cellpadding="0" cellspacing="0">
109
	<tr>
110
		<td>
111
		<?php
112
			$version = rtrim(file_get_contents("/etc/version"));
113

    
114
			$tab_array = array();
115
			$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
//			$tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
118
//			$tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other");
119
			$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
120
			display_top_tabs($tab_array);
121
		?>
122
		</td>
123
	</tr>
124
	<tr>
125
		<td>
126
			<div id="mainarea">
127
				<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0">
128
					<tr>
129
						<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
					</tr>
135
					<?php
136
						if(!$pkg_info) {
137
							echo "<tr><td colspan=\"5\"><center>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
138
						} else {
139
							$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
							
146
							foreach($pkg_names as $name)
147
								if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
148
							$pkg_keys = msort($pkg_keys);
149
							if(count($pkg_keys) != 0) {
150
								foreach($pkg_keys as $key) {
151
									$index = &$pkg_info[$key];
152
									if(in_array($index['name'], $instpkgs)) 
153
										continue;
154
									if($g['platform'] == "nanobsd")
155
										if($index['noembedded']) 
156
											continue;
157
									/* If we are on not on HEAD, and the package wants it, skip */
158
									if ($version <> "HEAD" &&
159
										$index['required_version'] == "HEAD" &&
160
										$requested_version <> "other")
161
										continue;
162
									/* If there is no required version, and the requested package 
163
										version is not 'none', then skip */
164
									if (empty($index['required_version']) &&
165
										$requested_version <> "none")
166
										continue;
167
									/* 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
										continue;
171
									/* 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
										continue;
175
									/* Package is only for an older version, lets skip */
176
									if($index['maximum_version'] &&
177
										(pfs_version_compare("", $version, $index['maximum_version']) > 0))
178
										continue;
179
									/* get history/changelog git dir */
180
									$commit_dir=explode("/",$index['config_file']);
181
									$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
					?>
192
					<tr valign="top">
193
						<td class="listlr" <?=domTT_title(gettext("Click on package name to access its website."))?>>
194
							<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
						<?php if ($g['disablepackagehistory']){?>
215
							<td	class="listr">
216
						<?php }else{?>
217
							<td class="listr" <?=domTT_title(gettext("Click ".ucfirst($index['name'])." version to check its change log."))?>>
218
						<?php }?>
219
						<?=$index['status'] ?>
220
						<br/>
221
						<?php
222
						if ($g['disablepackagehistory'])
223
							echo"<a>{$index['version']}</a>";
224
						else
225
							echo "<a target='_new' href='{$changeloglink}'>{$index['version']}</a>";
226
						?>
227
						<br/>
228
						<?=gettext("platform") .": ". $index['required_version'] ?>
229
						<br/>
230
						<?=$index['maximum_version'] ?>
231
						</td>
232
						<td class="listbg" style="overflow:hidden; text-align:justify;" <?=domTT_title(gettext("Click package info for more details about ".ucfirst($index['name'])." package."))?>>
233
						<?= $index['descr'] ?>
234
						<?php if (! $g['disablepackageinfo']): ?>
235
						<br><br>
236
						<a target='_new' href='<?=$pkginfolink?>' style='align:center;color:#ffffff; filter:Glow(color=#ff0000, strength=12);'><?=$pkginfo?></a>
237
						<?php endif; ?>
238
						</td>
239
						<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
						</td>
242
					</tr>
243
					<?php
244
								}
245
							} else {
246
								echo "<tr><td colspan='5'><center>" . gettext("There are currently no packages available for installation.") . "</center></td></tr>";
247
							}
248
						}
249
					?>
250
				</table>
251
			</div>
252
		</td>
253
	</tr>
254
</table>
255
<?php include("fend.inc"); ?>
256
</body>
257
</html>
(129-129/249)