Project

General

Profile

Download (7.81 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    pkg_mgr.php
5
    Copyright (C) 2004, 2005 Scott Ullrich
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
require_once("globals.inc");
42
require_once("guiconfig.inc");
43
require_once("pkg-utils.inc");
44

    
45
$pkg_info = get_pkg_info('all', array('noembedded', 'name', 'category', 'website', 'version', 'status', 'descr', 'maintainer', 'required_version', 'maximum_version', 'pkginfolink'));
46
if($pkg_info) {
47
	$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
48
	fwrite($fout, serialize($pkg_info));
49
	fclose($fout);
50
	//$pkg_sizes = get_pkg_sizes();
51
} else {
52
	$using_cache = true;
53
	if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
54
		$savemsg = "Unable to retrieve package info from {$g['xmlrpcbaseurl']}. Cached data will be used.";
55
		$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
56
	} else {
57
		$savemsg = "Unable to communicate to {$g['product_website']}.  Please check DNS, default gateway, etc.";
58
	}
59
}
60

    
61
if (! empty($_GET))
62
	if (isset($_GET['ver']))
63
		$requested_version = htmlspecialchars($_GET['ver']);
64

    
65
$pgtitle = array("System","Package Manager");
66
include("head.inc");
67

    
68
?>
69

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

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