Project

General

Profile

Download (8.34 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    pkg_mgr.php
5
    Copyright (C) 2004-2010 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
$pkg_info = get_pkg_info('all', array("noembedded", "name", "category", "website", "version", "status", "descr", "maintainer", "required_version", "maximum_version", "pkginfolink"));
48
if($pkg_info) {
49
	$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
50
	fwrite($fout, serialize($pkg_info));
51
	fclose($fout);
52
	//$pkg_sizes = get_pkg_sizes();
53
} else {
54
	$using_cache = true;
55
	$xmlrpc_base_url = isset($config['system']['altpkgrepo']['enable']) ? $config['system']['altpkgrepo']['xmlrpcbaseurl'] : $g['xmlrpcbaseurl'];
56
	if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
57
		$savemsg = sprintf(gettext("Unable to retrieve package info from %s. Cached data will be used."), $xmlrpc_base_url);
58
		$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
59
	} else {
60
		$savemsg = sprintf(gettext("Unable to communicate with %s. Please verify DNS and interface configuration, and that %s has functional Internet connectivity."), $xmlrpc_base_url, $g['product_name']);
61
	}
62
}
63

    
64
if (! empty($_GET))
65
	if (isset($_GET['ver']))
66
		$requested_version = htmlspecialchars($_GET['ver']);
67

    
68
$pgtitle = array(gettext("System"),gettext("Package Manager"));
69
include("head.inc");
70

    
71
?>
72

    
73
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
74
<?php
75
	include("fbegin.inc");
76
	if ($savemsg)
77
		print_info_box($savemsg);
78
?>
79
<table width="100%" border="0" cellpadding="0" cellspacing="0">
80
	<tr>
81
		<td>
82
		<?php
83
			$version = file_get_contents("/etc/version");
84
			$dash = strpos($version, ".");
85
			$hyphen = strpos($version, "-");
86
			$major = substr($version, 0, $dash);
87
			$minor = substr($version, $dash + 1, $hyphen - $dash - 1);
88
			$testing_version = substr($version, $hyphen + 1, strlen($version) - $hyphen);
89

    
90
			$tab_array = array();
91
			$tab_array[] = array($version . gettext("packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
92
//			$tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
93
//			$tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other");
94
			$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
95
			display_top_tabs($tab_array);
96
		?>
97
		</td>
98
	</tr>
99
	<tr>
100
		<td>
101
			<div id="mainarea">
102
				<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0">
103
					<tr>
104
						<td width="10%" class="listhdrr"><?=gettext("Package Name"); ?></td>
105
						<td width="25%" class="listhdrr"><?=gettext("Category"); ?></td>
106
<!--					<td width="10%" class="listhdrr">Size</td>	-->
107
						<td width="5%" class="listhdrr"><?=gettext("Status"); ?></td>
108
						<td width="5%" class="listhdrr"><?=gettext("Package Info"); ?></td>
109
						<td width="50%" class="listhdr"><?=gettext("Description"); ?></td>
110
					</tr>
111
					<?php
112
						if(!$pkg_info) {
113
							echo "<tr><td colspan=\"5\"><center>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
114
						} else {
115
							$installed_pfsense_version = rtrim(file_get_contents("/etc/version"));
116
							$dash = strpos($installed_pfsense_version, "-");
117
							$installed_pfsense_version = substr($installed_pfsense_version, 0, $dash);
118
							$pkgs = array();
119
							$instpkgs = array();
120
							if($config['installedpackages']['package'] != "")
121
								foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
122
									$pkg_names = array_keys($pkg_info);
123
							$pkg_keys = array();
124
							
125
							foreach($pkg_names as $name)
126
								if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
127
							$pkg_keys = msort($pkg_keys);
128
							if(count($pkg_keys) != 0) {
129
								foreach($pkg_keys as $key) {
130
									$index = &$pkg_info[$key];
131
									if(in_array($index['name'], $instpkgs)) 
132
										continue;
133
									if($g['platform'] == "nanobsd")
134
										if($index['noembedded']) 
135
											continue;
136
									$dash = strpos($index['required_version'], "-");
137
									$index['major_version'] = substr($index['required_version'], 0, $dash);
138
									if ($version <> "HEAD" &&
139
										$index['required_version'] == "HEAD" &&
140
										$requested_version <> "other")
141
										continue;
142
									if (empty($index['required_version']) &&
143
										$requested_version <> "none")
144
										continue;
145
									if($index['major_version'] > $major &&
146
										$requested_version <> "other")
147
										continue;
148
									if(isset($index['major_version']) &&
149
										$requested_version == "none")
150
										continue;
151
									if($index['major_version'] == $major &&
152
										$requested_version == "other")
153
										continue;
154
									/* Package is for a newer version, lets skip */
155
									if($installed_pfsense_version < $index['required_version'])
156
										continue;
157
									if($index['maximum_version'])
158
										if($installed_pfsense_version > $index['maximum_version'])
159
											continue;
160
					?>
161
					<tr valign="top">
162
						<td class="listlr">
163
							<A target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
164
						</td>
165
						<td class="listr">
166
							<?= $index['category'] ?>
167
						</td>
168
						<?php
169
							/*
170
							if(!$using_cache) {
171
								$size = get_package_install_size($index['name'], $pkg_sizes);
172
								$size = squash_from_bytes($size[$index['name']], 1);
173
							}
174
							if(!$size)
175
								$size = "Unknown.";
176
							*/
177
						?>
178
<!--
179
						<td class="listr">
180
							<?= $size ?>
181
						</td>
182
-->
183
						<td class="listr">
184
							<?=$index['status'] ?>
185
							<br/>
186
							<?=$index['version'] ?>
187
							<br/>
188
							<?=gettext("platform") .": ". $index['required_version'] ?>
189
							<br/>
190
							<?=$index['maximum_version'] ?>
191
						</td>
192
						<td class="listr">
193
						<?php
194
						if($index['pkginfolink']) {
195
							$pkginfolink = $index['pkginfolink'];
196
							echo "<a target='_new' href='$pkginfolink'>Package Info</a>";
197
						} else {
198
							echo gettext("No info, check the") . " <a href='http://forum.pfsense.org/index.php/board,15.0.html'>" . gettext("forum") . "</a>";
199
						}
200
						?>
201
						</td>
202
						<td class="listbg" class="listbg" style="overflow: hidden;">
203
							<?= $index['descr'] ?>
204
						</td>
205
						<td valign="middle" class="list" nowrap>
206
							<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>
207
						</td>
208
					</tr>
209
					<?php
210
								}
211
							} else {
212
								echo "<tr><td colspan='5'><center>" . gettext("There are currently no packages available for installation.") . "</center></td></tr>";
213
							}
214
						}
215
					?>
216
				</table>
217
			</div>
218
		</td>
219
	</tr>
220
</table>
221
<?php include("fend.inc"); ?>
222
</body>
223
</html>
(117-117/221)