Project

General

Profile

Download (7.36 KB) Statistics
| Branch: | Tag: | Revision:
1 ee11cc6e Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 ee11cc6e Scott Ullrich
/*
4
    pkg_mgr.php
5 b49448ac Scott Ullrich
    Copyright (C) 2004, 2005 Scott Ullrich
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
30 9f9dcd98 Scott Ullrich
require_once("guiconfig.inc");
31 f8e335a3 Scott Ullrich
require_once("pkg-utils.inc");
32 ee11cc6e Scott Ullrich
33 61a48553 Scott Ullrich
$pkg_info = get_pkg_info('all', array('name', 'category', 'website', 'version', 'status', 'descr', 'maintainer', 'required_version'));
34 3f3a5bef Colin Smith
if($pkg_info) {
35
	$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
36
	fwrite($fout, serialize($pkg_info));
37 1d1630ec Colin Smith
	fclose($fout);
38 47c44d0a Scott Ullrich
    //$pkg_sizes = get_pkg_sizes();
39 3f3a5bef Colin Smith
} else {
40
	$using_cache = true;
41 47c44d0a Scott Ullrich
	if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
42
	    $savemsg = "Unable to retrieve package info from {$g['xmlrpcbaseurl']}. Cached data will be used.";
43
		$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
44
	} else {
45 36d0358b Scott Ullrich
		$savemsg = "Unable to communicate to {$g['product_website']}.  Please check DNS, default gateway, etc.";
46 47c44d0a Scott Ullrich
	}
47 3f3a5bef Colin Smith
}
48 52380979 Scott Ullrich
49 61a48553 Scott Ullrich
if (! empty($_GET)) {
50
  if (isset($_GET['ver'])) {
51 d8c1a6c5 Scott Ullrich
    $requested_version = htmlspecialchars($_GET['ver']);
52 61a48553 Scott Ullrich
  }
53
}
54
55 d88c6a9f Scott Ullrich
$pgtitle = array("System","Package Manager");
56 52380979 Scott Ullrich
include("head.inc");
57
58 ee11cc6e Scott Ullrich
?>
59
60
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
61 859329c8 Scott Ullrich
<?php
62
include("fbegin.inc");
63
?>
64 ee11cc6e Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
65
<?php
66 859329c8 Scott Ullrich
67 ee11cc6e Scott Ullrich
?>
68 323d040b Scott Ullrich
69 ee11cc6e Scott Ullrich
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
70 e3ebc979 Scott Ullrich
<?php
71 61a48553 Scott Ullrich
	$version = file_get_contents("/etc/version");
72 64b243d2 Scott Ullrich
  $dot = strpos($version, ".");
73
  $hyphen = strpos($version, "-");
74
  $major = substr($version, 0, $dot);
75
  $minor = substr($version, $dot + 1, $hyphen - $dot - 1);
76
  $testing_version = substr($version, $hyphen + 1, strlen($version) - $hyphen);
77
78 e3ebc979 Scott Ullrich
	$tab_array = array();
79 64b243d2 Scott Ullrich
	$tab_array[] = array("Available {$version} packages", $requested_version <> "" ? false : true, "pkg_mgr.php");
80
	$tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
81
/*  $tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other"); */
82 61a48553 Scott Ullrich
	$tab_array[] = array("Installed Packages", false, "pkg_mgr_installed.php");
83 e3ebc979 Scott Ullrich
	display_top_tabs($tab_array);
84 5bd87465 Scott Ullrich
?>
85 ee11cc6e Scott Ullrich
  </td></tr>
86
  <tr>
87 d732f186 Bill Marquette
    <td>
88
	<div id="mainarea">
89
              <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
90 ee11cc6e Scott Ullrich
                <tr>
91 a15a15e7 Scott Ullrich
                  <td width="10%" class="listhdrr">Package Name</td>
92 ee11cc6e Scott Ullrich
                  <td width="25%" class="listhdrr">Category</td>
93 bfccf041 Colin Smith
<!--
94 ea395bfd Colin Smith
		  <td width="10%" class="listhdrr">Size</td>
95 bfccf041 Colin Smith
-->
96 9345a13c Colin Smith
		  <td width="5%" class="listhdrr">Status</td>
97 f417ddcc Scott Ullrich
		  <td width="5%" class="listhdrr">Maintainer</td>
98 ee11cc6e Scott Ullrich
                  <td width="50%" class="listhdr">Description</td>
99
                </tr>
100
101
		<?php
102 3f3a5bef Colin Smith
		 if(!$pkg_info) {
103 58d797bf Colin Smith
			echo "<tr><td colspan=\"5\"><center>There are currently no packages available for installation.</td></tr>";
104 3f3a5bef Colin Smith
		 } else {
105 0db271e0 Colin Smith
		 $pkgs = array();
106
		 $instpkgs = array();
107 94fbf631 Colin Smith
		    if($config['installedpackages']['package'] != "")
108
			foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
109 b426850b Colin Smith
		    $pkg_names = array_keys($pkg_info);
110 1507bd61 Colin Smith
		    $pkg_keys = array();
111 b426850b Colin Smith
		    foreach($pkg_names as $name) {
112
			if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
113 0db271e0 Colin Smith
		    }
114 b426850b Colin Smith
		    sort($pkg_keys);
115
		    if(count($pkg_keys) != 0) {
116
		    	foreach($pkg_keys as $key) {
117
			    $index = &$pkg_info[$key];
118
			    if(in_array($index['name'], $instpkgs)) continue;
119 64b243d2 Scott Ullrich
          $dot = strpos($index['required_version'], ".");
120
          $index['major_version'] = substr($index['required_version'], 0, $dot);
121
122
          if ($version <> "HEAD" &&
123
              $index['required_version'] == "HEAD" &&
124
              $requested_version <> "other") { continue; }
125
          if (empty($index['required_version']) &&
126
                    $requested_version <> "none") { continue; }
127
          if($index['major_version'] > $major &&
128
             $requested_version <> "other") { continue; }
129
          if(isset($index['major_version']) &&
130
             $requested_version == "none") { continue; }
131
          if($index['major_version'] == $major &&
132
             $requested_version == "other") { continue; }
133
134 ee11cc6e Scott Ullrich
                            ?>
135
                            <tr valign="top">
136
                                <td class="listlr">
137 61a48553 Scott Ullrich
                                    <A target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
138 ee11cc6e Scott Ullrich
                                </td>
139
                                <td class="listlr">
140 b426850b Colin Smith
                                    <?= $index['category'] ?>
141 9345a13c Colin Smith
    				</td>
142
				<?php
143 bfccf041 Colin Smith
					/*
144 3f3a5bef Colin Smith
					if(!$using_cache) {
145
						$size = get_package_install_size($index['name'], $pkg_sizes);
146
                               			$size = squash_from_bytes($size[$index['name']], 1);
147
					}
148
					if(!$size) $size = "Unknown.";
149 bfccf041 Colin Smith
					*/
150 9345a13c Colin Smith
				?>
151 bfccf041 Colin Smith
				<!--
152 9345a13c Colin Smith
				<td class="listlr">
153 3f3a5bef Colin Smith
                                 	<?= $size ?>
154
                                </td>
155 bfccf041 Colin Smith
				-->
156 9345a13c Colin Smith
				<td class="listlr">
157 3f3a5bef Colin Smith
					<?= $index['status'] ?>
158
					<br>
159
					<?= $index['version'] ?>
160 61a48553 Scott Ullrich
					<br />
161
					platform: <?= $index['required_version'] ?>
162 ee11cc6e Scott Ullrich
                                </td>
163 76341f29 Scott Ullrich
                                <td class="listlr">
164
					<?php
165
						if($index['maintainer'] != "") {
166 2c9d3735 Scott Ullrich
							echo "<a href='mailto:{$index['maintainer']}'>{$index['maintainer']}</a>";
167 76341f29 Scott Ullrich
						} else {
168 36d0358b Scott Ullrich
							echo "Nobody. <a href='mailto:{$g['product_email']}'>Apply</a> for it!";
169 76341f29 Scott Ullrich
						}
170
					?>
171 5bd87465 Scott Ullrich
                                </td>
172 61a48553 Scott Ullrich
                                <td class="listbg" class="listbg" style="color: #FFFFFF; overflow: hidden;">
173 b426850b Colin Smith
                                    <?= $index['descr'] ?>
174 ee11cc6e Scott Ullrich
                                </td>
175
                                <td valign="middle" class="list" nowrap>
176 677c0869 Erik Kristensen
                                    <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>
177 ee11cc6e Scott Ullrich
                                </td>
178
                            </tr>
179
                            <?php
180 b426850b Colin Smith
                        }
181
		    } else {
182 bfccf041 Colin Smith
			echo '<tr><td colspan="5"><center>There are currently no packages available for installation.</center></td></tr>';
183 b426850b Colin Smith
		    }
184 3f3a5bef Colin Smith
		}
185 ee11cc6e Scott Ullrich
		?>
186
        </table>
187 d732f186 Bill Marquette
	</div>
188 ee11cc6e Scott Ullrich
    </td>
189
  </tr>
190
</table>
191
<?php include("fend.inc"); ?>
192
</body>
193
</html>