Project

General

Profile

Download (6.96 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
##|+PRIV
31
##|*IDENT=page-system-packagemanager
32
##|*NAME=System: Package Manager page
33
##|*DESCR=Allow access to the 'System: Package Manager' page.
34
##|*MATCH=pkg_mgr.php*
35
##|-PRIV
36

    
37

    
38
require_once("guiconfig.inc");
39
require_once("pkg-utils.inc");
40

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

    
57
if (! empty($_GET))
58
	if (isset($_GET['ver']))
59
		$requested_version = htmlspecialchars($_GET['ver']);
60

    
61
$pgtitle = array("System","Package Manager");
62
include("head.inc");
63

    
64
?>
65

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

    
83
			$tab_array = array();
84
			$tab_array[] = array("Available {$version} packages", $requested_version <> "" ? false : true, "pkg_mgr.php");
85
			$tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
86
//			$tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other");
87
			$tab_array[] = array("Installed Packages", false, "pkg_mgr_installed.php");
88
			display_top_tabs($tab_array);
89
		?>
90
		</td>
91
	</tr>
92
	<tr>
93
		<td>
94
			<div id="mainarea">
95
				<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
96
					<tr>
97
						<td width="10%" class="listhdrr">Package Name</td>
98
						<td width="25%" class="listhdrr">Category</td>
99
<!--					<td width="10%" class="listhdrr">Size</td>	-->
100
						<td width="5%" class="listhdrr">Status</td>
101
						<td width="5%" class="listhdrr">Maintainer</td>
102
						<td width="50%" class="listhdr">Description</td>
103
					</tr>
104
					<?php
105
						if(!$pkg_info) {
106
							echo "<tr><td colspan=\"5\"><center>There are currently no packages available for installation.</td></tr>";
107
						} else {
108
							$pkgs = array();
109
							$instpkgs = array();
110
							if($config['installedpackages']['package'] != "")
111
								foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
112
									$pkg_names = array_keys($pkg_info);
113
							$pkg_keys = array();
114
							foreach($pkg_names as $name)
115
								if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
116
							sort($pkg_keys);
117
							if(count($pkg_keys) != 0) {
118
								foreach($pkg_keys as $key) {
119
									$index = &$pkg_info[$key];
120
									if(in_array($index['name'], $instpkgs)) continue;
121
										$dot = strpos($index['required_version'], ".");
122
									$index['major_version'] = substr($index['required_version'], 0, $dot);
123

    
124
									if ($version <> "HEAD" &&
125
										$index['required_version'] == "HEAD" &&
126
										$requested_version <> "other")
127
										continue;
128
									if (empty($index['required_version']) &&
129
										$requested_version <> "none")
130
										continue;
131
									if($index['major_version'] > $major &&
132
										$requested_version <> "other")
133
										continue;
134
									if(isset($index['major_version']) &&
135
										$requested_version == "none")
136
										continue;
137
									if($index['major_version'] == $major &&
138
										$requested_version == "other")
139
										continue;
140
					?>
141
					<tr valign="top">
142
						<td class="listlr">
143
							<A target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
144
						</td>
145
						<td class="listr">
146
							<?= $index['category'] ?>
147
						</td>
148
						<?php
149
							/*
150
							if(!$using_cache) {
151
								$size = get_package_install_size($index['name'], $pkg_sizes);
152
								$size = squash_from_bytes($size[$index['name']], 1);
153
							}
154
							if(!$size)
155
								$size = "Unknown.";
156
							*/
157
						?>
158
<!--
159
						<td class="listr">
160
							<?= $size ?>
161
						</td>
162
-->
163
						<td class="listr">
164
							<?= $index['status'] ?>
165
							<br/>
166
							<?= $index['version'] ?>
167
							<br/>
168
							platform: <?= $index['required_version'] ?>
169
						</td>
170
						<td class="listr">
171
						<?php
172
							if($index['maintainer'] != "")
173
								echo "<a href='mailto:{$index['maintainer']}'>{$index['maintainer']}</a>";
174
							else
175
								echo "Nobody. <a href='mailto:{$g['product_email']}'>Apply</a> for it!";
176
						?>
177
						</td>
178
						<td class="listbg" class="listbg" style="color: #FFFFFF; overflow: hidden;">
179
							<?= $index['descr'] ?>
180
						</td>
181
						<td valign="middle" class="list" nowrap>
182
							<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>
183
						</td>
184
					</tr>
185
					<?php
186
								}
187
							} else {
188
								echo '<tr><td colspan="5"><center>There are currently no packages available for installation.</center></td></tr>';
189
							}
190
						}
191
					?>
192
				</table>
193
			</div>
194
		</td>
195
	</tr>
196
</table>
197
<?php include("fend.inc"); ?>
198
</body>
199
</html>
(109-109/210)